1
\$\begingroup\$

I have a signal which is fed to one of the digital inputs of a microcontroller (PIC16F18326). The signal is shown in the image-1 below. This is during the normal operation of the circuit, that means when it has a load (array of LEDs). But when there is no load, or when open circuited, the signal becomes as shown in image-2.

Both the signals shown below were when the circuit is turned ON from an OFF condition.

Image_1: Circuit Turned ON under load; 5V to microcontroller through out the operation. This 5V is considered as 1 for the µC. (and 0V or GND is considered as 0)

Image_2: Circuit Turned ON under no load or under open circuit. Approx. 4.5 V after 1 sec.

I have to distinguish between the Normal Operation and Open circuit just by analyzing this signal at the microcontroller pin without using an ADC!

Does anyone have a logic solution or idea, what feature of the microcontroller I can use to realize the circuit condition?

Update: For a better understanding of the circuit, I have attached below

enter image description here

image1 image_1

image2 image_2

\$\endgroup\$
8
  • \$\begingroup\$ Please put a load of 10 to 20K ohm between TO_MICRO and ground and see what's happening , there is nothing to discharge 1u and 100n capacitors. \$\endgroup\$
    – Dorian
    Feb 21, 2019 at 15:28
  • \$\begingroup\$ Can you use external components or you're stuck to do that only in software? \$\endgroup\$
    – Dorian
    Feb 21, 2019 at 15:49
  • 1
    \$\begingroup\$ That’s an odd configuration for what is in essence a current-measurement circuit. Why do a fly back measurement when feed-forward might provide more resolution? \$\endgroup\$ Feb 21, 2019 at 16:15
  • \$\begingroup\$ Yes, I have a current measurement circuit, But I did not updated in the circuit. @Dorian, Yes If it is possible via software then I dont want to disturb the hardware. \$\endgroup\$
    – Vidu Kriss
    Feb 21, 2019 at 16:58
  • \$\begingroup\$ Yes I have a voltage dividing Resistor of 47K in parallel with a 100nF Cap at the To_Micro tag. \$\endgroup\$
    – Vidu Kriss
    Feb 21, 2019 at 17:01

2 Answers 2

2
\$\begingroup\$

Try the comparator module on page 193 of the datasheet which is available on your chip.

I didn't check how close to the supply rails you can take the inputs but I'd be surprised if it's not rail to rail. Check the hysteresis settings to give a definite "switch" when your condition is met.

\$\endgroup\$
1
  • \$\begingroup\$ There are spikes on the 5V shown in image_1. Make sure those spikes don't trigger the comparator. Feed the signal with an RC filter to the input pin? \$\endgroup\$
    – Huisman
    Feb 20, 2019 at 8:04
-1
\$\begingroup\$

Use WPUx to activate the weak pull-down resistor on the input pin and see the graphs again. The voltage you see is due the capacitive load of the pin. You will have to wait a bit before reading the pin.

Edit following the new info added

A simple way to achieve this is to set the pin as output low to discharge the capacitors , set as input again and count the time needed for the input to go high again.

A small 100 ohm resistor in series with TO_MICRO input might still be needed to protect the input .

Looking at the divider the peak cathode voltage (no LED load) is around 5V so keeping the pin low for more than 20ms will also discharge the 1uF capacitor down to 1.5V .

With the LED load the voltage on the 1uF capacitor will stay higher and the time until you read high is lower.

You can rely also only on 100nF capacitor charge time (using a short discharge time) but the difference will be small since the voltage difference is small.

Use TTL level input not Schmitt Trigger input.

\$\endgroup\$
6
  • \$\begingroup\$ The OP is looking at the supply voltage for an array of LEDs, and they are interested in what happens after 1 second. The capacitance is too small to matter, and a weak pull-down isn't going to change things either. \$\endgroup\$ Feb 20, 2019 at 15:08
  • \$\begingroup\$ @ElliotAlderson Thank you for at least explaining how you rushed to downvote without no good reason. The capacitor explanation was indeed to short, it might be a load capacitance combined with some leakage current but this was not the question, you could ask for details first. How are you so sure the capacitance and the resistive impedance of the source are not high? Then how do you explain the shape of the second graph and higher noise while the first is flat? Have you ever used an oscilloscope? \$\endgroup\$
    – Dorian
    Feb 21, 2019 at 8:29
  • 4
    \$\begingroup\$ There's no need to be condescending. Yes, I've used oscopes for more decades than I care to tell. The time scale for these measurements is 500ms/div, and at that scale the capacitance of a pin (~100pF) cannot be a factor. Furthermore, the OP stated that the signal was the supply voltage for a bank of LEDs...a low impedance load. This implies that the many kilohms of a pulldown resistor would also not make a noticeable difference. If you want upvotes then make sure your answer is clear, accurate and complete when you write it. \$\endgroup\$ Feb 21, 2019 at 11:51
  • \$\begingroup\$ @ElliotAlderson to understand better, I have updated with circuit \$\endgroup\$
    – Vidu Kriss
    Feb 21, 2019 at 15:12
  • 1
    \$\begingroup\$ @ElliotAlderson As you see , I was half right, there is a capacitor there without a path to discharge and there is no way to guess the voltage under a small load \$\endgroup\$
    – Dorian
    Feb 21, 2019 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.