Professional Documents
Culture Documents
1 de 7
http://www.optotech.net.br/fzanoto/uav_4.htm
Os testes com esse motor foram excelentes, por ser a gasolina ele tem excelente torque, boa
relao peso/potencia e tem um timo custo/benefcio.
Quanto ao aeromodelo agora, pensei em fazer um trike ou ultra-leve .
segue os firmwares feito em mikrobasic para controle de piloto automtico:
program ler_nmea
dim
dim
dim
dim
dim
dim
dim
dim
dado as byte[23]
valor, kk as byte
XX as longint
YY as longint
txt as char[11]
txt_2 as char [3]
txt_3 as char [11]
angulo, delta_x, delta_y, diferenca as float
'pula o "."
for kk = 5 to 8
24/12/2012 17:31
UAV
2 de 7
http://www.optotech.net.br/fzanoto/uav_4.htm
le_dado
dado[kk] = valor
xx = xx *10
xx = xx + (dado[kk]-48)
next kk
',N,12158.3416,W,1,07,1.0,9.0,M, , , ,0000*18
for kk = 0 to 2
le_dado
next kk
'descarta 3 bytes
for kk = 0 to 4
le_dado
dado[kk] = valor
yy = yy *10
yy = yy + (dado[kk]-48)
next kk
le_dado
'pula o "."
for kk = 6 to 9
le_dado
dado[kk] = valor
yy = yy *10
yy = yy + (dado[kk]-48)
next kk
' XX = 37232475 '
' YY = 121583416 '
'Calculo do angulo: arco-tangente (Y1-Y/X1-X)
longinttostr(xx,txt)
UART1_Write_text(txt)
UART1_Write(13)
longinttostr(yy,txt)
UART1_Write_text(txt)
UART1_Write(13)
'Calculo do angulo: arco-tangente (Y1-Y/X1-X)
'angulo = (valor * 3.14159 / 180)
'res = atan2(x,y) ' res = 7.853982e-1
'
'se aumentar a diferena, pq est indo sentido contrrio
'
'
'
'
delta_x = 2
delta_y = 7
'x1-x
'y1-y
diferenca = delta_y/delta_x
angulo = atan(diferenca)
angulo = (angulo*180/3.14159)
floattostr(angulo,txt_3)
UART1_Write_text(txt_3)
UART1_Write(13)
end sub
'----------------------------------------------------------main:
trisa = 0
trisb = %00000000
trisc = %10000000
UART1_Init(9600)
'--------------------------------------------------------------while true
'$GPGGA,161229.487,3723.2475,N,12158.3416,W,1,07,1.0,9.0,M, , , ,0000*18
'$GPGSV,2,1,07,07,79,048,42,02,51,062,43,26,36,256,42,27,27,138,42*71
le_dado
wend
end.
'--------------------------------------------------------------Cdigo:
program Acelerometro
dim LCD_RS
LCD_EN
LCD_D4
LCD_D5
LCD_D6
LCD_D7
as
as
as
as
as
as
sbit
sbit
sbit
sbit
sbit
sbit
at
at
at
at
at
at
RB2_bit
RB3_bit
RB4_bit
RB5_bit
RB6_bit
RB7_bit
24/12/2012 17:31
UAV
3 de 7
http://www.optotech.net.br/fzanoto/uav_4.htm
LCD_EN_Direction
LCD_D4_Direction
LCD_D5_Direction
LCD_D6_Direction
LCD_D7_Direction
as
as
as
as
as
sbit
sbit
sbit
sbit
sbit
at
at
at
at
at
TRISB3_bit
TRISB4_bit
TRISB5_bit
TRISB6_bit
TRISB7_bit
delay_ms(3000)
valor = 100
for kk = 0 to 200
delay_ms(13)
servo_1
next kk
'-----------------------------------------------------------while true
delay_ms(13)
'60hz
x = adc_read(0) '550
y = adc_read(1)
'550
zz = adc_read(2) '430
'wordtostr(x,txt)
'Lcd_Out(1,3,txt)
'Lcd_Out(1,1,"X=")
'
'wordtostr(y,txt)
'Lcd_Out(1,12,txt)
'Lcd_Out(1,10,"Y=")
'550
'550
'wordtostr(zz,txt)
'Lcd_Out(2,3,txt)
'Lcd_Out(2,1,"Z=")
'430
calculo = (zz*10)/40
valor = calculo
servo_1
wend
end.
'----------------------------------------------------Cdigo:
program Acelerometro
dim LCD_RS
LCD_EN
LCD_D4
LCD_D5
LCD_D6
LCD_D7
as
as
as
as
as
as
sbit
sbit
sbit
sbit
sbit
sbit
at
at
at
at
at
at
LCD_RS_Direction
LCD_EN_Direction
LCD_D4_Direction
LCD_D5_Direction
LCD_D6_Direction
LCD_D7_Direction
RB2_bit
RB3_bit
RB4_bit
RB5_bit
RB6_bit
RB7_bit
as
as
as
as
as
as
sbit
sbit
sbit
sbit
sbit
sbit
at
at
at
at
at
at
TRISB2_bit
TRISB3_bit
TRISB4_bit
TRISB5_bit
TRISB6_bit
TRISB7_bit
24/12/2012 17:31
UAV
4 de 7
http://www.optotech.net.br/fzanoto/uav_4.htm
Lcd_Init()
Lcd_Cmd(_LCD_CLEAR)
Lcd_Cmd(_LCD_CURSOR_OFF)
delay_ms(3000)
valor = 100
for kk = 0 to 200
delay_ms(13)
servo_1
next kk
'-----------------------------------------------------------while true
delay_ms(13)
'60hz
x = adc_read(0) '550
y = adc_read(1)
'550
zz = adc_read(2) '430
'wordtostr(x,txt)
'Lcd_Out(1,3,txt)
'Lcd_Out(1,1,"X=")
'
'wordtostr(y,txt)
'Lcd_Out(1,12,txt)
'Lcd_Out(1,10,"Y=")
'550
'550
'wordtostr(zz,txt)
'Lcd_Out(2,3,txt)
'Lcd_Out(2,1,"Z=")
'430
calculo = (zz*10)/40
valor = calculo
servo_1
wend
end.
'--------------------------------------------------------------------Cdigo:
program RX_usb_uav
include "usbdsc"
dim cnt as byte
dim readbuff as char[64] absolute 0x500
dim writebuff as char[64] absolute 0x540
'x
'y
'z
end if
end if
end if
end sub
'---------------------------------------------------------------------------------------------------sub procedure Interrupt()
USB_Interrupt_Proc()
' USB servicing is done inside the interrupt
end sub
'----------------------------------------------------------------------------------------------------main:
trisa = 0
trisb = 0
trisc = %10010000
'RX , Dporta = 0
portb = 0
portc = 0
cmcon = 7
24/12/2012 17:31
UAV
5 de 7
http://www.optotech.net.br/fzanoto/uav_4.htm
HID_Enable(@readbuff,@writebuff)
UART1_Init(9600)
pisca
for cnt = 0 to 63
writebuff[cnt] = 0
next cnt
'------------------------------------------------------------------------------------------------------while TRUE
while(HID_Read() = 0)
verifica
wend
while(HID_Write(@writebuff,64) = 0)
wend
wend
end.
'------------------------------------------------------------------Cdigo:
program uav
'interrupt servo5
24/12/2012 17:31
UAV
6 de 7
http://www.optotech.net.br/fzanoto/uav_4.htm
'$GPGGA,161229.487,3723.2475,N,12158.3416,W,1,07,1.0,9.0,M, , , ,0000*18
txt = "Val="
'--------------------------------------------------------------------------while true
if UART1_Data_Ready() <> 0 then
dado = UART1_Read()
Soft_UART_Write(dado)
inc(contador)
end if
wend
end.
Depois de muito bater cabea e tentar fazer tudo sozinho, descobri que tem isso tudo pronto a
venda no ebay:
ardupilot:
por miseros 32 dolares no Ebay:
Aps diversos softwares e firmwares de arduino para autopilot, at que enfim consegui fazer
funcionar:
GPS:
Apesar do arduino aceitar outros modelos de gps, ainda estou tendo trabalho para configurar
um modelo de gps padro "Nmea" que eu tenho aki que adquiri no Ebay de apenas 15 dolares.
O gps recomendado pelo arduino deveria ter uma taxa de pelomenos 4hz, porm ele meio caro
(aprox. 80 dolares) e o meu gps tem 1hz de atualizao, ento tive que fazer um "downgrade" no
24/12/2012 17:31
UAV
7 de 7
http://www.optotech.net.br/fzanoto/uav_4.htm
arduino da versao 2.7 e tentar a versao 2.4, pois esta versao aceita gps de menor taxa e est
menos complicado entender os arquivos.
Para fazer isso, precisei recompilar o firmware do arduino com o aplicativo abaixo (repare na
seleo do modelo de placa "Duemilanove w/ ATmega328":
Com a versao ardupilot_easyglider_v2.46 , basta ir olhando arquivo por arquivo que vc ir entender
como eles fizeram este projeto e facilmente vc altera as configuraes conforme o seu tipo de gps
utilizado.
*OBS:
Cuidado com o TX e o RX da placa ardupilot, pois ela usa o mesmo tx e rx do gps e da sua placa
FTDI para comunicar com o computador, portanto, quando tiver usando o computador, desligue o
gps e vice-versa.
Fazendo isso, o led que monitora o GPS dever ficar aceso indicando que ele est conseguindo ler
corretamente o GPS.
Sensores XYZ:
Para baratear o custo, eu mesmo fiz os sensores XYZ, utilizando um acelerometro analogico
comum, porm esses acelerometros so de 3.3V e o ardupilot est preparado para receber sinais
analogicos de 0 a 5V, onde atravs dos conversores A/D os sinais deverao ficar entre 2,5V e a
leitura deles no A/D proximos de 512. e os meus sensores ficam proximos de 1.6V, para isso eu
precisei amplificar um pouco o sinal.
Aqui tem todos os arquivos que vc precisa, manuais, firmwares, esquemticos, enfim, tudo para
fazer funcionar o seu ardupilot:
http://code.google.com/p/ardupilot/
Em breve irei postando mais notcias e melhorando esse tutorial....
24/12/2012 17:31