Searching \ for '[PIC] optical counting interface' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/time.htm?key=count
Search entire site for: 'optical counting interface'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] optical counting interface'
2008\03\17@180906 by alan smith

picon face
I'm using a Optek sensor OPB745, and its appliction is counting cycles based on a wheel that has alternating dark and light markings.  Rotational speed is about 25RPM and it can detect the difference between black and white by using the analog port of a 16F818 but now and then it seems to get a glitch and counts twice inside a dark section. I tried a simple filter to try and eliminate those glitches, but it runs the chance it then delays the detect of the light area.
 
  The other key to this is a another wheel is in sync (same shaft) with another sensor where its detecting an object on it based on the dark/light distinction of the first sensor (where is the object in relation to the start of the wheel) so the filter as mentioned above can end up missing when the object is presnt and thus not putting it to the right slot.
 
 So the problem is....detecting the dark to light....light to dark transitions because its not a clear cut...you have voltage A and then immidiatly voltage B...there is a ramping that occurs as the colors change under the sensor, along with the glitch,
 
 I assumed analog detection  is the right way to go.....or is it?  What are the robotic guys doing or maybe the clear cut distinction between light and dark isn't as important to them as it is for this.

     
---------------------------------
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.

2008\03\17@182623 by David VanHorn

picon face
>  So the problem is....detecting the dark to light....light to dark transitions because its not a clear cut...you have voltage A and then immidiatly voltage B...there is a ramping that occurs as the colors change under the sensor, along with the glitch,
>
>  I assumed analog detection  is the right way to go.....or is it?  What are the robotic guys doing or maybe the clear cut distinction between light and dark isn't as important to them as it is for this.
>


That's what schmidt trigger inputs are for.

2008\03\17@190502 by Bob Axtell

face picon face
alan smith wrote:
> I'm using a Optek sensor OPB745, and its appliction is counting cycles based on a wheel that has alternating dark and light markings.  Rotational speed is about 25RPM and it can detect the difference between black and white by using the analog port of a 16F818 but now and then it seems to get a glitch and counts twice inside a dark section. I tried a simple filter to try and eliminate those glitches, but it runs the chance it then delays the detect of the light area.
>    
>    The other key to this is a another wheel is in sync (same shaft) with another sensor where its detecting an object on it based on the dark/light distinction of the first sensor (where is the object in relation to the start of the wheel) so the filter as mentioned above can end up missing when the object is presnt and thus not putting it to the right slot.
>    
>   So the problem is....detecting the dark to light....light to dark transitions because its not a clear cut...you have voltage A and then immidiatly voltage B...there is a ramping that occurs as the colors change under the sensor, along with the glitch,
>    
>   I assumed analog detection  is the right way to go.....or is it?  What are the robotic guys doing or maybe the clear cut distinction between light and dark isn't as important to them as it is for this.
>
>        
> ---------------------------------
> Looking for last minute shopping deals?  Find them fast with Yahoo! Search.
>  
I got better results using magnetic (Hall) sensors, because the magnets
can be placed S-N-S-N and the sensor can snap to the other polarity
sharply.
Look at Allegro Microsystems   (or whatever their name is now).

--Bob A

2008\03\17@202403 by Jinx

face picon face
part 1 879 bytes content-type:text/plain; (decoded 7bit)

>   I assumed analog detection  is the right way to go.....or is it ?

Alan, I use a similar arrangement to measure propellor speed on
light aircraft, with a couple of differences

Inside the propellor head, approx 200mm diameter, are 6 strips
of adhesive aluminium foil on a painted black background. At
3000rpm this means 300 pulses/sec into b0 of a 16F628. INT
is the detection flag, and it works very well. The sensor collector
is pulled up to 12V (plane battery). Output from the resistor -
collector junction is normally high, and low over the foil. Pulses
go through a minimal filter and clamp, as shown

If you want to use an analogue input (ADC or comparator) I'd
suggest a low-high window to eliminate the false positive from
the transition. The difference between light and dark should be
distinct enough to do that successfully


part 2 1015 bytes content-type:image/gif; (decode)


part 3 35 bytes content-type:text/plain; charset="us-ascii"
(decoded 7bit)

2008\03\17@203429 by Richard Prosser

