Wiki

This version (12 Apr 2019 15:43) was approved by AndreiD1994.

PLC Arduino Shield Input Demo

The ADuCM3029_demo_cn0414 project provides a solution to control a PLC or DCS input system using the EVAL-CN0414-ARDZ and the EVAL-ADICUP3029. It uses an ADC with 4 differential voltage channels and 4 current channels and boasts low power Open-Wire Detection capabilities and HART communication. It has a 32kb EEPROM memory that can also be used to identify the board and is controlled via a command line interface (CLI).

General Description/Overview

The ADuCM_demo_cn0414 project uses EVAL-CN0414-ARDZ to provide a complete, fully isolated and highly flexible, four channel analog input system. The EVAL-CN0414-ARDZ is suitable for programmable logic controllers (PLC) and distributed control system (DCS) applications that require multiple voltage inputs. It boasts open wire detection and has HART-compatible, 4 mA to 20 mA current inputs, all protected from transient overvoltage or overcurrent events, suitable for the most harsh industrial environments.

The circuit can be divided into the following parts: the ADC, the input channels, the HART modem and the memory.

The ADC is the core of the EVAL-CN0414-ARDZ shield. It is an AD4111 with 8 single or 4 differential voltage channels and 4 current channels. The input channels in this application are configured as 4 differential voltage channels and the current channels. The application maintains 8 internal registers, one for each channel, that are updated periodically, on a timer interrupt, with the latest conversion results. This way, on a single read, the user can have the data on a channel without waiting for a conversion. Timer diagram Alternatively the user can request a burst read of up to 2000 samples returned at the ADC output data rate. The application uses the ADCs Open-Wire Detection capabilities for the voltage channels. When activated this option also tracks the state of the channel connection on every read and gives a warning when a channel is disconnected.

The EVAL-CN0414-ARDZ is HART capable. When this option is activated the current channels can be used to transmit or receive HART messages or command zero and receive response. The system is capable of receiving messages asynchronously using a GPIO interrupt.

The system also includes an EEPROM memory that communicates with the controller via I2C and can be used to store data or identification information for the board. The memory can be used to uniquely identify the board in a system of 4 similar boards (EVAL-CN0414-ARDZ or EVAL-CN0418-ARDZ) controlled by the same EVAL-ADICUP3029.

Demo Requirements

The following is a list of items needed in order to replicate this demo.

  • Hardware
    • EVAL-ADICUP3029
    • EVAL-CN0414-ARDZ
    • Mirco USB to USB cable
    • PC or Laptop with a USB port
    • 24V and 1A limited power supply (optional)
  • Software
    • CrossCore Embedded Studio (2.8.0 or higher)
    • ADuCM302x DFP (3.2.0 or higher)
    • ADICUP3029 BSP (1.1.0 or higher)
    • Serial Terminal Program
      • Such as Putty or Tera Term

Setting up the Hardware

  1. Connect EVAL-CN0414-ARDZ board to the EVAL-ADICUP3029.
  2. Set the jumpers into the position shown below. This is the standard position and only works for one board systems.Standard jumper position
  3. Connect a micro-USB cable to P10 connector of the EVAL-ADICUP3029 and connect it to a computer. The final setup should look similar to the picture below.Hardware setup example

Configuring the Software

The configuration parameters can be found in the config.h file.

vref - Reference voltage of the ADC. If the internal reference is used this value must be 2.5V. If an external reference is used then this value must be the value of the external reference.

Referece vref value
internal 2.5
external Actual reference voltage
   /* Reference voltage of the ADC */
   float vref = 2.5;

Outputting Data

A serial terminal is an application that runs on a PC or laptop that is used to display data and interact with a connected device (including many of the Circuits from the Lab reference designs). The device's UART peripheral is most often connected to a UART to USB interface IC, which appears as a traditional COM port on the host PC/ laptop. (Traditionally, the device's UART port would have been connected to an RS-232 line driver / receiver and connected to the PC via a 9-pin or 25-pin serial port.) There are many open-source applications, and while there are many choices, typically we use one of the following:

Before continuing, please make sure you download and install one of the above programs.

There are several parameters on all serial terminal programs that must be setup properly in order for the PC and the connected device to communicate. Below are the common settings that must match on both the PC side and the connected UART device.

  1. COM Port - This is the physical connection made to your PC or Laptop, typically made through a USB cable but can be any serial communications cable. You can determine the COM port assigned to your device by visiting the device manager on your computer. Another method for identifying which COM port is associated with a USB-based device is to look at which COM ports are present before plugging in your device, then plug in your device, and look for a new COM port.
  2. Baud Rate - This is the speed at which data is being transferred from the connected device to your PC. These parameters must be the same on both devices or data will be corrupted. The default setting for most of the reference designs in 115200.
  3. Data Bits - The number of data bits per transfer. Typically UART transmits ASCII codes back to the serial port so by default this is almost always set to 8-Bits.
  4. Stop Bits - The number of “stop” conditions per transmission. This usually set to 1, but can be set to 2 for redundancy.
  5. Parity - Is a way to check for errors during the UART transmission. Unless otherwise specified, set parity to “none”.
  6. Flow Control - Is a way to ensure that data lose between fast and slow devices on the same UART bus are not lost during transmission. This is typically not implemented in a simple system, and unless otherwise specified, set to “none”.

