I have it working. My problem was in the config.txt of the raspberry pi. I saw the issue in another forum post. If you are using a raspberry pi 3 you must include “enable_uart=1”. Lots of reasons, but anyone interested can read about it https://www.raspberrypi.org/documentation/configuration/uart.md I complicated the problem by mixing up version 2 Raspberry pi boards with version 3. So I would get mixed results.
My test code is here (note I borrowed from others to create this code):
ser = serial.Serial(
baudrate = 9600,
# designated all stop routine
packet4 = bytearray()
packet4.append(0xAA) # safe start
packet4.append(0x0A) # 10 unit addressed
packet4.append(0x60) # stop command
packet5 = bytearray()
packet5.append(0xAA) # safe start
packet5.append(0x0D) # 13 unit addressed
packet5.append(0x60) # stop command
# in theory, the joystick commands would be interperted and corresponding
# values would be passed to speed and direction variables
# Each packet would represent one SMC/motor and all would be written via
# ser.write() each loop. If there is a keyboard interrupt it would kill the loop
# When the loop dies, the stop packets are called.
packet2 = bytearray() # initiate an empty bytearray() to hold commands
packet2.append(0xAA) # safe start
packet2.append(0x0A) # 10 unit addressed (unit 10)
packet2.append(0x05) # forward command
packet2.append(0x00) # first part of speed info
packet2.append(0x32) # second part of speed info; half speed
packet3 = bytearray()
packet3.append(0x0D) # 13 unit addressed (unit 13)
The append method seems cleaner to me to create a string of hexidecimal commands. The command reference can be found in the “Pololu Simple Motor Controller User’s Guide.”
Thanks to Brandon and Amanda for the help.
FYI for anyone reading this post. My project was to develop a heavy duty 12v 25+amp capable system to move a robot. The canned solutions that Adafruit has are for low power systems. Quite honestly that bores the engineering class I am teaching. My robots are designed to be as large as a mini frig and very powerful. I tried several different Pololu products to develop a kid proof system to move the robot and the SMCs are the best. I have 4 - 12 volt CIM drive motors that that are driven through gears. The Pololu G2 High Power Motor Driver 18x25 theoretically should do the job if you call it from an Arduino. But I was never satisfied with passing command parameters to a raspberry pi, then having an Arduino pass PWM parameters to the the High Power Motor Controllers. I can control the PWM easily on the SMC from serial commands from the raspberry pi. Much cleaner system. I also developed a hat for the raspberry pi to make the wiring cleaner.
I have already established a system of controlling robots through an xbox 360 wireless controller and a raspberry pi. So my next step is to merge the my previous work with this project. Because I am using VEX Mechanum Wheels (can go in any direction), the control logic is going to be a bear. If you would like more information on lessons learned, reply to this thread and I will share.