picon face
er,
Shouldn't the 10k resistor be to the +ve line? As shown, there's
nothing to turn the transistor on.

RP

On 17/03/2008, Jinx <spam_OUTjoecolquittTakeThisOuTspamclear.net.nz> wrote:
{Quote hidden}

> -

2008\03\17@203939 by Jinx

face picon face

> Shouldn't the 10k resistor be to the +ve line? As shown, there's
> nothing to turn the transistor on.

Don't forget the sensor has a pull-up

2008\03\17@212910 by Richard Prosser

picon face
Sorry, it's now obvious.

RP

On 17/03/2008, Jinx <.....joecolquittKILLspamspam@spam@clear.net.nz> wrote:
>
> > Shouldn't the 10k resistor be to the +ve line? As shown, there's
> > nothing to turn the transistor on.
>
> Don't forget the sensor has a pull-up
>
> -

2008\03\17@222349 by alan smith

picon face
Well..I agree....but the mechanical setup (rather complicated) doesn't allow for magnets so Im stuck with the optics.  I much prefer hall sensors....well, lets face it...its digital..on or off, not something in between

Bob Axtell <engineerspamKILLspamcotse.net> wrote:  alan smith wrote:
> I'm using a Optek sensor OPB745, and its appliction is counting cycles based on a wheel that has alternating dark and light markings. Rotational speed is about 25RPM and it can detect the difference between black and white by using the analog port of a 16F818 but now and then it seems to get a glitch and counts twice inside a dark section. I tried a simple filter to try and eliminate those glitches, but it runs the chance it then delays the detect of the light area.
>
> The other key to this is a another wheel is in sync (same shaft) with another sensor where its detecting an object on it based on the dark/light distinction of the first sensor (where is the object in relation to the start of the wheel) so the filter as mentioned above can end up missing when the object is presnt and thus not putting it to the right slot.
>
> So the problem is....detecting the dark to light....light to dark transitions because its not a clear cut...you have voltage A and then immidiatly voltage B...there is a ramping that occurs as the colors change under the sensor, along with the glitch,
>
> I assumed analog detection is the right way to go.....or is it? What are the robotic guys doing or maybe the clear cut distinction between light and dark isn't as important to them as it is for this.
>
>
> ---------------------------------
> Looking for last minute shopping deals? Find them fast with Yahoo! Search.
>
I got better results using magnetic (Hall) sensors, because the magnets
can be placed S-N-S-N and the sensor can snap to the other polarity
sharply.
Look at Allegro Microsystems (or whatever their name is now).

--Bob A

2008\03\17@224328 by sergio masci

flavicon
face


On Mon, 17 Mar 2008, alan smith wrote:

> Well..I agree....but the mechanical setup (rather complicated) doesn't
> allow for magnets so Im stuck with the optics.  I much prefer hall
> sensors....well, lets face it...its digital..on or off, not something in
> between

could you have two sensors, arranged such that one is looking at a white
area while the other is looking at a black area and only count transitions
when they both agree on a colour change. This would compensate for the
glitch only happening in the black area.

Regards
Sergio

2008\03\17@224900 by Xiaofan Chen

face picon face
On 3/18/08, alan smith <.....micro_eng2KILLspamspam.....yahoo.com> wrote:
> I'm using a Optek sensor OPB745, and its appliction is
> counting cycles based on a wheel that has alternating dark
> and light markings.  Rotational speed is about 25RPM and
> it can detect the difference between black and white by
> using the analog port of a 16F818 but now and then it seems
> to get a glitch and counts twice inside a dark section. I tried
> a simple filter to try and eliminate those glitches, but it runs
> the chance it then delays the detect of the light area.
> ...
>  I assumed analog detection  is the right way to go.....or is it?

Another solution is to use a better sensor. Most of the
decent photoelectric switch will do the job and not
having gliteches.

If it counts twice in the dark section, this means that the
dark side is not dark enough for this paticular sensor.

Xiaofan

2008\03\18@083636 by Michael Rigby-Jones

picon face


