Get Latest Electronics / Electrical Projects directly to your Email ID


Computer Controlled Vehicle (ECE/Mechanical Project)

Introduction:

Imagine using your computer for more than just word processing and games. Just around the corner is the technology that will allow us to step outside of the computer and use it to control the outside world. We will be able to control anything and everything from coffee makers to light switches while being miles away from either. We will incorporate this idea into the control of a remote control car.

The two major parts to the project is the computer software and the car hardware. The software consists of receiving input from the keyboard, decoding the input, updating the screen and outputing the data over the serial port to the transmitter. The graphical portion of the project consists of a picture of an object (the car) drawn to the screen that is used to represent the different movements of the car.

For example, when the car has be instructed to move forward by pressing a specific key on the keyboard, the car on the screen will move forward. When the car has been instructed to turn right, the car on the screen turns right. The hardware transmits the data to the car, which inturn decodes the data through the microcontroller. The microcontroller will then output the data to its own port to control the light, horn and motor speeds.

Main Program:

The program starts out at the main menu. The options will be to view the instructions, credits, drive the car or to quit the program. The instructions will give the basics on how to control the car and which keys will do what. The credits will list those that have contributed to the project and what their contribution was.

These two selections will then direct the user back to the main menu. Selecting to drive the car will bring up the basic control screen. The control screen will consist of an inside view of the car consisting of the dashboard and steering wheel. Indicator lights will light up when moving, turning on the lights, and the horn. Hopefully with enough time all of these functions will work.

Also on screen will be what we hope will be an indication of movement with scrolling lines on the ground. The lines will scroll by using a refrence line, a differnetial spacing and a regular spacing. The differential spacing is the spacing between the refrence line and the first displayed line.

The regular spacing is the spacing between the first drawn line and everyother line. When the lines are needed to be scrolled down, indicating forward motion, the differential spacing can be decreased, which will move all of the lines down, since they are refrenced from the same line. When the car turns the lines will tilt, which is done by incrementing or decrementing the y-coordinates of the refrence line.

This introduces new problems when the lines have points outside of the screen. To fix this, a fix point function is needed to move the points back on the screen. By keeping the slope of the old line and the new line equal, the difference between the new x coordinates can be calucalted with a simple multiply and divide.

The software will also control the lights and horn. The lights were designed like the headlights of the car, where you push the light button once to turn the car on and then again to turn them off. The horn will sound while the key is pressed.

After the software has taken the inputs from the keyboard, it will then output the data through the serial port to the microcontrller on the car. The hardware will then take the data byte and use it to control the various parts of the car.

Hardware:

The Hardware portion of this project involved establishing a Radio Frequency connection between a PC and a radio-controlled car. The purpose of this interface between the two is to allow the PC, to be able to control the car using various directional keys and features key on the keyboard.

A main step was to establish a noise-free radio connection cable of receiving and transmitted at a distance of at least 15 meters. Specifically, this task required building a transmitter/receiver circuit to transmit and receive the signal. An important consideration that was necessary was for me to use a distinct transmission frequency, distinct from common frequencies that were present in the building. See the diagram of the transmitter receiver circuit.

Once the transmitter receiver circuit was built, the next step was to wire up the car. There were various parts needed and used to accomplish this task. Some parts included: 5 WLight bulbs(headlights), piezo buzzer (horn ), microcontroller (car’s brain), hex inverter, 0-5V rectifier, antenna, npn transistors, 12V regulator, 555 timer, etc.

The car was wire up were four pins operated the four different speeds of each motor; one pin was the direction pin for each motor (total of 2 motors), and finally a ground pin. To accommodate an eight bit data transfer, I use only: Two directional pins (one for each of the motors); a horn pin, a lights pin, and finally 2 speed pins (for each motor).

The final task involved programming the microcontroller to perform several of the serial tasks needed to receive data from the transmitting PC, and processing that data to produce car movement. A list of code used to program the microcontroller can be found here.

Software:

