MAGracing Forum

Share your MAGracing with the rest of the world, get inspired and enjoy
It is currently Tue 16. Oct 2018 08:03

All times are UTC




Post new topic Reply to topic  [ 41 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
 Post subject: Home-built lap counter
PostPosted: Sun 8. Jun 2014 19:52 
Offline

Joined: Sat 26. Apr 2014 00:16
Posts: 30
Since I started doing magracing I've been thinking about options for building a lap counter. I know that there are commercial solutions, but the $300 or so it would cost me to buy one of those is quite simply too expensive for me.

Today I made a really big breakthrough with the assistance of a friend: we now have a working prototype of a lapcounter that can sense the car ID from the ID LED at the bottom of the car and it can interface with a computer so basically things work.

The best part is that so far it seems like the component cost of a full system with IR sensors and so on will be around €20 as it pretty much only consists of an Arduino board, a few IR phototransistors, a few resistors and some wire.

I need to do a few more tweaks and build some usable software for actually showing lap counts, racing times and so on. When it's in a more finished state I'll draw up diagrams, clean up the software and so on so others can use it.

Within a few days I'll post a video of the working system, but for now I just wanted to share the good news :)


Top
 Profile  
 
PostPosted: Mon 9. Jun 2014 02:06 
Offline
User avatar

Joined: Fri 21. Dec 2012 21:47
Posts: 107
Location: Washougal, WA.
Good news is indeed a understatement. Very exciting to say the least. Can't wait for the next update you post. Keep up the good work.


Top
 Profile  
 
PostPosted: Sun 15. Jun 2014 17:54 
Offline

Joined: Sat 26. Apr 2014 00:16
Posts: 30
Okay, it took a little more than a few days because I got sidetracked by work :)



It's probably not possible to actually see anything useful in the video except some numbers on a screen. However, those numbers do match the r/c channel chosen on the two cars you can see.

Since then I have worked a bit on optimising and cleaning up the software for the arduino so it now runs quite nicely. The system consistently recognises all 16 car IDs (0-15) and supports 8 sensors on one arduino. Since I don't have 8 sensors I have only tested with two at a time, but they work as they should.

After a lot of work on the code it seems like the only real problem left is how to handle cars that don't go exactly straight when they pass the sensor. The "sight" of the IR sensor is fairly narrow so the LED has to pass almost directly over it or else the car will not be recognised. It should be possible to lower the risk of that happening by using more than one IR sensor in parallel to give a wider field of view. I'll experiment some more with that when I start working this system into a real track and not just my test track.

If someone wants schematics and the arduino code please let me know. So far the schematics only exist as scribbles on paper, but if someone want to build their own I'll make some prettier versions and post them here.


Top
 Profile  
 
PostPosted: Mon 16. Jun 2014 14:27 
Offline
Administrator
User avatar

Joined: Thu 13. Dec 2012 19:06
Posts: 396
Location: Copenhagen, Denmark
when we made our lapcounter, we had problems with cars i high speed and several cars after each other in both lanes, the data was coming to close to each other.
you must try that, and what happens if both cars passed the sensor at the same time?
or 16 cars after each other at full speed?

Yes best place for the sensor if at the end of a long straight section, but here there is normally high speed.
if you wait to the braking section you will have some cars going sideways.

we look forward to here news from your project, and you are very welcome to put the codes and parts no. on this forum.

_________________
/Keld


Top
 Profile  
 
PostPosted: Mon 16. Jun 2014 18:18 
Offline

Joined: Sat 26. Apr 2014 00:16
Posts: 30
Hi Keld,

Thanks for the feedback. You are absolutely right: cars going at high speed may be a challenge. Since I haven't built a sensor into anything resembling a real track that is something that may require a little tweaking.

However, I did run some numbers on this with regards to car speed, how long it takes to recognise a car, the field of view of the sensor and so on. The only thing I haven't properly measured (because it's a real pain to do so!) is the phototransistors field of view.

The absolute worst case is that the FOV is 0 degrees, i.e. that the sensor only sees straight up (and that the IR LED only lights straight down). In this case, with one IR phototransistor per sensor, cars can only go at around 1m/s = 3.6km/h (~0.4"/s = 2.2mph), but my estimate of the phototransistor's effective FOV is far better than that, so it's more likely 2m/s.

However, that still might not be enough which is where a brilliant friend of mine comes in handy. He's helped me with the electronics and he pointed out that there's nothing wrong with placing several IR phototransistors in parallel in the same sensor. This greatly increases not only the speed at which cars can travel but will also make it possible to better handle fish tailing and so on. As the IR phototransistors are passive it really is that simple, as can be seen in the diagram below.

This means that it's a very flexible setup in the sense that track builders can decide which setup works best for each part of the track, a full cluster for sector timing in the middle of a turn, 3-4 in a row at the end of a long straight and so on. And the good news is that no matter how many IR phototransistors you add it still only counts as one sensor as far as the Arduino is concerned.

With regards to not being able to detect several cars in a row that strikes me as really, really odd. The longest it will take to identify a car is 4ms, but let's call it 6ms to make a conservative estimate and because I require a period of "black-out" between cars. Given that the length of the cars is 12cm that means that cars would have to travel at, erm, around 20m/s (~ 66'/s, yes feet per second) or so before the car drives a full car length in less time than it takes the LED to blink the car's ID. And while the cars are speedy little buggers, I really don't think they can drive 72km/h (~ 45mph). At least not without us facing a whole slew of other practical problems with track building :)

