1.ESP 2G
1.Baby Commands

All commands are binary in the form as follows

Byte 0	command length – # of bytes in command excluding itself and the CRC
Byte 1 command – The command type (0..255)
Byte 2 Tag – a number assigned by the main processor to map messages to responses.  If a message from the main processor requests response(s) then it will contain a Tag value.  Messages from the main processor that do not generate responses omit the tag.  All responses from slaves to the master MUST contain a Tag.  Unsolicited responses where no Tag is known should use the reserved tag value of zero, as this will never be used as a Tag by the master processor.

   .
   .
   .
Byte n command data
Byte n+1 CRC

Valves

VC – Valve Configuration
	Configure valve control parameters

Byte 0 2
Byte 1	VConfig
Byte 2 Minimum Pulse Width (hundredths of seconds)
Byte 3 CRC

VS – Valve Status
	Return valve status and configuration

Byte 0 2
Byte 1	Vstatus
Byte 2	Tag
Byte 3 CRC

Controller will respond immediately with:

Byte 10
Byte 1 Vstatus
Byte 2	Tag
Byte 3	Minimum Pulse Width (hundredths of seconds)
Byte 4	Hundredths of seconds until end of current pulse (0 if none)
Byte 5 Valves 0 – 3
Byte 6 Valves 4 – 7
Byte 7 Valves 8 – 11
Byte 8 Valves 12 – 15
Byte 9 Valves 16 – 19
Byte 10 Valves 20 – 23
Byte 11 CRC

VP – Valve Pulse
	Used to pulse a latching valve to a different state.

Byte 0 8
Byte 1	VPvalue
Byte 2 Valves 0 – 3
Byte 3 Valves 4 – 7
Byte 4 Valves 8 – 11
Byte 5 Valves 12 – 15
Byte 6 Valves 16 – 19
Byte 7 Valves 20 – 23
Byte 8 CRC

Within each valve control byte, each valve's state is represented by
Two bits encoded as follows:
Value	Function	
00	Do nothing	
01	Pulse Open	
10	Pulse Closed	
11	Reserved	

The LSBs are associated with the lowest numbered valves
If a VP command is received before the end of the current Valve Pulse, the current two valve pulse commands are merged into one.  The valve pulse down counter is reset to the currently configured Minimum Pulse Width.  For each valve that is already being pulsed, if it is also pulsed in the new VP command, that takes precedence.  If it is “Do nothing” in the new VP command, the old pulse is simply extended.  Thus, there is  at most one pulse time-out in progress.

VH – Valve Hold
	Used to switch a non-latching valve to a different state.

Byte 0 8
Byte 1	VHvalue
Byte 2 Valves 0 – 3
Byte 3 Valves 4 – 7
Byte 4 Valves 8 – 11
Byte 5 Valves 12 – 15
Byte 6 Valves 16 – 19
Byte 7 Valves 20 – 23
Byte 8 CRC

Each valve has two bits encoded as follows:
Value	Function	
00	Do nothing	
01	Switch On	
10	Switch Off	
11	Reserved	

If a VH command is sent to a given valve that is currently pulsing, the VH command overrides the pulse command for that valve only.  That is to say, such valves will not be reset to the “Do nothing” state when the current pulse ends.

Thermal Control

TP – Thermal Program
This command is used to program a schedule of temperature control set points.  The program consists of pairs of 16-bit words, each of which define a temperature (T) set point and duration (D).  This command will accept up to four set points.  Zero set points may be sent do abort the current program.

Byte 0 8 | 12 | 16 | 20 | 24		#0..5 set point pairs
Byte 1 TPvalue
Byte 2	Tag
Byte 3 Maximum  LSB	#max allowed temperature
Byte 4 Maximum MSB
Byte 5 Minimum  LSB	#min allowed temperature
Byte 6 Minimum MSB
Byte 7 cycles LSB
Byte 8 cycles MSB
Byte 9 Temperature 1 LSB
Byte 10 Temperature 1 MSB
Byte 11 Dwell 1 LSB
Byte 12 Dwell 1 MSB
Byte 13 Temperature 2 LSB
Byte 14 Temperature 2 MSB
Byte 15 Dwell 2 LSB
Byte 16 Dwell 2 MSB
Byte 17 Temperature 3 LSB
Byte 18 Temperature 3 MSB
Byte 19 Dwell 3 LSB
Byte 20 Dwell 3 MSB
Byte 21 Temperature 4 LSB
Byte 22 Temperature 4 MSB
Byte 23 Dwell 4 LSB
Byte 24 Dwell 4 MSB
Byte 25 CRC

	After all cycles are completed and the temperature is settling to ambient, the controller will respond back with the following data packet:

Byte 0 2
	Byte 1 TPvalue
	Byte 2 Tag
	Byte 3 CRC

Otherwise, if an error occurred, the controller will send back:

Byte 0 8
	Byte 1 TPvalue
	Byte 2 Tag
	Byte 3 Error Mask
	Next 5 bytes Thermal Status at the moment the error occurred (see below)
	Byte 9 CRC

	Error mask
		Bit 0 Aborted due to new TP request
		Bit 1 User aborted
		Bit 2 over temperature
		Bit 3 under temperature
		Bit 4 
		Bit 5 
		Bit 6 
		Bit 7 

TQ – Thermal Query
This command is used read back the thermal program. 

Byte 0 2
Byte 1 TQvalue 
Byte 2 Tag
Byte 4 CRC

	The controller will respond back with the following data packet:

Byte 0 8 | 12 | 16 | 20 | 24
Byte 1 Command Value TBD
Byte 2 Tag
Byte 3 Maximum LSB
Byte 4 Maximum MSB	
Byte 5 Minimum LSB
Byte 6 Minimum MSB
Byte 7 cycles LSB
Byte 8 cycles MSB
Byte 9 Temperature 1 LSB
Byte 10 Temperature 1 MSB
Byte 11 Dwell 1 LSB
Byte 12 Dwell 1 MSB
Byte 13 Temperature 2 LSB
Byte 14 Temperature 2 MSB
Byte 15 Dwell 2 LSB
Byte 16 Dwell 2 MSB
Byte 17 Temperature 3 LSB
Byte 18 Temperature 3 MSB
Byte 19 Dwell 3 LSB
Byte 20 Dwell 3 MSB
Byte 21 Temperature 4 LSB
Byte 22 Temperature 4 MSB
Byte 23 Dwell 4 LSB
Byte 24 Dwell 4 MSB
Byte 25 CRC

TS – Thermal Status
	This command is used to query the current state of the thermal unit.  It will tell current temperature, how many cycles completed, and what step within the current cycle.  If no TP command is in progress, it just returns the current temperature.  An optional Sample Period specifies how often status updates should be produced.  The Sample Period of zero disables updates without producing any response.  A missing Sample Period produces an immediate response without disabling periodic updates.

Byte 0 2 | 3
Byte 1 TSvalue 
Byte 2 Tag
Byte 3 Sample Period (in tenths of seconds)
Byte 4 CRC

	The controller will respond back with the following data packet:

Byte 0 4 | 7 
Byte 1 Command Value TBD
Byte 2 Tag
Byte 3 Current temperature LSB
Byte 4 Current temperature MSB
Byte 5 Current Step (within current cycle)  	#if TP in progress
Byte 6 Cycles completed LSB		#if TP in progress
Byte 7 Cycles completed MSB		#if TP in progress
Byte 8 CRC

			
Servo Control

1.SC- Servo Configure
		This command is used to set the various parameters for a servo channel.
		#where is the pressure limit specified?
	Byte 0 2 | 13
	Byte 1 SC1value or SC2value
	Byte 2 Option Mask
	Byte 3 Kp
	Byte 4 Ki
	Byte 5 Kd
	Byte 6 Max V
	Byte 7 Percentage goal V for min V
	Byte 8 Acceleration
	Byte 9 Torque Limit (Percent of full)
	Byte 10 Max Position Error LSByte 
	Byte 11 Max Position Error 
	Byte 12 Max Position Error MSByte
	Byte 13 Max Pressure Difference	
	Byte 14 CRC

	Option mask
		Bit 0 reserved
		Bit 1 Ignore Reverse Limit Switch
		Bit 2 Ignore Forward Limit Switch
		Bit 3 Home on RLS  (reset position)
		Bit 4 Home on FLS (reset position -- implies offsets will be negative)
		Bit 5 reserved
		Bit 6 Ignore Pressure
		Bit 7 reserved

	SQ – Servo Query
		This command reads back the servo configuration set by SC. 

Byte 0 0
Byte 1 SQ1value or SQ2value
Byte 2 Tag
Byte 3 CRC

Byte 0 16
	Byte 1 SR1value or SR2value
	Byte 2 Tag
	13 bytes of Servo Configuration	
	Byte 16 CRC

	SS – Servo Status
		This command is used to query the current state of a servo channel. An optional Sample Period specifies how often status updates should be produced.  The Sample Period of zero disables updates without producing any response.  A missing Sample Period produces an immediate response without disabling periodic updates.

Byte 0 0
Byte 1 SS1value or SS2value
Byte 2 Tag
Byte 3 Sample Period in hundredths of seconds
Byte 4 CRC

		The controller will respond with the following data packet(s) containing the current servo dynamics.  This packet may be sent at any time that an error has occurred, such as a limit switch.

	Byte 0 10
	Byte 1 SS1 or SS2
	Byte 2 Tag
	Byte 3 Error/Status Mask
	Byte 4 Torque used
	Byte 5 Velocity
	Byte 6 Pressure Difference
	Byte 7 Absolute Pressure 
	Byte 8 Current position LSByte 
	Byte 9 Current position
	Byte 10 Current position MSByte
	Byte 11 CRC

	Error/Status mask
		Bit 0 Aborted due to new move request
		Bit 1 RLS
		Bit 2 FLS
		Bit 3 over current
		Bit 4 Exceeded Max. or Min. Velocity Limits
		Bit 5 over pressure
		Bit 6 Homed  (Holding at Forward or Reverse Limit Switch)
		Bit 7 Servo OFF

	Both the Homed and Aborted bits are cleared whenever a new SM command is received.