> -----Original Message-----
> From: EraseMEpiclist-bouncesspam_OUTspamTakeThisOuTmit.edu [piclist-bouncesspamspam_OUTmit.edu] On
Behalf
> Of alan smith
> Sent: 17 March 2008 22:09
> To: Microcontroller discussion list - Public.
> Subject: [PIC] optical counting interface
>
> I'm using a Optek sensor OPB745, and its appliction is counting cycles
> based on a wheel that has alternating dark and light markings.
Rotational
> speed is about 25RPM and it can detect the difference between black
and
> white by using the analog port of a 16F818 but now and then it seems
to
> get a glitch and counts twice inside a dark section. I tried a simple
> filter to try and eliminate those glitches, but it runs the chance it
then
> delays the detect of the light area.
>
>    The other key to this is a another wheel is in sync (same shaft)
with
> another sensor where its detecting an object on it based on the
dark/light
> distinction of the first sensor (where is the object in relation to
the
> start of the wheel) so the filter as mentioned above can end up
missing
> when the object is presnt and thus not putting it to the right slot.
>
>   So the problem is....detecting the dark to light....light to dark
> transitions because its not a clear cut...you have voltage A and then
> immidiatly voltage B...there is a ramping that occurs as the colors
change
> under the sensor, along with the glitch,
>
>   I assumed analog detection  is the right way to go.....or is it?
What
> are the robotic guys doing or maybe the clear cut distinction between
> light and dark isn't as important to them as it is for this.

I presume you are sampling the sensor output at a fixed rate?  How do
you currently determine wether the ADC value is light or dark, a fixed
threshold?

Ideally you should set your dark/light thresholds based on the DC
average e.g. run your ADC values through a low pass digital filter and
use the output as your dark light threshold.  For better noise immunity
add an positive or negative offset to the threshold depending on wether
you are looking for a dark or light value, i.e. add hysteresis.

The same could be achieved purely in analog using a comparator with one
comparator input from the sensor, and the other from a low pass filtered
version of the sensor to provide a DC threshold level.  Add some
positive feedback for hysteresis.

Another possibility (that could be used in conjunction with the above)
is to run a digital PLL, so you can place your decision making samples
away from the edge.  This way you can take several samples and make a
decision based on how many are above or below the threshold, just like a
UART does.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2008\03\18@174233 by Jinx

face picon face

> That's what Schmitt trigger inputs are for.

Roman Black and I tested PIC GP i/o some years ago. We believed
it was possible to "fool" them with a very slowly changing voltage.
ISTR it was on the order of 0.1Hz, certainly way less than 1Hz
anyway. I'm a little hazy on the details but I think you could ramp
an i/p voltage from 0 to Vcc without causing a logic change inside
the chip

There was more to it, some twist, but until I find the correspondence
between us (on a back-up CD) I can't say for sure what that was

2008\03\18@180418 by David VanHorn

picon face
> Roman Black and I tested PIC GP i/o some years ago. We believed
> it was possible to "fool" them with a very slowly changing voltage.
> ISTR it was on the order of 0.1Hz, certainly way less than 1Hz
> anyway. I'm a little hazy on the details but I think you could ramp
> an i/p voltage from 0 to Vcc without causing a logic change inside
> the chip


That's certainly icky!

I haven't tried it on the AVR, but it would surprise me.

2008\03\18@184606 by Jinx

face picon face
> ramp an i/p voltage from 0 to Vcc without causing a logic
> change inside the chip

> That's certainly icky!

