I came to ARM as part of my young apprenticeship and I had little experience of embedded chips and no experience of programming them. On my first couple of days I was playing around with the compiler and the mbed making the LED’s light up. As I got the hang of programming I started to think of a project that I would like to do and that would be useful to me. So I started to think about hobbies I do and an idea jumped out at me. I could improve the technology on my nitro R/C car! I now had an object to improve but I had to think of what to add to it, so I came up with a list:
• Engine temperature
• Fuel level
• Range finder
• Engine stop
• An accelerometer
I chose the three that I wanted to do the most and I chose to measure the RPM to make the engine stop if the car flipped and because we needed to use an accelerometer for the engine stop I chose that as well. We also thought that because we have this data it should be saved to a flash drive. We thought because the accelerometer was the most important part we would start with that, we used the LIS302 because it all ready had a library for it and it was easy to use. I wired it up to a LCD display to check the readings where correct but it printed lots or random numbers. I tried to work out what was wrong but in the end I just rewired it up and it worked! I next went on to making a program to work out the RPM there were a couple of things we could have used but we decided to use a QRD1114.
The QRD1114 detects black and white and the voltage is different for each (black is 0-5v and white is 5v+). I had a problem trying to get it to work because I could get it to give readings but they were not right. So I did tests on it and found that the QRD1114 was a dud so as soon as I changed the component it started to work! The penultimate component that I needed to get working was the servo. All I needed to do for this was use the calibration program in the mbed cookbook. To make the engine shut off we needed to make an array so if the accelerometer read a certain value for 2 seconds or more then it would turn the servo 90°. The servo would be attached to a butterfly valve inside the exhaust of the car and when it was closed the car would stop.
The final thing that I had to do was to get the data to save to a USB memory stick. This was no problem because I only had to change a little bit of my program. So I had made all the programs that I needed all I had to do was put them together (easer said than done). I started by getting the accelerometer and the QRD1114 to save to the flash drive and then I wired up the servo and added the array. The main problems I had was getting pieces of the different program in the right places. I did not think that it mattered but apparently it did. One of the most frustrating things was that the program would run but it would not do what I wanted it to do so I had to go through my program to work out what was wrong.
When we did our first test run on the QRD1114 only read 0RPM all the time so we decided that it could not determine the white and black at 31,000RPM, but there was one upside everything else worked almost perfectly. We decided that the best thing to do was to change the QRD1114 to a photo-interrupter (the KTIR0611S) luckily it worked with the same program so we did not have to make any changes. So I had finished my program. The photo interrupter went on the rear axle as you can see below. We added a bigger grub screw to the axle so it would pass through the photo interrupter showing that it had completed one rotation.
We thought that that it would be a good idea if every time the program made a file it used the RTC as a base for the file name that meant that the data would not be over write and we would know exactly when the file was created (we used the website http://www.unixtimestamp.com/index.php to get the time for the RTC. That is why we have a coin cell in the circuit to power it all the time so it does not need to be set every timer the mbed it turned off.
This is my finished program and circuit!
(It’s a bit messy because it is only the prototype!)
This is just a little test I did using my hands to spin the wheel and to move the accelerometer.
I have now started making a PCB for my circuit. I have to make two PCBs because the light gate needs to be at the back of the car and the mbed with the other components, I am trying to make the boards as small as possible and I have managed to make the light gate board (KTIR0611S) 27mm x 19mm and the mbed board is 42mm x 79mm. I have been using the free version of eagle ( http://www.cadsoftusa.com/ ) and it has been easy and fun to use. On this soft ware there is a very useful feature called auto router and as you can probably gather it auto routes the signals but I did not use this feature because it was more useful for me to do it myself. The prototypes are going to be made at ARM so we can check that it all works properly and when we are happy that it does what it is meant to it will be sent off so a proper one will be made. The equipment that is used for making the PCBs at ARM is not very accurate so I had to make all the vias bigger than they would normally be. This is so the top and bottom layer of the controller PCB will line up and so it is easier to make because the two layers have to be lined up by eye! This means the prototypes will look slightly different to the final PCB but all the wiring will be the same it will just be a bit bigger. We have tried to make the PCBs at ARM and we managed to make the KTIR0611S PCB but for some reason we could not make the controller. We tried for about 2 hours to make the board but to no avail. What we might have to do is get both of them properly made so they can be tested. I have soldered up the KTIR0611S PCB and tested it, good news it works better than the original :) The only change I made was that I removed the LED and changed the resistor to a 4k7.
These are my two boards and schematics (you will need to have eagle to see these)
(This one is just images of them so you can open it without eagle)
So I finally have my two PCBs and they look really good. I have soldered up the KTIR0611S PCB and the readings are the best I have ever had. The controller I have had some problems with as the accelerometers pins are slightly too big for the holes and i am trying to work out how to get the USB connector to lie flat.
I have now finished soldering both PCBs and I have attached them too! All the components work exactly how I need them to and I am going to run the car tomorrow to hopefully collect some data. The only part that is not connected up fully is the servo to the butterfly valve as I need to make a bracket for it and I can’t do that at ARM.
This the parts list for my project:
|Part||Description||Place of purchase|
|KTIR0611S Photo interrupter||single transistor output slotted photo interrupter featuring an aperture comprising an infra-red emitter and sensor housed in a black polycarbonate body. Available with 3 x 6mm or 5 x 7mm slot||http://www.rapidonline.com/Electronic-Components/Optoelectronics/Photodetectors/Transistor-Darlington-photo-interrupter/68054/kw/KTIR0611S|
|A mbed||you all know what the mbed is||http://mbed.org/order/|
|A USB socket||a USB socket that will attach to the PCB under the mbed so the data collected and be saved to a flash drive. i have used the coolcomponents USB board so the socket lies flat saving space and letting the mbed go on top of it||http://www.coolcomponents.co.uk/catalog/product_info.php?products_id=556|
|A voltage regulator||this is to change the 6v from the battery pack to 5v for the USB||http://uk.farnell.com/texas-instruments/lm317lilp/ic-adj-linear-reg-1-2v-to-32v-to/dp/1534499|
|A simple switch||a two way switch to start and stop data logging||http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=0334101|
|A LIS302 Accelerometer||An LIS302 is a 3-axis accelerometer, accessible via a digital SPI interface with a selectable range of 2g or 8g.||http://www.sparkfun.com/commerce/product_info.php?products_id=8658|
|A 6v battery pack||you can use 4 1.5v batteries (4xAA). This is power is used to power the mbed, the servo and the USB socket. You can run everything from your car but you will get a lot of noise so you will need to add some capacitors to the circuit||http://www.rapidonline.com/Electrical-Power/Batteries/Boxes-Holders/AA-Battery-holders/71696/kw/18-3687?source=googleps&utm_source=googleps|
|A 3v coin cell + holder||this battery is used to power the RTC||battery: http://www.sparkfun.com/commerce/product_info.php?products_id=338 holder:http://www.rapidonline.com/Electrical-Power/Batteries/Boxes-Holders/Coin-cell-holders-Keystone/71110/kw/18-3627?source=googleps&utm_source=googleps|
|A servo||the servo is used to turn the ball/butterfly valve. You can use almost any servo as long as it will be able to turn the valve remember that there will be a lot of pressure from the engine. I used the SRM-102 from sanwa but I’m sure there is a better one for the job||http://www.moormodels.co.uk/acatalog/SANWA_SERVOS.html|
|A ball or a butterfly valve||this is used to turn off the engine. I tried to make one but I was very had to make a complete seal so I ended up buying one. The problem with this is that the hole is restricted a lot even when there valve is open so you do lose power! So I am having a look to see what else I can do if anyone has any ideas they would be welcomed.||http://www.screwfix.com/search.do;jsessionid=3G4M044AXHU3ACSTHZOSFFY?_dyncharset=UTF-8&fh_search=89226&searchbutton.x=12&searchbutton.y=4 (I then had to machine it in the lathe to make it fit into the silicon adapter)|
|This is not too important but it could be handy to have: a silicon adapter||This is the part where you put the valve inside and because you have to cut this seal you might want another one or two just in case you get it wrong. (I’m speaking from experience)||http://www.fusionhobbies.com/ProductDetails.asp?ProductCode=AR201000002&click=2|
|Pin headers (male/male)||I used them to connect the USB socket to the PCB||http://www.coolcomponents.co.uk/catalog/product_info.php?products_id=241|
|Pin headers (female/male)||these are used to raise the mbed off the PCB to save space as you can put components under the mbed||http://www.coolcomponents.co.uk/catalog/product_info.php?products_id=377|