'*******************************************************************************
'Programa ALPINISTA_ARNEBASIC2k.bas
'Desenvolvido por Márcio José Soares
'
'Controla Robô Alpinista v2
'Usa 3 servos de aeromodelo padrão Futaba "standart"
'Recebe comandos do PC (programa em LOGO) para subir, descer ou parar
'
'* Obs.: Este programa foi desenvolvido para a versão do Robô Alpinista
'* com o Arne Basic 2k. Veja o circuito em www.arnerobotics.com.br
'*******************************************************************************
'*******************************************************************************
'Configs necessários ao microcontrolador
$crystal = 10000000
$regfile = "attiny2313.dat"
Config Portb =
&B11111111
'todo portB é saída
Config Portd =
&B11111110
'todo portD é saída, exceto PD0, PD2 e PD4
'*******************************************************************************
'Variáveis globais
Dim S As String * 4
Dim C As String * 1
'*******************************************************************************
'configura servos
'servo1 -> garra superior
'servo2 -> garra inferior
'servo3 -> elevação
Config Servos = 3 , Servo1 = Portb.0 , Servo2 = Portb.1 , Servo3 = Portb.2 , Reload = 10
'*******************************************************************************
'Declaração das subrotinas
Declare Sub Ainf()
Declare Sub Finf()
Declare Sub Asup()
Declare Sub Fsup()
Declare Sub Dob()
Declare Sub Est()
'*******************************************************************************
'habilta interrupção
Enable Interrupts
'*******************************************************************************
'Início do programa
Call Fsup()
Call Est()
Call Finf()
Waitms
500
'espera iniciar
'*******************************************************************************
'Laço principal... faz eternamente
Do
Input S
Noecho
'aguarda dado do logo
C = Mid(s , 4 ,
1)
'pega comando
Select Case C
Case "1" : Call Ainf()
Case "2" : Call Finf()
Case "3" : Call Asup()
Case "4" : Call Fsup()
Case "5" : Call Est()
Case "6" : Call Dob()
End Select
'envia para LOGO resposta de comando recebido
Waitms 300
Print "1"
Loop
'*******************************************************************************
'subrotinas do programa
'*******************************************************************************
'*******************************************************************************
'abre garra inferior
Sub Ainf()
Servo(2) = 150
End Sub
'*******************************************************************************
'fecha garra inferior
Sub Finf()
Servo(2) = 100
End Sub
'*******************************************************************************
'abre garra superior
Sub Asup()
Servo(1) = 150
End Sub
'*******************************************************************************
'fecha garra superior
Sub Fsup()
Servo(1) = 100
End Sub
'*******************************************************************************
'estica articulação
Sub Est()
Servo(3) = 150
End Sub
'*******************************************************************************
'dobra articulação
Sub Dob()
Servo(3) = 100
End Sub
End
'fim do programa