hanan
19-01-2007, 10:01
Hi,
Would like to write in easyC some come code for the motors to run like a tank.
if y axis of joystick moved - move forward. (4 motors forward. 4 will reverse)
if x axis changed - want to take a turn - move both sides same dir', only one will be slower.
my question - need to be able to move one axis at a time. wrote:
j1_y=GetOIAInput(1,1);
j1_x=GetOIAInput(1,2)
now I check which one is greater (there will also be a small deviation in x, even if move only in y direction, beacuse our hands are not that accurate...)
so I "detect" the operator intention, and then write:
SetPWM(motor according to comparator result, value)
however, somehow, I still get movement in the other motor, connected to "axis x". howcome, if I didn't tell him SetPWM???
I thought how to check which is greater - beacuse maybe (-100,-20) the computer want to move towards -20, while intention is for -100. so I did abs function and then compared.
However, I could do this since my assuption was that I have values between (127,-127) signed char from joystick. Is this correct assumption?
If not, how can I solve this out, and decide which way to go, if I have values 0-255. since 127 is greater than 100, robot will not move, eventhough want to move to 100 location. (127 is stop as I recall).
Can someone help?
Would like to write in easyC some come code for the motors to run like a tank.
if y axis of joystick moved - move forward. (4 motors forward. 4 will reverse)
if x axis changed - want to take a turn - move both sides same dir', only one will be slower.
my question - need to be able to move one axis at a time. wrote:
j1_y=GetOIAInput(1,1);
j1_x=GetOIAInput(1,2)
now I check which one is greater (there will also be a small deviation in x, even if move only in y direction, beacuse our hands are not that accurate...)
so I "detect" the operator intention, and then write:
SetPWM(motor according to comparator result, value)
however, somehow, I still get movement in the other motor, connected to "axis x". howcome, if I didn't tell him SetPWM???
I thought how to check which is greater - beacuse maybe (-100,-20) the computer want to move towards -20, while intention is for -100. so I did abs function and then compared.
However, I could do this since my assuption was that I have values between (127,-127) signed char from joystick. Is this correct assumption?
If not, how can I solve this out, and decide which way to go, if I have values 0-255. since 127 is greater than 100, robot will not move, eventhough want to move to 100 location. (127 is stop as I recall).
Can someone help?