Author Topic: How to wire this photointerrupter to Axon2?  (Read 3686 times)

0 Members and 1 Guest are viewing this topic.

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
How to wire this photointerrupter to Axon2?
« on: January 14, 2011, 06:58:00 PM »
Been bashing my head on this for FAR too long! I give up, I need assistance.

I recently acquired a couple of these:

http://www.rawnetworks.ca/q3/temp/opb804.pdf

Trying to set one up on the breadboard for testing, but am stuck with how to get the 'signal' back to the axon.

Was planning to use a 300K resister in the circuit (only one I have atm above 220K and below 330K).

There are only four pins on the sensor, two for power (one for the emitter, one for collector), a ground for the emitter, and then I get puzzled as to how to wire the collector output/negative.

The difference between the student and the master, is that the master knows what he does not know.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,702
  • Helpful? 173
    • Society of Robots
Re: How to wire this photointerrupter to Axon2?
« Reply #1 on: January 14, 2011, 07:19:46 PM »
On page 3 of the pdf is a schematic. Use that. The OUTPUT goes to the Axon, as a digital input. The input goes to a digital output, assuming you want to modulate the signal to make it immune from sunlight. Otherwise, just connect it to Vcc (5V).

For the transistor, use 5kohm. For the LED, use 250ohm.

I got both of those values from that same page :P

It says 20mA for the LED, and your Axon is 5V, so using ohms law requires 250ohms. The 5kohm was from the chart on the left of the schematic, the exact value doesn't matter that much.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: How to wire this photointerrupter to Axon2?
« Reply #2 on: January 15, 2011, 09:35:22 AM »
Hi,

For the transistor, use 5kohm. For the LED, use 250ohm.

I got both of those values from that same page :P

It says 20mA for the LED, and your Axon is 5V, so using ohms law requires 250ohms.
Don't forget the LED forward voltage drop of 1.25 typical (1.7V max), making it:

  (5V - 1.25V) / 20mA = 187.5 Ohm => 180 Ohm for ~20mA

(250 Ohm will give 15mA and give about 75% of nominal LED output).
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,702
  • Helpful? 173
    • Society of Robots
Re: How to wire this photointerrupter to Axon2?
« Reply #3 on: January 15, 2011, 09:42:59 AM »
For the transistor, use 5kohm. For the LED, use 250ohm.

I got both of those values from that same page :P

It says 20mA for the LED, and your Axon is 5V, so using ohms law requires 250ohms.
Don't forget the LED forward voltage drop of 1.25 typical (1.7V max), making it:

  (5V - 1.25V) / 20mA = 187.5 Ohm => 180 Ohm for ~20mA

(250 Ohm will give 15mA and give about 75% of nominal LED output).

oops my bad . . . I should have followed my own tutorial lol
http://www.societyofrobots.com/electronics_led_tutorial.shtml

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: How to wire this photointerrupter to Axon2?
« Reply #4 on: January 15, 2011, 03:23:01 PM »
Thanks for the help. Being new to electronics, I'm having trouble with datasheets having too much information. :)  Unfortunately, my bible, Getting Started in Electronics - Forrest Mims, doesn't explain datasheets.

That chart makes little sense to me. I understand the rise/fall graphs, but how did you determine the R1 ohmage(yes, i made that word up)? Why 5K and not 1K (beginning of 'rise' plateau)?

Also, the 'Electrical Characteristics' chart is confusing me too; MIN, TYP, MAX... ?? I just don't know how to get the info I need from that chart! Is there by chance a tutorial on reading datasheets?!
The difference between the student and the master, is that the master knows what he does not know.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,702
  • Helpful? 173
    • Society of Robots
Re: How to wire this photointerrupter to Axon2?
« Reply #5 on: January 15, 2011, 03:41:09 PM »
There is no 'trick' to reading datasheets. It packs a lot of info, and each bit of info requires fundamental understandings. As you get better, you'll start learning new things and they'll get easier to understand. I was once confused by them too :P

Lets say hypothetically your robot will be sent up to space in a balloon. How would you know if your sensor will freeze and stop working? Well, you search the datasheet for temperature, and you'll see several charts with Ambient Temperature written on them that says what happens at different temperatures.

Or lets say on page 2 you see a lot of information such as "Collector-Emitter Breakdown Voltage". This is a fundamental term in reference to transistors, so if you google it up, you'll learn all about it ;D

Quote
That chart makes little sense to me. I understand the rise/fall graphs, but how did you determine the R1 ohmage(yes, i made that word up)? Why 5K and not 1K (beginning of 'rise' plateau)?
The chart basically says it's ok to use from 100ohm to 10,000ohm. So then it just depends on what response time you want - a function of how fast your encoder wheel will be spinning. Do you know the frequency? The vertical value on the chart is in usec.

