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.
- IR sensor diagram.
- IR sensor.png (3.89 KiB) Viewed 32180 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.
- Close-up of my test setup.
- sensor setup.jpg (173.87 KiB) Viewed 32180 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!