|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#7
|
|||
|
|||
|
how about this code.
we tried to keep the motor speed down so the encoder will read each tick before the program refreshes. so the motor doesn't "beat" the program before it reads the encoder.
Code:
//the encoder is at 50 resolution
//the arm motor is attatched to pwm_02
//the encoder is attatched to rc_dig_in06
static unsigned int encoder;
static unsigned int pressedornot;
if (p1_sw_trig == 1)
{
if (encoder <= 10)
{
pwm_02 = 150;
if (rc_dig_in06 == 1)
{
encoder = encoder + 1;
if (encoder > 10)
{
pwm_02 = 127;
}
}
}
}
|
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [OCCRA]: motor brush springs | greencactus3 | OCCRA Q&A | 1 | 28-09-2004 20:56 |
| Multiple Motors | phrontist | Motors | 12 | 21-06-2004 23:05 |
| Mounting the drill motor | Veselin Kolev | Motors | 11 | 26-04-2004 14:27 |
| WHich motor to lift and for arm | thoughtful | Motors | 8 | 25-02-2004 10:34 |
| Thermal Protection | archiver | 2000 | 1 | 23-06-2002 23:27 |