Assuming you don't have tight tolerances, I just picked a number in between. According to ohms law, the wasted current is very low at a middle value, too.

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: How to wire this photointerrupter to Axon2?
« Reply #6 on: February 10, 2011, 02:43:04 PM »
Hi Folks,

Been awhile since I've been able to work on this, but I've got my new sensor all wired up on the bread board and I think I'm ready to connect it to my Axon and pull some data.

I'm worried as hell though about shorting something out, so could someone review my schematic and offer any corrective advice? Thanks!



Here's the data sheet on the sensor:
http://members.shaw.ca/jwarmuth/OPB804.pdf



If I have the wiring correct, my next question is can use the simple pin_change function to monitor it's values?

My plan is to use this sensor to monitor the RPMs or a spinning rotor. Sunlight is NOT an issue, so I don't need modulation, just simple yes/no values returned via an interrupt.

I'm I on the right path?! :) Thanks for the help!


*side note: I don't have a 180 or 1K ohm resistor, so I'm using the closest ones I have in inventory. I should be okay, but would appreciate any insights. Also, this is just a prototype to get the sensor up (first one I've ever built from scratch), when the design is tested, I'll purchase exact value resistors and clean up the circuit layout.
The difference between the student and the master, is that the master knows what he does not know.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,702
  • Helpful? 173
    • Society of Robots
Re: How to wire this photointerrupter to Axon2?
« Reply #7 on: February 10, 2011, 07:56:32 PM »
It's a bit hard to make out what is going on near the molex connector part, but the rest looks fine.

If you have it on a breadboard and power it up, you should be able to measure a change of voltage between ground and the out signal using a multimeter.

Quote
If I have the wiring correct, my next question is can use the simple pin_change function to monitor it's values?
What is the sensor measuring? If it's for an encoder, using the encoder feature in WebbotLib. Otherwise use ADC. The pinchange option is for interrupts, which you may or may not need depending on what you're doing.

Quote
I don't have a 180 or 1K ohm resistor, so I'm using the closest ones I have in inventory. I should be okay, but would appreciate any insights.
You're 150ohm is fine. If you need 1K, put two 2.5kohm resisters in parallel. It'll give you 1.25kohms, which is much closer.

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: How to wire this photointerrupter to Axon2?
« Reply #8 on: March 06, 2011, 03:52:02 PM »
Thanks again for the help folks, almost there!!

I've got the breadboard/sensor connected up to my Axon2, on ADC pin 8 (K0) because I require PCINT capability.

Note: This sensor has one single purpose; monitor the rpm of a spinning rotor, direction and degrees of resolution are not required.

So I have it all connected up and I'm trying to 'read' from the sensor, but seem to have a software problem.

(When axon running) Using my multimeter, I am able to see a steady 4.7v coming out of the ground (breadboard) so I know the LED circuit is working okay.  And when I test the signal out, it returns 0.05V (beam unbroken), and when the beam is broken, it drops to 0.00v.

So it appears I have a good circuit, but now i'm having problems getting the software setup.   Since the need is so simple (rpms, no directions) I figured i'd go with the pinChange function tied to a hardware interrupt.  Problem is, I get nothing (no response) to the pinChange event.

Here's the code:
Code: [Select]
#include "sys/axon2.h"

#include "a2d.h"
#include "uart.h"
#include "rprintf.h"
#include "pinChange.h"



void myCallback(const IOPin* io, boolean val, volatile void* data){
rprintf("Pin changed!!! OMGOMGOMGOMGOMGOMG!!!\n");
}

void appInitHardware(void){
uartInit(UART1, 115200);
rprintfInit(&uart1SendByte);
}

TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
pin_change_attach(K0, &myCallback, null);
return 0; // dont pause after
}


// This routine is called repeatedly - its your main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){
rprintf("Hello world\n"); //device alive messages for debug
return 1000000; // wait for 1 second before calling me again. 1000000us = 1 second
}

So am I misunderstanding the pinChange function, or just ADC all together?!!! :P

Thanks again folks!
The difference between the student and the master, is that the master knows what he does not know.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,702
  • Helpful? 173
    • Society of Robots
Re: How to wire this photointerrupter to Axon2?
« Reply #9 on: March 06, 2011, 04:03:10 PM »
Quote
(When axon running) Using my multimeter, I am able to see a steady 4.7v coming out of the ground (breadboard) so I know the LED circuit is working okay.  And when I test the signal out, it returns 0.05V (beam unbroken), and when the beam is broken, it drops to 0.00v.
First, ground should be 0V, not 4.7V. :P

