Next step would be to calculate the time for the drop to calculate the time for the drop to travel from IR led 1 to IR led 2. So, i guess signal would be cut as the drop pass through the ir beam. I would like to know from the output of the receiver how to connect it to the arduino uno and what code would be suitable for this purpose? Thanks in advance.
//Speedometer
/*This program computes the speed of a projectile using photo interrupter LED/transistor pairs,
and displays the result on the serial monitor.
The time elapsed between activation of two successive photo interrupters is measured.
The distance between the respective sensors is divided by the time elapsed.
The resulting value corresponds to the average speed during the interval between the two sensors.
There are two photo interrupter pairs used to obtain average speed data.
|Sensor| |Sensor |
| 1 | | 2 |
|<-----gateDist-------->|
*/
//Constants
const int gate1Pin = 2; //assigns the first photointerrupter to digital I/O pin 2
const int gate2Pin = 3; //assigns the second photointerrupter to digital I/O pin 3
//Variables
long startTime;
long travelTime;
float gateDist = 0.03; //This is the spacing between gates in meters. The default
//is 0.03 m or 3 cm. This value should be adjusted accordingly
//if the gates are spaced closer or further apart. For example, for
//a gate spacing of 2.5 cm spacing you would need to
//replace 0.03 with 0.025, etc. for accurate result.
float travelSpeed = 0; //the speed of traversing the two gates
void loop(){
if(digitalRead(gate1Pin)<1)
{
startTime = micros();
while(digitalRead(gate2Pin)>0);
travelTime = micros() - startTime;
travelSpeed = gateDist / travelTime * 100000000
;
Serial.print("The last velocity was ");
Serial.print(travelSpeed,0);
Serial.print(" centimeters per second");
}
}
Guys let me know what u think about this program. I am assuming that it will work just fine for my project.
Also, let me know how i could enhance it to have better results.
thanks
Basically, you feed the Vs pin on your detector with your voltage supply (5V from arduino), ground the ground pin, and then read the third pin with a digitalRead in your arduino sketch using any of the digital pins on the board. Looking at your data sheet, it looks like the OUT pin should read high when no modulated IR light is detected, and low when it is (the transistor should be getting a current from the detector).
If you read my other post, make sure to take not that the leads on the detector he used are in a different order than yours. (though I doubt you can harm the detector by hooking it up backwards.... but I would avoid it since I may be wrong)
I'll be modulating the beam at 38kHz. The system has already been tested. However i'm having trouble in writing the codes as I relatively new to using arduino. Any idea on how to write the codes and any tips would be welcomed
Yes the droplet will break the beam. From what i've understood from resources of the internet, the IR receiver i' ll be using would only be sensitive to a specific frequency of 38kHz. So ambient light would not be affecting the receiver and there would be change only when this specific beam is cut by the droplet. I've posted the link of the ir receiver i'll be using. I would be grateful if you could suggest better settings/devices that would help.
It seems to me that you will need to write some code to monitor the IR receiver input and lock on to the 38Kz signal, and then have some pretty quick way to detect loss of lock. And you'll need to play with the receiving code and the 'loss of lock' criteria to try to eliminate false positive or false negative triggers. If it's a nice clean signal you could just average the signal over the short term to smooth out frequency noise, average over a longer term to get rid of low frequency noise and identify the mean value, and detect when the smoothed signal was sufficiently above and below that mean to be deemed high and low, and then look for transitions at about the right interval; if you miss several expected transitions in succession, you could deem that a loss of signal. But that assumes a fairly well behaved signal and you might not be so lucky.
Ready for the buzzkill? From the TSOP1738 datasheet:
After each burst which is between 10 cycles and 70
cycles a gap time of at least 14 cycles is neccessary
TSOP1738 doesn't allow you to create a continuous beam; it will reject it after 70 pulses. You need a "fixed gain" (Vishay TSSP4038 et. al.) receiver to create a continuous beam. Might be worth mentioning that those fixed gain receivers are a bit hard to come get your hands on.