This circuit is an addressable ADC measurement and digital control module that communicates via 9600 baud.

Code and circuits (and more) are here.

  • Number of analog input channels: 3 (0-5V)
  • Number of digital output bits: 8
  • Address range: 0-31
  • 9600 baud input: three command/control bytes
  • 9600 baud output: one to four characters (ADC measurement)

  • This ADC/Digital unit is controlled by three bytes sent via RS232.

    • The first byte is a leader character. It is '$' (ASCII 036).

    • The second byte is the unit address and ADC channel select, whose bits are configured as:

    • The third byte is the digital value to be sent out Port C, whose bits are configured as:

    • A0, C0, and D0 are least significant bits.

    • If the second and third bytes are not each received within one second, the software resets to look for the '$' leader byte again.

  • Upon successfully receiving the three bytes, the digital value is placed on Port C, an ADC conversion is done and the ADC value is returned at 9600 baud.
  • The LED flashes once after initialization, and also when the measurement is done.
  • The serial Tx output floats when high, and is 0V when low. This allows paralleling several of these units on the same Rx and Tx line on the TTL side of the MAX235 RS232 converter. The Tx line must have a pullup resistor. However, only one pullup resistor and one MAX235 is required regardless of the number of units connected.
  • The ADC value is returned as four characters (0000-1023) followed by a trailing CR/LF. D0 is the least significant digit, as illustrated in the following:


  • If leading zeros are not desired tie NO ZEROS low.

Technical Reference

  • Port B pins have internal pullup resistors activated. Thus, any Port B signal that needs to be tied high may be left floating if desired. That also makes it possible to avoid external pullups on the bit switches.

  • There is a 25µS delay after channel selection to ensure that sample-and-hold time constants are observed after channel selection.
  • The LED flashes for 10mS.
  • The FLOAT_HIGH in the "#use rs232" instruction may be removed if multiple units are not used. The pullup resistor won't be necessary in that case