Wiki

This version is outdated by a newer approved version.DiffThis version (26 Feb 2019 22:37) is a draft.
Approvals: 0/1

This is an old revision of the document!


Solenoind Closed Loop Control Demo

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.

General Description/Overview

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.

 PID equation

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:

  1. Start increasing Kp constant while keeping Ki and Kd at 0. Increase Kp until the actuation time is reasonable and the current overshoot is within 5% of the wanted value.
  2. Start increasing Ki constant until the actuation time is reasonable and the current overshoot is within 5% of the wanted value.
  3. Pick Kd as 25% (1/4) of Ki.

A dither function allows a low-frequency AC signal to be superimposed, minimizing mechanical “stiction” in proportional solenoid applications.

Demo Requirements

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

  • Hardware
    • EVAL-ADICUP3029
    • EVAL-CN0415-ARDZ
    • Mirco USB to USB cable
    • PC or Laptop with a USB port
    • Solenoid actuator
    • 12V and 1A limited power supply
  • Software
    • CrossCore Embedded Studio (2.6.0 or higher)
    • ADuCM302x DFP (2.0.0 or higher)
    • ADICUP3029 BSP (1.0.0 or higher)
    • Serial Terminal Program (Required for running in release mode only)
      • Such as Putty or Tera Term

Setting up the Hardware

  1. Connect EVAL-CN0415-ARDZ board to the EVAL-ADICUP3029.  CN0415 stacked on ADICUP3029
  2. Connect a micro-USB cable to P10 connector of the EVAL-ADICUP3029 and connect it to a computer.
  3. Connect a solenoid actuator to the P8 connector with the positive wire on pin 1 and negative wire on pin 2.
  4. Connect a 12V power supply to the P1 connector with the positive wire on pin 1 and negative wire on pin 2. Powered CN0415 board with solenoid
  5. Turn on power supply.

Configuring the Software

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;

Outputting Data

Serial Terminal Output

The program outputs data and CLI interface to a serial terminal through UART.

  1. In order to view the data, you must flash the program to the EVAL-ADICUP3029.
  2. Then follow the UART settings below with the serial terminal program.

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.

Available commands

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 Set frequency to the specified value
<freq> = value of the new frequency
1Hz to 4MHz frequency is possible.
Example: f 5000<enter> (set frequency to 5kHz)
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: d 5234<enter> (set duty cycle to 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.
PID 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.
Digital dson Set digital solenoid high
dsof Set digital solenoid low
Proportional pss Set and activate proportional solenoid
<val> = value of the current or duty cycle
from 0 to 1 amperes.

 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_cn0415 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 three main parts:

  1. Board setup, with initialization;
  2. Calibration;
  3. Main process.

 Software main flow chart

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.

 Software board setup flow chart

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.

 Software calibration flow chart

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.

 Software process flow chart

End of Document

resources/eval/user-guides/eval-adicup3029/reference_designs/demo_cn0415.1551217037.txt.gz · Last modified: 26 Feb 2019 22:37 by Mark Thoren