Knowledge Base

The SX10502 and SX10502RH have up to 4 temperature/humidity measuring functions depending on the model and whether or not there is an optional TN9301 peripheral board attached. Each of these functions is returned as a floating-point number. If it is a temperature function, the returned value will be in degrees Celsius. If it is humidity the returned value will be a percentage.

The remote target temperature and the ambient temperature from the TN9301 is updated at a rate of 1.4Hz. The on board temperature and humidity is updated at a rate of 2Hz.

Because the SX10502 has 2 model variations and can be used with or without an optional TN9301 sensor, the programmer is required to enable/disable selected functions of the SX10502.

By setting the Xwire Transmit Data length to 0 Bytes the Control Byte is disabled and ALL measurement functions will be enabled by default.

By setting the Xwire Transmit Data length to 1 Byte the Control Byte is enabled.

If the Control Byte is set to a number between 0-15 certain functions will be enabled.

If the TN9301 or on board sensor is removed from the SX10502 or damaged an error value of NaN is returned from the SX10502 for the affected function.

The following table depicts what functions will be enabled depending on the contents of the Control Byte, and the number of bytes needed for the Receive Data length. The relative location of the data returned from the functions inside the Xwire Receive Data block is also shown.

Xwire Receive Data block relative byte addresses
Control Byte0 1 2 34 5 6 78 9 10 1112 13 14 15Receive Data length
0TN9301 Object TemperatureTN9301 Ambient TemperatureOn board TemperatureOn board Humidity16
1TN9301 Object Temperature   4
2TN9301 Ambient Temperature   4
3TN9301 Object TemperatureTN9301 Ambient Temperature  8
4On board Temperature   4
5TN9301 Object TemperatureOn board Temperature  8
6TN9301 Ambient TemperatureOn board Temperature  8
7TN9301 Object TemperatureTN9301 Ambient TemperatureOn board Temperature 12
8On board Humidity   4
9TN9301 Object TemperatureOn board Humidity  8
10TN9301 Ambient TemperatureOn board Humidity  8
11TN9301 Object TemperatureTN9301 Ambient TemperatureOn board Humidity 12
12On board TemperatureOn board Humidity  8
13TN9301 Object TemperatureOn board TemperatureOn board Humidity 12
14TN9301 Ambient TemperatureOn board TemperatureOn board Humidity 12
15TN9301 Object TemperatureTN9301 Ambient TemperatureOn board TemperatureOn board Humidity16

*Note that this data block does not need to start at memory location 0 and 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.

Example Program 1
* Example program demonstrating how to interface with a SX10502 *
* For use with MMI202 and SX10502 *
* 2x16 LCD *

** Setup **

* The SX10502 is interfaced to the MMI202 over X-Wire protocol by setting the communications jumper to
* the X position.
* No board ID jumpers are installed as the X-Wire slave address for the SX10502 is address 0.
* If it is a MMI202 the X-Wire cable is connected from the Spice connector to the X1 connector on the SX10502.
* If it is a MMI202a the X-Wire cable is connected from the CN12 connector to the X1 connector on the SX10502.


** Program operation **

* X-Wire is set up to return data to the MMI from both temperature functions on the TN9301.

* Temperature from the TN9301 peripheral board are continually updated on the display.

* If at any time there are Xwire communications errors the front panel LED on output 15 will light.



* Equates *

* XWire Receive data block *
* Data block of 16 bytes *

RxRAMstart: equ 100 ;the starting memory location of the Xwire receive data block
RxRAMlength: equ 8 ;the size of the returned data in bytes depending on what functions are enabled
fTN9Temp: mequ 100,4 ;Location where the TN9301 object temperature is returned.
fTN9Amb: mequ 104,4 ;Location where the TN9301 ambient temperature is returned.

* XWire Transmit data block *
* Data block of 1 byte *

TxRAMlength: equ 1 ;setting the Transmit Ram length to 1 enables the control byte. 0 disables it.
bControlByte: mequ 10 ;location of the control byte to enable/disable SX10502 functions
SlaveAddress equ 0 ;the XWire slave address.

* Output Equates *

oXW_XWireError: oequ 15 ;LED turns on when there is an Xwire communication error.

*******************
** Program start **
*******************

Start
XwireMaster XWireTab ;start xwire going
setmem bControlByte,3 ;set the control byte to 3 to enable both TN9301 temperature functions.

launchtask LCD_Task ;start the Display task running
launchtask Xwire_Task ;start the XWire error checking task running
runtasksforever

******************
** Display Task **
******************

LCD_Task:
oblcd_CLS
oblcd_Type 2 ;set LCD to 2x16 type
LCD0:
pause 50 ;Update the display every 500mS
oblcd_setcur 0,0
; "0123456789012345"
oblcd_text "TN9 Temp: "
frecallw fTN9Temp
oblcd_fdispw 4,1 ;display the TN9301 object temperature with 1 decimal place
oblcd_spclchar 223 ;display a degree sign
oblcd_text "C"
; "0123456789012345"
oblcd_setcur 1,0
oblcd_text "TN9 Amb: "
frecallw fTN9Amb
oblcd_fdispw 4,1 ;display the TN9301 ambient temperature with 1 decimal place
oblcd_spclchar 223 ;display a degree sign
oblcd_text "C"
goto LCD0


****************************
** Xwire Error Check Task **
****************************

Xwire_Task:

XW0:
yieldtask
xwiregeterrcount ;get the xwire error count
goiff XW1
on oXW_XWireError ;turn on error LED if there are XWire errors
pause 1
goto XW0
XW1: off oXW_XWireError
goto XW0


