How to detect a voltage input high 1.93V and voltage input low 1.25V

Thread Starter

tofulover

Joined Jun 6, 2020
10
I haven't read every post in this thread but referring to your 1st post, I am doing something very similar with a battery charging circuit. I use an 8 pin PIC microcontroller with an ADC input to monitor small changes in voltage. It is powered with 3.3V. If the ADC is configured as a byte variable with 256 steps, each step is 3.3/256 = .012V (approx). If configured as a word variable with 1024 steps, each step is 3.3/1024 = .003V (approx). Either one should have an ample amount of difference for the ADC to detect an off or on condition.
Thanks peterdeco. Sorry not too familiar with that. Is that a ADC input sorta like a voltage divider?

In post #10 crutschow has given you the schematic to interface your + 1,25 to 1,95 voltage transition to a zero to +4.5 volt signal for the digital input on the Arduino. (Assuming a 5 volt version of the Arduino.) If you are using a 3.3 volt version of the Arduino then just adjust the resitor values on the output of the comparator. If you use the LM339 then you will need two of them for your eight channels as each one contains four comparators. If you don't want to build the interface then using analogue inputs will work. What peterdeco says in post #10 about PICs applies just the same to Atmel chips used in the Arduinos.
Thanks LesJones. I will see if I can build this circuit on a breadboard to know how this all works.
 

peterdeco

Joined Oct 8, 2019
484
An ADC is an Analog to Digital Converter. It assigns a number to voltage. As I mentioned previously, let's assign a byte variable to the ADC reading (8 bits). .Connecting this ADC input to the full supply voltage of the PIC will produce a number of 255 (0-255 = 256 steps). Now let's say you want to detect if this pin has 1/2 the supply voltage or more applied to it (255/2 = 127 (approx). I program PICs in basic and I would give the command :

ADCIN,0,volts (Earlier in the program I declared volts as a byte variable)
if volts > 127 then high portb.0

Portb.0 is configured as an output and will go positive with the ADC at about 1/2 the supply voltage or higher. You can use this pin directly to light an LED or turn on a transistor if the load is greater than 25mA, the maximum current most PICs can safely supply.
 

Thread Starter

tofulover

Joined Jun 6, 2020
10
An ADC is an Analog to Digital Converter. It assigns a number to voltage. As I mentioned previously, let's assign a byte variable to the ADC reading (8 bits). .Connecting this ADC input to the full supply voltage of the PIC will produce a number of 255 (0-255 = 256 steps). Now let's say you want to detect if this pin has 1/2 the supply voltage or more applied to it (255/2 = 127 (approx). I program PICs in basic and I would give the command :

ADCIN,0,volts (Earlier in the program I declared volts as a byte variable)
if volts > 127 then high portb.0

Portb.0 is configured as an output and will go positive with the ADC at about 1/2 the supply voltage or higher. You can use this pin directly to light an LED or turn on a transistor if the load is greater than 25mA, the maximum current most PICs can safely supply.
Thaks peterdeco. I really appreciate that explanation.
Is there a circuit diagram that you have built so I can learn more about this?
 
Top