What could be causing one wheel of my robot to not move?

  • Thread starter Thread starter DrDanger
  • Start date Start date
  • Tags Tags
    Motor
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
2 replies · 2K views
DrDanger
Messages
44
Reaction score
0
// first write the basic functionality for motion
void left_forward() {
PORTC.F0 =1;
PORTC.F1 =0;
}
void left_reverse() {
PORTC.F0 =0;
PORTC.F1 =1;
}
void left_stop() {
PORTC.F0 =0;
PORTC.F1 =0;
}

void right_forward() {
PORTC.F5 =1;
PORTC.F6 =0;
}
void right_reverse() {
PORTC.F5 =0;
PORTC.F6 =1;
}
void right_stop() {
PORTC.F5 =0;
PORTC.F6 =0;
}

void setup_P16F690() {
// This is all the stuff that's needed for the chip
ANSEL=ANSELH=0;
PORTC=0;
TRISC=0;
}

main() {
setup_P16F690();
while(1) { // Do this forever
left_forward();
delay_ms(1000); // Wait 1000 ms = 1sec
left_reverse();
delay_ms(1000); // Wait 1000 ms = 1sec
left_stop();
delay_ms(2000); // Wait 1000 ms = 1sec
}

while(1) { // Do this forever
right_forward();
delay_ms(1000); // Wait 1000 ms = 1sec
right_reverse();
delay_ms(1000); // Wait 1000 ms = 1sec
right_stop();
delay_ms(2000); // Wait 1000 ms = 1sec
}
}

I am new to programming just started learning it a few days ago. I wrote this for a robot I am working on and can't get the right wheel to move. The left one works fine. thanks for any help
 
Physics news on Phys.org
There is nothing to break out of the first while loop. The program is just going to cycle the left motor through the various modes for as long as the program runs. Perhaps you were thinking that these while loops ran in parallel, but they don't. They are run sequentially, but since the first while loop never exits, the program never gets to the second while loop.

Remove the while(1){ }'s from the program and it should do one left cycle, then one right cycle.
 
Well the Problem appears to be that program was tampered by a rodent, also the the robot seems to represent a christmas tree when it should rellay have no religious affliation. Other than that it looks good.