1. Introduction
DC 500W motor control with an Arduino mega to limit starting current and to vary the speed of the scooter. The battery is in 24V, 10A.h. The following table summarizes their characteristics:
2. Bibliography:
Link download :
sketch_escooter_feed_back_reel_V1.ino
sketch_escooter_feed_back_reel_V1.ino - Google Drive
escooter_ampli_SIMULINK.mdl
escooter_ampli_SIMULINK.mdl - Google Drive
escooter feed back ISIS.DSN
escooter feed back ISIS.DSN - Google Drive
video
**youtube : "study trotinette electric e-scooter 100W et 350W, wiring" **
study trotinette electric e-sccoter 100W et 350W, wiring - YouTube
Article: «Study of electric scooters 100W and 500W (Arduino), Revue 3EI 2017»
Pdf?
Book «I realize my electric vehicle» at DUNOD
3. Open loop program
To test the programming, we simulate the program in ISIS, as can be seen in the following figure. In addition, we have an LCD display to display data (duty cycle corresponding to the PWM at 32Khz, motor current, motor voltage, action on the pushbuttons, 4 push buttons are used.
BP1 to manually increment the duty cycle, BP2 decrement it. BP3 set the duty cycle to 0, corresponding to the brake contact.
The speed of the motor is practically proportional to the duty cycle
There are many cards for Arduino to control DC motors especially of low powers and also of great powers as can be observed on the following links.Robot Power Products - MegaMoto Plus Motor Control Shield for Arduino
http://www.robotshop.com/en/dc-motor-driver-2-15a.html
https://www.pololu.com/file/0J51/vnh3sp30.pdf
https://i58.servimg.com/u/f58/17/56/35/17/a310.jpg
But all these chopper shields measure the current internally but there is no current limitation.
In order to have a current limitation, an analog current loop is required using specialized AOP or IC or a fast digital current loop.
But what should be the value of the limitation current?
The choice of the current value is normally for the 1-hour operation service in order to be able to carry out relatively long climbs without reaching the critical temperature of the engine.
In our case, the limitation current must be
Limiting motor = Power / Upper battery = 500W / 24V = 20A
In addition, the power transistor of the chopper can only support 50A in our case.
But in open loop, it has no current regulation, so as not to exceed the maximum current, a ramp of the duty cycle will be used.
A 0.1 second interruption routine will be used to measure the voltage of the current (sample measurement, sample). This sampling time is arbitrary but does not allow to be faster than the rise time of the current because the electric time constant of the motor is L / R = 1.5 ms.
Open loop operation with a 25.5s (8bit) ramp and 0.1s interrupt routine provides a good understanding of the operation of a DC motor drive.
The display will only be done every 0.2s to have a stability of the digits on the screen. In addition, a digital filtering will be done on the current and the voltage on 4 values therefore on 0.4.
[b] Algo open loop [/b]
Interrupt Routine All 0.1S
Read voltage and current
Loop loop (push button scan)
If BP1 = 1 then increment PWM
If BP2 = 1 then decrement PWM
If BP3 = 1 then PWM = 0
Displaying variables every 0.2s
// include the library code:
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
#include <TimerOne.h>
#define SERIAL_PORT_LOG_ENABLE 1
#define Led 13 // 13 for the yellow led on the map
#define BP1 30 // 30 BP1
#define BP2 31 // 31 BP2
#define BP3 32 // 32 BP3
#define LEDV 33 // 33 led
#define LEDJ 34 // 34 led
#define LEDR 35 // 35 led
#define relay 36 // 36 relay
#define PWM10 10 //11 timer2
LiquidCrystal lcd(27, 28, 25, 24, 23, 22); // RS=12, Enable=11, D4=5, D5=4, D6= 3, D7=2, BPpoussoir=26
// Configuring variables
unsigned int UmoteurF = 0; // variable to store the value coming from the sensor
unsigned int Umoteur = 0;
unsigned int Umoteur2 = 0;
unsigned int Umoteur3 = 0;
unsigned int Umoteur4 = 0;
unsigned int ImoteurF = 0;
unsigned int Imoteur = 0;
unsigned int Imoteur2 = 0;
unsigned int Imoteur3 = 0;
unsigned int Imoteur4 = 0;
byte Rcy=0 ; // 8bit duty cycle
unsigned int temps;
// the setup function runs once when you press reset or power the board
void setup() {
pinMode(Led, OUTPUT); // Arduino card
pinMode(LEDV, OUTPUT);
pinMode(LEDR, OUTPUT);
pinMode(LEDJ, OUTPUT);
pinMode (PWM10,OUTPUT); // Pin (10) output timer2
// digitalWrite(LEDV,LOW);
Timer1.initialize(100000); // initialize timer1, and set a 0,1 second period => 100 000
Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt
lcd.begin(20, 4);
Serial1.begin(9600);
TCCR2B = (TCCR2B & 0b11111000) | 0x01; //pin 10 32khz http://playground.arduino.cc/Main/TimerPWMCheatsheet
//http://www.pobot.org/Modifier-la-frequence-d-un-PWM.html
// analogWriteResolution(bits) https://www.arduino.cc/en/Reference/AnalogWriteResolution
lcd.setCursor(0,1);
lcd.print("Rcy");
lcd.setCursor(10,1);
lcd.print("Um");
lcd.setCursor(5,1);
lcd.print("Im");
lcd.setCursor(10,1);
lcd.print("Um");
lcd.setCursor(20,1); // 4 lines display * 20 characters
lcd.print("BP1+");
lcd.setCursor(25,1);
lcd.print("BP2-");
lcd.setCursor(29,1);
lcd.print("BP3=0");
}
// Interruptions tous les 0.1s
void callback() {
temps++;
//toogle state ledv for check
if ( digitalRead(LEDV)== 1 ) {digitalWrite(LEDV,LOW);}
else {digitalWrite(LEDV,HIGH);}
analogWrite(PWM10,Rcy); // frequency
Umoteur=analogRead(A0);
Imoteur=analogRead(A1);
Imoteur2=Imoteur;
Imoteur3=Imoteur2;
Imoteur4=Imoteur3;
ImoteurF=(Imoteur4+Imoteur3+Imoteur2+Imoteur)/4 ;
Umoteur2=Umoteur;
Umoteur3=Umoteur2;
Umoteur4=Umoteur3;
UmoteurF=(Umoteur4+Umoteur3+Umoteur2+Umoteur)/4 ;
}// End routine
// Loop corresponding to main function
void loop() {
// BP + LED
if ((digitalRead(BP1))==1) {
lcd.setCursor(20,0); // Column line
lcd.print("BP1");
digitalWrite(LEDR, LOW);
digitalWrite(LEDJ, LOW);
Rcy++; // PWM incrementation
if ( Rcy>254) {Rcy=254;}
delay(100); //8bits * 100ms = 25S increment 25ssecond slope
}
if ((digitalRead(BP2))==1) {
lcd.setCursor(20,0);
lcd.print("BP2");
Rcy--;
if ( Rcy<2) {Rcy=2;} // PWM almost at 0, engine stop
delay(100);
digitalWrite(LEDR, HIGH);
digitalWrite(LEDJ, HIGH);
}
if ((digitalRead(BP3))==1) {
lcd.setCursor(20,0);
lcd.print("BP3");
Rcy=2; // PWM almost at 0, engine stop
}
if (temps>=2) {
lcd.setCursor(0,0);
lcd.print(" "); // Erase line
lcd.setCursor(0,0);
lcd.print(Rcy);
lcd.setCursor(5,0);
ImoteurF=(ImoteurF)/20; //resistance (5/1024)*(10/0.25ohm) si ACS712 66mV/A
// For resistance 1ohm (ImoteurF) / 20; Simulation 5/25
lcd.print(ImoteurF);
lcd.setCursor(10,0);
UmoteurF=UmoteurF*10/38; //10/38 10/30 simula
if (Umoteur>ImoteurF){UmoteurF=UmoteurF-ImoteurF; } //U-R*I
lcd.print(UmoteurF);
temps=0;
}// End if time
} // End loop
Since there is a limit of 9000 characters in the forum below