SEXI: Serial I/O Expansion via Xwire Interface
Introduction
SEXI is an easy way of expanding the I/O of any 32 bit SPLat controller. Using SEXI allows the master controller to treat I/O on slave controllers as if it were physically on the master itself.
Here are the digital and analogue windows of SPLat/PC with an HMI430 connected. We see the HMI430 has 9 digital I/O's (8 I/O + beeper), 2 analogue inputs and 1 analogue output:
Here they are again but this time the HMI430 has added a DA8 as a SEXI slave device. Now the HMI430 has 12 digital I/O, 10 analogue inputs and 3 analogue outputs:
Both the analogue and digital I/O on the DA8 have been appended to the HMI430's I/O. All this I/O is controlled via the usual SPLat I/O instructions, eg:
- Input, InputK, GoIfInOn, GoIfInK, etc
All the input instructions are able to read the digital inputs on the DA8. Yes, this includes all the InputK style instructions too. So Input 10 would read the first input on the DA8. - Output, Blink, On, OutputM, etc
All the output instructions are able to control the digital outputs on the DA8 too. Yes, even Blink works. Hence Blink 12 would flash the last output on the DA8. - fAnIn
The analogue input function is able to read from the DA8 too. fAnIn 0 reads the first input on the HMI430, fAnIn 2 reads the first analogue input on the DA8. - fAnOut
The analogue output function can write the the DA8's analogue outputs. So fAnOut 1 would write to the first analogue output on the DA8. - SPLat/PC
With all the I/O now mapped into the master's I/O space, it can all be controlled via SPLat/PC. Note that the master must have run the XwireMaster instruction first, then when you STOP with SPLat/PC all the SEXI I/O will appear. You can now manually control outputs and view inputs on the master and SEXI slaves.
Programming
Master
SEXI is activated when the master controller executes an XwireMaster instruction with special SEXI entries in the Xwire table.
Normal Xwire table entry:
NV0Byte <SlaveAddress>, <TXBufferAddr>, <TXLength>, <RXBufferAddr>, <RXLength>
SEXI Xwire table entry
NV0Byte <SlaveAddress>, 255, <NofDigitalInputs>, <NofDigitalOutputs>, <NofAnalogueInputs>, <NoAnalogueOutputs>, <TXBufferAddr>, <TXLength>, <RXBufferAddr>, <RXLength>
As you can see, a SEXI entry is identified by the second byte of "255" (a value that is not legal in a normal Xwire entry). Then follows the NumberOF (nof) I/O points that are available on the SEXI slave.
The <TXBufferAddr>, <TXLength>, <RXBufferAddr>, <RXLength> values are still present but are typically set to 0. However their presence allows you to have a custom application running the the SEXI slave that's exchanging other information with you application running on the master.
Examples
;Addr, SEXI=255, Din, Dout, Ain, Aout, TXBuf, TXLen, RXBuf, RXLen
NV0Byte ADDR, 255, 16, 16, 2, 0, 0, 0, 0, 0 ;DT16/CC18, 16 din, 16 dout, 2 ain, 0 aout
NV0Byte ADDR, 255, 4, 4, 8, 2, 0, 0, 0, 0 ;DA8, 4 din, 4 dout, 8 ain, 2 aout
NV0Byte ADDR, 255, 6, 10, 0, 0, 0, 0, 0, 0 ;UI420, 6 din, 10 dout, 0 ain, 0 aout
NV0Byte ADDR, 255, 7, 4, 0, 0, 0, 0, 0, 0 ;UI216, 7 din, 4 dout, 0 ain, 0 aout
NV0Byte ADDR, 255, 4, 8, 0, 0, 0, 0, 0, 0 ;DR8, 4 din, 8 dout, 0 ain, 0 aout
NV0Byte ADDR, 255, 8, 8, 0, 0, 0, 0, 0, 0 ;DR240, 8 din, 8 dout, 0 ain, 0 aout
NV0Byte ADDR, 255, 8, 8, 4, 1, 0, 0, 0, 0 ;DR240A, 8 din, 8 dout, 4 ain, 1 aout
NV0Byte ADDR, 255, 5, 5, 1, 0, 0, 0, 0, 0 ;DW2, 5 din, 5 dout, 1 ain, 0 aout
Here's a working application that adds 2 DA8's to the master:
XwireMaster pMaster ;start Xwire
_Forever
Goto _Forever ;spin our wheels
NVEM0
pMaster
;Addr, SEXI=255, Din, Dout, Ain, Aout, TXBuf, TXLen, RXBuf, RXLen
NV0Byte 0, 255, 4, 4, 8, 2, 0, 0, 0, 0 ;first DA8 (all DIP switches off), 4 din, 4 dout, 8 ain, 2 aout
NV0Byte 1, 255, 4, 4, 8, 2, 0, 0, 0, 0 ;second DA8 (only DIP switch 1 on), 4 din, 4 dout, 8 ain, 2 aout
;EndOfTable=255
NV0Byte 255 ;End of Master Xwire table
Here's another example, this time with a single UI216. Note the Xwire table includes an entry that sends OBLCD text to the LCD via Xwire:
NVEM0
pMaster
;LCD=249, FirstChar, NofChars (max 32), Zero, Zero
NV0Byte 249, 0, 32, 0, 0 ;LCD chars 0 thru 31
;Addr, SEXI=255, Din, Dout, Ain, Aout, TXBuf, TXLen, RXBuf, RXLen
NV0Byte 10, 255, 7, 4, 0, 0, 0, 0, 0, 0 ;UI216, 7 din, 4 dout, 0 ain, 0 aout
;EndOfTable=255
NV0Byte 255 ;End of Master Xwire table
Slave
The interesting news about SEXI Slaves is they can be ANY SPLat controller, both 8 bit and 32 bit controllers can be a SEXI Slave. On the slave the SEXI protocol is implemented in SPLat. We've published default applications for the controllers later on this page which you are welcome to modify. You may, for example, decide to convert an analogue input to temperature in the slave application. Thus, when the master reads that "analogue input" it gets the temperature that has already been calculated by the slave.
Slave Applications
Here are the SEXI applications we've published for a range of SPLat controllers. Let us know if there's one we've missed.
Caveats
- A SEXI Master will only work on a 32 bit controller. HMI430, DC216, EC1, etc.
- There can be a maximum of 16 SEXI slaves.
- There can be a maximum of 255 digital inputs and 255 digital outputs
- There can be a maximum of 64 SEXI analogue inputs and 16 SEXI analogue outputs.
- The SEXI Slave must run a SPLat SEXI application, but this can be modified by you to perform additional functions.