Does the EVX-2 not work like a regular speed control? If it’s a regular speed control, you should be able to interface with it just like any servo (e.g. use our servo controller or generate the 1-2ms pulses on your microcontroller).
I’m using an Arduino with the Micro Servo Controller and the sample code from this site.
What setting would produce a 1-2ms pulse? Is that the servo speed or the servo direction?
void setup()// run once, when the sketch starts
{
Serial.begin(9600);
}
void loop() //Main program loop, executes forever after setup()
{
servoSetSpeed(0,10); // set servo speed
put(0,5000); // turn servo 1 right
}
void put(unsigned char servo, unsigned int angle){
//servo is the servo number (typically 0-7)
//angle is the absolute position from 500 to 5500
//Send a Pololu Protocol command
Serial.print(0x80,BYTE); //start byte
Serial.print(0x01,BYTE); //device id
Serial.print(0x04,BYTE); //command number
Serial.print(servo,BYTE); //servo number
//Convert the angle data into two 7-bit bytes
Serial.print(((angle>>7)&0x3f),BYTE); //data1
Serial.print((angle&0x7f),BYTE); //data2
}
void servoOff(unsigned char servo){//turns off a servo
//(servo will go limp until next position command)
//servo is the servo number (typically 0-7)
//Send a Pololu Protocol command
Serial.print(0x80,BYTE);//start byte
Serial.print(0x01,BYTE);//device id
Serial.print(0x00,BYTE);//command number
Serial.print(servo,BYTE);//servo number
Serial.print(0x0f,BYTE);//data1 (turn servo off, keep full range)
}
void servoSetSpeed(unsigned char servo, unsigned char speedcmd){
//servo is the servo number (typically 0-7)
//speed is servo speed (1=slowest, 127=fastest)
//set speed to zero to turn off speed limiting
speedcmd=speedcmd&0x7f;//take only lower 7 bits of the speed
//Send a Pololu Protocol command
Serial.print(0x80,BYTE);//start byte
Serial.print(0x01,BYTE);//device id
Serial.print(0x01,BYTE);//command number
Serial.print(servo,BYTE);//servo number
Serial.print(speedcmd,BYTE);//data1
}
All that RC hobby servos can do is go to a position as fast as they can (except for really fance specialized servos). The 1-2ms pulses just encode the desired position; in the case of a speed control, speed is substituted for position. When doing “speed control” with a servo controller, the servo controller is really just automatically gradually changing the target position. If you use the speed option with a speed control, you will just change the rate of changing the speed (i.e. have acceleration control).
I spent a month last winter trying to get the EVX-2 ESC to work correctly with pulses from a microcontroller. I gave up.
The EVX-2 works from pulses just like the servos. 2.0 msec pulse is high speed forward, 1.5 msec is off-no brake (actually 1.492 msec on my EVX-2) and 0.9 msec for full reverse or full brake. There is a 20 msec pause between pulses.
I had two problems. First, I could not get the EVX-2 to go into reverse reliably. Going from forward to reverse just produced brake, no reverse. I tried stopping the motors, monitoring the encoders for zero speed, then reversing the pulse. That worked some time, but not all of the time.
The second problem is that it doesn’t brake without a pulse width less than 1.5 msec. In other words, you could be going fast and give it a command to slow to another forward speed, and it just coasts for a long time. Even changing the pulse width to 1.5 msec doesn’t result in braking, just coasting. That is not a good characteristic if accurate speed control is desired.
Remember that the EVX-2 was made for manual control and intended to ease drive train shock loads regardless of driver input.
I gave up and bought a different control for the motor.
Thanks for the help. I played around with the settings till I found the right numbers.
I remember that I had to put the wireless remote in reverse twice for it to go from forward to reverse. Maybe something with the gear box on the E-maxx?
Richard: which motor controller did you use that worked better than the EVX-2?
Here is an example I used to go from forward to reverse with the code I posted earlier:
(I also put a “put(0,2900);” in the setup area of the code to reset the EVX-2, to bring it to a green light state)
Unfortunately, I did not use a Pololu product. I used a Robotec AX1500SC. This is one of the very few robots that I’ve built that does not use one of the Pololu motor drivers.
Going into reverse twice to get reverse drive does work with the remote control. I could not duplicate the function reliably with a microcontroller. It is not the gearbox, the EVX-2 is controlling reverse.
Once you have your code working, try an autonomous four point turn:
Drive forward up to a solid object (wall).
Give full right and reverse for a little while.
Stop.
Give full left and forward for a little while.
Stop.
Give full right and reverse for a little while.
Stop.
Give full left and drive away from the wall.
Once you can successfully perform that maneuver, then you’ve mastered the EVX-2.