Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

using ADC port for Cds / PIR input

Status
Not open for further replies.

MrDEB

Well-Known Member
Is this really wrong or ??
I tried setting up portB5 as input for the PIR which upon motion outputs 3.3v
Can't get B5 port to setup as an input. Tried several things but it apparently conflicts with my present code. I read 4.8v on B5 constantly.
So I combined the PIR output with my Cds cell and input to A0 as an ADC sample.
Seems to work just fine but am led to believe it might not be right or done correctly?
Don't get me wrong, the source is very knowledgeable but
WHY? might it be wrong.
Here is the schematic as well as the LT spice simulation results
the section in question is the PIR/Cds circuit.
 

Attachments

  • bear repellent current draws.PNG
    bear repellent current draws.PNG
    28.8 KB · Views: 413
  • LT voltage divider.PNG
    LT voltage divider.PNG
    26.3 KB · Views: 318
At some level, anything that works is ok. But this is like a house of cards waiting for a tiny breeze to knock it down.

Here's an analogy. Suppose the screw came of the cold water knob in your shower so you couldn't turn on the cold water anymore. The "right" solution is to find a replacement screw of the correct size and a screwdriver and fix it. But you could put the nozzle on the garden hose, run the hose through the window and into the shower and duct-tape the nozzle beside the shower head. To take a shower, just adjust the nozzle for the cold water and the still functioning hot water valve to regulate the temperature and if the spray pattern of the nozzle and the shower head are sort of the same, you'd have a nice warm shower. As long as you didn't get towards the edge of the spray where the nozzle and shower head patterns don't match too well. Or somebody turned off the garden hose. Or the duct-tape gave way because it got wet, scalding some parts of your body and freezing others.

Probably best to fix the shower the right way, before you trip over the hose. And probably best to UNDERSTAND the program you're trying to write and the fundamentals of the language you're using.
 
"Can't get B5 port to setup as an input. "

Check your configuration for the chip. On the 18F1320 pin b5 defaults as low voltage programming input pin.
 
Am aware that this "FIX" might not be the best but getting down to basics as I view the problem.
The Cds outputs an analog signal based on its resistance.
The Pir inputs 3.3v (in "normal usage the Cds is connected to Vdd) but here instead of Vdd am using the output of the PIR.
The ADC pin (A)) is pulled low until the PIR outputs .
Am going to look over the code I am using to determine WHY I am unable to get RB5 as a INPUT.
Being a beginner I may get closer to the train wreck.
 
Status
Not open for further replies.

Latest threads

Back
Top