PID Regulator Implementation for Electric Kart DC Motor Current Stabilization

Motor drives are controlled using some sort of modern controller. In the past, operational amplifiers were used extensively as main computing elements. As digital technology has advanced, more sophisticated devices have become popular, like industrial programmable logic controllers (PLC) or microcontrollers (MCU) with necessary additional hardware. This article deals with MSP430 series microcontroller implementation in closed current loop regulator. Regulator task is to control permanent magnet DC motor of an electric kart. When precise amount of power or torque has to be produced, motor control has always been an important task. With the conventional car which has an internal combustion engine most regulation is done by the driver. The response time of internal combustion engine is rather large, compared to an electric motor. Electrical motor torque response can be in the range of 1 millisecond, while internal combustion engine response time can be about hundred times longer [1]. Experienced drivers usually claim that they “feel” the car – they can precisely control engine by pressing the accelerator pedal in order to increase torque. Nowadays the engine is controlled via an on-board computer, but couple of decades ago, most of the control job was really done by the driver. If the car is equipped with an electric motor, torque response is much faster, thus if the driver presses the accelerator pedal too quickly then the acceleration may be too high for safe control of the vehicle. To avoid such behavior motor torque must be limited within the safe operation zone by the on-board computer. There are other problems arising as well. Electrical motors have large starting or inrush currents. These currents produce the high starting torque, which is beneficial. On the other hand high current can damage motor windings or semiconductor switches of power converter which delivers power from batteries to the motor. In order to avoid damage, current must be kept within safe operation levels for both motor and converter. Since motor torque is proportional to the motor current, both can be controlled with the same regulator. Because current measurement transducers are simpler and commonly used than torque sensors, the regulation parameter is armature current. Input signal of the controller is the desired current level, or current command which is proportional to the desired torque. The proposed regulation system is part of the electric kart (Fig. 1), which is built as a student project for educational purposes. Kart chassis has been chosen for particular project due to its relatively inexpensive platform and compact size if compared to a full size car. The small dimensions and lack of outer shell gives easy access to all parts if any improvements are necessary.


Introduction
Motor drives are controlled using some sort of modern controller.In the past, operational amplifiers were used extensively as main computing elements.As digital technology has advanced, more sophisticated devices have become popular, like industrial programmable logic controllers (PLC) or microcontrollers (MCU) with necessary additional hardware.This article deals with MSP430 series microcontroller implementation in closed current loop regulator.Regulator task is to control permanent magnet DC motor of an electric kart.
When precise amount of power or torque has to be produced, motor control has always been an important task.With the conventional car which has an internal combustion engine most regulation is done by the driver.The response time of internal combustion engine is rather large, compared to an electric motor.Electrical motor torque response can be in the range of 1 millisecond, while internal combustion engine response time can be about hundred times longer [1].Experienced drivers usually claim that they "feel" the car -they can precisely control engine by pressing the accelerator pedal in order to increase torque.Nowadays the engine is controlled via an on-board computer, but couple of decades ago, most of the control job was really done by the driver.If the car is equipped with an electric motor, torque response is much faster, thus if the driver presses the accelerator pedal too quickly then the acceleration may be too high for safe control of the vehicle.To avoid such behavior motor torque must be limited within the safe operation zone by the on-board computer.
There are other problems arising as well.Electrical motors have large starting or inrush currents.These currents produce the high starting torque, which is beneficial.On the other hand high current can damage motor windings or semiconductor switches of power converter which delivers power from batteries to the motor.In order to avoid damage, current must be kept within safe operation levels for both motor and converter.Since motor torque is proportional to the motor current, both can be controlled with the same regulator.Because current measurement transducers are simpler and commonly used than torque sensors, the regulation parameter is armature current.Input signal of the controller is the desired current level, or current command which is proportional to the desired torque.
The proposed regulation system is part of the electric kart (Fig. 1), which is built as a student project for educational purposes.Kart chassis has been chosen for particular project due to its relatively inexpensive platform and compact size if compared to a full size car.The small dimensions and lack of outer shell gives easy access to all parts if any improvements are necessary.

