I'm doing a project where I need to determine the coefficient of friction using a block on a tilt plane. When the plane is rotated the block passes two LDRs (Photodiodes in the image) at either end which are used to determine the time for the block to go from one end to the other, however I am not really sure how to go about doing this as I'm still relatively new to Arduino. Any help with writing that part of the code would great!
How fast is the block moving and how accurate do you want the time? LDRs are pretty slow to react to changes in light. Photo transistors would be faster and you can use modulation of the light to be able to ignore ambient light. Google "arduino light gates" for information.
I would use a variation on the state change detection method to sense the change in state of each sensor. On change of state of first sensor use the millis() function and record a start time. Then on the change of state of the second sensor record a stop time. The elapsed time is stop minus start. The distance divided by the stop time minus start time is the average velocity. For an analog sensor, the change of state would be the crossing of a predefined threshold.
The LDR wiring in your diagram is wrong. The LDR must be part of a voltage divider. What I often do is set the analog input pin to pinMode INPUT_PULLUP so use the internal pullup as the LDR load resistor. No external resistor required.
The LDR an resistor need to be wired as a voltage divider with the "center" connection going to the analog (or digital) input. Run the Analog Read Serial Example to make sure you're getting good-useable readings and to choose a threshold, etc.
...It doesn't really matter if the LDR is the "top" or "bottom" resistor as long as you match your code to the readings you're getting with the light blocked or unblocked.
Note that LDRs are "slow" (for electronics). They are probably OK for a sliding block but for something fast-moving a photo-diode or photo-transistor is better.
groundFungus:
How fast is the block moving and how accurate do you want the time? LDRs are pretty slow to react to changes in light. Photo transistors would be faster and you can use modulation of the light to be able to ignore ambient light. Google "arduino light gates" for information.I would use a variation on the state change detection method to sense the change in state of each sensor. On change of state of first sensor use the millis() function and record a start time. Then on the change of state of the second sensor record a stop time. The elapsed time is stop minus start. The distance divided by the stop time minus start time is the average velocity. For an analog sensor, the change of state would be the crossing of a predefined threshold.
The LDR wiring in your diagram is wrong. The LDR must be part of a voltage divider. What I often do is set the analog input pin to pinMode INPUT_PULLUP so use the internal pullup as the LDR load resistor. No external resistor required.
Thank you, I'll have a look into those. The block shouldn't be moving that fast as the plane is only being rotated until the block just starts to move and I don't think they're expecting our times to be too accurate. As for the wiring that's just an example schematic from my university for using to write the code, we have a rig on campus for actually implementing the code but thank you for the information about how to wire it.
DVDdoug:
The LDR an resistor need to be wired as a voltage divider with the "center" connection going to the analog (or digital) input. Run the Analog Read Serial Example to make sure you're getting good-useable readings and to choose a threshold, etc....It doesn't really matter if the LDR is the "top" or "bottom" resistor as long as you match your code to the readings you're getting with the light blocked or unblocked.
Note that LDRs are "slow" (for electronics). They are probably OK for a sliding block but for something fast-moving a photo-diode or photo-transistor is better.
Thank you, I'll keep all that in mind.
As for the wiring that's just an example schematic from my university for using to write the code,
Please have the cognizant authority correct that wiring diagram so as to not mislead more students in the future.
DVDdoug:
The LDR and resistor need to be wired as a voltage divider with the "center" connection going to the analog (or digital) input. Run the Analog Read Serial Example to make sure you're getting good-useable readings and to choose a threshold, etc.
The diagram was already correct (almost). The LDRs are connected between "analog" pins and ground, you use pinMode of INPUT_PULLUP to provide the "upper" resistor of about 47k. That may or may not suit by itself, you may require another pullup to 5 V.
The resistors in series with the LDRs are however, spurious, should not be there. From where did the OP get this circuit concept? A university? Really?
And yes, LDRs are generally too slow for such a purpose, particularly if you are wishing to detect when a light beam is broken.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.