cers_jack_nur_2016

5
Design and Implementation of a Speedometer and Speed Controller for Radio-controlled Cars Zhenyuan Yuan 1 and Nurali Virani 2 Abstract— This paper presents a setup for measuring the speed of a radio-controlled (RC) car using inexpensive on-board sensors. The proposed method has been experimentally tested on a laboratory-scale RC car in an indoor environment. The ground truth for the speed calibration is provided by a high- fidelity real-time motion capture system which is used to cali- brate the readings obtained from the Hall effect sensors. Fur- thermore, a proportional-integral-derivative (PID) controller for speed regulation of the car has also been implemented. The calibrated sensor readings are then used with a PID controller to regulate the speed of the car at any desired level. I. INTRODUCTION Recently, a lot of interest has developed for research of autonomous driving with an aim to make cars safe, fuel- efficient, and more comfortable. Easy-to-use small platforms which allow fast prototyping and physical implementation for validation of motion planning algorithms and navigation controllers are needed to reduce the risk and infrastructure requirement for full-sized cars. We propose to use an one- tenth scale RC car to simulate autonomous behaviors and implement algorithms, such as motion planning and machine learning. This car is inexpensive and easily available, yet most of realistic car dynamics can be demonstrated by this simple hardware. Modifications are built upon the car for the purpose of experiment and algorithm implementation. All radio-controlled cars are meant for remote operation by a human, or in other words, it is a human-in-the-loop system. Thus, the speed monitoring and regulation systems are not implemented on the car, but rely on human vision for feedback control. Most car-like robots used for experimental validation of control and planning algorithms in literature have little documentation on speed regulation, such as in [11] and [6]. Cameras have been used on the car-like robots as a visual odometry, from which linear speed can be obtained, as shown in [12]. However, this requires a high definition camera and it is sensitive to changes in ambient light. In the experiment of validating the estimation system based on Kalman filtering in [9], Real-time Kinematic Global Position System (RTK-GPS) is integrated with a car-like robot. In addition to its cost, our indoor experiment setup severely constrains the utility of RTK-GPS. On the other hand, *This work was supported by Networked Robotic Systems Laboratory under Department of Mechanical Engineering, The Pennsylvania State University, University Park, PA 16802 USA. 1 Zhenyuan Yuan is a sophomore with the Department of Electrical Engineering, The Pennsylvania State University, University Park, PA 16802 USA.[email protected] 2 Nurali Virani is with the Department of Mechanical and Nuclear Engineering, The Pennsylvania State University, University Park, PA 16802 USA.[email protected] inexpensive Hall effect sensors are suitable for speedometer applications. These sensors are usually paired with a toothed gear as in [14] and [8] and obtain speed data by detecting the changes in magnetic field when a gear tooth passes by. Hall effect sensors also served as a low cost simplified observer to assist control in [5]. PID controller was first introduced in 1936, when Nicolas Minorsky was designing a control algorithm for the automated steering of ships to avoid the disturbance force from distracting the ship from the desired course [10]. It is now usually used in feedback loop and acts as a method of regulation, such as regulating temperature and pressure [4]. Similarly, PID controller is suitable for real-time speed control of electric motors as demonstrated in [15] and [16]. In this work, Hall effect sensors are mounted on the car chassis, and two magnets are attached on the rotating axle. PID controller is implemented on a microprocessor regulating the output of the motor according to the feedback from the Hall effect sensor-based speedometer. The main contribution of this paper is the validation of the function of the speedometer made from Hall effect sensors and the effectiveness of the PID controller on regulating the speed of the car-like robot for this experimental setup. Since the RC car integrated with the speedometer and PID con- troller is designed for indoor experiments at low speeds, that is, less than 2 meter per second, and usually runs at slower than 1 meter per second, the assumption of non-slipping rotation holds very well in our setup. The speedometer setup is compact and easy to implement, requiring little knowledge of vehicle dynamics and sensor data processing, while the PID controller performs precise control as validated later in the paper. The rest of the paper is organized into four more sections. Section II explains the principle of implementation of the Hall effect sensor-based speedometer on the RC car. Section III displays the validation of the speedometer accuracy and the generated calibration curve. Section IV presents the PID controller implemented with the speedometer. Finally, in Section VI, conclusions are drawn and future research avenues are discussed. II. METHODOLOGY AND SETUP An overview of the project is shown in Fig. 1. The car used in the project is a 1/10 EXCEED RC 2.4GHz Electric Infinitive RTR Off Road Truck. The parts original from the car used in the project is the motor and the steering servo. The Electronic Speed Control (ESC) is replaced by an off- the-shelf motor driver. A platform is built upon the car in order to hold the designed hardwares to satisfy the project