** X-Wire Master table **

NVEM0
XWireTab:
NV0Byte SlaveAddress,bControlByte,TxRAMlength,RxRAMstart,RxRAMlength

NV0Byte 255 ;End of table sentinel. ;memory 10 (bControlByte) is transmit data block, 100 (RxRAMstart) is receive data block.
;TxRAMlength of 1 byte enables bControlByte
;RxRAMlength of 8 bytes for 2 floating point returned numbers.

Example Program 2
* Example program demonstrating how to interface with a SX10502RH *
* For use with MMI202 and SX10502RH *
* 2x16 LCD *

** Setup **

* The SX10502RH is interfaced to the MMI202 over X-Wire protocol by setting the communications jumper to
* 	the X position.
* No board ID jumpers are installed as the X-Wire slave address for the SX10502RH is address 0.
* If it is a MMI202 the X-Wire cable is connected from the Spice connector to the X1 connector on the SX10502RH.
* If it is a MMI202a the X-Wire cable is connected from the CN12 connector to the X1 connector on the SX10502RH.


** Program operation **

* X-Wire is set up to return data to the MMI from both temperature functions on the TN9301 and
*	the on board temperature and humidity.

* Temperature and humidity from the on board sensor are continually updated on the display.

* Pressing front panel button IN8 advances to the next screen.

* Temperature from the TN9301 peripheral board are continually updated on the display.

* If at any time there are Xwire communications errors the front panel LED on output 15 will light.



* Equates *

* XWire receive data block *
* Data block of 16 bytes *

RxRAMstart:		equ		100	;the starting memory location of the Xwire receive data block
RxRAMlength:		equ		16	;the size of the returned data in bytes depending on what functions are enabled
fTN9Temp:		mequ		100,4	;Location where the TN9301 object temperature is returned.
fTN9Amb:		mequ		104,4	;Location where the TN9301 ambient temperature is returned.
fOBTemp:		mequ		108,4	;Location where the on board temperature from the SX10502RH is returned.
fOBHumid:		mequ		112,4	;Location where the on board humidity from the SX10502RH is returned.

* XWire Transmit data block *
* Data block of 1 byte *

TxRAMlength:		equ		1	;setting the Transmit Ram length to 1 enables the control byte. 0 disables it.
bControlByte:		mequ		10	;location of the control byte to enable/disable SX10502RH functions
SlaveAddress		equ		0	;the XWire slave address.

* Output Equates *

oXW_XWireError:		oequ		15	;LED turns on when there is an Xwire communication error.

 *******************
 ** Program start **
 *******************

Start
 		XwireMaster 	XWireTab		;start xwire going
		setmem		bControlByte,15		;set he control byte to 15 to enable all SX10502RH measurement functions

		launchtask	LCD_Task		;start the Display task running
		launchtask	Xwire_Task		;start the XWire error checking task running
		runtasksforever

 ******************
 ** Display Task **
 ******************

* Input equates *

iLCD_Cycle:	iequ		8			;this input is used to cycle the data on the LCD

LCD_Task:
		oblcd_CLS
       		oblcd_Type      2                       ;set LCD to 2x16 type
LCD0:
		pause		50
		goifink		iLCD_Cycle,LCD1		;if toggle button is pressed change LCD display
		oblcd_setcur	0,0
		;		"0123456789012345"
		oblcd_text	"OB Temp:  "
		frecallw	fOBTemp
		oblcd_fdispw	4,1			;display the on board temperature with 1 decimal place
		oblcd_spclchar	223			;display a degree sign
		oblcd_text	"C"
		;		"0123456789012345"
		oblcd_setcur	1,0
		oblcd_text	"OB Humid: "
		frecallw	fOBHumid
		oblcd_fdispw	4,1			;display the on board humidity with 1 decimal place
		oblcd_text	" %"
		goto		LCD0
LCD1:
		pause		50
		goifink		iLCD_Cycle,LCD0		;if toggle button is pressed change LCD display
		oblcd_setcur	0,0
		;		"0123456789012345"
		oblcd_text	"TN9 Temp: "
		frecallw	fTN9Temp
		oblcd_fdispw	4,1			;display the TN9301 object temperature with 1 decimal place
		oblcd_spclchar	223			;display a degree sign
		oblcd_text	"C"
		;		"0123456789012345"
		oblcd_setcur	1,0
		oblcd_text	"TN9 Amb:  "
		frecallw	fTN9Amb
		oblcd_fdispw	4,1			;display the TN9301 ambient temperature with 1 decimal place
		oblcd_spclchar	223			;display a degree sign
		oblcd_text	"C"
		goto		LCD1

 ****************************
 ** Xwire Error Check Task **
 ****************************

Xwire_Task:

XW0:
		yieldtask
		xwiregeterrcount			;get the xwire error count
		goiff		XW1
		on		oXW_XWireError		;turn on error LED if there are XWire errors
		pause		1
		goto		XW0
XW1:		off		oXW_XWireError
		goto		XW0

 ** X-Wire Master table **

        NVEM0
XWireTab:
        NV0Byte         SlaveAddress,bControlByte,TxRAMlength,RxRAMstart,RxRAMlength

        NV0Byte         255    ;End of table sentinel.		;memory 10 (bControlByte) is transmit data block, 100 (RxRAMstart) is receive data block.
								;TxRAMlength of 1 byte enables bControlByte
								;RxRAMlength of 16 bytes for 4 floating point returned numbers.