Giter Club home page Giter Club logo

gocarttimer's Introduction

GoCartTimer - measuring lap times for gocart(racing cars)

This is one of my older projects which I developed originally in year 2003-2004. As I know it's still used by a customer. It is completely written in AVR assembler and uses well what the MCU offers. It has detection of low battery status, also uses very well MCU sleep mode, to minimize the battery consumption. The project uses IR LED to transfer signals and it was used on a track which was outside. Usually those devices are built in into the track and measuring times different way (there is a coil in the track and other one in the cars. In this case you don't need to change anything in the surface so it's very easy to deploy, no construction work needed. On the other side the solution with coil is more reliable and precise, in theory. In practice I didn't have problem with this, it was working without problem but you need to set it up correctly, so it needs a bit of testing as well and you need to put the static box in a part of a track where only one car can fit into the track at the same time.

The project is quite old so I am not sure if will have a complete documentation, but at least I found the source code. It has two parts:

  • base station (static box)
  • mobile station (mobile box)

base station

The base station should be mounted into the same position every time when you use it. On the track outside it's not always simple. You have to mount the base station in a position where it can pick up the signal only exactly at one position from the cars where the cars pass this position in the track. The bases station uses AT2313 MCU. I am sure today there are better version of this chip but that time this was good enough to use it. Today possibly there is a ATTiny2313 MCU which should be compatible with AT2313. The MCU pin count is 20. The clock source was a crystal with a frequency 3.6864 MHz, which is already good both for setting up a correct baud rate for serial port transfer and also for making the right frequency for the IR LED (which is still in the tolerance). The frequency in our case is 56kHz, earlier it was 38kHz - the same which is used in remote control for TV. With 56kHz the transfer might be a bit faster compared to 38kHz, which is quite important here. I used also a timer in MCU, just to counting time internally. The time is counted with a resolution of 5 ms. This is good enough for measuring a time for racing cars where usually should be enough two have on seconds counter two digits after the decimal point, which is a resolution of 10ms. I chose 5ms because this just fits nicely into the requirements and what the hardware offers. I can count 5ms units using a single byte, value 200 is 1s which fits into 8 bits (counted range is 0-199). Also you can make a transfer in 5ms. The static box is making a "broadcast to air" every 5ms, just to see if there is any mobile box in the area covered by the base station (the covered area is a cone from the bases station, depeding in the IR LEDs used, if I remember correctly it was about 36 degrees, definitely should be a narrow angle IR LED). If any mobile box will answer to this request the bases station will read the code, do some basic validation, if the code is validate and there is not error in the transmission the code with a time is sent out from the base station over the serial port. Also the right LED is switched on for a short time to indicate a successfull reading of the signal (very useful thing for debugging and during the setup and testing). I have 4 LEDs here because it was designed for 4 cars, although I could use more (in the communication protocol I designed up to 8 cars and it's easy to extend it more - to 16). You could use also more LEDs, there is enough outputs on MCU, then you will need to modify the source code - but I used 4 LEDs in our case (there was another LED - power ON indicator). The application in PC can read it from serial port, process it, count the times for each lap and print the data to paper later, also print who was the fastest, print fastest laps for each cars, etc. The serial cable can be long, in our case we used at least 20 meters. You need also a power cable to run this box as this is not running from battery. In theory, if you don't have electric power on the site you could run it also using a 12V car battery but still you will need a power for PC. OK, today it should be a problem, there are nice laptops available with a long battery times but bear in mind, this was in 2003, the technology was different compared to 2017. And still you will need to solve the power problem for the printer if you want to print out the results for customers (not just display for them on the laptop display). But usually power is not a problem, we have had also power on this site.

mobile station