I wish I hadn't remembered the experiment without remembering
the results. It'll bug me now until I find time to search old mail
folders ;-((  Probably quicker to do it again but I haven't time for
that either this week

It arose after we were testing the transition voltage specifications
in the datasheet. As you'd expect to do, the voltage was changed
very slowly to get a good fix on the logic change voltage

2008\03\19@015134 by Vasile Surducan

face picon face
On 3/17/08, Jinx <@spam@joecolquittKILLspamspamclear.net.nz> wrote:
>
> > That's what Schmitt trigger inputs are for.
>
> Roman Black and I tested PIC GP i/o some years ago. We believed
> it was possible to "fool" them with a very slowly changing voltage.
> ISTR it was on the order of 0.1Hz, certainly way less than 1Hz


 I have really doubts. As long is about a good schmitd trigger you
can't do that.
Except maybe if you've coupled the input in AC with a large capacitor
without any resistor on the input and  varry the signal slighty below
or above the schmitd trigger level. On the pin input that variation
could not appear as long there is only a parasitical current charging
path for the capacitor.

The problem with slow signals is how long it takes (dV/dt) untill the
signals pass the trigger thresold limit. All the passing time, the
output is oscillating between low and high levels because the positive
feedback is not enough for a stable change in the output.
But the output of the trigger is changing from one level to another.



> anyway. I'm a little hazy on the details but I think you could ramp
> an i/p voltage from 0 to Vcc without causing a logic change inside
> the chip
>
> There was more to it, some twist, but until I find the correspondence
> between us (on a back-up CD) I can't say for sure what that was
>
> -

2008\03\19@042232 by Jinx

face picon face

> I have really doubts. As long is about a good schmitd trigger
> you can't do that.

I should have made it clearer that these weren't Schmitt inputs

When I have time I'll search for the experiment we did

2008\03\19@101839 by alan smith

picon face
Well...think I have this solved.  I did try a few different sensors and this Optek seems to be pretty good, although I did get some other samples in but they were very expensive...sampled just to play with them for a future project.
 
 OK, so I right shifted the ADC so the values I am seeing in the dark portion are generally setting the upper to MSB's ('3') while in the lighter area, its always lower....a delta value of about 500 (in decimal).  Given this, I created a dead band area, where I allowed the 'dark' value to range down to the upper or high value of the dead band, so that in the event the dark didn't set the upper two MSB bits, it wouldn't trigger a light area, and if the value read was in the dead band area, I essentially ignored it.  This is because as you transition from dark to light, and you sample in that area, you will see the voltage ramp up and down.  So this dead band essentially acts as a digital filtering.  Then if the voltage drops below the lower threshold of this deadband area, it is a light area.  So the transistion is now more of a hard change rather than trying to detect where in the slope you are.
 
 So far with my testing, I'm right on and no longer have these false transistions.
 
 Sometimes....the easy things....are just hard  :-)

     
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

2008\03\19@104448 by Alan B. Pearce

face picon face
>So far with my testing, I'm right on and no longer have these false
>transistions.

So you have just created an 'optical Schmitt trigger' ...

Welcome to the joys of analogue interfacing. ;)

2008\03\19@114055 by alan smith

picon face
or....the dark majikal mysteries of it....  :-)

"Alan B. Pearce" <KILLspamA.B.PearceKILLspamspamrl.ac.uk> wrote:  >So far with my testing, I'm right on and no longer have these false
>transistions.

So you have just created an 'optical Schmitt trigger' ...

Welcome to the joys of analogue interfacing. ;)

2008\03\19@114327 by David VanHorn

picon face
Just for laughs, you could increase the LED current when you detect
"white" and decrease it when you detect "black".

I've also done sensors where I drove the LED from the phototransistor
so as to get a constant current in the transistor, like 1mA, and used
the LED drive voltage to determine the state of the system.   This
also detects failed components since you can't close the servo loop if
the LED or phototransistor fail.

2008\03\19@212223 by Xiaofan Chen

face picon face
On 3/19/08, David VanHorn <RemoveMEmicrobrixTakeThisOuTspamgmail.com> wrote:
> Just for laughs, you could increase the LED current when you detect
> "white" and decrease it when you detect "black".

Actually this works as kind of hysteresis. I believe similar methods
are used in photoelectric proximity switches.

> I've also done sensors where I drove the LED from the phototransistor
> so as to get a constant current in the transistor, like 1mA, and used
> the LED drive voltage to determine the state of the system.   This
> also detects failed components since you can't close the servo loop if
> the LED or phototransistor fail.

That is similar to how a laser diode works.

Xiaofan

2008\03\19@213617 by David VanHorn

picon face
On Wed, Mar 19, 2008 at 9:22 PM, Xiaofan Chen <spamBeGonexiaofancspamBeGonespamgmail.com> wrote:
> On 3/19/08, David VanHorn <TakeThisOuTmicrobrixEraseMEspamspam_OUTgmail.com> wrote:
> > Just for laughs, you could increase the LED current when you detect
> > "white" and decrease it when you detect "black".
>
> Actually this works as kind of hysteresis. I believe similar methods
> are used in photoelectric proximity switches.

That is exactly the point.

More... (looser matching)
- Last day of these posts
- In 2008 , 2009 only
- Today
- New search...