ADIO-Plus Networked I/O Controller Hardware Configuration This firmware requires the COMM-Link Version 2 board, configured with a 32K EPROM at address 0000 and either an 8K or 32K RAM. The 74LS386 multiplexer is required to provide manual mode and the LED heartbeat output. The 9346 serial EEPROM is required for any configuration or network address changes. If the EEPROM is not present, the firmware will assume the 8500 and ADC0831 are installed, set the address to ADP0, and start up in network mode. Heartbeat LED Error Codes The firmware checks the hardware during reset and while operating. If everything is OK the heartbeat LED will blink at about 0.5 Hz (one second ON, one second OFF). If an error is detected, the LED will display an error code by blinking in an irregular pattern that repeats every two seconds. The error codes are: Failure Blink code None steady blink at 0.5 Hz Bad EPROM checksum long, short Bad external RAM chip long, short, short Because the firmware cannot run without a RAM chip, the RAM error code will be reported only if the RAM is good enough to run the firmware. If the firmware fails due to a bad RAM or other hardware failure you will not see the normal blink code, so you'll know something is wrong. To Get Started Communications is 9600 b/s 8N1. Remove 75176 transceiver chip, install MAX-232. Connect PC to RS-232 header as usual. Verify commands to satisfy yourself that it works... Prefix all commands with "! ADP0 " (note spaces!) the default net address is ADP0 There is no command echo in this mode If you have trouble, install JP13 and reset the CPU to enter "interactive" manual mode: Descriptive banner appears and prefix is not used For Network Use Install 75176 transceiver, remove MAX-232. Connect PC through RS-485 converter. Your software must enable/disable RTS correctly! Make sure JP13 is not installed when you turn power ON. Checksums If you must be absolutely certain that there are no errors in either the commands or responses, you can add a checksum to each command. The firmware will respond only to commands with valid checksums, so your controller code must resend the command if it does not produce the expected response within a specified time-out. The command format is: #xx addr command where: # identifies a command with a checksum xx checksum byte in hex, described below blank a blank (ASCII 32, 20 hex) is required addr target node's network address blank a blank (ASCII 32, 20 hex) is required command command text carriage return (ASCII 13, 0D hex) The node's response will look like this: $xx addr command where: $ identifies node response (same as ! response) xx checksum byte in hex, described below blank a blank (ASCII 32, 20 hex) addr target node's network address blank a blank (ASCII 32, 20 hex) response the response to the command carriage return (ASCII 13, 0D hex) Note that ordinary and checksummed responses both start with a "$" character. You can distinguish between the two by examining the second character: if it's a blank, there is no checksum. Compute a checksum using this algorithm: - assemble the line with ASCII zeros in the checksum hexits #00 X10 QN01 - add up all the character values, including the zeros # 23 (all values in hex here) 0 30 0 30 blank 20 X 58 1 31 0 30 blank 20 Q 51 N 4E 0 30 1 31 total 7C (only the low byte is used) - find the 2's complement of the checksum byte -(7C) = 84 - convert the byte to ASCII hexits and replace the zeros #84 X10 QN01 To verify the checksum for an incoming line, - assemble the entire line $E7 X10 N01=XX - discard the trailing (and if present) $E7 X10 N01=XX - convert the checksum chars to a single binary byte $E7 X10 N01=XX (checksum is E7 hex) - replace the checksum chars with two ASCII zeros (30 hex) $00 X10 N01=XX (ASCII 48 chars, not binary zeros!) - add up all the character values, including the zeros $ 24 (all values in hex here) 0 30 0 30 blank 20 X 58 1 31 0 30 blank 20 N 4E 0 30 1 31 = 3D X 58 X 58 total 19 (only the low byte is used) - add the checksum byte 19 + E7 = 00 If the result is zero, the line is (quite likely) valid. After you think about it for a while you'll write a single subroutine to calculate or verify the checksum. If you hand the routine a line with a 00 checksum, it'll replace the zeros with the new checksum so you can send the line. If you hand it a (presumably) valid received line it will do the same, but also return the calculated checksum to the caller as an integer. Got it? Controller commands A=str Set network address to string (default ADP0) (16 chars max, capitalized, blanks discarded) C Set hardware configuration and write EEPROM NOADC no ADC installed ADC0831 8 bit, 1 differential input ADC0832 8 bit, 2 single-ended inputs or 8 bit, 1 differential input LTC1092 10 bit, 1 differential input LTC1292 12 bit, 1 differential input D Display program status (debugging use) E Show and clear error flags (debugging use) Ln Set logging mode (bit mapped) L report current mode L0 disable (default) L32 show device decoding Nn Set network/interactive mode N report current mode N0 set interactive mode N1 network mode (no error messages) (default) N2 network mode with command echo and err msgs N3 same as N1 with command acknowledgment Q Query inputs (immediate data, not stored samples) Q AI -> AI=003F Q DO -> DO=03 (only LSB used) Q DI.2 -> DI.2=1 Q AI,DI,DO -> AI=00FE,DI=0F,DO=00 RESET Perform power-on reset (must be completely spelled out) S Set outputs S DO=05 (only LSB used) S DO.0=1 X Erase EEPROM contents, resulting in blank EEPROM Use RESET to write default configuration You can query the output of the digital output driver even though it is a write-only device. The firmware maintains a copy of the most recent S command value and returns that in response to the Q command. The S command will set the value of an "input only" device such as the ADC chip, but the firmware suppresses the write commands. The next Q command will return the actual data read from the device as though the S command had not happened. I/O Devices The commands use these mnemonics for the I/O hardware: Name Function AI ADC converter DI 74LS386 digital input driver DO UCN8500 digital output driver Analog-to-Digital Converter The ADC converter may be one of several different chips providing different capabilities: ADC0831 8 bit, 1 differential input ADC0832 8 bit, 2 single-ended inputs 8 bit, 1 differential input LTC1092 10 bit, 1 differential input LTC1292 12 bit, 1 differential input You must use the Config command to tell the firmware which ADC chip is installed in the board and set JP12 to match the chip. The default configuration is an ADC0831. The ADC0831, LTC1092, and LTC1292 have only one input. You may use either of these commands to read the current value: Q AI Q AI.0 The converted value is always reported as four hexadecimal digits. The bits from the ADC are right-justified, so the ADC0831/32 converters use only the low-order byte. Although the ADC0832 has two inputs, the firmware defines four channels to control the chip's operation: Q AI.0 differential, input 0 positive Q AI.1 differential, input 1 positive Q AI.2 single-ended, input 0 Q AI.3 single-ended, input 1 The returned value will be in the 16-bit format described above. For all converters, if the voltage on the positive input pin is less than that on the negative input pin, the converter will return zero. There is no provision for negative differential voltages. The firmware drives the converters with a 150 kHz 50% duty cycle clock. Conversions take place only when the firmware decodes the Q AI command; the ADC chip is idle and deselected at all other times. All of the ADC converters produces a zero "dummy bit" during conversion, which the firmware verifies while reading the data bits. If the dummy bit is missing (either because the ADC is also missing or has failed) the firmware will return FFFF instead of a random value. In manual mode it will also display an error message. Digital Inputs and Outputs The firmware supports both "broadside" and bit-wise updates and queries for the digital I/O ports. To set or read all four bits at once, use these commands: Q DI S DO=05 You may also read the DO port with the Q command: Q DO to find the most recent value written to the port. The firmware uses only the low-order nibble of the value you provide, so you can use a single hexit to set the port: S DO=5 To read or update a single bit, use these commands: Q DI.1 S DO.3=1 Revision History Rev 1.0b Recompile with Micro-C 3.0 (cannot test locally...) Rev 1.0a Initial distribution Rev 0.1a Initial version