Use of robotic car control system

ABSTRACT

This piece of work presents the use of robotic car control system applied in PIC18 microcontroller application to take a control over a wheel slip. Controlling the vehicle robotic car when the wheel begin to slip there is a relation to the amount of force which is applied for driving the wheels based on road surface.

This work will involve a designing for robotic car which would have all the component and the brain for this system will be the PIC18, using this chip to get all the control operation for the system. Using some kind of measurement for the PWM for example by oscilloscope, and the test which would tell if the design is worked and succeeded or not by having some load on one of the wheels to have some kind of friction which will prevent the wheel from accelerating. Also by catching one of the wheels as well and wait for the respond to the other wheels, if one of the wheels is slew down the other wheels should respond and sew down as well.

ACKNOWLEDGEMENT

I would like to express my greatest thanks to my supervisor Dr. David Wilson for his help and guidance throughout the project time while the project was in progress.

I would like also to express my gratitude towards Dr. Peter Lennox for providing all the useful information and the key points on how to construct and present a report. I am also grateful to Lab technicians for letting me use the lab equipment and for helping me to overcome stressful situations during the time my project was in progress.

Last but certainly not least, I would like to specialize my thanks to my family for giving me the motivation to follow higher grounds and for their continuous support in the good times and bad times.

Finally I wish to acknowledge with gratitude and appreciation of the University Authority for the opportunity given to us to participate on this all-important programme on the education of the engineering.

INTRODUCTION

  • Introduction
  • Motivation
  • Previous Researches
  • Traction Principles
  • Minimum Slip Algorithm
  • Project Outline (Layout)

1.1 Introduction

All cars these days beginning to have traction control available on the vehicles, and most of the system which integrated with, by using what we called by the computerize field. The use of the microprocessor and the micro-controllers has growing sharply with the industry of the cars.

1.2 Motivation

Moving machines with intelligent designs to control their motion or in short robots have become a common sight these days. Their functionalities have increased tremendously and so are our expectations. We may desire to have a robot which can move without wheel slip on a wide variety of surfaces. This is exactly the aim of this project. I would use a simple no slip algorithm for controlling the speeds of individual motors driving the wheels.

There will be a using to pure electrical way of preventing slipping. As using the fact that the speed of a DC motor is directly proportional to the average voltage applied to it.

We will be using PIC18f8720 micro controller provided by Microchip co for our purpose. This micro controller has 5 CCP (capture, compare and PWM[1]) peripherals, 4 of which can be used to drive 4 motors through 4 H Bridges respectively. To get a feedback of the rotation speeds of the wheels, we would be using rotary encoders.

1.3 Previous Research

So many researchers have been carried to analyse the dynamic of vehicles and the parts which need to give the acceleration. To control the acceleration, a lot of dynamic theories involve with this controlling bit. The Figure 1.1 shows different surfaces having different coefficients of friction () verses slip (?).

1.4 Traction

Traction is the frictional force between the drive wheel tread and the racetrack. The frictional force between two items that are pressing together is easily evaluated. Friction force is dependent on the force with which the bodies are pressing together (also called as the normal force). It also depends on the coefficient of static friction between the two surfaces.

If Rb is the normal force and mu-static is the coefficient of static friction. I would like to calculate the frictional force, Ft which is the traction. The equation for evaluating this is:

We took the coefficient of static friction in the above case because there was no slipping motion between the ground and the wheel. If there is a slip, the coefficient of kinematic friction would be taken and the direction of frictional force is not dependable and the vehicle can face accident in such case, especially in case of a turn.

Moving machines with intelligent designs to control their motion or in short robots have become a common sight these days. Their functionalities have increased tremendously and so are our expectations. We may desire to have a robot which can move without wheel slip on a wide variety of surfaces. This is exactly the aim of this project. I would use a simple no slip algorithm for controlling the speeds of individual motors driving the wheels.

