Arduino to SyRen 25 Speed Controller

I am using a joystick to control the direction of a dc motor. I have my Arduino UNO connected via pin 3 to the S1 port of my SyRen 25A speed controller (http://www.dimensionengineering.com/datasheets/SyRen10-25.pdf). The speed controller is set to R/C Standard. When I use an oscilloscope to look at the signal coming from pin3 i get a pulse of 2000us when i move my joystick to the right and a pulse of 1000 when i move the joystick to the left (and 1500us when joystick is in netural). However I get no response from the motor (connected to M1 and M2 on the speed controller), a power supply is connected to B+ and B- as well. Has anyone run into this issue or have any idea on what else I can try (have tried analogWrite, and use of servo library)??

Here is my code…

int str = 3; //steering motor to PWM 3
int knobPin = 1; //joystick x axis pot to analog input 1
int knobValue; //store value read by joystick
int fadeValue, fadeValue2; //mapped values from joystick values
void setup () {
pinMode(knobPin, INPUT);
pinMode(str, OUTPUT);
Serial.begin(9600);
}

void loop () {
knobValue = analogRead(knobPin);

fadeValue = map(knobValue, 200, 800, 0, 1000);
if (knobValue >= 530) {
digitalWrite(str, HIGH);
delayMicroseconds(2000-fadeValue);
digitalWrite(str, LOW);
delayMicroseconds(10000-(2000-fadeValue));
Serial.println(knobValue);
}

fadeValue2 = map(knobValue, 200, 800, 0, 1000);
if(knobValue <= 500){
digitalWrite(str, HIGH);
delayMicroseconds(2000-fadeValue2);
digitalWrite(str, LOW);
delayMicroseconds(10000-(2000-fadeValue2));
Serial.println(knobValue);
}
}

on the datasheet for the speed controller is says the PWM frequency is 32kHz, does this have to match up with the output frequency on my Arduino UNO of 490Hz? If so does anyone know how to do this?

GucciMo: on the datasheet for the speed controller is says the PWM frequency is 32kHz, does this have to match up with the output frequency on my Arduino UNO of 490Hz? If so does anyone know how to do this?

No this is unrelated. The 32kHz PWM frequency is used by the SyRen to control your motor and does not apply to how you control the SyRen.

The controller expects a continues stream of pulses where pulse-length determines direction and speed. If your joystick is left at center, no pulses will be sent and this may trigger the motor controllers saftey/shutdown mechanism. Your options would be to always send a pulse or if you're brave disable the shutdown mechanism (switch 6 down).

Your loop might be something like this:

void loop()
{
  int DelayTime = 1500 + (analogRead(JoystickPin) - 512) * 500l / 1024l;
  
  digitalWrite(SyrenPin, HIGH);
  delayMicroseconds(DelayTime);
  digitalWrite(SyrenPin, LOW);
  delay(100);
  Serial.println(DelayTime);
}

thanks a lot for the feedback it was extremely helpful.

Hi,

don't do that, use a servo object instead, it is specifically designed to generate RC Signals in the background leaving your main code free to do something useful.

The servo object has a function - writeMicroseconds, call this once to set the pulse width and the Arduino will send a steady stream of pulses to you esc.

have a look at my blog, in particular the 'read an RC receiver' and 'control multiple channels' posts.

Duane B rcarduino.blogspot.com