In many instances there are other options that each of the different serial terminal applications provide, such as local line echo or local line editing, and features like this can be turned on or off depending on your preferences. This setup guide will not go over all the options of each tool, but just the minor features that will make it easier to read back data from the connected devices.

Example setup using Putty

  1. Plug in your connected device using a USB cable or other serial cable.
  2. Wait for the device driver of the connected device to install on your PC or Laptop.
  3. Open your device manager, and find out which COM port was assigned to your device.
  4. Open up your serial terminal program (Putty for this example)
  5. Click on the serial configuration tab or window, and input the settings to match the requirements of your connected device. The default baud rate for most of the reference designs is 115200. Make sure that is the selected baud rate as well.
  6. Ensure that local echo and line editing are enabled, so that you can see what you type and are able to correct mistakes. (Some devices may echo typed characters - if so, you will see each typed character twice. If this happens, turn off local echo.)
  7. Click on the open button, and as long as your connected device and serial terminal program are setup the same, than you should see data displaying.
Hint: If you see nothing in the serial terminal, try hitting the reset button on the embedded development board.

Available commands

Typing help or h after initial calibration sequence will display the list of commands and their short versions. Bellow is the short command list:

Command Description
General commands
h Display available commands.
stts Display parameters of the application.
Internal register commands
r Display voltage or current on the selected channel.
<chan> = channel to be shown
sur Change channel update rate.
<rate> = new channel update rate in Hz.
If it is bigger than output data rate divided by 80 can cause unpredictable behaviour.
HART commands
he Enable HART channel.
hd Disable HART channel.
hcc Select wanted channel.
<chan> = Channel to be selected.
ht Transmit string through HART.
<string> = string to be transmitted.
hg Send the received buffer through UART connection.
hcz Send command zero with the specified number of FFs in the preambule.
<pbsize> = size of the preambule (no. of 0xFFs in the beginning).
hpt Send command zero with the specified number of FFs in the preambule.
<byte> = byte to send in loop.
ADC commands
arr Display value of ADC register of the given address.
<reg> = address of the register.
awr Change value of the ADC register of the given address.
<reg> = address of the register.
<val> = new value of the register.
ags Get a specific number of samples from the given channel.
<ch> = selected chanel.
<nr> = number of channels; cannot exceed 2048.
aso Set sample rate.
<sps> = selected sample rate option.
If it is smaller than channel update rate multiplied by 80 can cause unpredictable behaviour.
asf Set filter option.
<filter> = selected filter option.
aep Enable post filter.
adp Select postfilter.
<opt> = selected postfilter option.
asp Reset controller, parameters and faults
aowe Enable open wire detection.
aowd Disable open wire detection.
EEPROM commands
de Discover EEPROM I2C addresses if there are any.

 Terminal example

Obtaining the Source Code

We recommend not opening the project directly, but rather import it into CrossCore Embedded Studios and make a local copy in your workspace.

The source code and include files of the ADuCM3029_demo_cn0414 can be found here:

How to use the Tools

The official tool we promote for use with the EVAL-ADICUP3029 is CrossCore Embedded Studio. For more information on downloading the tools and a quick start guide on how to use the tool basics, please check out the Tools Overview page.

Importing

For more detailed instructions on importing this application/demo example into the CrossCore Embedded Studios tools, please view our How to import existing projects into your workspace section.

Debugging

For more detailed instructions on importing this application/demo example into the CrossCore Embedded Studios tools, please view our How to configure the debug session section.

Project Structure

The program is composed of two main parts:

  1. Board setup with initial values.
  2. Main process.

 Main flow chart

Board setup initializes UART, SPI and I2C communication and verifies if there is an active EVAL-CN0414-ARDZ board connected by reading the AD4111 ID register. Here is also initialized the update timer for the internal channel registers.

 Board setup flow chart

The main process routine implements the CLI and calls the commands input by the user. This routine also checks the flags asserted in the asynchronous events (the update channel register flag, the HART received flag and the floating channel flags) and calls the appropriate handler methods. There is also a flag asserted by the channel register update rate and the ADC output data rate. If the update rate would be too close to the output data rate, the actual update rate might slow down to be possible for the program to maintain all functionality. The update rate may never be bigger or equal to the ADC output data rate divided by 8 (for 8 channels).

 Process flow chart

The flow chart below represents the way the channel registers are updated. Only one channel is active at any one time (the channel that must be read).

 Update channel flow chart

End of Document

resources/eval/user-guides/eval-adicup3029/reference_designs/demo_cn0414.txt · Last modified: 05 Mar 2019 16:16 by AndreiD1994