Mechanical and electromechanical setup of the kart
The discussed current regulator is part of a more complex system.Two permanent magnet DC (PMDC) motors are used to achieve traction and drive the kart.Each motor is connected to one of the rear wheels through pulley sheave-belt coupling.The coupling reduces motor speed by ratio 3:1.Because each motor has its own power converter the speed and torque of individual wheel can be controlled separately, hence electronic differential can be implemented.

Fig. 1. Kart with both motors and battery packs
Electrical energy is stored in two lead-acid battery packs.Each pack is used to supply individual converter.Parameters of motors and batteries are summarized in Table 1.
Weight of the kart is approximately 230 kilograms.Assuming that average driver weights around 80 kilograms the total weight of the kart is 310 kilograms.From known parameters such as tire diameter, coupling ratio and motor speed, the maximal speed can be is calculated 91 km/h.If both motors are operated at their nominal torque, theoretically it takes approximately seven seconds to achieve top speed from a stand still position.The average time of kart operation in steady state driving mode is estimated 15 minutes.Experimental performance test have not been done, because the kart is not yet fully functional.

Power converter
Power converter connects one of the battery packs to the corresponding motor.Regulator circuit uses power converter to control motor current.Power converter has two signal inputs to drive the transistor switches.Power converter can be divided in two parts: buck converter for drive mode and boost mode for regenerative mode.Converter circuit is shown in Fig. 2. To operate in drive mode, PWM signal has to be applied to the top switch, while the bottom switch is turned off.To operate in regenerative mode, PWM signal has to be applied to the bottom switch, while the top switch is turned off.Power converter is equipped with driver board to turn switch elements on or off.Each switch is composed of two MOSFETs connected in parallel, to lower the losses and improve heat dissipation.Maximal transistor drain current is 171 A, maximal drain-source voltage 150 V. To minimize load current ripple and passive component size, converter is operated at 40 kHz frequency.Smaller input decoupling capacitor is needed if the current ripple value is lower.This setup is running at hard switching mode.To improve converter efficiency soft switching of transistors should be performed [2].

Load dynamics improvement
DC motors typically have very high starting currents and armature current can increase rapidly if the applied voltage increases.Specific motor is equipped with additional series connected inductor with inductance of 200 μH that increases the total load inductance, thus decreasing the rate of change of armature current (ΔI) from 0.89 A/μs to 0.23 A/μs.
Maximal permissible continuous motor current is 100 A, but maximal permissible converter current is 171 A. Motor can operate with increased current for relatively long time, but semiconductor switches can be damaged if their rated current is exceeded and no sufficient cooling is provided.In particular case there is a "safe zone" (I Limit ) of 71 A. The minimum time (t) in which the safe zone will be breached can be calculated according to (1) if the current change time is known.In this particular setup, the minimal time is around 300 microseconds, during which motor current must be read and appropriate PWM signal for switches must be calculated, in order to limit current value to allowable level = ∆ . (1)

