Circuit help

Status
Not open for further replies.

Thread Starter

hero22222222222

Joined Dec 22, 2019
78
Hi I want to make a circuit that can detect sunrise,sunset, day and night and output binary . I found a circuit online which I have attached I understand the circuit but just don't know what to do to determine the 4 states
 
Last edited by a moderator:

dl324

Joined Mar 30, 2015
16,842
I found a circuit online which I have attached I understand the circuit but just don't know what to do to determine the 4 states
As it is, that circuit won't do what you want.

Presumably, the light levels for dawn and dusk will have similar brightness, so you need to know what the state was before you reach the dawn/dusk light level to know which it is.

What are your design constraints? Is an Arduino Uno/Nano an option?
 

SamR

Joined Mar 19, 2019
5,031
A photodiode with hysteresis on its output and serial data logging of when it switches. Good job for a uC. Cloudy/Foggy weather may be a problem.
 

AnalogKid

Joined Aug 1, 2013
10,986
The circuit you posted does not "detect" anything. It produces a voltage level that varies continuously with illumination levels. To this you need to add comparator circuits to produce digital signals that change state or level for your conditions.

what is this for?

ak
 

Thread Starter

hero22222222222

Joined Dec 22, 2019
78
The circuit you posted does not "detect" anything. It produces a voltage level that varies continuously with illumination levels. To this you need to add comparator circuits to produce digital signals that change state or level for your conditions.

what is this for?

ak
Hi, It's just for a small home project. I'm using a pic micro.

How can I use the comparator to detect my requirements and output 4 states?
 

Thread Starter

hero22222222222

Joined Dec 22, 2019
78
Do you want to just detect the light levels or the actual sunrise/sunset?
If the latter, just use a time and date clock chip, an Arduino and set a lookup table for your location.
The info to do that is available on line.
Here is just the first one that came up.
https://forum.arduino.cc/index.php?topic=41851.0
You may find the info there.
Hi, I don't want it to be complex I just want to use a LDR to determine my requirements.
 

LesJones

Joined Jan 8, 2017
4,174
I recently did something like this to trigger an automatic feeder to dispense food for a hedgehog that visits are garden. The main thing I considered was avoiding it being triggered by a shadow. I decided that taking an average of a number of readings was the simplest solution. It takes a trading every few tens of seconds and the reading is put into a table of readings (I chose 16 entries so it was easy to divide for an average value.) The value is first entered into position 1 then 2 then 3 and so on. After location 16 it is again entered into location 1 so the last 16 values are stored in the table. These are then added together and divided by 16. (Just 4 right shifts.) I used a PIC16F18446. You can have a copy of the code as a starting point if it is any help.

Les.
 
Last edited:

Thread Starter

hero22222222222

Joined Dec 22, 2019
78
I recently did something like this to trigger an automatic feeder to dispense food for a hedgehog that visits are garden. The main thing I considered was avoiding it being triggered by a shadow. I decided that taking an average of a number of readings was the simplest solution. It takes a trading every few tens of seconds and the reading is put into a table of readings (I chose 16 entries so it was easy to divide for an average value.) The value is first entered into position 1 then 2 then 3 and so on. After location 16 it is again entered into location 1 so the last 16 values are stored in the table. These are then added together and divided by 16. (Just 4 right shifts.) I used a PIC16F18446. You can have a copy of the code as a starting point if it is any help.

Les.
Yea that would be great . I'm looking to make a circuit that can detect if a capacitor is not charged, charging, fully charged and discharging. To detect the 4 requirements I need
 

LesJones

Joined Jan 8, 2017
4,174
I have attached the source file and the schematic. You can probably remove quit a lot of code as the unit has an option to be triggered by an infra red beam which broken when the hedgehog enters the feeding station. It can dispense food either at sunset or the first time after sunset that the beam is broken for more than a second. (This is so that mice do not trigger it. ) This activates the output relay for 1 minute. I used a ORP12 LDR which I had in stock. The values to set the detect level are defined as constants at the start of the program. The TX output displays the ring buffer contents and average as ASCII text. At the start of the program it waits until the ring buffer has been filled with 16 light level readings.
I am confused by your comments about capacitor charging at the end of post #9. I can't see how this is related to sensing light levels.

Les.
 

Attachments

Thread Starter

hero22222222222

Joined Dec 22, 2019
78
I have attached the source file and the schematic. You can probably remove quit a lot of code as the unit has an option to be triggered by an infra red beam which broken when the hedgehog enters the feeding station. It can dispense food either at sunset or the first time after sunset that the beam is broken for more than a second. (This is so that mice do not trigger it. ) This activates the output relay for 1 minute. I used a ORP12 LDR which I had in stock. The values to set the detect level are defined as constants at the start of the program. The TX output displays the ring buffer contents and average as ASCII text. At the start of the program it waits until the ring buffer has been filled with 16 light level readings.
I am confused by your comments about capacitor charging at the end of post #9. I can't see how this is related to sensing light levels.