A traction control system (TCS) or Anti-Slip Regulation (ASR) is an electro hydraulic system developed for preventing loss of friction or traction of the driven road wheels. It helps in maintaining the control of the vehicle in cases when excessive throttle is applied by the driver and the conditions of the road surface (due to varying factors) are unable to cope with the applied torque. It is similar to electronic stability control, ESC system. But traction control systems do not have the same goal as ESC systems.

To regain control over the vehicle or to prevent slipping, the system can do one of the following interventions:

  • It can decrease the spark or suppress it to just one cylinder.
  • It can reduce fuel supply to one or more cylinders.
  • It can brake one more wheels
  • It can close the throttle, if the vehicle is fitted with drive by wire throttle
  • The boost control solenoid can be actuated to reduce boost and therefore decrease the engine power in turbo charged vehicles.

We will be using pure electrical way of preventing slipping. I will use the fact that the speed of a DC motor is directly proportional to the average voltage applied to it.

We will be using PIC18f8720 micro controller provided by Microchip co for our purpose. This micro controller has 5 CCP (capture, compare and PWM) peripherals, 4 of which can be used to drive 4 motors through 4 H Bridges respectively. To get a feedback of the rotation speeds of the wheels, we would be using rotary encoders.

1.5 Minimum Slip Algorithm

We desire to develop a traction system to help vehicles accelerate to particular speeds without / minimizing slipping of its wheels. Slipping leads to loss in control and so is bad for a vehicle. Slipping occurs when some wheels move faster than the others. For perfectly no slipping, all the four wheels should move with the same speed. We use a simple algorithm to prevent slipping. We try to eliminate the difference in speeds by speeding the slowest wheel and slowing down the fastest wheel. We do this until all the wheels are in a particular neighborhood of the desired speed. Thus we try to equal out the speeds of individual wheels.

Outline and Highlights of the Project:

This project is classified and organized as follows:

  • Chapter (1):
  • An introduction to the project and some traction principles

  • Chapter (2)
  • Covers the hardware module from the actual components and parts

  • Chapter 3
  • Shows the PWM peripheral and the micro-controller configurations

  • Chapter 4
  • The software module and the code parameters

  • Chapter 5
  • Covers the closes of conclusion and further work in the future

2.1 Introduction

In the following chapter, there will be discuss about the various hardware modules used in the project. The main modules used were rotary encoder, H-bridge, DC Motor, PWM peripheral of the micro controller.

2.2 Rotary Encoder

Rotary encoders help in encoding the angular position of the shaft. The working of these encoders can be explained by make and break of circuits due to rotation of the wheel. There are contacts covering different sectors of the disc [4]. When a contact takes place, we get a 0 and when there is no contact we get a 1. The circuit simply consists of a resistor connected to Vcc. a 2 bit encoder have been used in the project, which gives 0 and 5 V at the output depending on the position of the shaft. The time interval between edges (rising or falling) gives an estimate of the velocity. Actually velocity is inversely related to this time interval [4].

For detecting the edges, we poll the output of the rotary encoder and maintain a counter for the duration in which the output maintained the same value. Higher this counter value, lower is the angular speed of the wheel. Thus we get an estimate of the velocity of the wheel. We use the inverse of the counter value as the wheel velocity. We declare a phase change in the output if we get 10 consistent reading of a particular phase. This was done to remove the effect of make and break in the switches used. The wheel with maximum velocity is slowed down and the wheel with minimum velocity is accelerated to equal out the velocities of the wheels. Rotary encoders help in encoding the angular position of the shaft. The working of these encoders can be explained by make and break of circuits due to rotation of the wheel. We have used a 2 bit encoder in the project, which gives 0 and 5 V at the output depending on the position of the shaft. The time interval between edges (rising or falling) gives an estimate of the velocity. Actually velocity is inversely related to this time interval.

2.3 DC Motors

