Starting two dc brushed motors at the same time

this is my first time posting here but I’ve read many of the topics in the last year. All are very helpful and informative. However I did not find any that addresses my issue.

First some background. I am building a rover that will eventually be automatous, and I still have a long way to go on the systems integration. But each month I get a little closer to that end. About 99% of Ivan is designed and printed on my 3D printer. The other 1% was purchased from a variety of vendors.

Now to the details. I have two 37Dx57L mm motors and two 18v7 drivers; each motor has its own driver. I have each of these drivers plugged into separated USB port on a raspberry pi 2, model ‘B’. Each motor drives a track on rover.

I would like both motors to start at the same time, but, unfortunately, they do not. Here is the python code I am using and it is running as a background process.

    if os.path.isfile("/mnt/robot/BMF"):
            os.system("./smc/smc_linux/SmcCmd --device 52FF-6F06-7283-5255-3352-2467 --resume --speed 3200") # right motor

            os.system("./smc/smc_linux/SmcCmd --device 52FF-7206-7283-5255-1221-2267 --resume --speed 3077")        # left motor


Currently I have two raspberries talking with each other through NFS. One pi is motorPi and the other is sensorPi. In the future additional Pis will be added for different functionality (including voice control). The “BMF” file the code is looking for is on the NFS share.

I know I am sending two different commands through the os and this is why the two motors start at different times.

From reading through the forums I learned that the two controllers can be daisy-chained. If I do this, will both motors start at the same time? (I will need to adjust the above code accordingly too). If daisy-chain will not work, do you have any other suggestions?


Hello, Bill.

Can you quantify the latency between sending the speed command for your right motor and left motor? How precisely do you need to have your motors start from each other? Which version(s) of the Raspberry Pi board are you using?

For your setup, I do not think daisy-chaining the SMCs will help or provide much benefit over just talking to the SMCs through their virtual serial ports. Instead, you might try running SmcCmd from two separate threads so both invocations of the command can run simultaneously. If that solution does not satisfy your application’s requirements, you should look into writing your own code to communicate with both SMCs in your system more efficiently, either using the SMC’s native USB interface or virtual serial port.

- Amanda

Hi Amanda,

thanks for the help. Threading fixed the issue perfectly.


1 Like