Quote:
Originally Posted by OMAR_567
We have gone through the default code, but we are missing what the code means. We have someone to help us with C programming, but how do we define things so that they match up with physical layout on the robot control. Is there some manual that helps explain some of this. For example:
pwm01 = p1_y;
pwm02 = p2_y;
pwm03 = p3_y;
pwm04 = p4_y;
pwm05 = p1_x;
pwm06 = p2_x;
pwm07 = p3_x;
pwm08 = p4_x;
pwm09 = p1_wheel;
pwm10 = p2_wheel;
pwm11 = p3_wheel;
pwm12 = p4_wheel;
The comments help in the program, but we need some more direction.
|
Basically what's going down below is that the pwm outputs on the robot controller are being mapped to the joystick inputs on the OI. So if you plug in a joystick to port 1 of the OI, and push it foward all the way, p1_y will be 255. This 255 on the Pwm01 will tell the speed controller to go +12V across the motor. Pulling it all the way back would give you a 0 on pwm01. This is a signal to go -12V for the speed controller(running a motor in reverse). When the joystick is at rest it is at a neutral value of 127.
So with what's setup below if you plug in joysticks to the OI in ports 1 and 2. Then plug in your speed controllers for your drive into PWMs 1 and 2. Then you should be able to drive your robot with 2 joysticks.
pwm01 = p1_y; //Map the y axis of joystick 1 to pwm01
pwm02 = p2_y; //Map the y axis of joystick 1 to pwm02
pwm05 = p1_x; //Map the x axis of joystick 1 to pwm01
pwm06 = p2_x; //Map the x axis of joystick 1 to pwm02