The mobile part is even on a smaller MCU and it really uses all the features what is in MCU and what I needed for this project. There is not a lot of memory there, I think that time it was only 0.5kB Flash memory, today there is 1kB. There is only 32 bytes of RAM, which is completely in CPU registers. EEPROM size is 64 bytes. The used CPU is ATTiny12, it's not recommened now for new designs and there is possibly a good replacement for it in a new product line. The MCU has 8 pins, 2 of them are used for power, of course. So there are 6 left, initially I used 2 for crystal as a clock source, so there is only 4 left - which is what I needed. One pin was for a battery status, one for IR LED output, one for IR sensor input and one of red LED indicator. The crystal was later replaced (first disabled in the software, then also soldered out from the board) because it proved to be unreliable in a condition with a lot of mechanical resonations on the car. The clock source was replaced by internal RC oscilator which was fine. Still the precision was good enough (in the tolerance for 56kHz IR sensor) and on the mobile part I didn't need very precise frequency (like on a static part where there was a serial communication). The mobile station is not doing anything else, just mostly sleeping, waiting for a broadcast. When there is a broadcast, it will check the validity of broadcast pulse and then will reply with an own code (plus battery status) in a payload. During the communication NRZ (non return to zero) encoding is used just to protect the transfer more. The own code is stored currently in the EEPROM in this version of the software (in the earlier version I had just a different version of source code for each car but that was not the best option). It switches on a red LED for a short time (just to indicate the successfull transfer) then it goes back again to sleep mode. During startup the red LED is also switched on for a short time (just to see we powered up the device without problem and it's ready to go - sometimes you might have a problems with contacts on a battery or the battery might be discharged completely). The mobile part is powered by batteries, of course. On a gocart there is no power source (no alternator), except maybe something inside which makes a high voltage pulse for ignition but that was not usable as a power source. Because of this I used a design with batteries. The easiest available batteries in 2003 where the normal AA batteries, including the rechargable batteries. I designed to work it with NiCd recharable batteries, 4 of them should be in the pack so the nominal voltage was about 4.8V (that's close to 5V) which I think was used directly by the MCU without any stabilizer, etc. I made also a connector where you could charge the batteries inside the cars, without dismounting the box. It was just a normal 3.5mm jack connector and made also a charger part (which was just only a hardware). You could charge the batteries fully overnight or just do a short charging (usually if it said the battery was low you still had few days to operate it on batteries so that's was not critical, but still you could do maybe a 30 minutes of charging if the batteries were empty and use this for a whole day). Usually the mobile station was able to operate on NiCd batteries for about 1 month which was more, than necessary but the hardware was able to do it. The highest consumption on the board was not by MCU but the IR sensor used most of the power (over long time at least). The IR sensor used constantly about 0.5mA, at least this was measured on the amper meter. The MCU in power down mode used much less power compared to this (should be less than 1uA by the data sheet and that was just about right). When it was active, of course it used a bit more, also a highest power consumption was when the IR LED was on (I guess that went up to range of 20-100mA). But mostly the mobile station was in a lower power mode because you don't need to broadcast it more than 1-2 seconds per lap, each lap was 40-70 seconds so that's a lot of low power mode. There is also some consumption by the resistor divider for measuring the voltage by internal comparator but that was also less than 1uA.

Hardware, mounting

Both stations where mounted in the same type of a plastic box where I drilled some holes to make visibility for an IR LED and IR sensor. There was also a hole for 4LEDs + power LED for the base station and holes for power input (that was on both, on mobile station used of charging batteries). The plastic box had rails inside so I was able to fit the board into those rails without drilling any holes on the circuit board and fixing it complicated way in the box. There was also enugh room in the plastic box to put 4 AA batteries in the mobile part. I used the shorter dimension (of the rectangle shape) for mobile board (so there was also enough space for batteries), on the base board I used the longer dimension because I needed more space for MCU and other electronic parts (stabiliser, etc.) but on the other side I wasn't limited with a usage of batteries here. The mobile staion with a plastic box was mounted to cars using one screw, we mounted it on the back part of the seat in a best spot for IR transmitter. The base station was mounted to a metal holder with cable ties and that was put outside together (as the metal holder was heavy then usually didn't move. The metal holder was behing the tyres protection area (or inside the tyres) in a part of the track where there is not high probability to crash the car into the tyres. You have to use also just a right angles, to have communication exactly just in one place at the track and of course only a single car should pass in that spot so the track should be narrow there. In terms of the IR range it was quite good. We tested also the maximum distance between the stations and it was able to transfer data on a distance about 10 meters on a sunlight, which is pretty impressing. At the evening (without direct sunlight) it was about 15 meters. I don't have the PCB yet in usable format but if I find a program where I can open it I will try to convert it into PDF format, then I can publish it as well.

Datasheets

http://www.atmel.com/Images/1006S.pdf - for ATTiny12 http://www.atmel.com/Images/Atmel-2543-AVR-ATtiny2313_Datasheet.pdf - for ATTiny2313 - I am not sure if this is compatible with an original AT2313 used in this project but I didn't see a different datasheet for this.

The software was AVR Studio 4 where I compiled, I believe there is a much newer version today and hopefully the source will work also with newer compilers. I uploaded also the binaries (hex file) but I am not sure if it will run without problems on the new versions of MCU. Anyway I don't think somebody will use it in a real life, that will be more interesting to see how some problems were solved on a MCU with very limited hardware resources.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.