MCU hardware implementation
In order to achieve good driving characteristics, motor torque has to be controlled.Since DC motor torque is proportional to motor current, sufficient control can be achieved using closed current loop regulator.Regulator circuit produces duty cycle signals for power converter switches.
By regulating current, the system can be protected from undesirable over current which can harm power converter.Each converter is operated by individual regulator circuit.Both regulators are controlled by main control board, which calculates necessary torque to achieve desired performance.
For the set task PI control method was selected.PI function was implemented in a microcontroller.Regulator receives input command from accelerator pedal.Accelerator pedal consists of pedal itself and it is coupled to a potentiometer.Potentiometer variable pin is connected directly to the microcontroller analogue to digital converter (ADC) input.Input signal varies from 0 V to 3 V.Regulator has another input: load current measurement.Motor current is measured using Hall effect current transducer HAIS 100-P made by LEM company.Sensor has +5 V power supply.At zero measured current (I P ), sensor output is 2.5 V.Each measured amp increases output voltage by 6.25 mV.If current flows in opposite direction, output value is decreased in similar manner.Output voltage (V o ) can be calculated according to (2) = 2.5 + 0.00625  .
(2) When motor reaches its nominal current 100 A, the transducer output voltage is 3.125 V. Since power converter maximal MOSFET current is 171 A, the same current can be conducted through load.At such situation transducer output voltage is 3.57 V.This value is higher than MCU ADC allowable input value.A simple resistor voltage divider is used to decrease transducer output voltage to permissible level.Signal is connected to MCU ADC input.At one of the outputs MCU produces PWM signal with constant frequency.The duty cycle of the signal is changing according to the regulator.Produced signal is fed into MOSFET driver circuit.For initial testing Concept Scale driver 2SD106AI-17 was used.Particular driver has two channels.At current setup, only one channel is in active use.It is driving the top switch of the power converter.Other channel is driving bottom switch.Currently second channel input is constantly pulled down, to keep the switch at OFF state.Thus only MOSFET built in diode is used as a freewheeling diode.In future development the same MCU will generate one more PWM signal to control low side switch to perform regenerative braking.Simplified regulator hardware setup is shown in Fig. 3.

MCU operation
Program code can be divided in multiple parts.First part is the main program.It is initiated after MCU is powered.During this part MCU CPU and peripheral settings are adjusted to match set tasks.CPU clock is set to operate with 8 MHz external quartz crystal.ADC inputs and operation mode is set.It is set to make six conversations of load current and save results in RAM.After conversations are done, program goes into ADC interrupt routine.This routine calculates next PWM duty cycle value.Timer is configured to work as a PWM generator.It is set to count up/down mode.Each time when counter counts to upper limit, it starts timer interrupt routine.Timer interrupt subroutine is used to write new duty cycle command value to the corresponding timer register.Zero current is measured and stored for reference.After zero current measurement CPU is turned off while global interrupt enable bit is set.Rest of the regulation processes are carried out using interrupt routines.

Zero current measurement
When there is no motor current, the current transducer produces certain voltage, which is reduced by the resistor divider.This value is recognized by MCU as zero current.Due to differences between transducers and resistor dividers, zero current reading is not always the same value.This value cannot be set as a constant, it has to be measured.Yet it has to be measured only once, since it can be assumed that transducers and resistor dividers parameters are not significantly changing over time.Each time MCU is turned on or restarted the zero current measurement procedure is performed.It is a part of main program.While no PWM signal is produced and there is no motor current, eight current values are read.They are averaged to get filtered zero current value.This value then can be tuned for additional precision, by experimentally increasing or decreasing its value.Transducer has a reference voltage output.It could be used as zero current value.Unfortunately if that voltage is used as a reference, current measuring process gets a bit more complicated.If reference voltage V ref is used then ADC reads value whether between V ref and power supply Vcc (positive current) or between V ref and ground GND.Two measurements have to be made.It takes extra computing time and it is not desirable.

PID regulator implementation
The regulator performs PI regulation of load current.Derivative (D) part is not used.It makes system more sensitive to noise.D part is useful when high speed systems have to be controlled.This case motor current control is not considered to be high speed system [3,4]

Experimental
Regulato generator setu synchronous t passive load ( was powered be seen in Fi synchronous g not be achieve

Fig
Fig. 5. Experim MCU w Initially gain v according to th experimentatio particular syst almost no cur the current ri Some current r

Table 1 .
Motor and battery bank parameters MHz using external quartz crystal.MCU is equipped with 10 bit ADC.MCU has three digital input/output ports.Together there are twenty two data lines.MCU has 8 kB of program memory, 256 B data memory and 256 B RAM. Chip has a 16 bit timer which can operate in capture or compare modes.JTAG interface programmer was used to program the chip.It is a handy programming tool, because it allows running program code command by command, thus relieving debugging process.