Robotic Car Control System Engineering Essay

Published:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

This piece of work presents the use of robotic car control system applied in PIC18 microcontroller application to take a control over the wheels slip. Controlling the robot car at any desired slip has a direct relation to the amount of force that is applied to the driving wheels based on road surface conditions.


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.


Chapter 1


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. We would use a simple no slip algorithm for controlling the speeds of individual motors driving the wheels.


We will be using pure electrical way of preventing slipping. We 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.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 (?).


Figure 1 : Traction-Slip/µ (?) curve for various road conditions, source [1]


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. We 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. We 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. We 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.


Chapter 2


2. Hardware Modules

In the following chapter, we will 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.1 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. 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 [4].


Figure 2: Truth Table of the Rotary Encoder (taken from [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.2 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 witch's 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. We use H Bridge to control the voltage applied to the motor. 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.


2.3 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 we 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].


Figure 3 gives the internal circuit diagram of the H bridge module BD6210F, which we are using in the project.

Figure 3: H Bridge chip BD6210F block diagram (taken from BD6210F datasheet)


2.4 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:

  • LP Low-power crystal
  • XT Crystal / Resonator
  • HS High Speed Crystal / Resonator
  • HS + PLL High Speed Crystal / Resonator with PLL enabled
  • RC External Resistor / Capacitor
  • RCIO External Resistor / Capacitor with I / O pin enabled
  • EC External Clock
  • 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.


Figure 4: Crystal / Ceramic Resonator operation HS configuration (adapted from [3])


  • The capacitors we use are C1 = 10 - 22 pF and C2 = 10 - 22 pF.

  • Resonator used is 16 MHz resonator with a tolerance of +/- 0.5 %.

Chapter 3


3. PWM peripheral in PIC micro-controller

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.


Figure 5: PWM timing diagram (adapted from [5])


We use 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.


Figure 6: Simplified PWM block diagram (adapted from [3])

Figure 7: Typical CCP PWM output (adapted from [3])


3.1 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.2 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].


Following equation can be used to find the duty cycle [3].


3.3 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.4 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:

    • Clearing the TMR2IF interrupt flag of the PIr1 register.

    • Setting the Timer2 prescale value by loading the T2CKPS bits of the T2CON register.

    • Enabling Timer2 by setting the TMR2ON bit of the T2CON register.

  • After a new PWM cycle has started, enable PWM output.

3.5 PWM (Enhanced Mode)

In Enhanced PWM mode [3], we can get PWM signal on upto four different output pins. We 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.


Figure 8: Simplified block diagram of Enhanced PWM mode (adapted from [3])


3.6 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.

Simplified schematic of a generic I/O port and its operation is shown in Figure 9.


Figure 9: Simplified schematic of PORT, LAT and TRIS operation (adapted from [3])


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 we read the PORTA register, we actually read the status of the pins. Writing to PORTA actually writes to the port latch.


Chapter 5


5. Software Modules


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]):

  • void ClosePWMx(void); // Disable PWM channel x

  • void OpenPWM x(char period); // Configure PWM channel x

  • 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. We 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:

  • Configure pins RA0, RA1, RA2 and RA6 for inputs from the rotary encoder. We do this by writing a 1 to the respective TRIS bits.

  • Start PWM from CCP1, CCP2, CCP3 and CCP4 pins with some initial duty cycle.

  • Start timer 0.

  • Measure time between pulses from each of the rotary encoders.

  • 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.

  • 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

Figure 10 gives the final schematic of the traction system and Figure 10 shows the pin diagram of the PIC microcontroller.


Figure 10: Circuit Diagram showing the connections to be made with the micro controller


Following points should be noted about the above circuit diagram:

  • We 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 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 our 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 our hand to slow it down. The result is all the other wheels also slow down.

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

Writing Services

Essay Writing
Service

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing
Service

Reports for any audience. Perfectly structured, professionally written, and tailored to suit your exact requirements.

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision
Service

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.