Tuesday, November 29, 2011

Part 4b - The Hardware parts continued

The ShiftBrite LED

Implementing the Shiftbrite with the Arduino wasn't that difficult. I thought there would be a lot of software involved, but the Arduino recommended a open source library to use to make things considerably easier. The library was called 'HughesyShiftbrite', I got the link from the Arduino website and downloaded it off code.google.

Shiftbrite connected to Arduino
For this particular project I wanted it to act as a warning light, so although it can be used for a lot of different things, I was just using it on a basic level.
Connecting to the Arduino involved 6 pins. The Vcc, Gnd and 4 other pins to control the Shiftbrite. You can declare these pins as a variable using the software library. In my case I used the following; sb = HughesyShiftBrite(5,4,3,2). This declared that the numbered pins are connected to the Data I, Latch I, Enable I and Clock I pins on the Shiftbrite respectively. The remaining pins on the Shiftbrite aren't used in this project.

Different angle capturing the shiftbrite
The Shiftbrite LED works using 3 colours, red, green and blue. Each colour have 10 bits each so that's 1024 different combinations on each colour. Combining the 3 colours gives over a billion different combinations, I'll be using 3. Red, green and orange. Setting the colours are easy enough using a function from the library. An example of this would be sb.sendColour(1023,0,0); where sb is just the variable I called the actual shiftbrite, and the function sendColour sets the red colour value at 1023 and the green and blue values at 0, making the shiftbrite emit a red light.

I used simple if statements to determine the colour of the shiftbrite depending on the distance of the obstruction determined from the Ultrasonic sensor. Green for safe, orange for warning and red for stop. It's very simple, I know, but it will work in my system.

Part 4a - The Hardware Parts

I have received the parts ordered for the first stage of my project, the Arduino board, LCD unit, Ultrasonic range finder and the Shiftbrite LED. I have been running tests with the Arduino and these parts to learn how to implement them into my project.

The Arduino Uno
I ran some simple tests on the Arduino to begin with, just to gain some experience building on the board and understanding the software. Arduino software code is called a sketch. It runs off a setup and a loop function that have to be there and any other functions you add, providing they work! The Arduino software provides a IDE(Integrated development Environment) to develop an run these sketches.

But first I had to install the Arduino onto the PC. This just involved downloading directly from the Arduino website. The only glitch was I had to install the driver software manually. This just involved going into the security file and device manager and update the driver software. Once that was up and running, you simply initialised the Arduino program, chose the board you were using from the drop down menu, the Arduino Uno, and selected the correct serial port.

First test I simulated was a simple blinking light using a LED. I expanded this using other LEDs to simulate traffic lights and a night rider simulation. I then introduced a tactile switch to use as a button to control a LED. I also used a potentiometer to adjust the brightness of a LED. These were all basic test that can be found on the Arduino website. Once I had a grasp of the board I moved on to the Ultrasonic.

The Ultrasonic Sensor

I had a fair understanding of the Ultrasonic sensor and had even tried to start writing the code before I had the part, so it wasn't long before I was able to use this.

Connecting the Arduino to the Sensor involved only 3 pins. Vcc, Gnd and a pin to control the sensor, I used pin 13. Basically, I initially used the pin as an output to make the sensor send out a pulse for 10ms then stop. I then changed the pin to an input to wait for the Sensors reply.
The sensor sends this pulse then waits for it to be reflected off the nearest obstruction and return. When the signals echo is returned, the Sensor sends this information back to the pin on the Arduino. The Arduino times the amount of time it takes for the signal to return. Then using the following calculation, I was able to determine the distance the obstruction was from the sensor.


Formula calculating time for 1cm
I did this using the pulseIn function on the Arduino software, the Arduino calculates the amount of time it takes in microseconds. The speed of sound through air is 340.29 meters per second. Based on all this, I was able to calculate the distance in cm by calculating the time it takes to travel 1 cm which is 29.386us. I divide this time by 2 because the distance it to and back from the obstruction. However long it took was divided by 14.693us giving me the distance.

 I was able to display these results on the serial monitor of the Arduino's IDE. I then added LEDs into this design to simulate some kind of warning system. As the obstruction moved closer, the green LED was for okay, orange for warning and red for collision inevitable for simulation purposes.

Arduino including the Sensor


