I’ve been trying to edit my operator controls so that one of my arms either goes up or down depending on whether channel 5 (rx button) is pressed up or down. i followed the set up like the the easyC faq for rx buttons, but they’re still something wrong that i cant figure out.
What I’m doing is telling the arm to move up if rx5>127 if my encoder value is less than 19 and then vice vera for down.
When I compile it, no problems
When i have downloaded it and try to run that arm- nothing happens…
So, since I’ve had no effect from the program at all i cant find the cause of the problem!:mad:
My program explanation is probably confusing, please tell me if you want me to copy&paste what exactly i entered, although i dont know how to do that…
Thanks in advance for any help.
changed a few things around and it went berserk… even took a few gear tooths off
is it bad to have an if statement inside another if statement? made sense to me but i cant tell if its messing some things up…
(Still needs helpz )
Zip you project and post your program.
i dont know how to zip it either =(
here ill try to upload the zipped projects i put together:
Dreadnaught.zip (200 Bytes)
Dreadnaughtrx.zip (204 Bytes)
Your missing a file.
Create a folder on your desktop, then click SaveAs and save in that folder. Then zip the folder.
well i added the bds files i missed
Dreadnaught.zip (2.69 KB)
Dreadnaughtrx.zip (2.61 KB)
For this application you really should be using a dual wire encoder (quadrature) or a potentiometer as they can sense direction. A single wire counter encoder cannot and that may be part of your issue.
Try this to see if it works:
rx5 = GetRxInput ( 1 , 5 ) ;
if ( rx5 > 127 )
SetMotor ( 5 , 0 ) ;
else if ( rx5 < 127 )
SetMotor ( 5 , 255 ) ;
SetMotor ( 5 , 127 ) ;
If that works add your encoder code back in peice by peice until it stops working.
If you decide to upgrade to a Quadrature encoder or a Potentiometer you could
do something like this.
void OperatorControl ( unsigned long ulTime )
unsigned char rx5;
// when u transfer, dont forget variables
StartQuadEncoder ( 2 , 5 , 0 ) ; //Interrupt 2, Input 5
PresetQuadEncoder ( 2 , 5 , 0 ) ;
while ( 1 )
Arcade4 ( 1 , 3 , 4 , 4 , 1 , 3 , 2 , 0 , 0 , 0 , 0 ) ; // redone-gear
MotorRcControl ( 1 , 2 , 7 , 0 ) ; // left conveyor
MotorRcControl ( 1 , 2 , 8 , 1 ) ; // right conveyor
MotorRcControl ( 1 , 6 , 6 , 1 ) ; // second arm
mainarm = GetQuadEncoder( 2 , 5 ) ; //Get value from encoder
rx5 = GetRxInput ( 1 , 5 ) ; //Get value from transmitter
if ( rx5 > 127)
armTarget = 19; //Move arm up 19 clicks
else if ( rx5 < 127 )
armTarget = 0; //Move arm down to starting position
armMotorPower = (armTarget - mainarm);
SetMotor( 5 , armMotorPower + 127); // +127 Moves center from 0 to 127
alright i’m going to try that out then. i’m pretty sure my encoders are the quadcore, they have the 2 sets of wires. i didnt plug them both in because i didnt know how it worked with the programming…
So, when i do plug both wires in, do i have to have the program get values from both interrupt ports? or is it just going to know that 0 is my starting position and 19 clicks is the spot i need it to go to?
You plug one cable into an input (default pins 5-10) and the other into a interrupt. My example is input 5, interrupt 2. For more information look in the help file.
The encoder will always start at zero when the program starts, so you need to make sure that the arm is down before you turn on your robot. That or install a limit switch that zero’s out the encoder when it hits the switch.