Data Structures and Variables:
MenuPCX    db ‘MENU.PCX’, 0  ; Variable name of the Menu PCX
creditPCX  db ‘CREDITS.PCX’, 0  ; Variable name of the Credits PCX
instructpcx db ‘INSTRUCT.PCX’, 0  ; Variable name of the Instructions PCX
forePCX  db ‘FORE.PCX’,0   ; Variable name of the Foregoround PCX
SpritePCX db ‘SPRITE.PCX’,0  ; Variable name of the Sprites PCX
Old_TimerVector dd ?   ; Remember the timer vector
Old_KBvector dd 0    ; Remember the keyboard interrupt
Timer_Flag       db 0    ; Set when 1/18 of a second has past
upkey_flag       db 0    ; The following flags correspond to key
downkey_flag     db 0    ;     presses
rightkey_flag    db 0
leftkey_flag     db 0
exitkey_flag     db 0
menu_flag        db 0
pkey_flag        db 0
ckey_flag        db 0
ikey_flag        db 0
nodraw_flag      db 0
lkey_flag        db 0
tparts  db 1
x1      dw 0     ; Starting and end (x,y) coordinates for
x2      dw 0     ;    drawline
y1      dw 0
y2      dw 0
dify    dw 0
difx    dw 0
y_inc   dw 0
x_inc   dw 0
error   dw 0
right   dw 319
bottom  dw 199
xstart1 dw xscreenmin   ; (x,y) coordinates of reference line
ystart1 dw ystart_in
xstart2 dw xscreenmax
ystart2 dw ystart_in
spacing dw space_in    ; Spacing between scrolling lines
diff_space  dw 0   ; Differential spacing between first and refrence

Sprite_temp dw 0
Move      Sprite<0,0,233,177,16,16>  ; Sprite data for the move light
Stop      Sprite<17,0,232,178,16,16>  ; Sprite data for the stop light
Light_on  Sprite<50,0,249,178,16,16> ; Indicator of lights on
Horn_on   SPrite<33,0,266,178,16,16> ; Indicator for horn on

Procedures:

Copy_Sprite:
Written by: Brad Stoor
Purpose:  This procedure is the same as for mp4, copies sprite to location
Inputs: DX = sprite data structure
Outputs:  To screen

Load_ForeGround:
Wirtten by: Brad Stoor
Purpose: To load the Foreground and Sprite PCX into the segments
Inputs: None
Outputs: Updates the Fore and Sprite segments with uncompressed PCX

Copy_ForeGround:
Written by: Brad Stoor
Purpose: to copy the forground into the Videobuffer as an overlay over the scrolling lines
Inputs: None
Outputs: Updates the VideoBuffer with the foreground in place.

Load_PCX:
Written by: Brad Stoor
Purpose: Same as mp4. Loads a PCX file uncompresses it and stores it in a Segment
Inputs:  DX = offset of variable containg file name
ES = Segment to store file
FS = Segment for temporary storage of file
Outputs:  Updates the proper segment with file data

Display_PCX macro:
Written by: Brad Stoor
Purpose: Eases the displaying of a full screen pcx
Inputs:  The file name and the keyboard flag to be cleared
Outputs: PCX file is displayed on screeen

Display_Menu:
Written by: Brad Stoor
Purpose: Displays the menu and the appropriate files if credits or instrustions selected
Inputs: Waits for keyboard flags to be set by interrupt
Outputs: Different graphics to screen depending on selection

Draw_Line:
Written by: Brad Stoor
Purpose: To draw a line from one point to another
Inputs: (X1, Y1) to (X2, Y2)
Outputs: Updates the VidBuf with the line in place

Fix_Points:
Written by: Brad  Stoor
Purpose: To fix a point that is outside the maximum allowed window
Inputs: A set of coordianates (X1, Y1) and (x2, Y2)
Outputs: Changes points to have same slope if outside of window