Upload: jack-yuan

Post on 13-Apr-2017

43 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: cers_jack_nur_2016

Design and Implementation of a Speedometer and Speed Controller forRadio-controlled Cars

Zhenyuan Yuan1 and Nurali Virani2

Abstract— This paper presents a setup for measuring thespeed of a radio-controlled (RC) car using inexpensive on-boardsensors. The proposed method has been experimentally testedon a laboratory-scale RC car in an indoor environment. Theground truth for the speed calibration is provided by a high-fidelity real-time motion capture system which is used to cali-brate the readings obtained from the Hall effect sensors. Fur-thermore, a proportional-integral-derivative (PID) controllerfor speed regulation of the car has also been implemented. Thecalibrated sensor readings are then used with a PID controllerto regulate the speed of the car at any desired level.

I. INTRODUCTION

Recently, a lot of interest has developed for research ofautonomous driving with an aim to make cars safe, fuel-efficient, and more comfortable. Easy-to-use small platformswhich allow fast prototyping and physical implementationfor validation of motion planning algorithms and navigationcontrollers are needed to reduce the risk and infrastructurerequirement for full-sized cars. We propose to use an one-tenth scale RC car to simulate autonomous behaviors andimplement algorithms, such as motion planning and machinelearning. This car is inexpensive and easily available, yetmost of realistic car dynamics can be demonstrated by thissimple hardware. Modifications are built upon the car for thepurpose of experiment and algorithm implementation.

All radio-controlled cars are meant for remote operationby a human, or in other words, it is a human-in-the-loopsystem. Thus, the speed monitoring and regulation systemsare not implemented on the car, but rely on human vision forfeedback control. Most car-like robots used for experimentalvalidation of control and planning algorithms in literaturehave little documentation on speed regulation, such as in [11]and [6]. Cameras have been used on the car-like robots as avisual odometry, from which linear speed can be obtained,as shown in [12]. However, this requires a high definitioncamera and it is sensitive to changes in ambient light. Inthe experiment of validating the estimation system based onKalman filtering in [9], Real-time Kinematic Global PositionSystem (RTK-GPS) is integrated with a car-like robot. Inaddition to its cost, our indoor experiment setup severelyconstrains the utility of RTK-GPS. On the other hand,

*This work was supported by Networked Robotic Systems Laboratoryunder Department of Mechanical Engineering, The Pennsylvania StateUniversity, University Park, PA 16802 USA.

1 Zhenyuan Yuan is a sophomore with the Department of ElectricalEngineering, The Pennsylvania State University, University Park, PA [email protected]

2 Nurali Virani is with the Department of Mechanical and NuclearEngineering, The Pennsylvania State University, University Park, PA [email protected]

inexpensive Hall effect sensors are suitable for speedometerapplications. These sensors are usually paired with a toothedgear as in [14] and [8] and obtain speed data by detecting thechanges in magnetic field when a gear tooth passes by. Halleffect sensors also served as a low cost simplified observerto assist control in [5]. PID controller was first introducedin 1936, when Nicolas Minorsky was designing a controlalgorithm for the automated steering of ships to avoid thedisturbance force from distracting the ship from the desiredcourse [10]. It is now usually used in feedback loop and actsas a method of regulation, such as regulating temperature andpressure [4]. Similarly, PID controller is suitable for real-timespeed control of electric motors as demonstrated in [15] and[16]. In this work, Hall effect sensors are mounted on thecar chassis, and two magnets are attached on the rotatingaxle. PID controller is implemented on a microprocessorregulating the output of the motor according to the feedbackfrom the Hall effect sensor-based speedometer.

The main contribution of this paper is the validation of thefunction of the speedometer made from Hall effect sensorsand the effectiveness of the PID controller on regulating thespeed of the car-like robot for this experimental setup. Sincethe RC car integrated with the speedometer and PID con-troller is designed for indoor experiments at low speeds, thatis, less than 2 meter per second, and usually runs at slowerthan 1 meter per second, the assumption of non-slippingrotation holds very well in our setup. The speedometer setupis compact and easy to implement, requiring little knowledgeof vehicle dynamics and sensor data processing, while thePID controller performs precise control as validated later inthe paper.

The rest of the paper is organized into four more sections.Section II explains the principle of implementation of theHall effect sensor-based speedometer on the RC car. SectionIII displays the validation of the speedometer accuracy andthe generated calibration curve. Section IV presents thePID controller implemented with the speedometer. Finally,in Section VI, conclusions are drawn and future researchavenues are discussed.

II. METHODOLOGY AND SETUP

An overview of the project is shown in Fig. 1. The carused in the project is a 1/10 EXCEED RC 2.4GHz ElectricInfinitive RTR Off Road Truck. The parts original from thecar used in the project is the motor and the steering servo.The Electronic Speed Control (ESC) is replaced by an off-the-shelf motor driver. A platform is built upon the car inorder to hold the designed hardwares to satisfy the project

Page 2: cers_jack_nur_2016

objective. As shown in Fig. 3, the stacks of the boards makeup the center of control for the car. Beginning from the topof the layer is the circuit for steeling control. The secondlayer is the motor driver. The third layer is equipped withbluetooth for transmission and the circuitry for Hall effectsensors. The bottom one is the Arduino, which consists ofthe microprocessor implementing the signal processing andcontroller.

The motion of the car is driven by the motor, which hasits speed controlled by the output voltage from the MonsterMoto Shield[2]. Two inputs are taken in the program tocontrol the motor driver. One is for mode control, whichcontrols the motor for spinning clockwise, counterclockwise,brake to ground (brake without using power) and braketo VCC (brake consuming power). The second input isthe the Pulse-Width-Modulation signal controlling the speedof the motor. A variation of the PWM signal sent fromArduino to the Moto shield leads to different levels of outputvoltage from the motor driver, and thus leads to the differentspeed of the car. Arduino is an open-source microprocessorembedded on the RC car, and it serves as the center ofspeed regulation. Arduino receives the command from usersand outputs corresponding PWM signal. The Hall effectsensors also report the speed measurements to Arduino,where the output PWM signal is adjusted accordingly by PIDcontroller. Nevertheless, this speed is unregulated, which canbe affected by factors such as battery voltage and varyingfriction at the wheel-ground interface. In order to have thecar running in the desired speed regardless of these varyingfactors, a speedometer is needed on the car to provide real-time measurements of the car’s speed. The Hall effect sensorsignals are used to compute the speed in Arduino, wherethe output PWM signal is adjusted accordingly by PIDcontroller.

As shown in Fig. 5, the speedometer made from the Halleffect sensor in Fig. 4 is attached right under the axle ofthe rear wheel, while two magnets are attached on the axleas a result of their magnetic attraction. Since the car isimplemented with differential gearing[4], two of the samesetup mentioned are implemented under both rear wheels.

Hall effect is the production of a voltage difference due tothe change of magnetic field, and it is implemented by Hall

Fig. 1. Project overview

effect sensors which would output 5V (logic HIGH) voltagewhen the north pole approaches and decrease to 0V (logicLOW) when the south pole is getting close (Source:[14]).By counting the pulses delivered by the Hall effect sensors(US1881) as a result of the rotation of magnets embedded onthe axle in the RC car, the RC car is able to measure it’s ownspeed. Vicon (source: [3]), the indoor motion capture system,would be used to measure the speed of RC car running in anominal load condition and validate the speed measurementof the Hall effect sensors.

The average of the two Hall effect sensor readings deter-mines the linear speed of the car. As the axle rotates, themagnets are alternating the poles facing the sensors, whichin turns giving off logical HIGH and LOW signals as shownand captured by oscilloscope in Fig. 6 to the microprocessor,Arduino. A rotation counter is incremented at the rising edgewhen the sensor output is changing from LOW to HIGHlogical level.

The two Hall effect sensors have the same circuitry builtup as shown in Fig. 2. The resistor-capacitor setup betweenthe input terminal and output terminal of the sensor makesup a low pass filter that attenuates the possible noise output.The numerical value of the two component is determined bythe cutoff frequency equation:

fc =1

2πRCwhere fc is the cut off frequency used to filter out the

noise, R is the resistance of the resistor that also serves thepurpose of limiting the current passing through the sensor toavoid the sensor from overheating, and C is the capacitanceof the capacitor. The other capacitor is used to protect thesensors from any fluctuations of the power supply.

III. VALIDATION

In order to count the revolutions of the wheel, a program issetup inside the Arduino with an interrupt function which isactivated whenever the north pole of the magnet is detected,causing a rising of output voltage of the Hall effect sensorsto 5V. Inside the interrupt service routines, there are twotime-recording variables. Once the interrupt function takesplace, the interrupt service routines have one of the valuablerecorded the current system time inside of the microprocessorand assigns the other valuable with the old recorded systemtime. Outside the interrupt, in the main loop function, thedifference of the two system time is calculated as

Fig. 2. Hall effect sensor schematics (source: [1])

Page 3: cers_jack_nur_2016