A DC motor takes in DC voltage for the drive input. Torque is produced by the interaction between the radial magnetic flux produced by the stator and the axial current carting conductors on the rotor. The flux or excitation can be furnished by permanent magnets or by means of field windings.

The main circuit in a DC motor consists of a set of identical coils wound in slots on the rotor, also known as the armature. Current is fed into and out of the rotor via carbon brushes which make sliding contact with the commutator. Commutator consists of insulated copper segments mounted on a cylindrical former. The term brush comes from the starting early attempts to make sliding contacts using bundles of wires bound together in much the same way as the willow twigs in a witchs broomstick. Not surprisingly these primitive brushes soon wore grooves in the commutator. All the electrical energy which is to be converted into mechanical output has to be fed into the motor through the brushes and commutator. As a high-speed sliding electrical contact is involved, we should keep the commutator clean to ensure trouble-free operation. In addition, the brushes and their associated springs need to be regularly serviced. Brushes wear away in course of time.

In DC motor, the amount of torque which the motor exerts on the shaft is proportional to the amount of current which flows into the motor. One way to control the current is to control the voltage applied to the motor. More the voltage more is the current, more is the torque and more is the rotational speed of the motor. I use H Bridge to control the voltage applied to the motor. Instead of directly driving the motor, I switch on or off a transistor using this current. The transistor can handle the large current needed for driving the motor. I use a circuit known as H Bridge for this purpose. The name of the circuit gets from the H like shape the circuit looks like.

2.4 H Bridge

There are two basic problems with motors which require a special circuitry for driving them.

  • The current and voltage requirements are higher for a micro controller to drive them directly. A single pin can supply a maximum of 25 mA of current. This current is too low for driving a motor. So I can not directly drive a motor directly by the micro controller unit.
  • Motors are electrically noisy and can send power back into control lines when the motor speed or direction is changed. This reverse voltage and current can damage the internal circuitry of the micro controller unit.

Instead of directly driving the motor, we switch on or off a transistor using this current. The transistor can handle the large current needed for driving the motor. We use a circuit known as H Bridge for this purpose. The name of the circuit gets from the H like shape the circuit looks like [6].

2.5 Oscillator Configuration

The PIC18F8720 micro controller can be operated in eight different oscillator modes (adapted from [3]). We can program three configuration bits (FOSC2, FOSC1 and FOSC0) to select one of these either modes:

  1. LP Low-power crystal
  2. XT Crystal / Resonator
  3. HS High Speed Crystal / Resonator
  4. HS + PLL High Speed Crystal / Resonator with PLL enabled
  5. RC External Resistor / Capacitor
  6. RCIO External Resistor / Capacitor with I / O pin enabled
  7. EC External Clock
  8. ECIO External Clock with I / o pin enabled

We will make use of the HS mode, FOSC2:FOSC0 = 010. In this mode a crystal or ceramic resonator is connected to pins OSC1 and OSC2 to establish oscillation. Figure 8 shows the pin connections for the same.

3.1 Overview:

PIC 18f8720 micro controller has 5 CCP modules. In PWM mode of the CCP module, the CCPx pin can output a 10-bit resolution digital periodic waveform with programmable period and duty cycle. A CCPx pin must be configured for output to operate in PWM mode.

We have used pulse width modulation to control the speed of the DC motor. We can see from the PWM timing diagram that by changing the pulse width we can change the average voltage received by the DC motor [5]. The higher the duty cycle, higher is the average voltage. Thus pulse width can be used to fix the motor speed. If duty cycle is 100 %, the motor operates at full speed. If the duty cycle is 10 %, the motor works at 10% of the maximum speed.

The PWM mode of the PIC micro controller generates a Pulse width modulated signal on CCP1 min. The following registers determine the duty cycle, period and resolution of the PWM:

  • PR2
  • T2CON
  • CCPR1L
  • CCP1CON

