This project is part of an assignment for my embedded systems class, and involves two classmates. In this post I’ll give a basic outline of our goals and post some block diagrams and datasheets for posterity. Basically, the goal is to build a vehicle that can follow another vehicle autonomously, and all the main components are shown above.
We are using the PIC18 development board offered by Microchip (far left) The package cost about $250 and has functionality beyond what I’d ever need. In a nutshell it is helpful in the design and debugging stage of embedded systems. The 8-bit chip we are using to implement the system is the PIC18F46K22. Our goal is to use this microcontroller to control the speed of a small vehicle to match that of a lead vehicle. We have three main peripherals to achieve this (from left to right): an ultrasonic distance sensor , a motor controller , and a robot car.
Because our course focuses on assembly coding, this is the language of choice for the project. All three of us will be writing code for different sections of the project. It divided up pretty neatly: I am focused on the distance sensor and the analog-to-digital conversion (ADC) of the sensor by the microcontroller (MCU). The two other main sections are: 1. devising an algorithm or control scheme to convert the distance value to an appropriate motor control signal, 2. configuring and implementing the PWM scheme to send to the motor controller.
Hopefully our lead car will respond quickly to speed changes in the lead vehicle. It the lead car speeds up, the trailer car will speed up; if it brakes so will the trailer. In fact we will use a set-point distance that the motor control unit will seek to maintain. Here is the block diagram that we put together. While it may not mean too much to you if you don’t know assembly, here is a rough draft of the code that I put together for the distance sensor.
At this moment I haven’t been able to get the distance sensor to properly communicate with the MCU. I know the sensor produces the correct analog voltage for the distance between it and an object. I know that the ADC will covert an analog value to a correct digital one. However I’m having trouble configuring the MCU pins to receive the distance signal. How many hours I’ve poured into this one, will not be revealed…