Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Prgm4 2 joystics control 1 speed cntrl??? (http://www.chiefdelphi.com/forums/showthread.php?t=2554)

punarhero 15-02-2002 19:12

Prgm4 2 joystics control 1 speed cntrl???
 
Can someone tell me how to program 2 of the joystick ports to operate 1 pwm output????

Ameya 15-02-2002 22:37

Why would you want to have two joysticks control the same PWM output? Seems redundantly redundant to me.

Ian W. 15-02-2002 23:08

Do you mean two pwm's on one joystick, because i don't think it's even possible to control one pwm with two joysticks. I mean, you could, but it would be rather pointless.

To control two pwm's with one joystick is easy:

serout [255,255,pwm1,relay1,pwm2,relay2,pwm3,pwm4...pwm16]

just replace which ever pwm with the variable of the joystick...

serout [255,255,p1_y,relay1,p1_y, relay2,pwm3,pwm4...pwm16]

if this makes no sense, sorry, but i'm typing this on like, no sleep, and well, it makes sense to me. :D

punarhero 16-02-2002 12:44

Thanks for replying. What I want is for forward on two joystics to work the same PWM output. Call me crazy but there's a long story of why I need it.

Joseph F 16-02-2002 18:24

this is just off the top of my head... but i think it may go something like this...

If p1_y > p2_y then use1
pwm1 = p2_y
goto end

use1
pwm1=p1_y
end:


basically it takes whichever joystick is greater and uses that as the output to pwm1

you would have to edit the serout command so that it would read

[255,255,pwm1,relayA,p2_y,relayB,p3_y,p4_y,p1_x,p2_ x,p3_x,p4_x,p1_wheel,p2_wheel,p3_wheel,p4_wheel,12 7,127,127,127]

just remember if you did this you couldnt use pwm2 because p2_y would still control it as well as pwm1 if you went forward.

Ameya 19-02-2002 18:03

problem with previous response:
 
Quote:

Originally posted by Joseph F


basically it takes whichever joystick is greater and uses that as the output to pwm1

The problem with that solution is that you won't be able to go in reverse (since joystick centered is 127 and joystick reverse is less than 127).

Joseph F 19-02-2002 19:42

then edit it to read:


If p1_y | p2_y < 115 then rev
if p1_y | p2_y > 135 then fwd
pwm1 = 127
goto end
fwd:
If p1_y > p2_y then use1
pwm1 = p2_y
goto end

use1
pwm1=p1_y
goto end

rev:
if p1_y < p2_y then use2
pwm1 = p2_y
goto end

use2:
pwm1 = p1_y
end:

ttedrow 21-02-2002 09:57

Try this

pwm1 = (p1_y + p2_y) / 2


All times are GMT -5. The time now is 13:28.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi