Hello, I am working on a slot car timer. I have my prototype working with LDR, light sensitive resistors. I found out about photo diodes a little bit ago.
Which should I use?
Is the wiring dramatically different? I'm usually a voltage divider with my photo resistors.
What photo diodes should I get for my Arduino mega board?
I could easily install an overhead IR light. The nice thing about visible light is trouble shooting however.
If I went with a visible light sensor, any recommendations?
" light (UV) from 200 to 400 nm, blue light from 400 to 500 nm, green light from 500 to 600 nm, red light from 600 to 700 nm, near infrared light (NIR) from 700 to 800 nm and finally infrared light (IR) from 800 to 1200 nm"
I currently have a photo resistor facing upwards below the track. It detects the car passing over it.
My first attempt used an ISR at 1000 times a second (once per millisecond) and I missed the transit unless I went slowly.
I now have ADC free running with an ISR running at 33000 times a second and easily catch the car. So much so, I can count the time the car breaks the beam so I will be able to calc trap speed.
I think I can dial back that rate back a bit to save on battery.
Features:
Low heat, energy saving, low power consumption, long service life.
Specification:
Receive Wave Range : 400-1100 nm
Response Peak Wavelength:940 nm
Receiving Angle : 40°
Material:Si, Plastic, Metal
Head Color : Clear
Head Size : 3 x 4mm / 0.12 x 0.16 inch (D*H)
Pin Dia : 0.4 mm / 0.016 inch
Total Length: 33mm / 1.3 inch
to the original question "Photo diodes or photo resistors, which is better?"
it depends how you define "better"
Photodiodes are better suited for applications requiring high speed and precision, such as optical communication or light intensity measurement. They offer fast response times and are ideal for detecting specific wavelengths like the infrared that was suggested by @LarryD.
Photoresistors are more appropriate for simple light-sensing applications where cost and ease of use are more important than speed or accuracy, such as automatic night lights.
Neither.
Most people use photoTRANSISTORS in their slot car timing/lap counting applications. There are many examples on the web and a few on the forum.
@jim-p, photo transistors, I will have to look into those as well.
I suspect I am affected by the slowness of the LDR. In my application, according to my math, I should have been able to detect the slot car at 1000 times a second scanning with a sensor as the car moves at 0.1 inches in a millisecond, so I should have 20 tries to detect it. But I'm told analogRead is rather slow so that might have been the issue in the first solution. (I am using GitHub so I can review it as it was before the ADC ISR.)
I have a light above the track. Since shadows from the room light is too annoying.
Very strange. With the photo resistors sampling at 1000 times a second using ISR and analog read, definitely had problems. If a photo resistor reacts slowly that could have been part of the problem.
So for a car that is 5" long, it would break the beam for 50ms. Depending on the light level and load resistance, that may be too fast for most cheap LDRs. However, even though it may not turn completely off it will still generate a detectable signal.
EDIT: see my posts #18 and #20 for a much better solution tailored specifically for slot car racing hobbyists.
Another option is an LDR module. I prefer these to LDRs as they have a potentiometer to dial in just the right trip level based on your application. They also provide a nice, clean digital trip so you don't have to calibrate some analog setpoint in your code.
For slot cars, I can't say if that's something you would have to adjust frequently; however, it seems to me that such a race track will have the same room lighting overall in general so it shouldn't be too much of a hassle as long as the potentiometer on the module is easily accessible.
The photo resistor won't make analogRead() go slower, so you should still get a good samples per second rate — of course depending on what the rest of the code does. Of course the slower the sensor, the bigger the latency to get an update
This made me Google around a little since I love the higher end slot car setups and they look a blast but I've never had one.
Found this, could be useful.
Seems to be a popular option among slot car racing hobbyists from what I can tell. Appears to be an all-in-one kit solution that indeed, incorporates Arduino.
EDIT: Does indeed seem to be useful. Just downloaded this passion project (free with optional invitation to donate to St Jude's Children's Hospital or a charity personal to the project lead Dave called First Candle: https://firstcandle.org/ ) and it looks really slick. @c-compute were you aware of this Race Coordinator resource?
From the free software suite I just downloaded under C: > Program Files (x86) > Race Coordinator > Data > Arduino > lapCounter > Arduino Uno > Race Coordinator.pdf , page 2:
Note 1:
I will leave my earlier post #16 as is in case someone else finds the info about LDR modules useful.
Note 2:
Out of respect for the passion of the project authors Dave Aufderheide and Kevin Gee and as thanks for the work he provided for free to his hobby community, in case Dave ever happens to come across this forum post, thanks and I'm happy to donate to First Candle, an organization I just found out about through Dave's work, in honor and memory of his son, Noah Jack.
From the "thank you" email I received from First Candle, I'd like to take the opportunity to share a description of First Candle's work, from their Executive Director Alison Jacobson:
Dear [redacted for privacy],
Thank you for your donation of $[redacted for privacy] to First Candle. Already your gift is helping. Through your generosity we are training maternity nurses, social workers, daycare providers, grandparents and parents on the Safe Sleep Guidelines that can eliminate sleep-related infant deaths and reduce the rate of SIDS. We’re also able to have someone at the other end of the phone when a parent calls overwhelmed with grief because their precious baby has just died.
@c-compute
A phototransistor with an IR light source is a simpler circuit and has been used extensively for detecting the passing of an object. Maybe you've answered this question elsewhere but why is it you've chosen to have an ISR running at some rate to sense the output of your sensor and not to have the sensor trigger an interrupt on its change of state?
@c-compute if you happen to go with the Race Coordinator option, it seems the author(s) are still actively maintaining the project and there is a big upgrade available using an ESP32 instead of an Arduino Uno.
As of Sept. 25, 2024, the following slot car forum member SlingshotX had this to say:
I have got the ESP32 DevKit board working as an Race Coordinator interface. Bluetooth will work on some of the ESP32 boards so you can connect to the PC wirelessly, see the README.
In addition to not having to connect a USB cable from PC to the track, I've found Bluetooth to be much more reliable than USB, and less susceptible to noise issues such as losing connection and spurious laps.