Les.
Hi thank you for your help. Your circuit is to complicated for me to understand (I am a beginner...). What I wanted to do with my design was to detect different stages of a capacitor . Considering there are 4 states a capacitor can be in I wanted to convert this to binary 00,01,10,11 then put into a microcontroller. I've attached a picture
 

Attachments

Last edited:

AnalogKid

Joined Aug 1, 2013
10,986
Hi, It's just for a small home project. I'm using a pic micro.

How can I use the comparator to detect my requirements and output 4 states?
Unless you have a strong desire to mess with analog parts (ALWAYS a good thing), you don't need to. The circuit you have produces a voltage that varies with light level, and the PIC has an internal A/D converter. You can do all of the comparing and detecting in software.

I would change R1 to a pot so you can adjust the circuit to get you get the largest change in voltage throughout the day.

ak
 

Thread Starter

hero22222222222

Joined Dec 22, 2019
78
Hi thank you for your help.

I'm not very good with coding. That is why i was asking if I can convert it without the pic micro. I want to gain experience with solving problems with elelctronics (I don't want to spend ages learning and making code to get the solution....)

I have a "strong desire to mess around with analogue parts" :)
 

Janis59

Joined Aug 21, 2017
1,834
Sunrise? Nautical sunrise, Civil sunrise, Astronomical sunrise, Road Traffic sunrise etc etc etc. Which one to detect is demand?
 

Thread Starter

hero22222222222

Joined Dec 22, 2019
78
Hi, I want this to be a basic project I don't want to go into details of detecting different sunrise. As soon as the capacitor charges... I want a circuit to detect this or if there is any other basic method rather than using a capacitor please do let me know

Thanks
 

Reloadron

Joined Jan 15, 2015
7,501
Hi I want to make a circuit that can detect sunrise,sunset, day and night and output binary . I found a circuit online which I have attached I understand the circuit but just don't know what to do to determine the 4 states
Pretty sure one state is the state of confusion. Binary, as mentioned only has two states, it's 1 or 0 and that's all there is. True or False, Yes or No and you get the idea. What PIC do you plan on using? You really need to start being specific in your topics. The circuit you posted at the very beginning is no more than a LDR (Light Dependent Resistor) in series with another resistor of fixed value providing an analog voltage output. There is no reason to have a capacitor in there. Now if you want something like you posted in your post #11 you can have that. I can't tell you how because as mentioned you have yet to say which uC you have or plan to have. Now if were me I would use any old uC because all I need is an analog in and some simple code around my uC ADC. So again which PIC and how do you plan to program it because less any more information we have nothing. You don't learn to swim in the deep end of the pool.

Ron
 
Last edited:

AnalogKid

Joined Aug 1, 2013
10,986
I feel a need to apologize for some of the comments.

But beyond that, while your question is clear, you have not thought it all the way through. From the point of view of a single sensor circuit, sunrise and sunset are transient events, moments in time when the environment changes from one steady state to the other. Day and night are the two steady states. A LDR and one comparator will give you a signal that is (for example) high during daytime and low during nighttime. When properly adjusted, the illumination when the circuit output changes state will be in the middle of the transition periods when night is transitioning into day (sunrise) and vice versa. So one comparator gives you four signals:

Positive-going edge: sunrise
Steady state high: daytime
Negative-going edge: sunset
Steady-state low: night

It is up to the downstream circuits or PIC to interpret and act on these conditions.

The next layer of complexity could be one of several options, such as have the circuit make a pulse output during sunrise and sunset. Or, with the window comparator mentioned above, have a signal line that is high only during the sunrise period between full nighttime and full daytime.

Saying that you want to "detect states" is not enough. Expand your description of how you want the circuit to behave, how many output signals you want (such as separate signals for day and night), and what downstream circuits these signals are going to drive.

ak
 
Last edited:

dl324

Joined Mar 30, 2015
16,842
I want this to be a basic project I don't want to go into details of detecting different sunrise. As soon as the capacitor charges... I want a circuit to detect this or if there is any other basic method rather than using a capacitor please do let me know
You need to know whether the last "state" was dark or light before you can determine whether some intermediate light level is dawn or dusk.

You also need to worry about shadows, clouds, fog, rain, etc that will affect the amount of light hitting the LDR.
 
Status
Not open for further replies.
Top