The following table shows how the Xwire data block needs to appear in memory. The Transmit data block consists of 16 bytes.
Xwire transmit data block:
| Memory | Description | Format |
|---|---|---|
| 3 | 10 bit analog out. | 0V-10V output voltage range |
| 7 | 10 bit analog out | 0V-10V output voltage range |
| 11 | 8 bit analog out | 0V-10V output voltage range |
| 15 | 8 bit analog out | 0V-10V output voltage range |
*Note that this data block does not need to start at memory location 0. The data block can be moved anywhere in memory as long as it stays together, is in the order above and is defined in the NVEM Xwire table in the program code.
Memory locations in the Xwire transmit data block 0-7 correspond to the two 10 bit analog outputs on the SX10505.
Memory locations in the Xwire transmit data block 8-15 correspond to the two 8 bit analog outputs on the SX10505.
Each channel is sent in 4 bytes as a floating point number in the range of 0 to 1. The same format used by the "fanout" instruction.
* The MMI202 communicates to the SX10505 over the XWire peripheral.
* MMI202 controller is the XWire master and the SX10505 is the XWire slave.
* The MMI202 has both its analog inputs set to Thermistor mode.
* The SX10505 has 4 analog output channels.
* Channel O0 is connected to a fan set to run off 5 volts.
* Channel O1 is connected to a fan set to run off 7.5 volts.
* Channel O2 is connected to a pump which will echo analog input 2 on
* the MMI202.
* Channel O3 is connected to a pump which will output the inverse of analog
* input 2 on the MMI202.
* If at any time there are Xwire communications errors OP15 on the MMI202 front panel will light.
* Equates *
oError: oequ 15 ;LED is lit when there is an XWire error.
* XWire Transmit data block *
* Data block of 16 bytes *
fSXAnout0: mequ 10,4 ;Location where analog Output 0 value is stored for SX10505 to take.
fSXAnout1: mequ 14,4 ;Location where analog Output 1 value is stored for SX10505 to take.
fSXAnout2: mequ 18,4 ;Location where analog Output 2 value is stored for SX10505 to take.
fSXAnout3: mequ 22,4 ;Location where analog Output 3 value is stored for SX10505 to take.
* Initialisation *
Start:
XwireMaster XWireTab ;start xwire going
floadw 1
fanout 8 ;set the MMI analog drive voltage
floadw .5 ;analog output channel O0 set to 50%
fstore fSXAnout0
floadw .75 ;analog output channel O1 set to 75%
fstore fSXAnout1
loop:
pause 10 ;only sample analog inputs every 100mS.
fanin 2 ;read analog channel 2 on the MMI, returns a number 0 - 1 in W. (0-100%)
fstore fSXAnout2
fanin 3 ;read analog channel 3 on the MMI, returns a number 0 - 1 in W. (0-100%)
floadq 1
fsub ;invert the analog sample.
fstore fSXAnout3
xwiregeterrcount ;get the xwire error count
output oError ;if the error count is above 1 led 15 on the MMI202 will light until next run
goto loop
NVEM0
XWireTab:
NV0Byte 0,10,16,0,0
NV0Byte 255 ;End of table sentinel.