Plot_Pixel:
Written by: Brad Stoor
Purpose: to take a set of coordinates and calculate the linear memory address
Inputs: BX = y coordinates
AX = x coordinate

CopySeg:
Written by: Brad Stoor
Purpose: to copy the VidBuf to the VIDSEG

Blackout:
Written by: Brad Stoor
Purpose: to reset the background to cover up the old lines

Scroll_lines:
Written by: Brad Stoor
Purpose: To calculate a set of lines spaced from the refrenced line
Inputs: two starting reference points

Red_light:
Written by: Brad Stoor
Purpose: To show the red stop light when there is no movement input

Lights:
Written by: Brad Stoor
Purpose: To set the light bit of the output to 1 and to show light indicator

Horn:
Written by: Brad Stoor
Purpose: To set the horn bit to 1 of the output byte and to display horn indicator

De/Install_Timer:
Written by: Brad Stoor
Purpose: To Install/Deinstall the timer interrupt

De/Install_Keyboard
Written by: Brad Stoor
Purpose: To Deinstall/Install the keyboard interrupt

Timer_Interrupt:
Written by: Brad Stoor
Purpose: To let the main program know when 1/18 of a second has passed
Outputs: Sets timer_flag at every call of interrupt

Keyboard_Interrupt:
Written by: Brad Stoor
Purpose: to handle the user inputs.  Sets flags according to keys pressed
Outputs: Sets the flags according to which key was pressed

Serial Communication Procedures

Initailize_port
Written by: Brad Stoor
Purpose: to set up the serial transfer register for appropriate stop and parity bits
Inputs: None
Outputs: Changes serial line control register

Output_Data:
Written by: Brad Stoor
Purpose: to output the initializing byte and then the data byte
Input: AL = byte to be outputted
Outputs: None

ComWrite:
Written by: Brad Stoor
Purpose: to write out one data byte
Input: AL = dbyte to be written to serial port
Output: none

ComBaud:
Written by: Brad Stoor
Purpose: to set the necessary baud rate of the port, synchronized with controller
Input: none
Output: Changes the serial reigsters for 2400 baud

ComGetLCR:
Written by: Brad Stoor
Purpose: to retrieve the old serial statues register
Inputs: None needed
Outputs: AX = status of register

ComSetLCR:
Written by: Brad Stoor
Purpose: to set the serial status register
Inputs: AL = new setting
Output: None

External procedures used:

From the 291 library:             dosxit

Serial proceudres based off of UCR standard library

Problem Description:

Some problems that we experienced came from the interface of the computer and microcontroller. The problem was left unsolved, but we believe that it stemmed from the signal noise and different serial transfer modes. The microcontroller was very touchy when it came with serial data settings. It would except some of them, but would mysteriously disallow others. If this problem was solved, we believe that the communication between the car and the computer would have been flawless

Conclusion:

With this project, we learned a lot about interfacing with hardware. We believed that it would be a simple task to get data out of the computer, but soon learned that it would be more difficult that it first seemed. If anyone believes that they want to do a hardware project, we would fully support the decision. We learned valuable lessons about the different specifications of the computer’s hardware, that will enable us to have a higher sucess rate in the future. The only savior is that we know for a fact that the software works perfectly.

Although we did not reach our goal of controlling the outside world, we learned alot of issues with our journey. Our program may not have followed the norm of designing a game for out project, our ingenuity in a creative project proved more valuable to ourselves than we could ever imagine.
Authors: Shola Ward – Hardware design, Brad Stoor – Software design
Source: University of Illinois

Subscribe for Electronics / Electrical Project Downloads (Free):

Enter your email address:  

2 comments on “Computer Controlled Vehicle (ECE/Mechanical Project)

  1. Devidas Pamane said:

    Dear Sir / Mam

    I very impressed, i would like to try this project my self.
    Ca I get the full working source code the software & desing of the car?

    Thanks & Regards

  2. Rivas said:

    want a full working source code??? thats not trying urself….hahaha….jus kiddin ;)…

Discuss this Project:

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>