Circuit help

Status
Not open for further replies.

Bernard

Joined Aug 7, 2008
5,784
I erased post # 34, rotated drawing. Submitted an outline that gives all 4 stages, Day, Dawn, Dusk, & Dark. PV is a 2" X 2" photo cell, OC = 3 V, light load. Dawn = + .25 V to + 1V, Day = +1 V or higher, Dusk = + .25 V to +1 V, & Dark = less than +.25V, or U1, U4, & U7 all Lo making U8 Hi.
Seems to me that there is a glitch but cant seem to find it.
 

Attachments

Thread Starter

hero22222222222

Joined Dec 22, 2019
78
I erased post # 34, rotated drawing. Submitted an outline that gives all 4 stages, Day, Dawn, Dusk, & Dark. PV is a 2" X 2" photo cell, OC = 3 V, light load. Dawn = + .25 V to + 1V, Day = +1 V or higher, Dusk = + .25 V to +1 V, & Dark = less than +.25V, or U1, U4, & U7 all Lo making U8 Hi.
Seems to me that there is a glitch but cant seem to find it.
Hi thank you for your help. I do not understand your truth table.

For U2 and U3 when positive input of comparator is less than 0.25V then the comparator should output a low not a high?
 

Bernard

Joined Aug 7, 2008
5,784
Looks like I have my greater than & less than symbols reversed. > greater than, < less than.
First column of L & H s is for input of < , less than, .25 V. The H s & L s are the output states
of the ICs for the different input voltages.
 

Reloadron

Joined Jan 15, 2015
7,889
Bernard, if you are going to go the photo voltaic (Solar Cell) route why not just use a solar cell like the SC10050 5.0V 100mA Solar Cell My guess is under bright sunlight you will see about 5 VDC and maybe 100 mA and not like much current to speak of is needed. They even come fitted with a barrel plug. Mouser cost about $8.00 USD and likely much less cost on Amazon. The output could be passed on to something like an LM3914 Dot/Bar Display Driver. That would afford 10 outputs based on the voltage level from the solar cell.

Initially the thread starter showed a simple series LDR circuit and mentions "why do i need to use diodes on the output if im connecting the output directly to a microcontroller"?

Should that be true and the uC has an Analog ADC all he needs to do is run a simple signal from the circuit he originally posted into his uC and write a few basic lines of code and do whatever he wants to do.

Ron
 

danadak

Joined Mar 10, 2018
4,057
If you are not a coder you can always use a block language to generate code. Videos on
web to train you.

Here you drag and drop programming blocks onto canvas and then upload to Arduino,
like a Nano board, or to ATTINY85 show below on proto board. Latter a little more
involved programming as you use an Arduino board to program the ATTINY85.

mBlock converts your blocks and configuration into Arduino code for you.

The code following is not complete, just a starting point. For example I did not limit
the time the LEDs stay on after detecting sunrise or sunset. Or if you just want them
to stay on until they are detected by opposite state. Eg. sunrise led stay on from time
of detection until sunset is detected.....

1584011737383.png


1584011816538.png

Bicolor LED used.


Regards, Dana.
 
Last edited:

Thread Starter

hero22222222222

Joined Dec 22, 2019
78
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
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
Hi i decided not to use the capacitor but what resistor value would you recommebd I use for my potential divider (LDR and resistor). I'm currently doing trial and error but I'm not getting a gradual voltage increase as the light increases, the voltage increase changes rapidly....
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
Hi o decided to use the potential divider
Below is a schematic of a LM339 comparator using two of the four comparators. They are configured as a window comparator. Vsupply in this case is 12 VDC. The lower and upper limits are 4 volts and 8 volts. The outputs are tied as Analog mentions and R4 serves as a pullup resistor since the LM339 outputs are what is known as open collector.

Here is the circuit:
View attachment 200807

View attachment 200808

Comparing Vin and Vout you can see where Vout is only on (high) while the level is inside the window. Vin is just an increasing voltage (blue trace) which gets to 12 VDC, where it sits a few seconds then decreases.

The only way to remember or recall a last state is as Analog mentions, using a latch. The more features you want the more parts you add.

Ron
hi i implemented the circuit you uploaded but used an AND gate rather than a pull up resistor but it didn't work. Why does this not work?
 

Thread Starter

hero22222222222

Joined Dec 22, 2019
78
Below is a schematic of a LM339 comparator using two of the four comparators. They are configured as a window comparator. Vsupply in this case is 12 VDC. The lower and upper limits are 4 volts and 8 volts. The outputs are tied as Analog mentions and R4 serves as a pullup resistor since the LM339 outputs are what is known as open collector.

Here is the circuit:
View attachment 200807

View attachment 200808

Comparing Vin and Vout you can see where Vout is only on (high) while the level is inside the window. Vin is just an increasing voltage (blue trace) which gets to 12 VDC, where it sits a few seconds then decreases.

The only way to remember or recall a last state is as Analog mentions, using a latch. The more features you want the more parts you add.

Ron
hi i implemented the circuit you uploaded but used an AND gate rather than a pull up resistor but it didn't work. Why does this not work?
 
Actually, I have no proper knowledge of sunrise ckt. I just purchased PCB from cplfpc.com for my college project. Anyone who can clear me about sunrise ckt?
 

Reloadron

Joined Jan 15, 2015
7,889
hi i implemented the circuit you uploaded but used an AND gate rather than a pull up resistor but it didn't work. Why does this not work?
Less a drawing it's hard to say but likely an AND gate has such a high input impedance. Doing that would not work with an open collector output to an AND gate.

