Go Down

Topic: Feasibility of reading 72 photoresistors on Uno (Read 2244 times) previous topic - next topic

jqlee85

Hey all. Been a while, but I'm back on this project.

I did some experimenting with a single laser diode / phototransistor pair to see if breaking the laser beam would result in usable signal.

I set the phototransistor at the end of a 6" long black tube, and had the laser diode aimed directly at it. I hooked the transistor up to an analog input to get some readings in the Serial Monitor.

Here is the sketch code:

Code: [Select]

void setup() {
  pinMode(4, OUTPUT);
  Serial.begin(115200);
}

void loop(){
  digitalWrite(4, HIGH);
  Serial.println(analogRead(0));
  if (analogRead(0) < 10){
    Serial.write("BEAM BLOCKED");
  }
}


And this is an example of the Serial Monitor readouts when I broke the beam by flicking a finger through it:

Code: [Select]
47
48
47
44
34
20
9
BEAM BLOCKED
2
BEAM BLOCKED
1
BEAM BLOCKED
0
BEAM BLOCKED
0
BEAM BLOCKED
0
BEAM BLOCKED
35
44
47
47
47
47
47


When the laser is shining directly on the photo transistor, the analog reading is around 40. It looks like this is not a large enough difference to produce a digital signal, correct? Is there some way I can do signal conditioning with the phototransistor? Do I need a more sensitive phototransistor?

My goal is to be able to read all 72 phototransistors digitally to see if the corresponding laser beams have been blocked in less than 1ms.

Any ideas would be greatly appreciated, thanks!
Let's make stuff.

ChrisTenone

It's obvoiusly enough to generate a digital signal. I mean, you are reading the signal by digital means, right?44/255ths may not be enought to generate an interrupt, but hopefully, you can poll all 72 fast enough.
What, I need to say something else too?

TomGeorge

Hi,
How have you got the phototransistors wired, I think they can be biased to give some gain and hopefully better response.

Tom.... :)
Everything runs on smoke, let the smoke out, it stops running....

jqlee85

Here's the basic diagram of how I have it wired to test the one pair (the full 72 is going to require a chain of shift registers, I'm told).

https://circuits.io/circuits/2657971-the-unnamed-circuit

I'm currently using analogRead just to test it out. I tried reading the transistor's output through digitalRead, but it was reading 0 the entire time whether or not the laser was hitting the transistor. I assume this is because via analog it's only reading around 40/1023 at its peak. So dropping from 40ish to 0 is read as a 0 either way when using digitalRead.

I'm going to need to just read a 1 or 0 to be able to input the values into shift registers.

Let's make stuff.

lastchancename

Personally, I'd do it arse-about (asuming you're using NPN photo-transistors

Quote
+V --- 4K7 --- Collector --- (opto) --- Emitter --- 0V
                                                           |
                                                       Base
                                                    Input pin  
Then using pinMode(pin, INPUT_PULLUP), you should get nice snappy DIGITAL inputs.
You could go higher than 4K7, but it's a good starting point, and will give full voltage swing.

Experienced responders have a nose for laziness, (they were beginners once)... Sure, there are trolls, chest-beaters, and pretenders - but the help you'll get here is about as good as it gets - if you try to help youself!.

INTP

#20
Sep 05, 2016, 07:31 am Last Edit: Sep 05, 2016, 07:33 am by INTP
So your goal is to map where a ball hits a "wall" plane. Use a camera.
Set up a trip plane, sort of like what you're planning but much simpler. Ball trips sensor, camera snaps a pic, plots ball location based on comparison to baseline image of no ball.
Even a dismal VGA webcam is basically over 300,000 points to your 72, and you probably can't find a webcam less than 720p resolution these days.


Forget the shooting chrono. The field of measurement is small, you can't expect human throwers to hit that window, and if it's made for bullet speeds, it will likely not register thrown object speeds. My shooting chrono doesn't care about the sht I throw through it.

The camera method is how electronic target systems display paper targets. Snap a pic after every shot, blink back and forth between prev and new to "blink" your most current shot.

Wawa

If you are using a pull-down resistor (as you are doing now), you should get less than 300 without laser light, and more than 625 with laser. Only then will moving to a digital port work.

Maybe you should also try the inbuild pull-up resistor.
Declare the photo transistor pin as INPUT_PULLUP, and connect the photo transistor between pin and ground.
Emitter (short lead/flat part) to ground. No external resistor.
Logic is now reversed, but still <<300 and >>625.
Leo..

DrDiettrich

Analog sensors should be tied to Gnd, i.e. the resistor goes to Vcc.

A phototransistor is off in the dark, goes on with light. With above wiring it should read 1023 when off (dark).
It reacts on ambient light, too, you'll have to cover it fully to turn it off.
If it's an IR type, you'll need an IR LED to really turn it on.

Reverse polarity to find out when the transistor goes fully off, without light, and turns on with light. The more light the lower the ADC readings. You can use a DVM as well.

The transistor should react on the amount of light. Vary the LED brightness, using a pot or resistor, and the ADC readings should vary accordingly.

Are you sure to use a 5V (red) laser diode? It should make a big difference whether or not the laser beam hits the transistor.

You can increase the resistor, for higher sensitivity, to obtain a digital signal (full 0-5V range). But this will make your circuit more sensitive to ambient noise.

jqlee85

Use a camera.
Set up a trip plane, sort of like what you're planning but much simpler. Ball trips sensor, camera snaps a pic, plots ball location based on comparison to baseline image of no ball.
Yeah, I had originally considered using a camera, but I'm hoping to have sensing frame/board be a self-contained unit, instead of having to set up and calibrate a camera in another location each time I move it. I'm hoping the structure will be reasonably portable.

But we'll see, if I can't get the speed I need reading all 72 transistors, I may have to use a camera instead. I guess in that case I could set up the trip plane using a single laser/transistor pair with mirrors, if all I need to know is when the plane is crossed.

You can increase the resistor, for higher sensitivity, to obtain a digital signal (full 0-5V range). But this will make your circuit more sensitive to ambient noise.
Ah! I didn't realize I could change the sensitivity by changing the resistor! I switched to a 100k ohm resistor, which made it much more sensitive, and it worked perfectly!

I'm not too worried about ambient light noise, as I'm setting the phototransistors deep into narrow black tubes, and because of the angle of my surrounding structure, there's very little chance ambient light will be able to find its way down there.

Thanks for the input everyone! Now to figure out how to chain shift registers to read an array of these beams, haha.
Let's make stuff.

Go Up