Next, the difference between 0.05V and 0.00V is too small. Interrupts are based on a binary voltage, so the high signal needs to be at least 3.3V on the Axon. To fix this, you'll need to use different resistors in your circuit.

Use this tutorial to select optimal resistor values:
http://www.societyofrobots.com/schematics_photoresistor.shtml

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: How to wire this photointerrupter to Axon2?
« Reply #10 on: March 06, 2011, 04:39:43 PM »
Thanks for that Admin, I'll head a back to the drawing board. :)

Curious, what should the amperages be? I seem to be getting an overload testing the IR LED amp out (even at 200m on my MM!), but getting 20uA reading from the signal (collector) out (beam unbroken), 0uA when broken. (Shouldn't this be 20mA/0mA?)

So my goal is to find the right resistor to get the collector output up to 3.3V, correct?

Keeping in mind the whole thing is powered by the Axon2. :)


(or does this whole thing, just mean this sensor is not designed to be used in this configuration and I have to switch to ADC readings to obtain data, as opposed to pinChange?)
The difference between the student and the master, is that the master knows what he does not know.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,702
  • Helpful? 173
    • Society of Robots
Re: How to wire this photointerrupter to Axon2?
« Reply #11 on: March 06, 2011, 05:06:28 PM »
Just follow the tutorial and you'll be fine.

The emitter should be less than 30mA, and the detector should be under 10mA.

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: How to wire this photointerrupter to Axon2?
« Reply #12 on: March 06, 2011, 05:48:16 PM »
Okay, focusing on the photo resistor portion, I *may* have found my problem...

It seems the photo resistor circuit, is always outputting 4.70v, and 4.75v when the beam is broken. This would explain the lack of pin change detection.

I did re-read your tutorial on photo resistors, but am still confused.

Why would the the photo resistor have such a high voltage output, with such a minimal fluctuation in voltage? I have read, re-read, and read again the product manual and cannot figure out where they specify (using their own example of 5Vcc in) the expected voltages of the rise and drop. I see rise and fall times, but not voltages (probably right in front of my face too!).

How would I get this sensor to read 0v unbroken beam, 3.3v+ broken beam?! I don't see a change in resistors doing this.  ???
The difference between the student and the master, is that the master knows what he does not know.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,702
  • Helpful? 173
    • Society of Robots
Re: How to wire this photointerrupter to Axon2?
« Reply #13 on: March 06, 2011, 05:52:57 PM »
Look up voltage divider in google. Basically the resistances change the output voltage, and specific resistances give you an optimal voltage output.

Just follow the tutorial to find the proper resistor values and you'll get the voltages you need. :P

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: How to wire this photointerrupter to Axon2?
« Reply #14 on: March 06, 2011, 06:08:10 PM »
Hi,

Why would the the photo resistor have such a high voltage output, with such a minimal fluctuation in voltage? I have read, re-read, and read again the product manual and cannot figure out where they specify (using their own example of 5Vcc in) the expected voltages of the rise and drop. I see rise and fall times, but not voltages (probably right in front of my face too!).

How would I get this sensor to read 0v unbroken beam, 3.3v+ broken beam?! I don't see a change in resistors doing this.  ???
I assume you have a DMM, so measure the resistance of the LDR (Light Dependant Resistor/photo resistor) with the LDR lighted as well as in "dark". Your statements sounds like you are using a (wrongly) guessed value for it.

You want the resistor to be a value around the percentile mean of these two values - the formula...  Resistor = sqr(Rdark/Rlight)*Rlight
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: How to wire this photointerrupter to Axon2?
« Reply #15 on: March 06, 2011, 10:02:44 PM »
Hi,

Why would the the photo resistor have such a high voltage output, with such a minimal fluctuation in voltage? I have read, re-read, and read again the product manual and cannot figure out where they specify (using their own example of 5Vcc in) the expected voltages of the rise and drop. I see rise and fall times, but not voltages (probably right in front of my face too!).

How would I get this sensor to read 0v unbroken beam, 3.3v+ broken beam?! I don't see a change in resistors doing this.  ???
I assume you have a DMM, so measure the resistance of the LDR (Light Dependant Resistor/photo resistor) with the LDR lighted as well as in "dark". Your statements sounds like you are using a (wrongly) guessed value for it.

You want the resistor to be a value around the percentile mean of these two values - the formula...  Resistor = sqr(Rdark/Rlight)*Rlight


Thank you, I did just that. Even built on the idea by putting in an adjustable resistor (0-10K). No luck.


Then I kept upping the resistor (R2) until I hit 500K. Works like a charm. 0v unbroken beam, 4.6ishv broken. Odd.


Thanks for the help folks! Working through this problem has been a major leap forward in my understanding.
The difference between the student and the master, is that the master knows what he does not know.

 


Get Your Ad Here