Hey
I am trying to use Python to control a motor over RS232 (serial ports).
It is connected to COM3, and the connection settings are correct (baud=9600, etc).
I am using pySerial in Python 2.5.
My code is:
import serial, time
# the serial port connections - customise as necessary
motor = serial.Serial('COM3', baudrate=9600)
# start doing stuff
try:
motor.write('''1ON
1LIMITS(3,0,0)
iD4000
1G
''')
time.sleep(.1)
print motor.read(motor.inWaiting())
finally:
# in case of an error, close the serial ports - avoids them being locked
motor.close()
If I type exactly the same thing into HyperTerminal/Teraterm it works fine.
However. the motor does not move, but I get varying outputs such as:
1ON
1LIMITS(3,0,0)
iD4000
1G
or
1ON
1LIMITS(3,0,*E
)
iD4000
1G
where *E denotes an error. This error can be in various locations.
I have no idea why this is not working