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

  • Thread starter DrDanger
  • Start date
  • Tags
    Motor
In summary, the conversation discusses the basic functionality for motion on a robot, including left and right motor control functions, a setup function, and a main function that cycles through the motor modes. The issue of the right wheel not moving is addressed and it is suggested to remove the while loop in the main function to fix the problem. It is also mentioned that the program may have been altered by a rodent and that the robot has no religious affiliation.
  • #1
DrDanger
44
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
 
Technology news on Phys.org
  • #2
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.
 
  • #3
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 religous affliation. Other than that it looks good.
 

1. What could be causing the motor to malfunction?

There are several possible reasons for a motor to malfunction in a bot. It could be due to a faulty motor, loose or damaged wiring, a malfunctioning power source, or a programming error.

2. How can I troubleshoot the problem with the motor?

Start by checking all connections and wires to ensure they are secure and undamaged. If everything appears to be in order, try replacing the motor with a new one to see if that resolves the issue. If not, it may be necessary to review the programming and make any necessary adjustments.

3. Is there a way to prevent motor problems in the future?

Regular maintenance and proper handling can help prevent motor problems in the future. Make sure to clean and lubricate the motor as needed, and avoid overloading or overheating it. Also, double-check all wiring and connections before each use.

4. Can a motor be repaired or does it need to be replaced?

It depends on the extent of the damage and the availability of replacement parts. In some cases, a simple repair may be possible, but in others, it may be more cost-effective to replace the motor entirely.

5. What should I do if the motor continues to have problems?

If the motor continues to have problems after troubleshooting and attempting repairs, it may be best to consult a professional. They can help diagnose the issue and offer solutions, such as replacing the motor or making adjustments to the bot's programming.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
Back
Top