NPN photocell and AVR

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi there,

How would you connect a comercial npn photocell to an AVR input (Vcc = 5V). Also, would you debounce the signal in order to avoid the very fast noise pulses and also to have a fast enough system.

Does anybody have the experience on photocells?

Thanks,

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Photocell as in phototransistor? Try https://www.avrfreaks.net/modules...

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

daqq,

Thanks for your support, but because of my wrong I am not talking exactly about this. I am talking about an 24V comercial photocell (sometimes called as intermatic photocell) used for automation solutions connected to PLCs. For example they used for bottle counting.

Thanks.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The device's output dictates how you connect it. If the unit's output is '0' or '24vdc then a simple transistor circuit can drop the levels for you. Some of these sensors have a 4-20ma output so then you will need to design a circuit to convert it. And still others have TTL levels. Do you have a part number we could look up?

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, I got it,

The type of sensor I use has 24V when inactive and floating when active. My problem was that when active I thought that the voltage might be ~0V (RTFM stupid).
That's why my circuit wasn't functional.

Now everything is fixed.

Anyway, thanks for your time.

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you saying you send 24v into an AVR pin?

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you send the 24V into a voltage divider to get 5V. When the 24V is off, the input pulls down to 0. Hopefully.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Are you saying you send 24v into an AVR pin?
Well, it is possible - the AVR would protect itself through the protection diodes in it. But if it's a good idea... well, EXTREMELY BAD IDEA is more like it :-D Anyway, a simple resistor divider should suffice, although an optocoupler or something like Jim suggested would be more appropriate.

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Well, it is possible - the AVR would protect itself through the protection diodes in it. But if it's a good idea... well, EXTREMELY BAD IDEA is more like it Very Happy Anyway,

Not likely! The diodes would conduct and much current would flow thus causing smoke.

NPN would imply current sink, wheras PNP would imply current source. So, if it is NPN, you could have a pullup resistor to 5V and the sensor would pull the input to 0V. If it is a PNP style, it will switch 24V and cause smoke. As suggested, a resistor divider would address this issue.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Actually I use a circuit based on the reset ic NCP305-2 (On semiconductors). I have a resistanse voltage divider to it's input and some other components.

Of course I don't use 24 V to any pin.

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer