Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Description The NKM2401 Radio Data Encoder/Decoder IC enables serial data to be easily transported over low power radio links and therefore allows users to quickly and easily add short range “wireless” capabilities to their systems. It is designed for use with licence exempt transmitter and receiver modules operating in the VHF and UHF bands and provides the buffering, packetisation, encoding, error checking and ‘bit bashing’ required for transmitters and the reverse processes for receivers. It can be interfaced to any PC or microprocessor serial port to provide simplex (one way) transfer of data with built in error checking ensuring data integrity. It is ideally suited for use with the Parallax BASIC Stamp or other similar devices. Features ♦ ♦ ♦ Applications Simple to use Transparent operation Single chip solution ♦ ♦ ♦ Data acquisition Alarm systems Hand held terminals Typical Application Serial Data In Serial Data Out TxD RxD Data Ready* Busy* User Send Data* TxEn NKM2401 Application RF Transmitter RF Receiver NKM2401 * Optional handshake lines User Application Introduction Radio links comprising pre built and tested transmitter and receiver modules are now readily available from a number of suppliers. These are easily connected to standard encoders and decoders allowing simple On/Off remote control systems to be assembled. However, sending data over these radio links is difficult as they are generally AC coupled, bandwidth limited (100Hz to 5KHz typical) and may be subject to noise and interference. The receiver may produce digital ‘white noise’ on its data output in the absence of any signal and in addition requires some time to extract the data from the received audio signal. The format of the data must also be given consideration as asymmetric data such as Serial ASCII (RS232) which is non DC balanced will cause the ‘data slicer’ in the receiver to give poor performance leading to errors after consecutive sequences of ones or zeros. There may also be considerable pulse width distortion and ‘jitter’ produced by the link. These radio links cannot therefore, usually be successfully connected directly to a UART, as such devices will not tolerate these errors and almost certainly will produce erroneous data which may be worse than useless ! NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 1 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Some form of communication protocol is required when using links over a noisy communication channel. This needs to rugged, secure and have built in error checking. A number of complex standards do exist but they are not really suited to simple radio links and they are not implemented on a simple to use IC. The NKM2401 is intended to address this problem and provides the services required for an interface between a data source and a radio module. It is intended for simplex (one way) communications and transports short packets of data and is therefore suited to ‘control and sense’ (bytes) rather than ‘file transfer’ (Megabytes) tasks. The NKM2401 is configured as a ‘transmitter encoder’ or a ‘receiver decoder’ by the state of a single mode pin. It interfaces to the hosts by a simple serial interface operating at 2400 baud. NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 2 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Pin Out Schematic & Description Vcc Serial Data In Busy 1 Gnd Transmit Enable NKM2401 Mode High Transmit Data Test Transmit Mode Pin 1 2 3 4 5 6 7 8 Function - Mode Pin High - Transmit Vcc +5V supply Serial Data Input, 2400bps Busy Output. Goes high whilst transmitting. Active High Mode Pin high (Vcc) selects transmit mode Test Input sends pre-set message. Active Low Transmit Data Output to RF transmitter Transmit Enable Output to RF transmitter. Active High Ground. 0 Volt Vcc 1 Data Ready Output Rx Data Input No Connect Gnd NKM2401 Serial Data Output Send Data Input Mode Low Receive Mode Pin 1 2 3 4 5 6 7 8 Function - Mode Pin Low - Receive Vcc +5V supply Data input from RF receiver No connection. Do not connect. Factory test point. Mode Pin low (0V) selects receive mode Send Data Output. Pull high to send the data in receive buffer Serial Data Output. 2400bps Data Ready Output flag. Goes low when valid data in buffer Ground. 0 Volt NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 3 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Technical Specifications Ambient Temperature 20° C Supply Voltage +5.0 V Parameter Min Typical Max Units Supply Voltage Supply Current 4.75 1.8 5.0 5.25 2.4 Volts mA Serial In/Out Baud rate Character time RF transmit bit time RF transmit time Receive & decode time Handshake delay Serial data output time Tx Enable source current Operating temperature Storage Temperature 2400 4.16 200 35 36 1 50 8.0 0 -40 20 20 bps mS uS mS mS mS mS mA +40 +85 deg. C deg. C Notes 1 2 3 4 Notes 1) Data is always ‘true’ i.e. same polarity as RS232 +/-12V levels but at 0v to +5V (Vcc) logic levels. (Start bit is logic high, stop bit is logic low.) 2) 1 start, 8 data, 1 stop = 10 bits @ 416uS/bit = 4.16mS 3) Manchester encoded. 4) Eight bytes with handshake delay. NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 4 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 System Timing Diagram Approx 128mS Overall Host sends 8 Characters 42mS NKM2401 RF Transmit and RF Receive/Decode 35mS Data Ready Output Send Data Input NKM2401 Serial Data Out 50mS Handshake delay 1mS NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 5 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Transmit Mode Interface Host Vcc 1 Serial Data Busy Mode High Gnd Transmit Enable NKM2401 Transmit Data Test Ground (0V) Two Wire Interface Transmit Mode Operation In transmit mode the NKM2401 receives eight bytes of serial data from the sending host. It stores this data in a local buffer and then calculates a CRC (Cyclic Redundancy Check) checksum on the data only. It then sets the Transmit Enable line high to enable the RF transmitter module and a ‘busy’ line high to indicate that no more data can be received. A pre-amble character is sent on the Transmit Data line followed by a special synchronising character, the eight bytes of data and the CRC result. The complete packet of transmitted data is Manchester encoded for optimum transmission over the RF link. Notes 1. 2. 3. 4. 5. Serial data format must be: 1 Start Bit, 8 data bits, 1 stop bit, No parity, 2400bps only. Data is true. Any data byte format may be sent (Hex, decimal, ASCII) The Serial Data In status is continuously tested, waiting for the positive going start bit of a character. It must therefore normally be held low. The NKM2401 accepts eight characters at a time. If more than this are sent, the internal buffer overflows and the first eight are accepted and sent, the others may be lost. Radio packets always contain eight bytes of data. Characters can be sent to the NKM2401 character by character. There is no need for them to be in a continuous stream. When the buffer has received eight characters they will be sent. The use of the ‘Busy’ output line is optional. It goes high during transmission and may be monitored by the host to provide a ‘handshaking’ function if required. i.e. Clear to send and NOT clear to send. If handshaking is not used time must be allowed for the completion of the transmission and reception of the message before sending any more data. (typically 120mS ) The ‘busy’ output can also be connected to a LED to provide visual indication of ‘busy’. Test Pin To aid testing and diagnostics, a test pin is provided in transmit mode. This should normally be pulled high by an external pull up resistor of 10k Ohm. If this pin is switched low by a pushbutton or jumper the Serial Data Input is ignored and an internally generated test message is transmitted whilst the test pin is held low. There is a 500mS delay between messages. The eight character message reads “123Test”. NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 6 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Receive Mode Interface +5V LED (Option) 470R Vcc Host Data Ready Rx Data Input NKM2401 No Connect Serial Data Send Data Mode +5V Low Ground (0V) One Wire Interface (No Handshake) +5V LED (Option) Vcc 470R Host Data Ready Rx Data Input NKM2401 No Connect Serial Data Send Data Mode Low Ground (0V) Three Wire Interface +5V LED (Option) Vcc 470R Rx Data Input NKM2401 No Connect Mode Host Data Ready Serial Data Send Data Low 10k Ground (0V) NKM2401 Issue 1.1 Nov-98 Two Wire Interface Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 7 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Receive Mode Operation In receive mode the NKM2401 is continually listening for messages and searching the digital ‘white noise’ on the receiver data output for the preamble followed by the unique synchronising character. If it finds this character it “locks on” to the signal, decodes it and stores the data in a local buffer. The CRC is calculated on the received data and if correct the ‘Data Ready Output’ line is set low. Handshake Methods One Wire Interface. (Beginners) This is the simplest method. The ‘Send Data’ line is permanently wired high. Whenever the buffer is full (signalled by the ‘Data Ready’ line going low) it is immediately sent out on the ‘Serial Data’ line. The host must therefore always be “ready and waiting” for this data. Three Wire Interface. This full handshaking method allows complete flow control by the host at the expense of using two extra I/O lines. The host monitors the ‘Data Ready’ line (by polling or interrupt) until the NKM2401 signals that it has data in its buffer by setting the ‘Data Ready’ line low. When the host is ready to receive data, it must set the ‘Send Data’ line high. After a 1mS delay (to allow settling) the serial data is sent. After each character is sent there is a further 1mS delay and the ‘Send Data’ line is tested again. If it is still high another character is sent, if it is low no more characters are sent. This allows the host to unload the buffer a character at a time, process the data (at its own pace) and then collect another character. The ‘Data Ready’ line will only go high again when the buffer is empty. The only disadvantage to this method is that the NKM2401 cannot receive any more new messages until the buffer is empty. Two Wire Interface. (Advanced) This is a refinement of the above method and saves one I/O line by using a configurable bi-directional port in the host.. The ‘Data Ready’ output is connected to the ‘Send Data’ input by a 10k resistor. The host I/O line is initially set up as an input and it is normally pulled up to Vcc (+5V) via the 10k resistor from the ‘Data Ready’ line. When the buffer is full the ‘Data Ready’ line goes low as above. The host should detect this state, configure the I/O line as an output and set it high when it is ready to receive the serial data. The series resistor allows the ‘Send Data’ input to be set high overriding the ‘Data Ready’ low output. When the serial data has been sent (buffer empty) the ‘Data Ready’ line returns high awaiting the next packet. Status No data available Data ready Send data Sending data Done Data Ready Output Serial Data Output Send Data Input High Low Low Low Serial Data Low Set Low Low r Pull High r Keep High Set Low o Goes Low Low Low r Goes High Notes 1. The Data Ready line can drive an optional LED which indicates when the buffer has valid data available. This is a useful diagnostic tool. 2. The Send Data input is tested after the transmission of each character and therefore must be held high for the total duration of transmission (Eight characters) 3. The error checking (CRC) ensures (with 99.9% certainty) that any message received and flagged by Data Ready will be error free. However if the CRC fails for any reason the message is lost forever. In simplex (one way only) systems such as these it may therefore be prudent to send the message multiple times. NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 8 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Low cost modules usually share the same RF channel. Whilst it is possible for one transmitter to transmit to many receivers, care should be taken if multiple transmitters are being used in vicinity of each other to ensure that they do not transmit simultaneously. Messages may “clash” and therefore destroy each other. There is no addressing built into the NKM2401. This should be done at the application layer embedded in the users message. E.g. first character is the address. This should be inspected by the host to determine if the intended destination has been reached. NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 9 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Typical Application Circuit +5V 100n 10k AERIAL NKM2401 1 2 3 4 SERIAL DATA IN BUSY VDD GP5 GP4 GP3 8 7 6 5 VSS GP0 GP1 GP2 1 2 RF GND RF OUT 3 4 5 VCC GND D IN TXEN TXD MODE HIGH 470R TXM-418F BUSY TEST 5V VERSION ONLY 0v 10k PB SW LED 10R AERIAL RF GND 100n LED 1 2 +5V 470R 10k RXD TP DTCT GND VCC AF DATA 100n 1 2 3 4 MODE LOW 3 4 5 6 7 NKM2401 VDD GP5 GP4 GP3 VSS GP0 GP1 GP2 8 7 6 5 DATA READY SERIAL DATA OUT SEND DATA 10k SILRX-418F 0V 100n Notes 1. The LEDs are optional but very useful. 2. The TXM module must be the 5V (low voltage) version. External buffering may be required to drive other modules. 3. The TP is for factory use only. NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 10 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Connection to PC RS-232 Port 100n +5V 10k AERIAL DCD DSR RXD RTS TXD CTS DTR RI GND 1 6 2 7 3 8 4 9 5 NKM2401 SERIAL DATA IN 47k 1 2 3 4 RXD BUSY MODE HIGH PC AT VDD GP5 GP4 GP3 VSS GP0 GP1 GP2 8 7 6 5 TXEN 1 2 RF GND RF OUT 3 4 5 VCC GND D IN TXD 470R TXM-418F TEST 5V VERSION ONLY 0v 10k PB SW BUSY LED 10R 100n AERIAL LED 100n +5V DATA READY RF GND 1 2 470R 10k RXD TP 1 2 3 4 NKM2401 VDD GP5 GP4 GP3 VSS GP0 GP1 GP2 8 7 6 5 1 6 2 7 3 8 4 9 5 SERIAL DATA SEND DATA 1k MODE LOW DTCT GND VCC AF DATA 3 4 5 6 7 DCD DSR RXD RTS TXD CTS DTR RI GND PC AT SILRX-418F 0V 100n The NKM2401 can be directly connected to a PC RS232 port as shown above. A simple terminal programme can be used to drive the devices. In transmit mode the +/-12V PC RS232 output is connected to the RXD input via a series resistor of 47k. Internal protection diodes clamp the input voltage to ground and +5V. In receive mode the serial data output is connected to the RXD input of the PC. The 0-5V logic levels will usually drive most PC serial inputs (but not all!) A series resistor of 1k provides some short circuit protection to the NKM2401. The polarity of the signals is correct for these direct connections. If longer lines need to be driven a logic level to RS232 level converter should be used. These are usually inverting so extra inverters should be connected in the signal lines. No handshaking is used in these examples as PC UARTs will usually accept the eight byte packets. The hardware handshake lines of the PC should be tied as shown to defeat any hardware handshaking that may be used on some PCs or .checked by software. NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 11 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Connection to Stamp +5V 100n 10k AERIAL +9V PWR GND PC0 PC1 +5V RES P0 P1 P2 P3 P4 P5 P6 P7 1 2 2 4 5 6 7 8 9 10 11 12 13 14 NKM2401 SERIAL DATA IN 1 2 3 4 BUSY VDD GP5 GP4 GP3 VSS GP0 GP1 GP2 8 7 6 5 1 2 RF GND RF OUT 3 4 5 VCC GND D IN TXEN TXD MODE HIGH 470R TXM-418F STAMP1 BUSY TEST 5V VERSION ONLY 0v PB SW LED 10R AERIAL RF GND 100n 1 2 LED +5V +9V 470R 10k RXD TP DTCT GND VCC AF DATA 100n 1 2 3 4 NKM2401 VDD GP5 GP4 GP3 VSS GP0 GP1 GP2 8 7 6 5 MODE LOW 3 4 5 6 7 DATA READY SERIAL DATA OUT SEND DATA 1 2 2 4 5 6 7 8 9 10 11 12 13 14 PWR GND PC0 PC1 +5V RES P0 P1 P2 P3 P4 P5 P6 P7 STAMP1 SILRX-418F 0V 100n The NKM2401 provides an ideal interface to Stamp modules. It frees valuable resources and allows users to quickly and easily add ‘wireless’ capabilities to their systems. The low current consumption allows the NKM2401 to be powered from the 5V regulated supply available from the Stamp. Stamp Software Examples The following code snippets demonstrate the ease of use of these modules. The familiar SERIN and SEROUT commands hook in directly to the Stamp and no special coding is required. Transmit Routines Send: serout 0,N2400,("12345678") pause 500 goto Send ' Send message on Pin 0 ‘do something useful here ' send message again Receive Routines Receive: serin 0,N2400,b1,b2,b3,b4,b5,b6,b7,b8 pause 500 goto Receive NKM2401 Issue 1.1 Nov-98 ‘Receive message on Pin 0 ‘Store data in variables b1 to b8 ‘do something with the data ‘get some more data Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 12 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 No ‘handshaking’ is used here so adequate time must be allowed for the complete transmission, reception and handling of the message before sending another one. ( approx. 130mS) If handshaking is used the characters may be unloaded a character at a time into a single variable. Real World Stamp Application The following circuits illustrate a working example of a Stamp based data acquisition system. An ADC converter and a temperature sensor transmit their data to a remote LCD display. Full working software listings for the Stamp code are available on disk. Transmitter Circuit (Available as part number 1-484) +9-12V DC INPUT +5V 10k 10k PROG PORT +5V CLOCK DATA 10k ADC0831 1 2 3 4 CS VCC +VIN CLK -VIN D0 GND VREF 8 7 6 5 1 2 3 4 BS1-1C 1 2 3 4 5 6 7 8 9 10 11 12 13 14 PWR GND PC0 PC1 +5V RES P0 P1 P2 P3 P4 P5 P6 P7 DS1620 D0 CLK RST GND VCC T(HI) T(LO) T(COM) 8 7 6 5 AERIAL +5V 100n 10k NKM2401 1 2 3 4 VDD GP5 GP4 GP3 VSS GP0 GP1 GP2 8 7 6 5 RF GND RF OUT 3 4 5 VCC GND D IN TXEN TXD MODE HIGH 0-5V 1 2 470R TXM-418F 5V VERSION ONLY 0v ANALOGUE INPUT 100n NKM2401 Issue 1.1 Nov-98 100n SW1SW2 BUSY 10k TEST 100n Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 13 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Receiver Circuit (Available as part number 1-485) 10k +5V 10k 1N4001 PROG PORT 1N4001 RA2 1k 470R 470R 1k LM7805 +9-12V DC INPUT VO G VI N D BS2-1C 1 2 3 4 5 6 7 8 9 10 11 12 RA1 470R 220u SOUT PWR SIN GND ATN RES GND +5V P0 P15 P1 P14 P2 P13 P3 P12 P4 P11 P5 P10 P6 P9 P7 P8 24 23 22 21 20 19 18 17 16 15 14 13 LED 1 2 3 SERIAL LCD DISPLAY + - LED BC184L BC184L LED SW1 SW2 10R AERIAL 100n RF 1 GND 2 0V LED +5V 470R 10k RXD TP DTCT GND VCC AF DATA PIEZO 1 2 3 4 NKM2401 VDD VSS GP5 GP0 GP4 GP1 GP3 GP2 8 7 6 5 DATA READY SEND DATA SERIAL DATA MODE LOW 3 4 5 6 7 SILRX-418F 0V 100n RF Environment Receivers are very sensitive and like all radios can be subject to interference. Care should be taken to avoid local sources of interference such as noisy switch mode power supplies or external bus micro systems. Such devices can generate harmonics that have considerable energy in the UHF band. This will desensitise the receiver and may cause loss of range. Aerials should be kept clear of large metallic objects or surfaces and should ideally be surrounded by “free space”. The module manufacturers data sheets detail these requirements and should be carefully studied. NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 14 of 15 Data Sheet and Application Notes NKM2401 Code/decoder chip Part number 1-982 Further Reading Radiometrix Data Sheets. TXM-418, SILRX-418, BiM Transceiver. See www.radiometrix.co.uk RS-232 Simplified. Everything YOU need to Know About Connecting, Interfacing & Troubleshooting Peripheral Devices. Author: Byron W.Putman. Publisher: Prentice Hall. ISBN 0-13-783499-3 Product Order Codes Description Order Code NKM2401 Modem IC RF AppKit Assembled Receiver Unit Assembled Transmitter Unit 1-982 1-939 1-484 1-485 Document History Issue Date Revision 1.0 1.1 1.2 Oct-98 Oct-98 Nov-98 Preliminary Minor corrections Stamp App Circuits added Copyright The information contained in this data sheet is the property of Milford Instruments/nikam electronics and copyright is vested in them with all rights reserved. Under copyright law this documentation may not be copied, photocopied, reproduced, translated or reduced to any electronic medium or machine readable form in whole or in part without the written consent of Milford Instruments/nikam electronics. Disclaimer Milford Instruments has an on going policy to improve the performance and reliability of their products, we therefore reserve the right to make changes without notice. The information contained in this data sheet is believed to be accurate however we do not assume any responsibility for errors nor any liability arising from the application or use of any product or circuit described herein. This data sheet neither states nor implies warranty of any kind, including fitness for any particular application. Milford Instruments-England Tel: +44 1977 683665, Fax: +44 1977 681465 [email protected]; www.milinst.demon.co.uk End of Data Sheet NKM2401 Issue 1.1 Nov-98 Milford Instruments/nikam electronics www.milinst.demon.co.uk Page 15 of 15