The CCP module in PWM mode can produce a 10 bit resolution PWM output on the CCP1 pin. The TRIS for CCP1 pin must be cleared to enable the CCP1 min output driver as the pin is multiplexed with PORT data latch.

3.2 PWM Period

PWM is a periodic signal and has a constant period. PR2 register of Timer2 specifies PWM period. We can calculate PWM period by the following formula.

When PR2 = TMR2, following events occur on the next increment cycle:

  • TMR2 clears, i.e. set to 0
  • CCP1 pin sets
  • The PWM duty cycle is latched from CCPR1L into CCPR1H

3.3 PWM duty cycle

The duty cycle for PWM is specified by writing a 10 bit value to multiple registers, namely CCPR1L register and DC1B<1:0> bits of the CCP1CON register. The CCPR1L register contains the MSB bits and the DC1B<1:0> bits contain the LSbs. We can at any time write to these 10 bits but they will be latched to CCPR1H only after the period completes, i.e. a match between TMR2 and PR2 occurs. CCPR1H is read only in PWM mode of operation. Following equation is used for finding the pulse width [3].

3.4 PWM Resolution

PWM resolution is the number of available discrete duty cycles. The maximum available resolution is 10. This occurs when PR2 = 255. The PWM resolution is a function of PR2 as seen from the following equation [1].

PWM pins will remain unchanged if the pulse width is greater than PWM period.

3.5 Set-up for PWM operation

The following steps are necessary for configuring the CCP module for PWM operation [3]:

  • Set the associated TRIS bit to disable the PWM pin (CCP1) output driver.
  • Load the PR2 register to set the PWM period.
  • Load CCP1CON register with appropriate value to configure the CCP module for the PWM mode.
  • Load the CCPR1L register and DCB1B<1:0> bits of the CCP1CON register for setting the PWM duty
  • cycle.
  • Configure and start the Timer2 by:
    1. Clearing the TMR2IF interrupt flag of the PIr1 register.
    2. Setting the Timer2 prescale value by loading the T2CKPS bits of the T2CON register.
    3. Enabling Timer2 by setting the TMR2ON bit of the T2CON register.
  • After a new PWM cycle has started, enable PWM output.

3.6 PWM (Enhanced Mode)

In Enhanced PWM mode [3], I can get PWM signal on upto four different output pins. I have four different modes to choose from Single PWM, Half Bridge PWM, Full Bridge PWM (forward) and Full Bridge PWM (reverse). The P1M bits of the CCP1CON register must be set appropriately to select an Enhanced PWM mode.

3.7 I/O Ports in PIC18 micro-controller

There are either 7 or 9 I / O ports available on PIC18FXX20 devices, depending on the device selected. Some of their pins are multiplexed and may have some other functions depending on which of the peripherals id active. A pin which is shared with a peripheral can no longer be used as a general purpose I/O if that peripheral is enabled. Every port has 3 registers for operation (taken from [3]). These are listed below:

  • TRIS register: This register is used to specify the data direction, either input or output.
  • PORT register: This is used to read the levels on the pins of the device.
  • LAT register: This is the output latch register. The data latch is useful for read modify write operations on the value that the input / output pins are driving.

The port which we are going to use in our project is PORT A. PORT A is a 7-bit wide port. It is bi directional. The corresponding data register is TRISA. If we set a TRISA bit to 1, we make the corresponding PORTA pin as input, i.e. put the corresponding output driver in a high impedance mode. If we clear a TRISA bit, i.e. make it 0, the corresponding pin starts behaving as an output pin. If I read the PORTA register, we actually read the status of the pins. Writing to PORTA actually writes to the port latch.

4.1 PWM C Library functions

The Microchip PIC18 C compiler provides the following functions to deal with common needs in a PWM application (adapted from [1]):

  1. void ClosePWMx(void); // Disable PWM channel x
  2. void OpenPWM x(char period); // Configure PWM channel x
  3. void SetDCPWMx(unsigned int dutycycle); // Write a new duty cycle value to PWM channel x

