LVDS motor controller Item 120

Hi,

Can this motor controller be used as an LED driver? I’m thinking of trying to drive some strings (length undetermined yet) of single color LEDs with the driver, if it’s safe. Of course, keeping it within the amp limits.

Thanks

PS, anyone have some sample Arduino code for this driver? I’m getting it ready to test drive.

Hello.

Yes, the motor outputs can be used to drive LEDs (make sure you include the appropriate current-limiting resistors). Note that the low operating voltage limit of this controller will in turn limit the length of the LED strings you can drive, however.

I am not aware of any Arduino code written specifically for this driver, but there are plenty of examples out there for sending serial bytes. You can use these as a starting point for your own programs (just change the values of the bytes you are sending to conform with the LVDSMC protocol).

- Ben

Thanks Ben.

I am confused about the assignment of motor numbers. Why are there 6 motor numbers if the controller only supports 1 or 2? If I set the configuration for a 2-motor setup, how do I know what # each motor is assigned?

I used number 0 (all motors) to try and get it up and running. When I use the following code, I get the LEDs on the driver board to light up, but when I connect the power source to the motor, I get unpredictable results and sometimes the driver shuts down after a half second.

I’m using a common ground. Same results if I use the 5v AC adaptor or 4xAA battery pack. (Am I exceeding the voltage causing it to crash?)
EDIT I subbed in a single AA for the power source to the motor. Now it pulses power to the motor for 30 seconds, goes off for 3 and then pulses again…

Lastly, I am using the reset as seen in the code, but if I can only get the driver to work if the lead is disconnected. If I connect it, I get no response.

Thanks. PS, yes, I am a rookie at coding.

void setup() {
  // initialize serial port:
  Serial.begin(9600);
int reset=2;  
int start=0x80; //start byte
int device=0;  //device type
int motorNumberDirection=1; //Motor number and direction
int speedA=110;  //speed
int varE=2;

pinMode(reset, OUTPUT);      // swt reset as output

digitalWrite(reset, LOW);   // engages reset
delay(10);
digitalWrite(reset, HIGH);   // releases reset
delay(100);
  

Serial.write(start);
Serial.write(device);
Serial.write(motorNumberDirection); 
Serial.write(speedA);
}
void loop() {
}

Before I look at your code in detail, can you tell me exactly what you have connected to the motor outputs? For example, what color LEDs, how many (and in parallel or series?), what the value of your current-limiting resistor is, etc.

There aren’t six motor numbers, there are six bits for specifying the motor number, which means there are 64 possible motor numbers. Each controller can only drive two motors, but you can chain multiple controllers together on the same serial bus, in which case you would want to configure different controllers to respond to different motor numbers (e.g. controller 1 has motors 2 and 3, controller 2 has motors 4 and 5, controller 3 has motors 6 and 7, etc.).

- Ben

Actually, for now I am using a “tamiya 70168 Double Gearbox kit”. I want to make sure I can get the code and connections ironed out before playing with the LED strings. In my post I was referring to the indicator LEDs on the driver board. I am testing it with just a single motor and the power sources I identified, but can’t seem to get consistent results …

Do you get consistent results if you disconnect your motor and just use the motor indicator LEDs for feedback? The Tamiya motor you are using is very noisy and could be resetting the motor controller if you haven’t taken steps to reduce motor noise (e.g. by soldering 0.1 uF caps across the motor terminals). Going by the motor indicator LEDs will be more representative of what you will see if you connect LEDs to the driver outputs rather than a motor.

- Ben

Hi Ben,

Thanks, the capacitor resolved my resetting issue. I think I have a problem with configuring the motor controller. (I can get it to operate if I use motor #s 0 and 1, however, that engages both motors and I can’t operate them independently).

I am configuring with the following code. It doesn’t seem to be registering the motor #s I am assigning it. I am trying to assign the motors to #s 2 and 3. As I read page 7 of the user guide, I should be getting at least 3 LED flashes after configuration to represent the assignment of motor #2. However, I am only getting one flash, making me think something is wrong. Here’s my configuration code:

void setup() {
  // initialize serial port:
  Serial.begin(9600);
int reset=2;  
int start=0x80; //start byte
int configA=0x02; //change configuration
int configB=0x02;  //new settings

pinMode(reset, OUTPUT);      // set reset as output
digitalWrite(reset, HIGH);   // disengages reset

  // configuration
Serial.write(start);
Serial.write(configA);
Serial.write(configB);

delay(10);
digitalWrite(reset, LOW);   // engages reset
delay(10);
digitalWrite(reset, HIGH);   // disengages reset
delay(100);
 
}
void loop() {
}

Your configuration command looks correct, but you are resetting the controller 10 milliseconds after you send the command, which means you aren’t giving it any time to flash the LEDs. Can you see what happens if you remove the code that resets the controller (or delay for a really long time before doing so, like 10 seconds)?

- Ben

Thanks for the suggestions. I tried both, but no change in the results. I’m only getting one quick flash from one of the LEDs after configuration.

From your code, it looks like you have the motor controller connected to the hardware serial receive line of the Arduino (pin 0). This pin is also used for programming, which means the LVDSMC is getting all sorts of random commands every time you upload a new sketch, and this could be putting it into a bad state before you ever try to configure it.

Can you briefly reset the board at the beginning of setup() after you call Serial.begin()?

void setup() {
  Serial.begin(9600);
  int reset=2;  
  int start=0x80; //start byte
  int configA=0x02; //change configuration
  int configB=0x02;  //new settings

  pinMode(reset, OUTPUT);      // set reset as output
  digitalWrite(reset, LOW);  // reset the board
  delay(10);
  digitalWrite(reset, HIGH);   // disengages reset
  delay(10);

  // configuration
Serial.write(start);
Serial.write(configA);
Serial.write(configB);
}

- Ben

Actually, I have it connected to pin 1, not 0. Your suggested delays seem to be working though. So big thanks to you for saving the rest of the hair on my head.

Are there other pins or a different setup you would suggest to avoid the problems of loading in new sketches?

Oops, sorry, I meant pin 1 (Arduino serial transmit). I’m very glad to hear you have it working now. Some Arduinos have multiple UARTs, which would let you use something other than the one used for programming. If your Arduino only has one UART, you could consider using software serial on arbitrary digital I/O pins, but you should continue to do the initial reset since activating the software serial module can put initial noise on the serial lines that confuses the LVDSMC.

- Ben