You have said you were going to run this into a PIC so why not just use a circuit based on the very first circuit you posted and run the Vout into a uC? None of this has to be complicated.

Ron
 

Reloadron

Joined Jan 15, 2015
7,889
Actually, I have no proper knowledge of sunrise ckt. I just purchased PCB from cplfpc.com for my college project. Anyone who can clear me about sunrise ckt?
Start a new thread. Post a link to your board you bought and state clearly what your objective is. That means all the details.

Ron
 

Thread Starter

hero22222222222

Joined Dec 22, 2019
78
Less a drawing it's hard to say but likely an AND gate has such a high input impedance. Doing that would not work with an open collector output to an AND gate.

You have said you were going to run this into a PIC so why not just use a circuit based on the very first circuit you posted and run the Vout into a uC? None of this has to be complicated.

Ron
Thanks.
In addition, do you know any good resource I can use to learn how to program the microcontroller in assembly code. I know the basics but ive never worked with anaogue inputs and how to compare them to a voltage. that is why I wanted to make the circuit more complex to avoid analogue
 

Reloadron

Joined Jan 15, 2015
7,889
Assembly you got me. These days since retiring my code is limited to some VB I still remember and C++ for playing around with micro-controllers.

I can share this with you. I have an el' cheap LDR sitting here and I placed a 10K resistor in series with it. One side of LDR to Vcc of 5.0 volts and one side to 10K resistor, the other side of resistor to ground. The junction voltage dark is about 0.5 volt and under bright light about 4.7 volts. Not a bad swing. Back a few post I mentioned the LM3914 which if you look at a data sheet it's called a LED dot/bar driver but it has 10 distinct outputs which we can say are digital over an input range you establish. That chip and a few parts is about all you need. Place a LDR and 10 K resistor in series. Apply 5 volts and ground, similar to your original image. Measure the voltage for light, dark and in between at the light levels you want. Then set up the LM3914 accordingly with a few external parts. Now you have 10 digital outputs across a range of light.

LM3914 Data Sheet

Ron
 

LesJones

Joined Jan 8, 2017
4,511
I learned how to program in assembler from articles in electronics magazines such as Elector and Practical Electronics. Looking at code written by someone else and seeing how they do things taught me what I now about assembler. Don't ecpect to find a book that will teach you everything in a few hours. You learn most by trying to do things yourself or modifying someones program to do what you want. The thing that you want to measure is an analogue value (Varying light level.) so you have to start with some analogue circuitry. You would use a microcontroller with a built in ADC (Analog to digital converter. ) That converts the analogue input value (Voltage.) For example the PIC I used in the design I posted in post #7 (A PIC16F18446) has a 10 bit ADC so it conerts the input voltage into a number. As it is 10 bit it will convert it to a number between zero and 4095. So you just be testing if that number (Which now corresponds to a light level .) is above or below chosen levels for light or dark. You can also test if the value is more or less than the last reading so you could decide if it was sunset (Readings going down.) or sunrise. (Readings going up.)

Edit. Correction. I should have said 12 bit ADC not 10 bit.
Les.
 
Last edited:

Reloadron

Joined Jan 15, 2015
7,889
I learned how to program in assembler from articles in electronics magazines such as Elector and Practical Electronics. Looking at code written by someone else and seeing how they do things taught me what I now about assembler. Don't ecpect to find a book that will teach you everything in a few hours. You learn most by trying to do things yourself or modifying someones program to do what you want. The thing that you want to measure is an analogue value (Varying light level.) so you have to start with some analogue circuitry. You would use a microcontroller with a built in ADC (Analog to digital converter. ) That converts the analogue input value (Voltage.) For example the PIC I used in the design I posted in post #7 (A PIC16F18446) has a 10 bit ADC so it conerts the input voltage into a number. As it is 10 bit it will convert it to a number between zero and 4095. So you just be testing if that number (Which now corresponds to a light level .) is above or below chosen levels for light or dark. You can also test if the value is more or less than the last reading so you could decide if it was sunset (Readings going down.) or sunrise. (Readings going up.)

Les.
Les, wouldn't 10 bit be 1024 (2^10) so we get 1024 quantization levels. I have to totally agree as to code and learning it. Good books only get you so far. What I did learn was from samples I found and tailored for my use and after awhile it just starts happening.

Ron
 
1 2 4 8 16 32 64 128 256 512

Doing it the hard way, since i know the power of 2 table, but the wrong way around.
10 bit is indeed 0 to (2^10)-1 or 0-1023

You also have to watch for representation (e.g. unipolar, bi-polar, xbits + sign) and the reference (e.g. fixed, Vcc, 1/2 Vcc) value.
 

Bernard

Joined Aug 7, 2008
5,784
Finally: A pot simulates a PV cell. As pot advances from 0V, Dark LED is on, passing .25 V Dawn LED lights, Dark goes out, passing 1V Day LED lights,
Dawn goes out, up to 3V & reverse. Passing 1v Day goes out & Dusk LED comes on, below .25V Dusk out Dark on. This seems to track the suggestion by @LesJones #30 .
Just 3 ICs, LM 339, 4081, & 4025. U2 B,C, & D make a 3 input AND.
U3, A & B form a latch. U 1- D no longer used. LEDs just for monitoring.
If requested , I can ink the drawing for better readability.
 

Attachments

Last edited:
Status
Not open for further replies.
Top