API¶
PTHat class¶
-
class
pthat.
PTHat
(command_type='I', command_id=0, serial_device='/dev/ttyS0', baud_rate=115200, test_mode=False)¶ Bases:
object
-
class
PTHat
¶ This is the main Pulse Train Hat class. It is used to run commands against the PTHat and to run general commands.
- Parameters
command_type (str, optional) – type of command, I = instant, B = buffered - defaults to I
command_id (int, optional) – optional command ID, 0-99 - defaults to 0
serial_device (str, optional) – path to the serial device - defaults to /dev/ttyS0
baud_rate (int, optional) – serial port baud rate - defaults to 115200
test_mode (boolean, optional) – if true then serial commands will not actually be sent - defaults to False
-
debug
= False¶ Sets debug mode. This just prints additional information. This must be set directly
-
wait_delay
= 0¶ - Wait delay between commands - 0-9999 - This can be set directly.
Delay in milliseconds: 1000ms = 1 second delay,
Delay in microseconds: 1000us = 0.001 of a second
-
auto_send_command
= False¶ Automatically send the command when command methods are called. This can be set directly.
-
command_type
= 'I'¶ - Type of command, instant or buffer. This can be set directly.I = Instant or B = Buffer.
-
command_id
= 0¶ - Optional command ID. This can be set directly.Any value between 0 and 99.
-
test_mode
= False¶ This lets all methods to be run without actually sending them to the serial port. This can be set directly.
-
serial
= None¶ The path to the serial device such as /dev/ttyS0. This can be set directly.
-
property
motor_enabled
¶ - Specifies if the motor is enabled or not. Do not set this as it is set internally.Read-only property
- Returns
True or False
- Return type
bool
-
property
received_command_replies_enabled
¶ - If received command replies are enabled or not.Read-only property
- Returns
True or False
- Return type
bool
-
property
completed_command_replies_enabled
¶ - If completed command replies are enabled or not.Read-only property
- Returns
True or False
- Return type
bool
-
property
command_end
¶ - Serial command ending character. Set to *.Read-only property
- Returns
command end character
- Return type
str
-
property
version
¶ - Version of this API.Read-only property
- Returns
version number
- Return type
str
-
init_serial_interface
(write_timeout=2, timeout=2)¶ Initializes the serial port
- Parameters
write_timeout – write timeout - default 2
timeout – read timeout - default 2
- Returns
serial port object
- Return type
class:serial.Serial
-
send_command
(command)¶ This method sends the command to the serial port asynchronously
- Parameters
command – command to send
-
get_all_responses
()¶ This method gets all responses until no more can be returned
- Returns
a list of responses
- Return type
list
-
get_response
()¶ This method gets a single response. A response is the value returned up to an *.
- Returns
a single response as a string
- Return type
str
-
parse_responses
(responses)¶ Parse the list of responses and set the various values in the class. Returns responses that were not parsed as some responses may come from the other classes such as Axis or AUX.
- Parameters
responses – list of responses to parse
Todo
finish parsing
-
get_io_port_status
()¶ When this request is sent, it will return the state of the Emergency Stop input port and each of the Limit Switch input ports. This allows them to be used as general inputs when limits disabled.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
LI
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant CommandB=Buffer CommandSets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
LI = Port Status
Request current Port Status
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. In this case the received command will be sent back along with the state of the ES/Limit inputs and then completed command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
IO Port Status Received *Result*
IO Port Status Completed
RI00LI**Result*
CI00LI*
Result will show asL11111*Bit5=ES inputBit4=X Limit inputBit3=Y Limit inputBit2=Z Limit inputBit1=E Limit input
-
set_wait_delay
(period='W', delay=None)¶ When this request is sent, it causes a wait delay between buffered commands. Typical use is when switching one of the AUX outputs and you want to wait a while for it to complete. Note this is a wait and will pause the firmware routines, so do not use if a pulse train channel is running. You can set the Wait period to be in Milliseconds or Microseconds.
- Parameters
period – period of time for the delay, W = Milliseconds, M = Microseconds - default W
delay – length of delay - default 0
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6-9
Byte 10
I
00
WW
1000
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
WW = MillisecondsWM = MicrosecondsSet Wait Delay in either Milliseconds or Microseconds
Byte 6-9
0-9999
Delay in ms so 1000ms = 1 second delayDelay is us so 1000us = 0.001 of a secondByte 10
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
Received
Completed
R00WW*
C00WW*
-
toggle_motor_enable_line
()¶ Toggles the Motor Enable Line
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
HT
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
HT
Toggle Motor Enable Line On/Off
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
Toggle Enable Command Received
Toggle Enable Command Completed
R00HT*
C00HT*
-
received_command_replies_on
()¶ Turns on the Received Replies.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
R1
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
R1 = Turn OnR0 = Turn OffTurn on/off Received Command Replies
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
Received Command Replies Turned On Received
Received Command Replies Turned Off Received
Received Command Replies Turned On Completed
Received Command Replies Turned Off Completed
RI00R1*
RI00R0*
CI00R1*
CI00R0*
-
received_command_replies_off
()¶ Turns off the Received Replies.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
R0
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
R1 = Turn OnR0 = Turn OffTurn on/off Received Command Replies
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
Received Command Replies Turned On Received
Received Command Replies Turned Off Received
Received Command Replies Turned On Completed
Received Command Replies Turned Off Completed
RI00R1*
RI00R0*
CI00R1*
CI00R0*
-
completed_command_replies_on
()¶ Turns on the Completed Replies.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
G1
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
G1 = Turn OnG0 = Turn OffTurn on/off Completed Command Replies
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
Received Command Replies Turned On Received
Received Command Replies Turned Off Received
Received Command Replies Turned On Completed
Received Command Replies Turned Off Completed
RI00G1*
RI00G0*
CI00G1*
CI00G0*
-
completed_command_replies_off
()¶ Turns off the Completed Replies.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
G0
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
G1 = Turn OnG0 = Turn OffTurn on/off Completed Command Replies
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
Received Command Replies Turned On Received
Received Command Replies Turned Off Received
Received Command Replies Turned On Completed
Received Command Replies Turned Off Completed
RI00G1*
RI00G0*
CI00G1*
CI00G0*
-
get_firmware_version
()¶ Requests the Firmware Version from the PTHAT
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
FW
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
FW
Request Firmware version
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
Firmware Command Received*Version*Firmware Command Completed Turned Off
RI00FW**Version*
CI00FW*
-
reset
()¶ Resets the PTHAT back to turn on state and resets all pulse generators. Can be used in an emergency to close everything down and stop the pulse trains.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2
N
*
Command breakdownByte
Setting
Description
Byte 1
N
Sends a Reset to the PTHAT.
Byte 2
*
End of Command
ReplyThe PTHAT will send back a reply when it receives this command.
Reset Command Received
Reset Command Completed
Nothing
Nothing
-
initiate_buffer
()¶ With all the Instant commands you can also send as buffered commands, but you will need to use a couple of extra commands to initiate the buffer first using the H0000* command.
Next you would need to decide how many commands you would like to store in the buffer (up to a maximum of 100 commands) before sending a Buffer Start command Z0000*.
With the release of Firmware V5.3 upwards you can now store 2000 commands in the buffer.
Buffering commands allow you to queue up your commands, so they execute one after the other and reduce latency between commands being executed. Instant commands apart from the Stop command cannot be sent while sending Buffered commands. We recommend to buffer around 20 commands before sending a Buffer Start command and then to send a new command when you get the Complete Reply back, until all your commands have been sent. When all commands have been executed from the buffer you will get a Buffer Empty Reply come back and you will have to Initiate the buffer again to start.
Initiate the buffer before sending any buffered commands.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-5
Byte 6
H
0000
*
Command breakdownByte
Setting
Description
Byte 1
H
Byte 2-5
0000
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives this command.
Initiate Buffer Command Received
RBH000*
-
start_buffer
()¶ Start executing buffered commands.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-5
Byte 6
Z
0000
*
Command breakdownByte
Setting
Description
Byte 1
Z
Byte 2-5
0000
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command.
Start Buffer Command Received
RBZ000*
-
start_buffer_loop
()¶ *Available Firmware V5.3 upwards* Start executing buffered commands. With this command it will run through the buffered commands and when it gets to the last, it will go back to the first command and repeat all commands in a loop until a Stop command is sent.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-5
Byte 6
W
0000
*
Command breakdownByte
Setting
Description
Byte 1
W
Byte 2-5
0000
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command.
Start Buffer Loop Command Received
RBW000*
-
rpm_to_frequency
(rpm, steps_per_rev, round_digits)¶ - Convert RPM to frequencyFormula for calculating stepping motor speed.Below is the RPM formula for stepping motor drives that use pulse signals to create motion.RPM = a/360 * fz * 60RPM = Revolutions per minute.“a” = step angle (degrees of rotation per step)“fz” = pulse frequency in hertzstep angle = degrees of rotation (360) / steps per revolutionExample 1: Drive step resolution is set for 1000 steps per revolution.Find step angle: 360 (degrees of rotation) divided by 1000 (steps per revolution) =.36 (degrees of rotation per step)With input frequency of 1000hz, .36 / 360 * 1000 * 60 = 60 rpmExample 2: Drive step resolution is set for 500 steps per revolution.Find step angle: 360 (degrees of rotation) divided by 500 (steps per revolution) =.72 (degrees of rotation per step)With input frequency of 1000hz, .72 / 360 * 1000 * 60 = 120 rpm.
:param round_digits number of digits to round to :param rpm RPM to convert :param steps_per_rev steps per revolution :returns: frequency :rtype: float
-
frequency_to_rpm
(frequency, steps_per_rev)¶ - Convert frequency to RPMFormula for calculating stepping motor speed.Below is the frequency formula for stepping motor drives that use pulse signals to create motion.To find required frequency to meet desired speed we must find Fz:Fz = RPM / ( (a/360) * 60)“fz” = pulse frequency in hertz“a” = step angle (degrees of rotation per step)RPM = Revolutions per minute.step angle = degrees of rotation (360) / steps per revolutionStep 1. Divide step angle by 360: .36/360 = .001, then multiply by 60 (seconds) .001 * 60 = .06Step 2. Divide desired speed by .06: Desired speed of 500 rpm’s. Therefore ; 500 / .06 = 8333.33( 8333.33 is the frequency in hertz required to reach 500 rpm’s for drive set at 1000 steps per revolution)
:param frequency the frequency :param steps_per_rev steps per revolution :returns: RPM :rtype: int
-
calculate_pulse_count
(steps_per_rev, total_revs)¶ - Calculates the pulse count from the steps per revolution and the total revolutions desired.Calculation ispulse count = steps per rev * total revs
- Parameters
steps_per_rev – steps per revolution
total_revs – total revolutions desired
- Returns
pulse count
- Return type
int
-
calculate_revolutions
(steps_per_rev, pulse_count)¶ - Calculates the number of revolutions from the steps per revolution and the pulse count.Calculation istotal revs = pulse count / steps per rev
- Parameters
steps_per_rev – steps per revolution
pulse_count – total pulse count
- Returns
number of revolutions
- Return type
int
-
class
Axis class¶
-
class
pthat.
Axis
(axis, command_type='I', command_id=0, serial_device='/dev/ttyS0', baud_rate=115200, test_mode=False)¶ Bases:
pthat.PTHat
-
class
Axis
¶
This is an Axis object that contains info about an axis. It inherits from PTHat so contains all functionality needed to communicate with the PTHat via the serial interface.
- Parameters
command_type – type of command, I = instant, B = buffered - default I
command_id – optional command ID, 0-99 - default 0
serial_device – serial device - default /dev/ttyS0
baud_rate – serial port baud rate - default 115200
test_mode – if true then serial commands will not actually be sent - default False
-
frequency
= 0.0¶ Frequency of the pulse train - 000000.000 - 500000.000. This can be set directly.
-
pulse_count
= 0¶ Required pulse count - 0000000000 - 4294967295. This can be set directly.
-
direction
= 0¶ Direction - 0 = clockwise (cw - forward), 1 = counter clockwise (ccw - reverse). This can be set directly.
-
start_ramp
= 0¶ Start ramp - 0 = No Ramp, 1 = Ramp. This can be set directly.
-
finish_ramp
= 0¶ Finish ramp - 0 = No Ramp, 1 = Ramp. This can be set directly.
-
ramp_divide
= 0¶ Ramp divide. Divides target frequency by this value for each ramp increment. 0 - 255. This can be set directly.
-
ramp_pause
= 0¶ Ramp pause between each ramp increment. 0 - 255. This can be set directly.
-
link_to_adc
= 0¶ Link to ADC - 0 = No ADC, 1 = Link to ADC1, 2= Link to ADC2. This can be set directly.
-
enable_line_polarity
= 0¶ Enable line polarity - 0 = Enable Line 0 Volts, 1 = Enable Line 5 Volts. This can be set directly.
-
pulse_count_change_direction
= 0¶ Sets the Pulse count to change direction on the fly - 0000000000-4294967295. This can be set directly.
-
pulse_counts_sent_back
= 0¶ Sets the Pulse count at which all Axis pulse counts will be sent back - 0000000000-4294967295. This can be set directly.
-
enable_disable_x_pulse_count_replies
= 1¶ - Enable/disable X axis pulse count replies. This can be set directly.0=Disable X Axis Pulse Replies, 1=Enable X Axis Pulse Reply
-
enable_disable_y_pulse_count_replies
= 0¶ - Enable/disable Y axis pulse count replies. This can be set directly.0=Disable Y Axis Pulse Replies, 1=Enable Y Axis Pulse Reply
-
enable_disable_z_pulse_count_replies
= 0¶ - Enable/disable Z axis pulse count replies. This can be set directly.0=Disable Z Axis Pulse Replies, 1=Enable Z Axis Pulse Reply
-
enable_disable_e_pulse_count_replies
= 0¶ - Enable/disable E axis pulse count replies. This can be set directly.0=Disable E Axis Pulse Replies, 1=Enable E Axis Pulse Reply
-
pause_all_return_x_pulse_count
= 0¶ - Pause all and send back pulse count replies for X axis. This can be set directly.0=Disable X Axis Pulse Count Replies, 1=Enable X Axis Pulse Count Reply
-
pause_all_return_y_pulse_count
= 0¶ - Pause all and send back pulse count replies for Y axis.This can be set directly.0=Disable X Axis Pulse Count Replies, 1=Enable X Axis Pulse Count Reply
-
pause_all_return_z_pulse_count
= 0¶ - Pause all and send back pulse count replies for Z axis. This can be set directly.0=Disable X Axis Pulse Count Replies, 1=Enable X Axis Pulse Count Reply
-
pause_all_return_e_pulse_count
= 0¶ - Pause all and send back pulse count replies for E axis. This can be set directly.0=Disable X Axis Pulse Count Replies, 1=Enable X Axis Pulse Count Reply
-
axis
= 'X'¶ - The axis this object represents. This can be set directly.X, Y, Z or E or A (all)
-
set_axis
(frequency=None, pulse_count=None, direction=None, start_ramp=None, finish_ramp=None, ramp_divide=None, ramp_pause=None, link_to_adc=None, enable_line_polarity=None)¶ This Command sets the properties of each Axis, but does not start the pulse train on that Axis. A Start Command must be used after to activate.
- Parameters
frequency – frequency of the pulse train, 0.0-500000.0 - default 0.0 or self.frequency
pulse_count – required pulse count, 0-4294967295 - default 0 or self.pulse_count
direction – direction, 0 = forward (CW), 1 = reverse (CCW) - default 0 (forward - CW) or self.direction
start_ramp – start ramp, no ramp = 0, ramp = 1 - default 0 or self.start_ramp
finish_ramp – finish ramp, no ramp = 0, ramp = 1 - default 0 or self.finish_ramp
ramp_divide – ramp divide, 0-255, will divide the target frequency by this value for each ramp increment - default 0 or self.ramp_divide
ramp_pause – ramp pause between each ramp increment, 0-255 - default 0 or self.ramp_pause
link_to_adc – link to ADC, no ADC = 0, ADC1 = 1, ADC2 = 2 - default 0 or self.link_to_adc
enable_line_polarity – enable line polarity, enable line 0 volts = 0, enable line 5 volts = 1 - default 0 or self.enable_line_polarity
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6-15
Byte 16-25
Byte 26
Byte 27
Byte 28
Byte 29-31
Byte 32-34
Byte 35
Byte 36
Byte 37
I
00
CX
125000.000
4294967295
1
1
1
100
010
0
1
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
CX = Set X-AxisCY = Set Y-AxisCZ = Set Z-AxisCE = Set E-AxisSets which Axis is to be set
Byte 6-15
000000.000-500000.000
Sets the frequency of the pulse train
Byte 16-25
0000000000-4294967295
Sets the required pulse count.
Byte 26
0-1
Direction0=CW (forward)1=CCW (reverse)Byte 27
0-1
Start Ramp0=No ramp1=RampByte 28
0-1
Finish Ramp0=No ramp1=RampByte 29-31
0-255
Ramp divide. This will divide the target frequency by this value for each ramp increment
Byte 32-34
0-255
Ramp pause between each ramp increment
Byte 35
0-2
Link to ADC 0=No ADC 1=Link to ADC1 2=Link to ADC2
Byte 36
0-1
Enable Line Polarity 0=Enable Line 0 Volts 1=Enable Line 5 Volts
Byte 37
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply. These can be turned off if needed.
X setReceivedY setReceivedZ setReceivedE setReceivedX setCompletedY setCompletedZ setCompletedE setCompletedRI00CX*
RI00CY*
RI00CZ*
RI00CE*
CI00CX*
CI00CY*
CI00CZ*
CI00CE*
-
set_direction_forward
()¶ Sets the direction to forward
- Returns
the command to send to the serial port
- Return type
str
-
set_direction_reverse
()¶ Sets the direction to reverse
- Returns
the command to send to the serial port
- Return type
str
-
enable_start_ramp
()¶ Enables the start ramp
- Returns
the command to send to the serial port
- Return type
str
-
disable_start_ramp
()¶ Disables the start ramp
- Returns
the command to send to the serial port
- Return type
str
-
enable_finish_ramp
()¶ Enables the finish ramp
- Returns
the command to send to the serial port
- Return type
str
-
disable_finish_ramp
()¶ Disables the finish ramp
- Returns
the command to send to the serial port
- Return type
str
-
enable_line_polarity_0_volts
()¶ Enable the line polarity at 0 volts
- Returns
the command to send to the serial port
- Return type
str
-
enable_line_polarity_5_volts
()¶ Enable the line polarity at 5 volts
- Returns
the command to send to the serial port
- Return type
str
-
set_auto_direction_change
(pulse_count=None)¶ This Command sets the Auto Direction Change of each Axis, but does not start the pulse train on that Axis. A Start Command must be used after to activate.
- Parameters
pulse_count – pulse count to change direction on the fly, 0-4294967295 - default 0 or self.pulse_count
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6-15
Byte 16
I
00
BX
0000000100
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
BX = Set X-AxisBY = Set Y-AxisBZ = Set Z-AxisBE = Set E-AxisSets which Axis is to be set to auto change direction
Byte 6-15
0000000000-4294967295
Sets the Pulse count to change direction on the fly
Byte 16
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply. These can be turned off if needed.
X setReceivedY setReceivedZ setReceivedE setReceivedX setCompletedY setCompletedZ setCompletedE setCompletedRI00BX*
RI00BY*
RI00BZ*
RI00BE*
CI00BX*
CI00BY*
CI00BZ*
CI00BE*
-
set_auto_count_pulse_out
(pulse_count=None, xreplies=None, yreplies=None, zreplies=None, ereplies=None)¶ This Command sets which Axis and at what pulse count it should send back the current pulse count of each axis. It also sends back direction of travel. You can also choose what pulse replies are sent back X, Y, Z or E. A Start Command must be used after to activate.
Be aware that this command can cause a lot of data being sent back over the serial port and if you try to send other commands while it is sending data back, there could be a clash.
- param pulse_count
pulse count at which all Axis pulse counts will be sent back, 0-4294967295 - default 0 or self.pulse_count
- param xreplies
enable/disable X axis pulse count replies, disable = 0, enable = 1 - default 1 or self.enable_disable_x_pulse_count_replies
- param yreplies
enable/disable Y axis pulse count replies, disable = 0, enable = 1 - default 0 or self.enable_disable_y_pulse_count_replies
- param zreplies
enable/disable Z axis pulse count replies, disable = 0, enable = 1 - default 0 or self.enable_disable_z_pulse_count_replies
- param ereplies
enable/disable E axis pulse count replies, disable = 0, enable = 1 - default 0 or self.enable_disable_e_pulse_count_replies
- returns
the command to send to the serial port
- rtype
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6-15
Byte 16
Byte 17
Byte 18
Byte 19
Byte 20
I
00
JX
0000000100
1
1
1
1
*
- I01JX00000064001111
- Command breakdown
Byte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
JX = Set X-AxisJY = Set Y-AxisJZ = Set Z-AxisJE = Set E-AxisSets which Axis is to be set to auto send pulse counts on
Byte 6-15
0000000000-4294967295
Sets the Pulse count at which all Axis pulse counts will be sent back
Byte 16
0-1
Enable/Disable X Axis Pulse Replies0 = Disable1 = EnableByte 17
0-1
Enable/Disable Y Axis Pulse Replies0 = Disable1 = EnableByte 18
0-1
Enable/Disable Z Axis Pulse Replies0 = Disable1 = EnableByte 19
0-1
Enable/Disable E Axis Pulse Replies0 = Disable1 = EnableByte 20
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. The Pulse Count and direction that the motor is travelling will be sent back when pulse target is hit. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply. These can be turned off if needed.
X setReceivedY setReceivedZ setReceivedE setReceivedX setCompletedY setCompletedZ setCompletedE setCompletedRI00JX*
RI00JY*
RI00JZ*
RI00JE*
CI00JX*
CI00JY*
CI00JZ*
CI00JE*
DI00JX*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295DI00JY*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295DI00JZ*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295DI00JE*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295
-
start
()¶ Start one of the pulse trains running.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
SX
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
SX = Start X-AxisSY = Start Y-AxisSZ = Start Z-AxisSE = Start E-AxisSA = Start AllSets which Axis is to be started
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. In this case the completed command will be sent back when the Axis that has been started completes the Pulse Count. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
X StartReceivedY StartReceivedZ StartReceivedE StartReceivedAll StartReceivedX PulseCountCompletedY PulseCountCompletedZ PulseCountCompletedE PulseCountCompletedRI00SX*
RI00SY*
RI00SZ*
RI00SE*
CI00SA*
CI00SX*
CI00SY*
CI00SZ*
CI00SE*
-
start_all
()¶ Start all of the pulse trains running.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
SA
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
SX = Start X-AxisSY = Start Y-AxisSZ = Start Z-AxisSE = Start E-AxisSA = Start AllSets which Axis is to be started
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. In this case the completed command will be sent back when the Axis that has been started completes the Pulse Count. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
X StartReceivedY StartReceivedZ StartReceivedE StartReceivedAll StartReceivedX PulseCountCompletedY PulseCountCompletedZ PulseCountCompletedE PulseCountCompletedRI00SX*
RI00SY*
RI00SZ*
RI00SE*
CI00SA*
CI00SX*
CI00SY*
CI00SZ*
CI00SE*
-
stop
()¶ Stop one of the pulse trains from running. This is a controlled stop, in that the Axis will ramp down and not just stop to protect the motors. If you want to use a sudden stop then we recommend a external Emergency Stop button that cuts the power or send a Reset command.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
TX
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
TX = Stop X-AxisTY = Stop Y-AxisTZ = Stop Z-AxisTE = Stop E-AxisTA = Stop AllSets which Axis is to be stopped
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. In this case the completed command will be sent back when the Axis that has came to a stop. If the Command sent ID number was set for bytes 2-3, then this will be returned in the Received reply, but the completed command ID will be from the original ID used in the Start command.
X StopReceivedY StopReceivedZ StopReceivedE StopReceivedAll StopReceivedX PulseStoppedY PulseStoppedZ PulseStoppedE PulseStoppedRI00TX*
RI00TY*
RI00TZ*
RI00TE*
RI00TA*
CI00TX*
CI00TY*
CI00TZ*
CI00TE*
-
stop_all
()¶ Stop all of the pulse trains from running. This is a controlled stop, in that the Axis will ramp down and not just stop to protect the motors. If you want to use a sudden stop then we recommend a external Emergency Stop button that cuts the power or send a Reset command.
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
TA
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
TX = Stop X-AxisTY = Stop Y-AxisTZ = Stop Z-AxisTE = Stop E-AxisTA = Stop AllSets which Axis is to be stopped
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. In this case the completed command will be sent back when the Axis that has came to a stop. If the Command sent ID number was set for bytes 2-3, then this will be returned in the Received reply, but the completed command ID will be from the original ID used in the Start command.
X StopReceivedY StopReceivedZ StopReceivedE StopReceivedAll StopReceivedX PulseStoppedY PulseStoppedZ PulseStoppedE PulseStoppedRI00TX*
RI00TY*
RI00TZ*
RI00TE*
RI00TA*
CI00TX*
CI00TY*
CI00TZ*
CI00TE*
-
pause
(return_x_pulse_cnt=None, return_y_pulse_cnt=None, return_z_pulse_cnt=None, return_e_pulse_cnt=None)¶ Pauses one of the pulse trains from running. Bytes 6-9 choose to send Pulse count back after pause for each Axis.
- Parameters
return_x_pulse_cnt – X axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_x_pulse_count
return_y_pulse_cnt – Y axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_y_pulse_count
return_z_pulse_cnt – Z axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_z_pulse_count
return_e_pulse_cnt – E axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_e_pulse_count
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
Byte 7
Byte 8
Byte 9
Byte 10
I
00
PX
1
0
0
0
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
PX = Pause X-AxisPY = Pause Y-AxisPZ = Pause Z-AxisPE = Pause E-AxisPA = Pause AllSets which Axis is to be Paused
Byte 6
0-1
Sends back pulse count from Axis if set to 1 with:PA = X-AxisPX = X-AxisPY = Y-AxisPZ = Z-AxisPE = E-AxisByte 7
0-1
Sends back pulse count from Axis if set to 1 with:PA = Y-AxisSet to 0 for PX, PY, PZ, PEByte 8
0-1
Sends back pulse count from Axis if set to 1 with:PA = Z-AxisSet to 0 for PX, PY, PZ, PEByte 9
0-1
Sends back pulse count from Axis if set to 1 with:PA = E-AxisSet to 0 for PX, PY, PZ, PEByte 10
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If Pulse Count is selected then it will also send back the pulse count of chosen Axis. In this case the completed command will be sent back when the Axis is resumed, after a Pause. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
X PauseReceivedY PauseReceivedZ PauseReceivedE PauseReceivedPause AllReceivedRI00PX*
RI00PY*
RI00PZ*
RI00PE*
RI00PA*
DI00PX*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295DI00PY*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295DI00PZ*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295DI00PE*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295DI00PX to E*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295
-
pause_all
(return_x_pulse_cnt=None, return_y_pulse_cnt=None, return_z_pulse_cnt=None, return_e_pulse_cnt=None)¶ Pauses all of the pulse trains from running. Bytes 6-9 choose to send Pulse count back after pause for each Axis.
- Parameters
return_x_pulse_cnt – X axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_x_pulse_count
return_y_pulse_cnt – Y axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_y_pulse_count
return_z_pulse_cnt – Z axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_z_pulse_count
return_e_pulse_cnt – E axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_e_pulse_count
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
Byte 7
Byte 8
Byte 9
Byte 10
I
00
PA
1
0
0
0
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
PX = Pause X-AxisPY = Pause Y-AxisPZ = Pause Z-AxisPE = Pause E-AxisPA = Pause AllSets which Axis is to be Paused
Byte 6
0-1
Sends back pulse count from Axis if set to 1 with:PA = X-AxisPX = X-AxisPY = Y-AxisPZ = Z-AxisPE = E-AxisByte 7
0-1
Sends back pulse count from Axis if set to 1 with:PA = Y-AxisSet to 0 for PX, PY, PZ, PEByte 8
0-1
Sends back pulse count from Axis if set to 1 with:PA = Z-AxisSet to 0 for PX, PY, PZ, PEByte 9
0-1
Sends back pulse count from Axis if set to 1 with:PA = E-AxisSet to 0 for PX, PY, PZ, PEByte 10
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If Pulse Count is selected then it will also send back the pulse count of chosen Axis. In this case the completed command will be sent back when the Axis is resumed, after a Pause. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
X PauseReceivedY PauseReceivedZ PauseReceivedE PauseReceivedPause AllReceivedRI00PX*
RI00PY*
RI00PZ*
RI00PE*
RI00PA*
DI00PX*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295DI00PY*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295DI00PZ*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295DI00PE*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295DI00PX to E*XP(D)XResult*YP(D)XResult*ZP(D)XResult*EP(D)XResult*(D)=Directionof motortravelResult=0000000000-4294967295
-
resume
(return_x_pulse_cnt=None, return_y_pulse_cnt=None, return_z_pulse_cnt=None, return_e_pulse_cnt=None)¶ Resumes one of the pulse trains from running. Bytes 6-9 choose to send Pulse count back after pause for each Axis.
- Parameters
return_x_pulse_cnt – X axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_x_pulse_count
return_y_pulse_cnt – Y axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_y_pulse_count
return_z_pulse_cnt – Z axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_z_pulse_count
return_e_pulse_cnt – E axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_e_pulse_count
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
Byte 7
Byte 8
Byte 9
Byte 10
I
00
PX
1
0
0
0
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
PX = Pause X-AxisPY = Pause Y-AxisPZ = Pause Z-AxisPE = Pause E-AxisPA = Pause AllSets which Axis is to be Paused
Byte 6
0-1
Sends back pulse count from Axis if set to 1 with:PA = X-AxisPX = X-AxisPY = Y-AxisPZ = Z-AxisPE = E-AxisByte 7
0-1
Sends back pulse count from Axis if set to 1 with:PA = Y-AxisSet to 0 for PX, PY, PZ, PEByte 8
0-1
Sends back pulse count from Axis if set to 1 with:PA = Z-AxisSet to 0 for PX, PY, PZ, PEByte 9
0-1
Sends back pulse count from Axis if set to 1 with:PA = E-AxisSet to 0 for PX, PY, PZ, PEByte 10
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If Pulse Count is selected then it will also send back the pulse count of chosen Axis. In this case the completed command will be sent back when the Axis is resumed, after a Pause. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
X ResumeReceivedY ResumeReceivedZ ResumeReceivedE ResumeReceivedResume AllReceivedCI00PX*
CI00PY*
CI00PZ*
CI00PE*
CI00PA*
-
resume_all
(return_x_pulse_cnt=None, return_y_pulse_cnt=None, return_z_pulse_cnt=None, return_e_pulse_cnt=None)¶ Resumes all of the pulse trains from running. Bytes 6-9 choose to send Pulse count back after pause for each Axis.
- Parameters
return_x_pulse_cnt – X axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_x_pulse_count
return_y_pulse_cnt – Y axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_y_pulse_count
return_z_pulse_cnt – Z axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_z_pulse_count
return_e_pulse_cnt – E axis pulse count replies, disable = 0, enable = 1 - default 0 or self.pause_all_return_e_pulse_count
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
Byte 7
Byte 8
Byte 9
Byte 10
I
00
PA
1
0
0
0
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
PX = Pause X-AxisPY = Pause Y-AxisPZ = Pause Z-AxisPE = Pause E-AxisPA = Pause AllSets which Axis is to be Paused
Byte 6
0-1
Sends back pulse count from Axis if set to 1 with:PA = X-AxisPX = X-AxisPY = Y-AxisPZ = Z-AxisPE = E-AxisByte 7
0-1
Sends back pulse count from Axis if set to 1 with:PA = Y-AxisSet to 0 for PX, PY, PZ, PEByte 8
0-1
Sends back pulse count from Axis if set to 1 with:PA = Z-AxisSet to 0 for PX, PY, PZ, PEByte 9
0-1
Sends back pulse count from Axis if set to 1 with:PA = E-AxisSet to 0 for PX, PY, PZ, PEByte 10
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If Pulse Count is selected then it will also send back the pulse count of chosen Axis. In this case the completed command will be sent back when the Axis is resumed, after a Pause. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
X ResumeReceivedY ResumeReceivedZ ResumeReceivedE ResumeReceivedResume AllReceivedCI00PX*
CI00PY*
CI00PZ*
CI00PE*
CI00PA*
-
get_current_pulse_count
()¶ When this request is sent, it will return of the current pulse count of the running Axis.
- Returns
the command to send to the serial port
- Return type
str
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
XP
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
XP = Pulse Count X-AxisYP = Pulse Count Y-AxisZP = Pulse Count Z-AxisEP = Pulse Count E-AxisRequest current pulse count for Axis specified
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. In this case the received command will be sent back along with the Pulse Count and direction that the motor is travelling, then completed command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
X Pulse CountReceivedResultY Pulse CountReceivedResultZ Pulse CountReceivedResultE Pulse CountReceivedResultX PulseCountCompletedX PulseCountCompletedX PulseCountCompletedX PulseCountCompletedRI00XP*
RI00YP*
RI00ZP*
RI00EP*
CI00XP*
CI00YP*
CI00ZP*
CI00EP*
XP(D)XResult*(D)=Directionof X motortravelXResult=0000000000-4294967295YP(D)XResult*(D)=Directionof Y motortravelXResult=0000000000-4294967295ZP(D)XResult*(D)=Directionof Z motortravelXResult=0000000000-4294967295EP(D)XResult*(D)=Directionof E motortravelXResult=0000000000-4294967295
-
change_speed
(new_frequency)¶ This Command changes the speed of each Axis on the fly. A Set Axis Command and a Start Command must be used to set the Axis running before this command can be used. Note that this command does not have a ramp up and ramp down value so speed adjustments must be made in smaller increments with a stepper motor so as to not cause it to stall.
- Parameters
new_frequency – new frequency to change the speed to, 0.0-125000.0 - required
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6-15 | Byte 16
I
00
QX
001000.000 | *
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
QX = Set X-AxisQY = Set Y-AxisQZ = Set Z-AxisQE = Set E-AxisSets which Axis is to be set
Byte 6-15
000000.000-125000.000
Sets the new frequency of the pulse train
Byte 16
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply. These can be turned off if needed.
X SetReceivedY SetReceivedZ SetReceivedE SetReceivedX SetCompletedY SetCompletedZ SetCompletedE SetCompletedRI00QX*
RI00QY*
RI00QZ*
RI00QE*
CI00QX*
CI00QY*
CI00QZ*
CI00QE*
-
enable_limit_switches
()¶ When this request is sent, it will Enable Limit Switch or Emergency Stop inputs. A reset on the PTHAT will set them to default of Disable
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6 | Byte 7
I
00
KX
1 | *
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
KX = Set Limit Switch XKY = Set Limit Switch YKZ = Set Limit Switch ZKE = Set Limit Switch ESet Limit Switch or Emergency Stop Enable/Disable
Byte 6
0-1
Switches selected Limit Switch to Enable/Disable0=Disable1=EnableByte 7
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
X LimitReceivedY LimitReceivedZ LimitReceivedE LimitReceivedEmergencyStopReceivedX LimitCompletedY LimitCompletedZ LimitCompletedE LimitCompletedEmergencyStopCompletedR00KX*
R00KY*
R00KZ*
R00KE*
R00KS*
C00KX*
C00KY*
C00KZ*
C00KE*
C00KS*
-
disable_limit_switches
()¶ When this request is sent, it will Disable Limit Switch or Emergency Stop inputs. A reset on the PTHAT will set them to default of Disable
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6 | Byte 7
I
00
KX
0 | *
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
KX = Set Limit Switch XKY = Set Limit Switch YKZ = Set Limit Switch ZKE = Set Limit Switch ESet Limit Switch or Emergency Stop Enable/Disable
Byte 6
0-1
Switches selected Limit Switch to Enable/Disable0=Disable1=EnableByte 7
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
X LimitReceivedY LimitReceivedZ LimitReceivedE LimitReceivedEmergencyStopReceivedX LimitCompletedY LimitCompletedZ LimitCompletedE LimitCompletedEmergencyStopCompletedR00KX*
R00KY*
R00KZ*
R00KE*
R00KS*
C00KX*
C00KY*
C00KZ*
C00KE*
C00KS*
-
enable_emergency_stop
()¶ When this request is sent, it will Disable Limit Switch or Emergency Stop inputs. A reset on the PTHAT will set them to default of Disable
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6 | Byte 7
I
00
KS
1 | *
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
KX = Set Limit Switch XKY = Set Limit Switch YKZ = Set Limit Switch ZKE = Set Limit Switch ESet Limit Switch or Emergency Stop Enable/Disable
Byte 6
0-1
Switches selected Limit Switch to Enable/Disable0=Disable1=EnableByte 7
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
X LimitReceivedY LimitReceivedZ LimitReceivedE LimitReceivedEmergencyStopReceivedX LimitCompletedY LimitCompletedZ LimitCompletedE LimitCompletedEmergencyStopCompletedR00KX*
R00KY*
R00KZ*
R00KE*
R00KS*
C00KX*
C00KY*
C00KZ*
C00KE*
C00KS*
-
disable_emergency_stop
()¶ When this request is sent, it will Disable Limit Switch or Emergency Stop inputs. A reset on the PTHAT will set them to default of Disable
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6 | Byte 7
I
00
KS
0 | *
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
KX = Set Limit Switch XKY = Set Limit Switch YKZ = Set Limit Switch ZKE = Set Limit Switch ESet Limit Switch or Emergency Stop Enable/Disable
Byte 6
0-1
Switches selected Limit Switch to Enable/Disable0=Disable1=EnableByte 7
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
X LimitReceivedY LimitReceivedZ LimitReceivedE LimitReceivedEmergencyStopReceivedX LimitCompletedY LimitCompletedZ LimitCompletedE LimitCompletedEmergencyStopCompletedR00KX*
R00KY*
R00KZ*
R00KE*
R00KS*
C00KX*
C00KY*
C00KZ*
C00KE*
C00KS*
-
reset
()¶ Call reset on the parent class and then reset all the variables
-
class
ADC class¶
-
class
pthat.
ADC
(adc_number, command_type='I', command_id=0, serial_device='/dev/ttyS0', baud_rate=115200, test_mode=False)¶ Bases:
pthat.PTHat
-
class
ADC
¶
This is an ADC class containing info about an ADC. It inherits from PTHat so contains all functionality needed to communicate with the PTHat via the serial interface.
- Parameters
adc_number – ADC number, 1 or 2
command_type – type of command, I = instant, B = buffered - default I
command_id – optional command ID, 0-99 - default 0
serial_device – serial device - default /dev/ttyS0
baud_rate – serial port baud rate - default 115200
test_mode – if true then serial commands will not actually be sent - default False
-
adc_number
= 1¶ ADC number - Currently 1 or 2. This can be set directly.
-
get_reading
(adc_number=None)¶ When this request is sent, it will return the value of the ADC requested.
:param adc_number ADC number, 1 or 2 - default 1 or self.adc_number :returns: the command to send to the serial port :rtype: str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6
I
00
D1
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
D1 = ADC1 ResultD2 = ADC2 ResultRequest current ADC value
Byte 6
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. In this case the received command will be sent back along with the ADC result and then completed command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
ADC1 Received*Result*ADC1 Received*Result*ADC1CompletedADC2CompletedRI00D1**Result*
RI00D2**Result*
CI00D1*
CI00D2*
-
reset
()¶ Call reset on the parent class and then reset all the variables
-
class
AUX class¶
-
class
pthat.
AUX
(aux_number, command_type='I', command_id=0, serial_device='/dev/ttyS0', baud_rate=115200, test_mode=False)¶ Bases:
pthat.PTHat
-
class
AUX
¶
This is an AUC class containing info about an AUX. It inherits from PTHat so contains all functionality needed to communicate with the PTHat via the serial interface.
- Parameters
aux_number – AUX number, 1-3
command_type – type of command, I = instant, B = buffered - default I
command_id – optional command ID, 0-99 - default 0
serial_device – serial device - default /dev/ttyS0
baud_rate – serial port baud rate - default 115200
test_mode – if true then serial commands will not actually be sent - default False
-
aux_number
= 1¶ ADC number, currently 1, 2 or 3. This can be set directly.
-
output_on
(aux_number=None)¶ When this request is sent, it will switch on the Aux port.
- Parameters
aux_number – AUX number, 1-3, default 1 or self.aux_number
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6 | Byte 7
I
00
A1
1 | *
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
A1 = Set Aux1 A2 = Set Aux2 A3 = Set Aux3
Set Aux port for switching
Byte 6
0-1
Switches selected Aux On or Off0 = Off1 = OnByte 7
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
Aux1 Received
Aux2 Received
Aux3 Received
Aux3 Completed
Aux3 Completed
Aux3 Completed
R00A1*
R00A2*
R00A3*
C00A1*
C00A1*
C00A1*
-
output_off
(aux_number=None)¶ When this request is sent, it will switch off the Aux port.
- Parameters
aux_number – AUX number, 1-3, default 1 or self.aux_number
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6 | Byte 7
I
00
A1
0 | *
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
A1 = Set Aux1 A2 = Set Aux2 A3 = Set Aux3
Set Aux port for switching
Byte 6
0-1
Switches selected Aux On or Off0 = Off1 = OnByte 7
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply.
Aux1 Received
Aux2 Received
Aux3 Received
Aux3 Completed
Aux3 Completed
Aux3 Completed
R00A1*
R00A2*
R00A3*
C00A1*
C00A1*
C00A1*
-
reset
()¶ Call reset on the parent class and then reset all the variables
-
class
PWM class¶
-
class
pthat.
PWM
(axis, command_type='I', command_id=0, serial_device='/dev/ttyS0', baud_rate=115200, test_mode=False)¶ Bases:
pthat.PTHat
-
class
PWM
¶
This is an PWM class containing info about an PWM. It inherits from PTHat so contains all functionality needed to communicate with the PTHat via the serial interface.
From Firmware V5.3 onwards there are commands for controlling two dedicated PWM channels. Details for PWM can be found here: http://pthat.com/index.php/pwm/
- Parameters
axis – axis for this class
command_type – type of command, I = instant, B = buffered - default I
command_id – optional command ID, 0-99 - default 0
serial_device – serial device - default /dev/ttyS0
baud_rate – serial port baud rate - default 115200
test_mode – if true then serial commands will not actually be sent - default False
-
frequency
= 0¶ Frequency for the channel is in 1Hz steps - 0000000-1000000. This can be set directly.
-
duty_cycle
= 0¶ Sets the Duty Cycle 0-100%, The last 2 digits are decimal places. So 08050 would be 80.5%. This can be set directly.
-
frequency_x
= 0¶ - Used for Set Both PWM Channels Command onlySets the Frequency for the channel in 1Hz steps for X-Axis. This can be set directly.
-
frequency_y
= 0¶ - Used for Set Both PWM Channels Command onlySets the Frequency for the channel in 1Hz steps for Y-Axis. This can be set directly.
-
duty_cycle_x
= 0¶ - Used for Set Both PWM Channels Command onlySets the Duty Cycle 0-100% for X-Axis. This can be set directly.
-
duty_cycle_y
= 0¶ - Used for Set Both PWM Channels Command onlySets the Duty Cycle 0-100% for Y-Axis. This can be set directly.
-
axis
= 'X'¶ Sets which Axis is to be set - X or Y, if UA then this doesn’t matter as it will do both X and Y. This can be set directly.
-
set_channel
(frequency=None, duty_cycle=None)¶ *Available Firmware V5.3 upwards* This Command sets the Frequency and Pulse Width for the desired channel. It then also starts it.
- Parameters
frequency – frequency for the channel in 1Hz steps, 0000000-1000000 - default 0 or self.frequency
duty_cycle – duty cycle 0-100%. The last 2 digits are decimal places. So 08050 would be 80.5% - default 0 or self.duty_cycle
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6-12 | Byte 13-17 | Byte 18 |
I
00
UX
0000000 | 00000 | * |
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
UX = Set X-Axis UY = Set Y-Axis
Sets which Axis is to be set
Byte 6-12
0000000-1000000
Sets the Frequency for the channel in 1Hz steps
Byte 13-17
00000
Sets the Duty Cycle 0-100%
Byte 18
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply. These can be turned off if needed.
X SetReceivedX SetReceivedX SetReceivedX SetReceivedRI00UX*
RI00UY*
CI00UX*
CI00UY*
-
set_frequency
(frequency)¶ Set the PWM frequency
- Parameters
frequency – frequency for the channel in 1Hz steps, 0000000-1000000 - default 0
- Returns
the command to send to the serial port
- Return type
str
-
set_duty_cycle
(duty_cycle)¶ Set the PWM duty cycle
- Parameters
duty_cycle – duty cycle 0-100%. The last 2 digits are decimal places. So 08050 would be 80.5% - default 0
- Returns
the command to send to the serial port
- Return type
str
-
set_both_channels
(frequencyx=None, frequencyy=None, duty_cyclex=None, duty_cycley=None)¶ *Available Firmware V5.3 upwards* This Command sets the Frequency and Pulse Width for both channels at the same time. It then also starts both together.
- Parameters
frequencyx – frequency for the X channel in 1Hz steps, 0000000-1000000 - default 0 or self.frequency_x
frequencyy – frequency for the Y channel in 1Hz steps, 0000000-1000000 - default 0 or self.frequency_y
duty_cyclex – duty cycle for X channel 0-100%. The last 2 digits are decimal places. So 08050 would be 80.5% - default 0 or self.duty_cycle_x
duty_cycley – duty cycle for Y channel 0-100%. The last 2 digits are decimal places. So 08050 would be 80.5% - default 0 or self.duty_cycle_x
- Returns
the command to send to the serial port
- Return type
str
Command
Byte 1
Byte 2-3
Byte 4-5
Byte 6-12
Byte 13-17
Byte 18-24
Byte 25-29
Byte 30
I
00
UA
0000000
00000
0000000
00000
*
Command breakdownByte
Setting
Description
Byte 1
I=Instant Command B=Buffer Command
Sets command to either Instant or Buffer.
Byte 2-3
0-99
Optional Command ID
Byte 4-5
UA=Set X-Axis and Y-Axis
Sets both X-Axis and Y-Axis settings
Byte 6-12
0000000-1000000
Sets the Frequency for the channel in 1Hz steps for X-Axis
Byte 13-17
00000
Sets the Duty Cycle 0-100% for X-Axis
Byte 18-24
0000000-1000000
Sets the Frequency for the channel in 1Hz steps for Y-Axis
Byte 25-29
00000
Sets the Duty Cycle 0-100% for Y-Axis
Byte 30
*
End of Command
ReplyThe PTHAT will send back a reply when it receives a command and also when it has completed a command. If the Command sent ID number was set for bytes 2-3, then this will be returned in the reply. These can be turned off if needed.
Set both PWM channelsReceivedSet both PWM channelsCompletedRI00UA*
CI00UA*
-
reset
()¶ Call reset on the parent class and then reset all the variables
-
class