This is an old revision of the document!
The ADuCM3029_demo_cn0415 provides a solution for controlling and monitoring solenoid actuator current, using an EVAL-CN0415-ARDZ shield installed on an EVAL-ADICUP3029 base board. The user interface is implemented as a command line interface (CLI) through a serial UART connection. The project is created using CrossCore Embedded Studio and GNU ARM compiler.
The circuit can be divided into four parts for the purpose of analyzing interaction with the software project: The supply block, the sense block, the actuator block, and the overcurrent fault / reset block.
The supply block consists of DC-DC converters and protection circuits. This block does not interact with the software.
Overcurrent fault and Overcurrent Reset block, controlled by general-purpose input/output (GPIO) pins on ADICUP3029. If the solenoid current exceeds a resistor-programmed threshold, a comparator trips off the MOSFET gate driver and notifies software via a GPIO signal. The user can then re-enable the driver once the fault condition is removed.
The sense block, consisting of a 0.1Ω current sense resistor, sense amplifier, filtering, and 14-bit Analog to Digital converter (ADC). The ADC is connected to the ADICUP3029 via Serial Peripheral Interface (SPI)
The voltage fed to the ADC with respect to current passing through the solenoid is given by the equation:
VADC = Isolenoid * Rsense * 20 Isolenoid - Current through solenoid Rsense - Sense resistor (0.1Ω)
The code output by the ADC is then calculated:
VADC - Voltage on the ADC input CODE = (VADC * 2^14) / Vref CODE - Code output by the ADC Vref - Reference voltage of the ADC
Here Vref is the reference voltage of the ADC and depends on the chosen supply. If the 12V on P1 was selected the supply voltage of the ADC will be 5V and the corresponding reference is 4.096V. If the ADC is powered from Arduino with 3.3V the reference will be 2.048V.
So the ADC code with respect to current sense will be:
CODE = (Isolenoid * Rsense * 20 * 2^14) / Vref
The actuator block, consisting of a logic-level to MOSFET driver. The logic signal is driven by the ADICUP3029’s PWM peripheral, allowing the the effective voltage across the solenoid to be varied.
The software implements several functions with the sense and actuator blocks. PWM frequency and duty cycle can be controlled directly. This mode of operation would normally be combined with an outer feedback loop in a control system. One example would be a system in which the solenoid controls air pressure, that is in turn measured by a pressure sensor, which is then used to determine a new duty cycle value that brings the pressure closer to the desired setpoint.
A PID control loop allows the solenoid current to be accurately controlled, compensating for variations in supply voltage and coil resistance. This mode of operation allows for optimum drive current for 2-state solenoids, minimizing power dissipation. An additional function allows a higher initial “pull in” current to be applied for a short time, after which current drops back to a lower “hold” current.
Using the data gathered form the sense block the a PID controller is implemented that can be used to set a specific current value or duty cycle. To use the PID controller it must be first tuned with the right values of Kp, Ki and Kd. Various methods can be used for tunning. The proposed method, which is easy, but does not yield perfect results, is:
A dither function allows a low-frequency AC signal to be superimposed, minimizing mechanical “stiction” in proportional solenoid applications.
The following is a list of items needed in order to replicate this demo.
The configuration parameters can be found in the config.h file.
vref - Reference voltage of the ADC set by supply method as described above. Set to 4.096 if the supply is the 12V on P1 or to 2.048 if supply is the Arduino 3.3V.
Supply voltage | vref value |
---|---|
3.3V | 2.048 |
12V | 4.096 |
/* Reference voltage of the ADC */ float vref = 4.096;
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.
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
Typing help or h after initial calibration sequence will display the list of commands and their short versions. Below is the short command list:
Type | Command | Description |
---|---|---|
System | h | Display available commands |
rst | Reset controller, parameters and faults | |
stts | Show application status and parameters | |
clb | Run calibration sequence | |
Control | f ex: f 5000<enter> (set frequency to 5kHz) | Set frequency to the specified value <freq> = value of the new frequency 1Hz to 4MHz frequency is possible. |
d ex: d 5234<enter> (set duty cycle to 52.34%.) | Set duty cycle to the specified value <duty> = value of the new duty cycle The duty cycle is from 0 representing 0% and 10000 representing 100%. |
|
r | Read and display the value of the ADC | |
ad | Activate PWM dither functionality | |
rd | Deactivate PWM dither functionality | |
df ex: df 50<enter> (set dither freq. to 50Hz) | Set dither frequency to the given value <freq> = value of the new frequency Recommended maximum value of the PWM frequency divided by 10. |
|
da ex: da 200<enter> (set dither amplitude to 2%) | Set dither amplitude <duty> = value of the amplitude in duty cycle variation Any value between 0 and 10000, same as duty cycle. Recommended to be lower than the lowest value needed for the duty cycle to be 0 or full scale. |
|
PID | ap | Activate PID controller |
rp | Deactivate PID controller | |
kp ex: kp 5000.0<enter> (set kp to 5000) | Set PID Kp constant <kp> = value of the new Kp constant From zero to maximum number represented by a 32 bit float value. |
|
ki ex: ki 1.5<enter> (set ki to 1.5) | Set PID Ki constant <ki> = value of the new Ki constant From zero to maximum number represented by a 32 bit float value. |
|
kd ex: kd 0.25<enter> (set kd to 0.25) | Set PID Kd constant <kd> = value of the new Kd constant From zero to maximum number represented by a 32 bit float value. |
|
spf ex: spf 100<enter> (set sample freq. to 100Hz) | Set PID sampling frequency <freq> = value of the new frequency Recommended to be at most equal with the dither frequency. |
|
sps ex: sps 2500<enter> (setpoint to 25%) | Set PID set point(hold value) <sp> = new hold value in A or 0.01%(duty cycle) From 0 to 1 amperes or from 1 to 10000 as duty cycle. |
|
Digital | dson | Set digital solenoid high |
dsof | Set digital solenoid low | |
Proportional | pss ex: pss 2500<enter> (setpoint to 25%) | Set and activate proportional solenoid <val> = value of the current or duty cycle from 0 to 1 amperes. |
There are two basic ways to program the ADICUP3029 with the software for the CN0415.
Using the drag and drop method, the software is going to be a version that Analog Devices creates for testing and evaluation purposes. This is the EASIEST way to get started with the reference design
Importing the project into CrossCore is going to allow you to change parameters and customize the software to fit your needs, but will be a bit more advanced and will require you to download the CrossCore toolchain.
The software for the ADuCM3029_demo_cn0415 can be found here:
Prebuilt CN0415 Hex File
Complete CN0415 Source Files
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.
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.
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.
The program is composed of three main parts:
The boards initial parameters can be given in the software in the main function or the FLASH_INIT_PARAMETERS define in the config.h file can be uncommented and the relevant parameters can be changed in program from the command line and the program will retain these parameters in the non-volatile memory. The program initializes timers and UART, SPI, GPIO and FLASH controllers.
Calibration is done to minimize full scale error. It sets control signal to logic “1” and measures the current, then prompts the user for a manual measurement with a precision tool. The difference between these two measurements is stored and used in calculating future values from ADC codes.
The main process is the infinite loop in which the program implements CLI, PID and dither functionality. The UART is used for the CLI and three different timers implement the PWM signal, the PID periodic calculation and the dither functionality.
End of Document