sebulli

High Speed RC Actuator

Actuator

RC actuator with a digital controller and 1-2ms settling time.

The actuator consists of a coil and a NdFeB magnet, whitch is magnetized in a N-S-N polarization. A linear photo sensor with two BPW34 photo diodes acts as a position sensor. The controller is a digital PD in the feedback loop controller. Sampling time: 400µs.

Actuator

The testbench:

Actuator
Actuator

Step response:



The actuator with a RC system. You can see, the RC signals are updated in a 20ms cycle. The actuator reaches the new position in 2ms. This caused the typical stairway pattern.


Actuator with a Graupner MX10:


The digital controller runs on a STM32F4 microcontroller (a 32Bit ARM with 168MHz).


C-code of the PD controller:

  1. /*
  2.  *
  3.  *  High Speed Actuator - Free Invoicing Software
  4.  *  Copyright (C) 2012  Gerd Bartelt
  5.  *
  6.  *  This program is free software: you can redistribute it and/or modify
  7.  *  it under the terms of the GNU General Public License as published by
  8.  *  the Free Software Foundation, either version 3 of the License, or
  9.  *  (at your option) any later version.
  10.  *
  11.  *  This program is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *  GNU General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU General Public License
  17.  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20.  
  21. #include "controller.h"
  22. #include "adc.h"
  23. #include "pwm.h"
  24.  
  25.  
  26. int32_t meas;
  27. int ad_channel_map[4][2];
  28. int32_t rdiff;
  29. int32_t meas_old[4]={0,0,0,0};
  30. int32_t reg = 0;
  31. int32_t setpoint[4]={0,0,0,0};
  32. int32_t KP = 120; //120
  33. int32_t KI = 0;
  34. int32_t KD = 300; //-300
  35. #define CONTR_LIMIT 1000
  36.  
  37. /**
  38.  * Initialize the controller and configure the analog channels
  39.  */
  40. void controller_init(void) {
  41.  
  42.     // Create a table with the index of all analog channels
  43.     ad_channel_map[0][0]=3;
  44.     ad_channel_map[0][1]=4;
  45.  
  46.     ad_channel_map[1][0]=2;
  47.     ad_channel_map[1][1]=5;
  48.  
  49.     ad_channel_map[2][0]=1;
  50.     ad_channel_map[2][1]=6;
  51.  
  52.     ad_channel_map[3][0]=0;
  53.     ad_channel_map[3][1]=7;
  54.  
  55. }
  56. /**
  57.  * Setter for the controllers setpoint
  58.  *
  59.  * @param
  60.  *          channel Channel no from 0 to 3
  61.  *          setp  Setpoint from -1000 to +1000
  62.  *
  63.  */
  64. void controller_setSetpoint(int channel, int setp) {
  65.     setpoint[channel] = setp;
  66. }
  67.  
  68. /**
  69.  * Controller task
  70.  * Call this every 100µs
  71.  *
  72.  * @param
  73.  *          channel Channel no from 0 to 3
  74.  *
  75.  */
  76. void controller_task(int channel){
  77.  
  78.     // Get the sensor value.
  79.     meas = adc_getResult(ad_channel_map[channel][0]) - adc_getResult(ad_channel_map[channel][1]);
  80.  
  81.     // Calculate the difference between setpoint and sensor value
  82.     rdiff = setpoint[channel] - meas;
  83.  
  84.     // The PD regulator with a scaling factor
  85.     reg = rdiff *KP + (meas_old[channel]-meas) * KD;
  86.     reg /= 32;
  87.  
  88.     // Store the old value for the D-value
  89.     meas_old[channel] = meas;
  90.  
  91.     // Limit the value
  92.     if (reg > +CONTR_LIMIT) reg = +CONTR_LIMIT;
  93.     if (reg < -CONTR_LIMIT) reg = -CONTR_LIMIT;
  94.  
  95.     // Set the PWM output
  96.     pwm_set(channel,reg);
  97. }