Apologies for my late response but I've had to attend to other matters. 

 

In your sample Python code where is "data" defined?

 

-----Original Message-----
From: Ernesto Lo Valvo <[email protected]> 
Sent: December 11, 2020 11:06 AM
To: [email protected]
Subject: Re: [Emc-users] Sample code

 

I have made something similar to what you ask between a Raspberry and an
Arduino board with a 16x2 LCD display.

The Python program that runs on the Raspberry is this:

 

------

import linuxcnc

import serial, time

 

ser = serial.Serial('/dev/ttyUSB0')  # open serial port data =
linuxcnc.stat()

 

try:

         while True:

                      data.poll()

                      x=data.actual_position[0]-data.g5x_offset[0]

                      y=data.actual_position[1]-data.g5x_offset[1]

                      z=data.actual_position[2]-data.g5x_offset[2]

                      a=data.actual_position[3]-data.g5x_offset[3]

               r0=("X{x:5.2f} Y{y:5.2f}".format(x=x,y=y))

               r1=("Z{z:5.2f} A{a:5.2f}".format(z=z,a=a))

 

               ser.write(r0.encode('utf-8')+'%')

               ser.write(r1.encode('utf-8')+'%')

               time.sleep(.05)

 

except KeyboardInterrupt:

         ser.close()

------

 


_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to