Fig. 3. Layers of circuit boards on top of the car platform

Fig. 4. Hall effect sensor

Fig. 5. Speedometer setup(source: [13])

Fig. 6. Oscilloscope showing the signals from the Hall effect sensor, whichare detecting the wheel revolutions

∆t = tnew − told

where ∆t is the time between the consecutive two detectionof rising pulse sent from the Hall effect sensor, which isalso the time it takes for the wheel to finish one revolution.The calculation begins when the wheel finishes the secondrevolutions.

Since the ∆t is calculated after each revolution, the rota-tional speed is then obtained from

ω =1∆t

where ω is the rotational speed in revolution per second asa result of the Hall effect sensor measurement.

The instantaneous speed of the car is represented by thewheel speed for each revolution, which is also the speedthe magnets finish each alternation of the poles. With therotational speed determined, the linear speed of the wheelcan be calculated as follows:

v = ω ∗P

where v is the linear speed of the wheel, and P is theperimeter of the wheel measured as 38 centimeters.

The car is run in the room equipped with indoor trackingsystem, which accurately captures the motion of the car inreal time. The speed data measured by the speedometer andthe position data obtained by the indoor tracking systemare recorded by MATLAB, where the speed data from thespeedometer is integrated to obtain position data. Eventually,the two position data, collected from speedometer and theindoor tracking system, are brought to comparison under aplot, as shown in Fig. 7. The position data from Vicon iscalculated as the sum of displacements over each samplingperiod as

D1 =i=n

∑i=0

√∆y2

i +∆x2i

where y is the displacement along the y-coordinate of theVicon coordinate system, x is the displacement along the x-coordinate of the Vicon coordinate system, D1 is the totaldisplacement since the starting time.

The transformation of the speed data from the speedometerinto the position data is accomplished as the integral of speeddata over time, as

D2 =∫

τ

0vdt

but it is actually done by summing up individual displace-ment calculated by multiplying each speed data with thecorresponding sampling time, as

D2 =i=n

∑i=0

vi∆ti

where D2 is the displacement obtained from the speeddata, vi is the speed data obtain after each sampling time ti.

Page 4: cers_jack_nur_2016

Fig. 7. Figure of validating speedometer accuracy with Vicon measurement

Fig. 8. The no load setup of the car for generating the calibration curve

According to the plot, both resulted position versus timedata match really well, which validates the performanceof the speedometer made from Hall effect sensors on thislaboratory-scale car-like robots.

IV. PID CONTROLLER

PID controller is a control loop feedback algorithm that isused to regulate the speed to maintain at a desired level [7].Based on the measurements from Hall effect senors, thePID controller would adjust the output PWM signal to themotor by implementing proportional, integral and derivativeoperation on the error between the measured speed andthe desired speed, so that the error would eventually beminimized.

Fig. 9. PID controller block diagram

With the speedometer validated, a calibration curve isgenerated by running the car under no load condition asshown in Fig. 8, and the calibration curve is shown in Fig. 11.Since this car is mainly used for experimental function andrun under low speed condition, the calibration curve is drawnby recording the average speed of car under ten differentlow PWM inputs. Ten trials are taken for each PWM inputlevel. Plotting the PWM signal level against the averageand implementing curve fitting technique by finding the bestcurve that can fit the dots in the plot generate calibrationcurve with equation

Ure f =−0.03369∗ v̄3 +0.1804∗ v̄2 +4.524∗ v̄+19.3

where Ure f in microseconds is the duration of the HIGHpulses of the PWM signal sent to the motor driver, v̄ is thevalue obtained after the desired speed v is normalized bymean 207.6 and standard deviation 87.01, that is,

v̄ =v−207.6

87.01.

Upon the calibration curve, PID controller is implementedto realize speed regulation to maintain the car running atdesired speed regardless of outside factors. As summarizedin the diagram is Fig. 9, PID controller adjusts the outputof PWM signals according to the error between the desiredspeed and the actual speed measured by the speedometer.The adjustment is done by the equation:

u(t) = Kp ∗ e(t)+Ki

∫ t

0e(t)dt +Kd

de(t)dt

where u(t) is the adjustment value adding to the referencePWM signal output. As in the diagram, Kp ∗ e(t) is the Pterm, Ki

∫ t0 e(t)dt is the I term and Kd

de(t)dt is the D term of

the controller, and Kp, Ki and Kd are the gains of the PIDcontroller needed to be tuned for desired performance. Heree(t) is the error between the desired speed and the actualspeed with respect to time.

Since the car is running at low speed, Eventually theadjustment value from the PID controller is amended to thereference value, and the result is PWM duty cycle output tothe motor driver from the microprocessor is:

