RS232-ADC16/24 RS232-ADC16/24 Manual Version 1.13 Copyright taskit GmbH 2009 www.taskit.
RS232-ADC16/24 Table of contents 1 Features..................................................................................................................3 2 Introduction.............................................................................................................3 3 Bringing into service................................................................................................4 4 Application Sample......................................................................................
RS232-ADC16/24 1 Features ● ● ● ● ● ● ● ● ● ● ● C8051F350/C8051F352 microcontroller at 3 – 49 Mhz RS232 interface Eight analog 16/24-bit inputs Eight digital 3.3V IOs (5V tolerant) Supply voltage range from 4.5V – 15V (absolut max. 20V) Provides 3.
RS232-ADC16/24 3 Bringing into service The following steps illustrate how to setup the device correctly. 1. Connect DSUB-9 adaptor to serial port. 2. Configure serial port to 115200 baud, 8N1 (8 bit data, no parity, 1 stop bit). 3. Power the device. Use VIN (pin 24) and GND (pin 18) pins of DSUB-25 connector. (15V max) After this, a terminal program should display RS232-ADC's boot message. Referring to the advice given in the boot message sending a questionmark will produce a help text.
RS232-ADC16/24 4 Application Sample To illustrate the use of RS232-ADC16/24 – in special regard to VCC and VIN – you might consider this schematic overview. The task is to obtain sensor's data and transfer it to a monitoring software. In case of critical or unusal conditions a nearby LED should indicate this. Obviously, up to eight pairs of sensor and LED can be controlled using one RS232-ADC16/24. As described earlier, the device is powered via VIN at a maximum of 15V.
RS232-ADC16/24 5 Frame layout This chapter specifies the used frame format. A frame does not contain more than one command; each command is send together with all of its parameters. Parameters larger than eight bits are expected in big-endian format, which means the most significant byte (MSB) is send before the least significant byte (LSB). On serial line each byte is send with eight bits, one start bit and one stop bit. There are no parity bits envolved in communication.
RS232-ADC16/24 5.1 LRC calculation The packet LRC is the two's complement of the sum over the packet's parameter and command bytes. LRC = -((∑datan) + command); with data n as binary byte values of the packet's parameter list and command as binary value. The correct LRC for the sample request above would have been 0xF8. In regard to this including the LRC of a received packet itself into calculation will result in a sum equal to 0, otherwise a transmission error has occured.
RS232-ADC16/24 6 Commands The device uses a MODBUS similar command set, assuming all parameters as 16-bit values. The following commands are provided. 6.1 Read Holding Registers A contiguous block of 16-bit software holding registers can be read at once. Addressing starts at 0, count is greater than 0 and less or equal 125.
RS232-ADC16/24 Response : Read Input Registers Function code 1 byte 0x04 Byte count 1 byte (Register count) * 2 Register values (Register count) * 2 bytes Otherwise an error response is send. 6.3 Write Single Register Single holding registers can be written using this function. The function code is followed by a 16-bit register address and a 16-bit register value.
RS232-ADC16/24 Response : Write Multiple Registers Function code 1 byte Register address 2 bytes Register count 2 bytes 0x10 Otherwise an error response is send. 6.5 Calibrate device This command calibrates the device for external circuits. Analog channels 0 and 1 have to be set to the following levels during calibration. Channel 0 must be connected to analog ground. Channel 1 must be connected to the highest expected valid level. Note : The device is already calibrated at delivery.
RS232-ADC16/24 6.7 Error Response Every function that leads into an error condition responds with a two-byte answer containing the indicated function code and an additional error code. Indication is achieved by setting the function code's highest bit.
RS232-ADC16/24 7 Register description The device's configuration is handled via read/writeable holding registers. PIO data is also available at these holding registers. ADC channels appear as readonly input registers. 7.
RS232-ADC16/24 REG_OUT_VAL 0x0002 15 14 13 12 11 10 9 8 - - - - - - - - 7 6 5 4 3 2 1 0 Out7 Out6 Out5 Out4 Out3 Out2 Out1 Out0 Outn sets the pin level of the corresponding pin D n. Any changes to input pins are ignored. The default value of this register is 0x00FF. REG_IN_VAL 0x0003 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - - - - - - - - In7 In6 In5 In4 In3 In2 In1 In0 Input levels at pin Dn appear in bit Inn if Dn is programmed as input.
RS232-ADC16/24 Output frequency is calculated the following way : foutput = clockSYS / 3 / 128 / 2ADC cyles. 3 Note : Output frequency is also limited by the selected baud rate. When using clockSYS at 49 MHz the clock used by ADC is 24.5 MHz. 1 Firmware version 1.12 extends range of accepted values to 5 – 15, for earlier versions this range is 5 – 11. 2 For devices with at least firmware version 1.11 – default value for earlier versions is 5. 3 Firmware versions below 1.
RS232-ADC16/24 REG_SYSCLK 0x000F 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 clockSYS select The system clock can be choosen in five steps from 3.0625 MHz to 49 MHz. Any register setting outside range will result in default clock SYS at 12.25 MHz. Altering the system clock will cause a short delay before sending the boot message. All pin and register settings remain untouched by clock change.
RS232-ADC16/24 7.
RS232-ADC16/24 8 Techincal Details 8.1 RS232 connector Connection between host and RS232ADC16/24 device is realizied with a female 9-pin D-SUB connector. The pin layout is consistent with the standard RS232 pin mapping except -RI* which can either be used to detect the device or as device's alternative power supply pin. Therefore -RI* is internally wired to VIN. As result, if -RI* pin is connected to the host, input voltage of device's power supply is limited to 15V maximum due to the RS232 specification.
RS232-ADC16/24 8.3 Electrical characteristics Digital IO Min Max Output high level 2.5 V 3.3 V Output low level - 1.0 V Input high level 2.0 V 5.0 V Input low level - 0.8 V Output current1 - 75 mA Min Max 0V 2.5 V (analog max.) 3.6 V (elec. max.) - 16/24 bit Min Max Supply voltage (VIN, -RI* connected) 4.5 V 15 V (absolut max. 20V) Output voltage (VCC) - 3.
RS232-ADC16/24 8.4 Reaction time Reaction time depends on two things – the baud rate and system clock of course. Each request has to be received and decoded before any action could occure. The overhead of decoding is partly time-shared with pure transmission overhead thus falling less and less in account in either higher system clock rates or slower transmission speed. Note that transmission and decoding overhead do not account the main time when making more precise ADC measurements.
RS232-ADC16/24 8.5 Power consumption Power consumption depends on SYSCLK settings, ADC decimation ration and the device's busy cycle. If no commands have to be processed idle mode is entered resulting in lower power consumption. Disrupting the RS232 connection will also lead to lower values. Power consumption fSYSCLK MHz Idle mA Busy Busy (REG_ADC_DEC = 5) (REG_ADC_DEC = 11) mA mA 3.0625 8.5 10.0 10.5 6.125 9.3 12.1 13.0 12.25 11.0 15.2 17.7 24.5 14.4 19.0 24.8 49 22.0 27.2 37.
RS232-ADC16/24 8.6 Baud rate error Since SYSCLK is not dividable by standard baud rates errors occur when setting transmission speed. The table shows errors for the default value according to SYSCLK. Baud rate errors fSYSCLK MHz Desired baud rate Resulting baud rate Error in % 3.0625 57600 56179 2.47 6.125 115200 114285 0.79 12.25 115200 114942 0.22 24.5 115200 117647 2.12 49 115200 113636 1.36 8.
RS232-ADC16/24 Since firmware version 1.11 provides ADC output rates that scale with SYSCLK one might consider the influence of SYSCLK on output rate and precision. REG_ADC_DEC = 11 SYSCLK MHz I in mA foutput Hz Min mV Max mV Noise mV Noise % Bit 3 10.5 4 -0.04 0.03 0.07 0.0028 15.12 6.1 13.0 7.5 -0.04 0.07 0.11 0.0044 14.47 12.2 17.7 15 -0.04 0.04 0.08 0.0032 14.93 24.5 24.8 29 -0.08 0.04 0.12 0.0048 14.35 49 37.6 29 -0.07 0.08 0.15 0.0060 14.