Forum >default code doing weird things lol
General

default code doing weird things lol

userHead bkrause 2012-01-13 16:57:29 6219 Views5 Replies
hi guys, i have a romeo board and the rover 5 2wd platform.. the code is the default code used for forward back left right, found in the manual for the romeo board..
case 'w'://Move Forward
advance (100,100); //PWM Speed Control
break;
case 's'://Move Backward
back_off (100,100);
break;
case 'a'://Turn Left
turn_L (100,100);
break;
case 'd'://Turn Right

the weird thing is since day one, when pressing "w" in serial monitor it will turn....and likewise "a" drives forward (advance)..

its not really been a problem cuz the controls are just inverted..but now i wish to have a command to "turn right a little bit" instead of turning nearly 90 degrees.

any help would be excellent with these problems which i just cant work out.
thanks
ben
2012-01-18 18:43:38 Cool! Glad you got it working! Come back soon! Share your project, I want to see what you are working on  ;D userHeadPic Hector
2012-01-18 11:56:14 Hi Hector, it was reverse polarity , the left drive motor went backwards when the right went forward.

all sorted now tho, so tanks for your help u legend
userHeadPic bkrause
2012-01-13 22:33:37 Hi Bkrause,


If you have not changed anything, I think I found the problem... we need to change the following:


  int i;
for(i=6;i<=9;i++) pinMode(i, OUTPUT);
Serial.begin(19200);      //Set Baud Rate

to: 

int i;
for(i=4;i<=7;i++) pinMode(i, OUTPUT);
Serial.begin(19200);      //Set Baud Rate


The sample code was not updated correctly...I've made the corrections now. It was not initializing the right pins...
userHeadPic Hector
2012-01-13 21:27:42 ok thanks for reply, il recheck internal wiring  and the check to see if the motor are running in reverse polarity..

the code is the sample code from the wiki yeah, some values where changed for speed.

on the pwm

turn_L (100,100);

what is the highest it can go? and the lowest? and is the (100,100) the two motors? and can i change the two values? ie. (155,255)?

still cant work out how running both motors HIGH , runs one motor HIGH and the other LOW as in turning , even with reverse polarity seems way weird.
userHeadPic bkrause
2012-01-13 20:00:07 Hi,


Are you using the wiki sample code, completely unmodified? Have you tried the PLL sample code below? give it a try, it might work better. Just keep in mind you do need to change some wiring to get it working, read the wiki for details.


Also, have you tried changing the motors wiring? Sometimes the polarity is reversed on one motor, making the robot act strange. I'm not sure what is going on, since you only seem to be affected by reverse, if this was the case you would also be affected in forward. Still, it might be worth it to double check your wiring. You could also make modifications to the code, to fit your needs.




In the PWM sample code, you might also want to experiment with the values provided, this might help make tighter or smaller turns...


turn_L (100,100);
userHeadPic Hector