PWM =Ure f +u(t)

where PWM is the real PWM duty cyle output to the motordriver.

Kp determines the rising time but cannot help eliminate thesteady-state error ,Ki can help eliminate the steady state-errorbut increase the settling time and Kd helps reduce the settlingtime. With these the gains of controller, the Kp, Ki, and Kdcoefficients are manually tuned to desired performance [7].Because of the space limitation in the lab, the validationof PID controller is achieved by running the car running inno load condition the same way as the generation of thecalibration curve. With different desired speeds input, thePID controller performance with final tuned gains as P = 0.5,

Page 5: cers_jack_nur_2016

Fig. 10. PID controller performance validation

Fig. 11. Calibration curve generated under no load condition at low speed

I = 0.00000001 and D = 7.355, is shown in Fig. 10, whichshows that the regulation is achieved by rapid response andsatisfying accuracy.

V. CONCLUSIONS

In this paper, a project of designing a speed-regulator for acar-like robot is displayed. The solution, using PID controllerover the measurement from the speedometer made from Halleffect sensors, is efficient at monitoring and regulating thecar speed in a laboratory scale. When applied for futuremotion planning research project, this setup is effective atcontrolling the car-like robot at different speed. In orderto further simulate an autonomous car, direction regulation,which is steering control in a calibrated and accurate way,will be integrated into the car for the purpose of trajectoryfollowing. PID controller will be again used for steeringcontrol. Combining this two types of control together, aprototype of experimental car-like robot would be built andready for performing higher level of autonomous motionalgorithm.

REFERENCES

[1] US 1881: CMOS Multi-Purpose Latch, June 2005.[2] VNH2SP30-E: Automative fully integrated H-bridge motor driver,

October 2008.[3] Vicon Tracker User Guide, May 2015.[4] John Bechhoefer. Feedback for physicists: A tutorial essay on control.

Reviews of Modern Physics, 77(3):783, 2005.

[5] Jianrog Bu, Longya Xu, Tomy Sebastian, and Buyun Liu. Near-zero speed performance enhancement of pm synchronous machinesassisted by low-cost hall effect sensors. In Applied Power ElectronicsConference and Exposition, 1998. APEC’98. Conference Proceedings1998., Thirteenth Annual, volume 1, pages 64–68. IEEE, 1998.

[6] Chih-Lyang Hwang and Nai-Wen Chang. Fuzzy decentralized sliding-mode control of a car-like mobile robot in distributed sensor-networkspaces. Fuzzy Systems, IEEE Transactions on, 16(1):97–109, 2008.

[7] Yongho Lee, Sunwon Park, Moonyong Lee, and Coleman Brosilow.Pid controller tuning for desired closed-loop responses for si/sosystems. Aiche journal, 44(1):106–115, 1998.

[8] John A Lock. Changeable divider and index for a vehicle speed anddistance transducer including a hall effect sensor, September 19 1995.US Patent 5,451,868.

[9] Chang Boon Low and Danwei Wang. Integrated estimation forwheeled mobile robot posture, velocities, and wheel skidding per-turbations. In Robotics and Automation, 2007 IEEE InternationalConference on, pages 2355–2360. IEEE, 2007.

[10] Nicolas Minorsky. Steering of ships. 1984.[11] Keiji Nagatani, Yosuke Iwai, and Yutaka Tanaka. Sensor based

navigation for car-like mobile robots using generalized voronoi graph.In Intelligent Robots and Systems, 2001. Proceedings. 2001 IEEE/RSJInternational Conference on, volume 2, pages 1017–1022. IEEE, 2001.

[12] Navid Nourani-Vatani, Jonathan Roberts, and Mandiam V Srinivasan.Practical visual odometry for car-like vehicles. In Robotics andAutomation, 2009. ICRA’09. IEEE International Conference on, pages3551–3557. IEEE, 2009.

[13] Ali Pearlman. Car differential, retrieved from.

[14] Edward Ramsden. Hall-effect sensors: theory and application.Newnes, 2011.

[15] Hwi-Beom Shin and Jong-Gyu Park. Anti-windup pid controller withintegral state predictor for variable-speed motor drives. IndustrialElectronics, IEEE Transactions on, 59(3):1509–1516, 2012.

[16] Jianxin Tang. Pid controller using the tms320c31 dsk with onlineparameter adjustment for real-time dc motor speed and positioncontrol. In Industrial Electronics, 2001. Proceedings. ISIE 2001. IEEEInternational Symposium on, volume 2, pages 786–791. IEEE, 2001.