The header pwm.h must be included in order to use the functions of this library.

x in the above functions can take any value 1, 2, 3, depending on how many CCP modules are available in our microcontroller. Thus if we are using CCP1 module, we should use ClosePWM1, OpenPWM1 and SetDCPWM1 as our functions for disabling CCP1, configuring CCP1 as PWM mode and setting a new duty cycle respectively.

We can choose either Timer2 or Timer4 as the base timer of the PWM function by configuring the T3COM register to select the desired base timer for PWM operation.

4.2 Software Design and Pseudo `code

Let us take the PIC18F8720 micro controller to be particular. This micro controller has 5 CCP ports. I will use one each for driving four motors via H Bridge.

  • Let us take the oscillator frequency equal to 16 kHz.

The steps involved in the Pseudo code are as follows:

  1. Configure pins RA0, RA1, RA2 and RA6 for inputs from the rotary encoder. I do this by writing a 1 to the respective TRIS bits.
  2. Start PWM from CCP1, CCP2, CCP3 and CCP4 pins with some initial duty cycle.
  3. Start timer 0.
  4. Measure time between pulses from each of the rotary encoders.
  5. If the difference between the time required for the pulse to complete between the fastest and slowest wheels is above a threshold, we increase the duty cycle of that wheel for which the pulse time is highest and decrease the duty cycle of that wheel for which the pulse time is lowest. Else we just increase the duty cycle given to all the wheels, in order to accelerate to the desired duty cycle. we accelerate only if the final duty cycle is lower than the desired duty cycle.
  6. Again go to step 4. Suppose due to some reason a wheel slows down relative to other. In step 4, we will come to know that it has slowed down. The system will try to accelerate that particular wheel and slow down all the other wheels. Thus our system will do exactly the job it is expected to do. Thus we have designed a good traction system.

4.3 Final Circuit Diagram

Following points should be noted about the above circuit diagram:

  • Only give forward input to the H Bridge.
  • In the connection between the H Bridge and the DC motor, we have actually two wires coming out of the H Bridge and going into the two polarity connections of the motor.
  • We are using only one bit out of the two output bits of the rotary encoder.
  • Both the capacitors should be in the range 10-22 pF.
  • XTAL is a 16MHz Resonator.

4.4 Logic structure of the hardware

The following diagram show the blocks of each part for the traction control system. PWM would be generated using the micro-controller and four of them would send to the H-Bridge and to the take the value of the rotary encoder signals.

4.5 Circuit Analysis

In this project we have designed and implemented a way of electronically controlling the traction in a vehicle. We have used pulse width modulation duty cycle for controlling the speed of individual wheel. We try to maintain same speed for all the four wheels and try to prevent the slipping. We have used H Bridge to drive a DC motor.

Some ways to test that the circuit is serving the purpose it should, are listed in the following:

  • Acceleration test: we slow down the acceleration of a wheel by introducing more mass to it in the form of a magnet which will rotate with its shaft. Other wheels are left untouched. Then we start the car. The wheel with higher mass accelerates slowly. At the beginning the other wheels reach higher velocity. But eventually they are slowed down by the system and we have all the four wheels moving with nearly the same velocity.
  • Deceleration test: When the car is in motion, we put extra weight on one of the wheels using hand to slow it down. The result is all the other wheels also slow down.

The above two tests show that the system is serving the purpose of traction control and is successful in preventing the slipping between the wheels.

5.1 Investigation on the project

The project has been discussed in so many categories, and most of the main parts which the project is relying on have been covered and some theory was delivered. In this piece of work the actual design has been carried as suggested in the proposal. But when I was working on developing the project from the side of the software bit, there were some problems in the section for the assembly language. At the beginning I thought that the instructions for the assembly language in the PIC18 family will be similar to the PIC16 family, it was very far away and I had a lot of work to carry for understanding the structures but at the end I couldnt manage to have the whole Code in the assembly, so I decided to carry the work on the C language which is simpler and easier, and developing the assembly code still undergoing. Its just the deadline for handling the project which made it impossible to have it ready by that time.

I have carried the use for the assembly language in another module which was in the Embedded System, and I had worked in team with two other class mates to carry some tasks on the AGV (Derbot) Automatic Guided Vehicle. This module was very interesting and we did manage the work, even we got the fourth place in the competition. For this reason I chose my project to be on something like the Derbot design and implementation, in the Derbot we have used PIC16 and the structure for this family was easier than the structures in PIC18 family. This is why I finished the project on C language rather than the Assembly.

In the current time I cant tell that the project was succeeded by having all the structures for the assembly code, I have attached what I have started with in the appendices and over the period till handling the actual circuit and presenting the project I will try to finish the code in the assembly.

5.2 Conclusion

In conclusion, my design of car traction system tells how the use of the micro-controller used accurately to control any variation and possibility of non-stable system. The micro-controller will maintain the wheel rotation to the desired speed whenever one of the wheels slip a direct response will be applied to the other wheels to make sure that the vehicle wheels are moving in a same desired speed. The quick response for the wheels were by adjusting the PWM each time, in addition to that the accuracy for the encoders within the implementation control would help to get more accurate results.

This kind of project we can see it very clear with the vehicle industry and manufacturing is growing, all new cars has some kind of intelligence like the anti lock breaking system ABS, and ESC electronic stability control system.

5.3 Future work

In a future work, more effort needs to be taken to figure a new way, a new system which could be used within this field. The project so far has its objectives and been carried, what else is needed that more accuracy in the results needs to be met and a larger hardware needs to be implemented to carry the entire test and getting more accurate results.

References & Bibliography

References

[1] Han Way Huang, PIC Micro controller An Introduction to Software and Hardware Interfacing, Thomson Delmar Learning Publications, 2006.

[2] John Iovine, PIC Micro controller project book A true beginners guide to the popular PIC MCU, Mc Graw Hills Publications, 2007.

[3] PIC18f8720 Micro chip data sheet, Microchip co.

[4] Series 288 Rotary Encoder Technical datasheet, CTS co.

[5] HTTP Link: http://www.emicro.com Accessed 2010

[6] BD6210F datasheet H Bridge driver series for brush motors, ROHM co., 1998.

[7] Ramesh Gaonkar, Fundamental of Microcontrollers and Applications In Embedded Systems (with the PIC18 Microcontroller Family), Penram International Publishing (India) Pvt. Ltd., 2007.

[8] Barry Brey, Applying PIC18 microcontrollers: architecture, programming, and interfacing, Wiley Publications, 2007.

[9] Dogan Ibrahim, Advanced PIC microcontroller projects in C: from USB to RTOS with the PIC18F, Mc Graw Hills Publications, 2007.

[10] HTTP Link: http://scholar.lib.vt.edu/theses/available/etd-05182004-215925/unrestricted/Thesis2.pdf Accessed on 15th November 2009

[11] HTTP Link: http://instruct1.cit.cornell.edu/Courses/ee476/FinalProjects/s2009/atg23_rjm73/atg23_rjm73/Traction%20Control%20Andrew%20and%20Rob.htm Accessed on 4th October 2009

Bibliography

[1] Designing Embedded Systems with PIC Microcontrollers. Principles and Applications ( Tim Wilmshurst) 1st edition.

[2] Designing Embedded Systems with PIC Microcontrollers. Principles and Applications ( Tim Wilmshurst) 2nd edition.

Please be aware that the free essay that you were just reading was not written by us. This essay, and all of the others available to view on the website, were provided to us by students in exchange for services that we offer. This relationship helps our students to get an even better deal while also contributing to the biggest free essay resource in the UK!