Serial Monitor distance display



Ultrasonic Sensor


Next up, was the Shiftbrite and LCD unit.

Tuesday, November 22, 2011

Part 3c-The LCD unit

LCD unit
The last component of the first stage of my project is the LCD unit. This display unit will be used to display the distance the obstruction is from the moving vehicle. The part I will be using is a Serial Enabled 16x2 LCD.

The reason I chose this is because it has a serial input facility. It will enable me to use less connections to the Arduino. Unfortunately,using less pins does not make it any easier to use the LCD. There are a couple of library for the serial LCD and parallel LCD with the Arduino and to be honest, the parallel one is a lot easier to follow and understand. Researching the libraries, there seems to be a lot more software involved running the serial. If I can't get the serial working properly I can always revert back to the parallel. This product allows me to do both.

The data sheet on this LCD contains alot of addresses and commands to control it. For example, the back light brightness, clear display, scroll, cursor positions etc. These are controlled using different values like 0x01, 0x0C etc, and will have to be implemented into my software as needed.

When I get this piece of hardware, I plan to run small sample test to learn to understand it and how it works before I start implementing my own code.

Part 3b-The Shiftbrite LED

The next part I'll look at is the Shiftbrite LED. This will act as a warning light system as an object gets too close to the vehicle. Shiftbrite is a high-brightness LED module containing red, green, and blue elements. It uses a simple clocked serial interface to receive a 10-bit brightness value for each colour. That's over a billion possible colours. I'm thinking along the lines of using green as safe, blue as an initial warning and red as a collision is imminent. But I might change this as I go along.

Illustrated picture of aShiftbrite
These warning lights will co-exist with the distance the object is away. Green for greater than 2 meters, Blue for 20cm-2 meters, and Red for less than 20cm. These values may also be changed as I test the board. This is a limited use for the Shiftbrite, but it will suit my project. As I've researched it further, there are many applications for the use of these lights. The main selling point being that you can link several of these devices together. Each input to one Shiftbrite is buffered and can pass the signal to the next Shiftbrite. They also contain safety features including current control and automatic over-temperature control to prevent overheating.


The recommended supply voltage for these devices are between  5.5 to 9V. But because I'm only using just the one, the 5V supply from the Arduino board will suffice. This 5V should be sufficient to run up to 3 of these devices linked. With that in mind, I might add some more to the project at a later date, if I have the time.

Wiring the device to the Arduino will require 6 pins. Two pins for the Vcc and Gnd that I will share with the other devices and 4 pins to control the Data, Latch, Enable and Clock pins on the Shiftbrite.

I've examined some other projects that have used the Shiftbrites to familiarise myself with the kind of software that I will need to implement to use them the way I want. I quickly realised that there is no Shiftbrite library in the Arduino libraries, so I've had to download one and save it into library. The only problem is that there is no real reference to the functions in this library. But there are plenty of samples available that I have examined, understand and can now use.

Part 3a-The Ultra Sonic Range Finder

One of the devices I'll be using is an Ultra Sonic Range finder. I've been learning how to implement this into my project. The device is a Sensor, that will emit a pulse. This pulse will bounce of the nearest object and return to the Sensor. The Sensor will time how long it takes the signal to return. From this I can calculate exactly how far away the object is from the sensor.
Ultrasonic Range Finder
The sensor I'll be using is the Maxbotix LV-EZ1. There are a lot of similar devices available. The reason I chose this one is because its cheap, accurate and easily available. It has a range of 0 to 6.45meter approximately. It can work of 5V directly from the Arduino board. It will only need 3 connections to the Arduino. This will free up the pins on the Arduino, allowing me to connect other devices. This will prove particularly useful when I'm experimenting and testing the device with the Arduino.

The pins connecting will be Vcc (5V), Gnd and a 3rd pin to send out the pulse and receive the signal. I have been examining and familiarising myself with the software needed to run this device.The Arduino software will send a pulse out through the pin, wait for the pulse signal to be returned, record the time and then send another pulse starting the process over again.

To calculate the distance from the object I will use the following formula:



The results of this formula will be displayed on the LCD unit. The range of distance will effect both the Shiftbrite LED and the buzzer.

Thursday, November 17, 2011

Part 2 - The Christmas Schedule