SM – Servo Move
		This command will cause the motor move to a defined absolute position or a relative distance.  This command may be issued while a motor is moving.

	Byte 0
	Byte 1 SMA1value, SMA2value, SMR1value or SMR2value
	Byte 2 Tag
	Byte 3 Goal position or displacement LSByte 
	Byte 4 Goal position or displacement
	Byte 5 Goal position or displacement MSByte
	Byte 6 CRC

	Upon arrival at the Goal Position, the controller responds with:

Byte 0
	Byte 1 SMA1value, SMA2value, SMR1value or SMR2value
	Byte 2 Tag
	Byte 3 CRC
	
	The servo then enters the “Hold” state and subsequently behaves as though a
	Servo Hold command were issued at the Goal Position.  However, any subsequent
	error message is delivered with the original SM Command's Tag byte value.

	If a SM Home error occurs, if the relevant Ignore Limit Switch configuration 
	bit is not set, the controller first queues up SM error reply (below),
	then resets the servo's current and goal positions to zero.  
	The servo finally enters the “hold” (on) state at a position of zero.

	However if, in the Servo Configuration, the relevant Home and Ignore Limit
	Switch bits are both set,  the servo will abort the move when the Limit Switch is
	reached, but it will NOT reset the encoder to zero.  In this case, the servo will be
	left in the “hold”  state at the limit switch's position.  

	If an SM error other than Home occurs, just before the servo enters the
	 “Off” state, the controller responds with:

Byte 0
	Byte 1 SMA1value, SMA2value, SMR1value or SMR2value
	Byte 2 Tag
	8 bytes of Servo Status  (beginning with the error/status mask)
	Byte 12 CRC

SH – Servo Hold
		This command is used hold a motor in position.  It uses the current position as the goal position to start control.  Any servo move command in progress will be aborted with the appropriate Abort response and the motor held at the current position.
	Byte 0
	Byte 1 SO1value or SO2value
	Byte 2 Tag
	Byte 3 CRC

If  Servo Hold is terminated by another Servo command, no Abort response is produced.
If, however, the Position Error limit is exceeded the controller responds with:

Byte 0
	Byte 1 SH1 or SH2
	Byte 2 Tag
	Byte 3 Error mask
	10 bytes of Servo Status
	Byte 14 CRC

	Error mask
		Bit 0 reserved
		Bit 1 Limit switch activated
		Bit 2 reserved
		Bit 3 over current
		Bit 4 Exceeded Max. or Min. Velocity Limits
		Bit 5 Exceeded Position Limit
		Bit 6 over pressure
		Bit 7 reserved

SO – Servo Off
		This command turns off control of a servo.  It continues to monitor position but power is removed from the motor.  This can be used to save power if the servo can hold position without control.  This will abort any move in progress.

	Byte 0
	Byte 1 SO1value or SO2value
	Byte 2 CRC

SG – Servo Goal
		This command returns information about the current servo command in progress:

	Byte 0
	Byte 1 SG1value or SG2 value
	Byte 2 Tag
	Byte 2 CRC

		The controller responds 
	Byte 0 2 | 5
	Byte 1 SO1, SO2, SH1, SH2, SMA1, SMA2, SMR1, or SMR2
	Byte 2 Tag
	Byte 3 Goal position LSByte   #if byte 1 not SO1 or SO2
	Byte 4 Goal position    	  #if not SO1 or SO2
	Byte 5 Goal position MSByte  #if not SO1 or SO2
	Byte 6 CRC

1.Unresolved issues
How do we measure pressure?
Differential pressure
Two Absolute

Do we really need the byte length?
  Yes, multiple messages may be included in one response to a slave poll

The original stuff
2.
2 Brushed Servo Channels
1 Thermal control loop
	heating
	cooling
24 valves to control

Valves
	Current position of valve(s)
	Toggle/set/clear valve
	Set/clear bank valves

Thermal control
	Output value
	Set-point read/set
	Time to hold temperature
	Time remaining at temperature
	Notify when complete
	Set maximum and minimum temperatures

Servo channels
	Set/Read PID values
	Set/Read Acceleration values
	Set/Read maximum speed
	Set/Read minimum speed
	Stop on over/under pressure
	Notify error conditions
	Read Limit switches
	Read current status
	Current position
	Set/Read torque limits
	Notify at position
	Move to absolute position
	Move by distance
	Notify move complete
	Jog motor
Define absolute position