billhayley
New Member
I have adapted a computer joystick to send infrared signals to a model Puma Armoured car.It works fine with the normal remote supplied by rev-ed but with the joystick the movement is jerky. My first effort didnt work over long ranges but having read the article on Infr red on the forum I built the enhanced circuit with twin leds. The range is much better but the movement is not smooth.I think it is something to do with the code below paarticularly tm .Pictures of Joystick and Model attached. Any ideas I have tried the simulations but to no avail.
Code:
; *******************************
; ***** Infra Joystick *****
; *******************************
; Filename: infra joystick small twin leds
; Date: 30/01/2011
; File Version: 1
; Written by: billhayley
; Function:infra joystick control
; Last Revision:
; Target PICAXE:20m
; *******************************
init:
if pin4=1 then main
if pin5=1 then revs
if pin6=1 then fire
if pin7=1 then rotate
goto init
main:
if pin3 = 1 then ir3; fwdlft
if pin2 = 1 then ir2; fwd
if pin1 = 1 then ir1; fwdrht
if pin0 = 1 then ir0; rev
goto main
revs:
if pin3 = 1 then ir4; revlft
if pin2 = 1 then ir2; fwd
if pin1 = 1 then ir5; revrht
if pin0 = 1 then ir0; rev
goto revs
fire:
if pin3 = 1 then ir8; firelft
if pin2 = 1 then ir9; fire
if pin1 = 1 then ir7; firerht
if pin0 = 1 then ir6; fire
goto fire
rotate:
if pin3 = 1 then ir12; rotlft
if pin2 = 1 then ir10; raise
if pin1 = 1 then ir13; rotrht
if pin0 = 1 then ir11; lower
goto rotate
ir0: b2=12;rev
b3=pin0
goto tm
ir1: b2=18;fwd rht
b3=pin1
goto tm
ir2: b2=9;fwd
b3=pin2
goto tm
ir3: b2=16;fwd lft
b3=pin3
goto tm;
ir4: b2=17;revlft
b3=pin3
goto tm
ir5: b2 = 19;revrht
b3=pin1
goto tm
ir6: b2 = 2;fire
b3=pin0
goto tm
ir7: b2 = 3;firerht
b3=pin1
goto tm
ir8: b2=4 ;firelft
b3=pin3
goto tm
ir9: b2=2;fire
b3=pin2
goto tm
ir10: b2=6;raise
b3=pin2
goto tm
ir11: b2=7;lower
b3=pin0
goto tm
ir12: b2 = 0 ;rotate
b3=pin3
goto tm
ir13: b2 = 1;back
b3=pin1
goto tm
tm:
high 2;indicator led to show transmission.
w0 = 0
Do
infraout 1,b2
pause 45
w0 = w0 + 1
w0 = b3 * w0
Loop Until w0 > 30;keep sending the signal until input pin goes low
low 2
goto init
Attachments
-
536.4 KB Views: 19
-
550.1 KB Views: 17
Last edited: