Subject:
|
motor code questions
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Wed, 2 Dec 1998 14:54:42 GMT
|
Original-From:
|
Shiva Sinha <sinha@wam.{StopSpam}umd.edu>
|
Viewed:
|
2544 times
|
| |
| |
Hi,
I got my Handyboard up and going and was trying the following code for
driving my motors. (Figure I would try known code before forking out on my
own). The code I got from the 'Inspiration to implemntation' book. Anyways
it does not seem to drive the motors (no LEDs lighting), and I was
wondering if any one knows of any problems with the code. I've looked it
over and it seems pretty reasonable.
Thanks in advance,
Shiva Sinha
----------------------------------------------
int write_port (int port, int value, int mask)
{ poke(port,(value & mask) | (peek(port) & ~mask)); }
void motor_cmd(int l_ena, int l_dir, int r_ena, int r_dir) {
write_port(port_a, (l_ena & m_mask_l) | (r_ena & m_mask_r), m_mask);
write_port(port_d, (l_dir & m_mask_l) | (r_dir & m_mask_r), m_mask); }
void move(int operation) {
if (operation == STOP)
motor_cmd(off_,0,off_,0);
else if (operation == FORWARD)
motor_cmd(on,fwd,on,fwd);
else if (operation == BACKWARD)
motor_cmd(on,bkw,on,bkw);
else if (operation == LEFT_TURN)
motor_cmd(on,bkw,on,fwd);
else if (operation == RIGHT_TURN)
motor_cmd(on,fwd,on,bkw);
}
|
|
Message is in Reply To:
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|