I'm working on a self balancing unicycle using this http://www.instructables.com/id/Easy-build-self-balancing-skateboardrobotsegway-/ instructable as a guide and using a Syren 25a motor controller SyRen 25A regenerative motor driver - analog, R/C, and serial motor control.
When I finally wired everything up and tested my modified version of his code the motor went crazy and didn't do anything I expected. I tried various stuff to get some decent result out of the motor controller and failed.
So I tried to write a code to check the Syren is functioning properly and the motor is still not behaving as I expected.
From the Syren instructions it says
"Simplified serial mode uses TTL level RS-232 serial data to set the speed and direction of the
motor. This is used to interface the SyRen to a PC or microcontroller. If using a PC, a level
converter such as a MAX232 chip must be used. The baud rate is set via DIP switches.
Commands are single-byte, with 0 representing full reverse and 255 representing full forward.
There is also a Slave Select mode which allows the use of multiple motors from a single
microcontroller serial port."
Here is my sketch
#include <SoftwareSerial.h>
SoftwareSerial SaberSerial(8, 12);
void setup()
{
Serial.begin(9600);
SaberSerial.begin(9600);
}
void loop()
{
Serial.println("start");
SaberSerial.print (10, BYTE);
delay (5000);
Serial.println ("20");
SaberSerial.print (20, BYTE);
delay (5000);
Serial.println ("40");
SaberSerial.print (40, BYTE);
delay (5000);
Serial.println ("60");
SaberSerial.print (60, BYTE);
delay (5000);
Serial.println ("80");
SaberSerial.print (80, BYTE);
delay (5000);
SaberSerial.print (100, BYTE);
delay (5000);
Serial.println ("100");
SaberSerial.print (127, BYTE);
Serial.println ("FULL STOP");
delay (10000);
SaberSerial.print (150, BYTE);
delay (5000);
Serial.println ("175");
SaberSerial.print (175, BYTE);
delay (5000);
Serial.println ("200");
SaberSerial.print (200, BYTE);
delay (5000);
Serial.println ("225");
SaberSerial.print (225, BYTE);
delay (5000);
Serial.println ("250");
SaberSerial.print (250, BYTE);
delay (5000);
Serial.print ("loop");
}
Which should start at almost full speed in one direction slow down to zero and then speed up in the other direction sending it's progress to the serial window so I can see what it's doing and when.
I have the battery and motor connected to the battery and motor connections on the syren, S1 on the syren is connected to pin 12 on the Arduino and 0v on the syren connected to ground on the Arduino nothing else is connected except USB and power from the batteries through a converter for the Arduino.
Does that look ok? am I doing something basically wrong ? or do I actually have some faulty hardware somewhere.
When I apply power the motor instantly speed's up and then acts erratically it appears to be trying to do something ... but its certainly not doing what I expect. The figures in the serial window look right.
I've reached the point where I just want to get the motor to do ANYTHING I ASK it to just to confirm all my hardware is ok.
Thanks for any help you may be able to give.