Running Motors through DHB-10 motor controller using serial messages

Hi,

I'm trying to run the motors (https://www.parallax.com/product/28962) with the DHB-10 (https://www.parallax.com/product/28231) using a raspberry pi 2 with python serial messages. I have the wires connected as shown in this post: http://forums.parallax.com/discussion/166289/dhb-10-with-raspberry-pi-3, and my code is as follows:
import serial
import time

def readlineCR(port):
rv = ""
while True:
ch = port.read()
rv += ch
if ch == '\r' or ch == '':
return rv


port = serial.Serial(

port = "/dev/ttyAMA0",
baudrate = 19200,
parity = serial.PARITY_NONE,
stopbits = serial.STOPBITS_ONE,
timeout = 1

)

print('Starting...')

while True:
port.write("GOSPD 32 32\r".encode())
rcv = readlineCR(port)
print(rcv)
time.sleep(0.1)

This all seems to run fine, but the DHB-10 motor lights continue to flash orange and the motors do not move.

Any suggestions to why this is not working?

Comments

  • 1 Comment sorted by Date Added Votes
  • have you tried "\r\n" ?

    Mike
    I am just another Code Monkey.

    A determined coder can write COBOL programs in any language. -- Author unknown.

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
Sign In or Register to comment.