This is an old revision of the document!
The ADuCM3029_demo_cn0415 provides a solution to control current using pulse width modulation(PWM) for solenoid actuators, for the EVAL-ADICUP3029 base board with additional EVAL-CN0415-ARDZ shield, created using CrossCore Embedded Studio and GNU ARM compiler. The demo uses a command line interface(CLI) on UART.
The ADuCM360_demo_cn0415 project uses the EVAL-CN0415-ARDZ shield which is a control module that uses PWM to control current in solenoid actuators. The end product is an Arduino compatible daughter board for rapid prototyping platform that can be deployed to a robust Industrial environment and application. Its design is optimized for two types of applications: a two-state driver (open/close) for loads such as solenoids and actuators, and a linear driver for valves, positioners, heaters, and lamps. Its wide supply range, adjustable delay to PWM mode, and adjustable duty cycle make it suitable for a wide range of applications. Another is to monitor the proper operation of the plunger in valves controllers along with a resistor current sensing circuit making it a close loop system application. The target application is for automotive which addresses challenges in cold cranking, load dumping, reverse polarity connection, transient immunity, and EMI.
The circuit can be divided into three parts for the purpose of analysis: the supply block, the sense block and the actuator block. The supply block consists of DC-DC converters and protection circuits. The main supply is a 12V and 1A limited source that must be connected to P1. This is compatible with most power supplies available in an automobile. Alternatively the controller can be powered from a regulated 3.3V source on the Arduino connector. The current sense block contains a sense resistor of 0.1Ω that converts the current passing through the solenoid into a voltage drop that is picked up by an instrumentation amplifier. The resulting voltage is fed to the ADC that converts it to a 14 bit value and sends it via SPI to the ADICUP3029.
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 consists of N-channel MOSFET gate driver, and over current protection IC and a N-MOSFET transistor that is the actuator. The controller generates a PWM signal that, if integrated by the solenoids transfer function, it results in a current level.
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:
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;
The program outputs data and CLI interface to a serial terminal through UART.
Following is the UART configuration.
Select COM Port Baud rate: 115200 Data: 8 bit Parity: none Stop: 1 bit Flow Control: none
The terminal program must interpret new line as LF and local echo must be enabled.
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 |
---|---|
h | Display available commands |
f | Set frequency to the specified value <freq> = value of the new frequency 1Hz to 4MHz frequency is possible. |
d | 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%. Example: 5234 = 52.34%. |
r | Read and display the value of the ADC |
ad | Activate PWM dither functionality |
rd | Deactivate PWM dither functionality |
df | Set dither frequency to the given value <freq> = value of the new frequency Recommended to be maximum the PWM frequency divided by 10. |
da | 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. |
ap | Activate PID controller |
rp | Deactivate PID controller |
kp | Set PID Kp constant <kp> = value of the new Kp constant From zero to maximum number represented by a 32 bit float value. |
ki | Set PID Ki constant <ki> = value of the new Ki constant From zero to maximum number represented by a 32 bit float value. |
kd | Set PID Kd constant <kd> = value of the new Kd constant From zero to maximum number represented by a 32 bit float value. |
spf | Set PID sampling frequency <freq> = value of the new frequency Recommended to be at most equal with the dither frequency. |
sps | 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. |
dson | Set digital solenoid high |
dsof | Set digital solenoid low |
pss | Set and activate proportional solenoid <val> = value of the current or duty cycle from 0 to 1 amperes. |
rst | Reset controller, parameters and faults |
stts | Show application status and parameters |
clb | Run calibration sequence |
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_cn0415 can be found here:
! - LINK
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