Anyway, please find the diagram below. The parts list is fairly simple:
  • a few resistors (27k Ohm and 10k Ohm). Price: ~ nothing.
  • one PNP transistor (BC547). Price: ~ nothing.
  • the IR phototransistors (the ones I used were marked with "940nm ( 840nm~1100nm )" as the active range). Price: ~ 0.2GBP each.
  • wires, connectors, board for mounting components (PCB, breadboard or whatever), housing and so on to your liking. Price: varies, but should be well below 5GBP.
  • one Arduino board. I used the Arduino Leonardo R3, but other boards should be usable without any significant changes to anything. Price: ~10-12GBP.
Attachment:
File comment: IR sensor diagram.
IR sensor.png
IR sensor.png [ 3.88 KiB | Viewed 5907 times ]


One important note about the diagram: I've used normal transistor symbols for the IR phototransistors since the program I used to draw it with didn't have the proper symbols. In reality the IR phototransistors only have two connectors ("legs") so the dangling wire in the diagram is not there. I hope that doesn't cause too much confusion.

Please also note that while I have three IR phototransistors in the diagram it is, as mentioned above, possible to attach as many as you'd like.

My sensor setup currently still only lives on a bread board, but I will make a more permanent solution Soon(tm) and post pictures of that as well.
Attachment:
File comment: Close-up of my test setup.
sensor setup.jpg
sensor setup.jpg [ 173.24 KiB | Viewed 5907 times ]


And what about the Arduino code?
Well, it should be attached in a zip file, but I really don't want to go into details about it as I've rambled on for far too long already :)

I have added comment to the source code so it should be fairly readable, and it's also incredibly simple once you get down to it, so it should be usable as-is: upload it to an Arduino, attach the sensors (and +5V and GND) and see what happens :)

As always: questions, comments, criticism and so on are more than welcome!


Attachments:
File comment: Arduino code.
LapCounter.zip [3.95 KiB]
Downloaded 381 times
Top
 Profile  
 
PostPosted: Mon 16. Jun 2014 20:28 
Offline
Administrator
User avatar

Joined: Thu 13. Dec 2012 19:06
Posts: 396
Location: Copenhagen, Denmark
I think you are really helpfull to other magdrivers doing this. thanks.


what i mean was that the board we used was having trouble rading from 2 or 3 lanes at the same time if cars coming over straight after each other.

We had that problem ealier, my friend who make the lapcounter fix it, I don't know how he fixed it but he did, I am not making this lapcounter my self, my brain ain't sharp enough :idea: but I can paint a car :yes

hope someone else try this and come back with more feedback, great to hear about this.

_________________
/Keld


Top
 Profile  
 
PostPosted: Mon 16. Jun 2014 20:44 
Offline

Joined: Sat 26. Apr 2014 00:16
Posts: 30
Keld wrote:
I think you are really helpfull to other magdrivers doing this. thanks.


No worries! I've had a lot of help reading other people's posts about their experiences so giving something back just seems like the natural thing to do. Besides, it's just so much fun to work with these things :)

Keld wrote:
what i mean was that the board we used was having trouble rading from 2 or 3 lanes at the same time if cars coming over straight after each other.


Ah, sorry about not catching that part :)

For this to be a problem the cars would have to pass the sensors within a few milliseconds of eachother. And even then I don't think it's a problem. A huge advantage with the arduino is that it runs at 16MHz so it's actually very powerful.

Keld wrote:
but I can paint a car


And you're good at it - unlike me :)


Top
 Profile  
 
PostPosted: Mon 16. Jun 2014 22:56 
Offline
User avatar

Joined: Fri 21. Dec 2012 21:47
Posts: 107
Location: Washougal, WA.
Looking very good. Ordered my parts today...


Top
 Profile  
 
PostPosted: Tue 17. Jun 2014 03:27 
Offline

Joined: Sat 26. Apr 2014 00:16
Posts: 30
Joel, LeNoir wrote:
Looking very good. Ordered my parts today...


That sounds great. I will put together a simple program to show lap counts and times and post it here :)


Top
 Profile  
 
PostPosted: Wed 18. Jun 2014 06:47 
Offline
Administrator
User avatar

Joined: Thu 13. Dec 2012 19:06
Posts: 396
Location: Copenhagen, Denmark
steellynx wrote:

Keld wrote:
what i mean was that the board we used was having trouble rading from 2 or 3 lanes at the same time if cars coming over straight after each other.


Ah, sorry about not catching that part :)

For this to be a problem the cars would have to pass the sensors within a few milliseconds of eachother. And even then I don't think it's a problem. A huge advantage with the arduino is that it runs at 16MHz so it's actually very powerful.



You did, I think the problem was that our sensors was connected to the same entrance, that means that 2 cars in 2 lanes gave signal at the same time, and then the pc didn't understand it.
But it is fixed now i know.

_________________
/Keld


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 41 posts ]  Go to page 1, 2, 3, 4, 5  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group