In [1]:
from arduinostepper import arduinostepper as ardstep

In [15]:
import serial

In [16]:
ser = serial.Serial('COM3',57600,timeout=0.005)

In [17]:
motor = ardstep.arduinoMotor(ser,verbose=True)

In [18]:
ardstep.motordict['sample']['handle'] = motor

In [93]:
def checksum(msg):
    chk = 0
    for c in msg:
        try:
            chk -= ord(c)
        except TypeError:
            chk -= c
    return bytes([chk % 256])

def append_checksum(msg):
    return msg.encode('ascii') + checksum(msg)

In [23]:
ser.close()

In [19]:
ser.write(b'\x89PX\xed')


Out[19]:
4

In [11]:
hex(237)


Out[11]:
'0xed'

In [20]:
motor.readAndParse()


0
Out[20]:
'0'

In [22]:
for i in range(100):
    ardstep.go_to_degree(25)
    ardstep.go_to_degree(0)


OK
43
833
OK
789
0
OK
44
833
OK
791
0
OK
44
833
OK
790
0
OK
43
833
OK
790
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-22-e88b04aeea6a> in <module>()
      1 for i in range(100):
      2     ardstep.go_to_degree(25)
----> 3     ardstep.go_to_degree(0)

C:\Users\holde\Documents\GitHub\ArduiArcStepper\arduinostepper\arduinostepper.py in go_to_degree(degree, blockuntilcomplete)
     92             except ValueError:
     93                 continue
---> 94             time.sleep(1)
     95 
     96 def go_to_mm(distance,blockuntilcomplete = True):

KeyboardInterrupt: 

In [9]:
ardstep.go_to_degree(50)


OK
46
1666

In [ ]:


In [ ]:


In [ ]:


In [89]:
checksum(append_checksum('X1234556'))


Out[89]:
b'\x00'

In [90]:
checksum('X')


Out[90]:
b'\xa8'

In [20]:
a=append_checksum('X0')

In [22]:
def wrap_message(msg):
    return b'<'+msg+b'>'

In [23]:
wrap_message(append_checksum('X0'))


Out[23]:
b'<X0x>'

In [84]:
ser.write(append_checksum('X0'))


Out[84]:
3

In [29]:
ser.write(wrap_message(append_checksum('X500')))


Out[29]:
7

In [30]:
motor.readAndParse()


OK
Out[30]:
'OK'

In [51]:
b = 'X'

In [53]:
b.encode('ascii')


Out[53]:
b'X'

In [47]:
checksum('X')


Out[47]:
b'\xa8'

In [45]:
bytes([120])


Out[45]:
b'x'

In [38]:
ser.write(b'X\xa8')


Out[38]:
2

In [40]:
ser.write(b'X')


Out[40]:
1

In [41]:
motor.readAndParse()


ChecksumError
Out[41]:
'ChecksumError'

In [26]:
ord('X')


Out[26]:
88

In [33]:
hex(168)


Out[33]:
'0xa8'

In [36]:
b'X\xa8'


Out[36]:
b'X\xa8'

In [28]:
chr(168)


Out[28]:
'¨'

In [27]:
-88 % 256


Out[27]:
168

In [135]:
ser.close()

In [7]:
import time

In [159]:
ser.write(b'<X500')


Out[159]:
5

In [167]:
ser.write(b'X500>')


Out[167]:
5

In [160]:
ser.write(b'<X1500>')


Out[160]:
7

In [168]:
ser.write(b'<X100>')


Out[168]:
6

In [173]:
ser.write(b'<PX>')


Out[173]:
4

In [174]:
motor.readAndParse()


100
Out[174]:
'100'

In [113]:
motor.waittime=0.1

In [116]:
ser.readline?

In [47]:
ser.write(wrap_message(append_checksum('PX')))


Out[47]:
5

In [49]:
motor.readAndParse()



Out[49]:
''

In [50]:
append_checksum('PX')


Out[50]:
b'PXX'

In [51]:
checksum('PXX')


Out[51]:
b'\x00'

In [89]:
ser.close()

In [31]:
for i in range(20):
    ser.write(wrap_message(append_checksum('X900')))
    time.sleep(0.25)
    print(motor.readAndParse())
    time.sleep(1)
    ser.write(wrap_message(append_checksum('X0')))
    time.sleep(0.25)
    print(motor.readAndParse())
    time.sleep(1)


OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-31-c894e1fd446a> in <module>()
      1 for i in range(20):
      2     ser.write(wrap_message(append_checksum('X900')))
----> 3     time.sleep(0.25)
      4     print(motor.readAndParse())
      5     time.sleep(1)

KeyboardInterrupt: 

In [61]:
for i in range(20):
    ser.write(wrap_message((b'X900')))
    time.sleep(0.25)
    print(motor.readAndParse())
    time.sleep(1)
    ser.write(wrap_message((b'X0')))
    time.sleep(0.25)
    print(motor.readAndParse())
    time.sleep(1)


OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-61-dd96292cbc76> in <module>()
      3     time.sleep(0.25)
      4     print(motor.readAndParse())
----> 5     time.sleep(1)
      6     ser.write(wrap_message((b'X0')))
      7     time.sleep(0.25)

KeyboardInterrupt: 

In [19]:
for i in range(20):
    ardstep.go_to_degree(10)
    ardstep.go_to_degree(0)


OK
44
333
OK
290
0
OK
42
333
OK
289
0
OK
43
333
OK
290
0
OK
42
333
OK
292
0
OK
42
333
OK
291
0
OK
44
333
OK
289
0
OK
44
333
OK
290
0
OK
41
333
OK
286
0
OK
44
333
OK
290
0
OK
43
333
OK
289
0
OK
42
333
OK
287
0
OK
41
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-19-dbfa8c6d1870> in <module>()
      1 for i in range(20):
----> 2     ardstep.go_to_degree(10)
      3     ardstep.go_to_degree(0)

C:\Users\holde\Documents\GitHub\ArduiArcStepper\arduinostepper\arduinostepper.py in go_to_degree(degree, blockuntilcomplete)
     76             except ValueError:
     77                 continue
---> 78             time.sleep(1)
     79 
     80 def go_to_mm(distance,blockuntilcomplete = True):

KeyboardInterrupt: 

In [ ]:


In [20]:
ser.close()

In [ ]:


In [ ]:
`