This project will be broken into 2 stages, so I've decided on what I hope to have achieved by the end of the first stage. The last lab date on the college calender is December 13th, so I'll aim to have the first stage complete by then, including a full report of what I have done and achieved up until that point.


Fig 1) Block diagram
My plan is to use one of the Arduino Uno boards in conjunction with the Ultra Sonic Sensor, the LCD unit and the Sparkbrite LED that will detect an object and measure and display the distance from that object. This will include fully working software and will be built on a breadboard for display purposes only. Once again I've drawn a simple block diagram to demonstrate this(Fig 1).
The parts to complete this stage have been ordered. I will continue with my research until these parts arrive.


Researching the Arduino Uno

What I've started to do is to break up the project into the individual devices and I am trying to learn how these work and how to implement them. My first port of call is obviously the Arduino Uno, after all, this will be the microcontroller running the show. Most of the basic information regarding the Arduino can be got from the arduino website (www.arduino.cc). Information including the memory, clock speed, the number of pins available and the recommended input voltage. This I took note off, as the recommendation in 7-12Volts, so there is enough power to run the other devices connected to in. But there is lots of information and arduino projects available on the web.

Arduino Uno board
The software used with the Arduino is C based so I already have a basic understanding of the software. There are however, an abundance of libraries and functions. Some of which I'll need to know and understand how to use for my project. For example there's a liquid crystal library with lots of functions I'll need for the LCD unit. Another function I've notices is the Pulse( ) function that will be useful for the ultrasonic sensor.
Each individual software program is called a sketch. Each sketch has a setup function and a loop function to run the program. These have to be included in the file. The setup is used to initialise pin modes or to begin serial. The loop is the main part of the program, which loops continuously allowing and program to change and respond to various interactions, inputs and outputs.
There are lots of beginner programs and demonstrations available on the arduino website that I've been running on a virtual breadboard to familiarise myself with the programming in preparation for the actual real board.
The next part of the project is to familiarise myself with the other components I will be using and learn to interface them with the Uno board.

Monday, November 14, 2011

Part 1- My initial project design

The first few weeks have been spent researching this project and coming up with a simple design that will hopefully enable me to build this collision detector. I've created a simple block diagram to aid me in this design.
This is my initial design. I haven't quiet yet decided on all the parts yet but I'll run through what I have so far and then go into more details as I develop the project.

The design is based on using two Arduino microcontroller systems and hardware that includes an ultrasonic sensor, a shiftbrite LED, a LCD display unit, a device to aid wireless communications between the two Arduino boards and a warning buzzer.

  • The Arduino Unos: These will be the microcontroller systems used. The Arduino boards are open source, very cheap and very popular. I will delve into greater detail as I research the boards more.
  • The Ultrasonic Range Sensor: This device will send out a pulse and detect the pulse being reflected back. This will detect the obstructions ahead.
  • A wireless communication device will be used to transmit between the two Arduino boards. I haven't completely decided what I'll be using. Initial thoughts were a transmittor and receiver, there is also a piece of hardware called 'Zigbee' which is popular with the Arduino boards. But I am leaning more towards some sort of Bluetooth device. I will make my decision on this at a later date.
  • LCD Display Unit: This will the display the distance the obstruction is to the vehicle.
  • The Shiftbrite LED: This will act as a warning light, changing colours as the obstruction gets closer.
  • Warning buzzer: If you haven't guessed, this will warn you as the obstruction gets closer with a serious of beeping noises. The closer the object is, the faster the frequency of the beeps.
As you can see, there aren't too many parts in the design. There will be however, lots of software involved trying to program all these devices to work in unity with the Arduino boards. My next step is to try and work out some kind of strategic plan so I can develop this board within the specific time I have been given. This project will be broken up into two. I have until Christmas to complete the first half. So I will just concentrate what I will need to do for then.



Wednesday, November 9, 2011

Microprocessor controlled car collision avoidance system

Welcome to my new blog. This blog will show the development and steps I will take to develop a Microprocessor Controlled Car Collision Avoidance System. The objective of this project is to design and build a microprocessor system that can detect, measure and display the distance a vehicle is from obstructions while the vehicle is moving.

My blog entries will indicate the progress I will make throughout this project as well as record any ideas or changes I make along the way. The very first step I will take will be to research this project for ideas and decide on what I'm going to build and how I'm going to do it.