Convert PWM wave when PRESENT to stable 'on'

Thread Starter

JackPollack

Joined Feb 29, 2016
34
I trying to determine if a piece of equipment is on or off using its power LED and an opt isolator.

When I look at the output of the OI on an Ohm meter I get a nice stable “—“when the unit is off and, a stable 120K when it is turned on. I then connected the OI to a micro controller and set the pin to read resistance. What I am seeing is 12,0,12,0,12…

I assume that LED is using PWM to control its brightness and the meter is just not fast enough to detect the fluctuation.
I could probably deal with this in software but would rather provide the micro controller with a clean signal.

Is there a few component way to stabilize the wave output and “slow it down” so it reads “0” when off, or “12’ when on?
I tried a 104 cap across the output of the OI but that just made the “12” reading drop and still picked up the “0”


I don’t have a scope or freq counter to examine the output more closely.
 

Thread Starter

JackPollack

Joined Feb 29, 2016
34
the micro controller has a "pot in" mode which measures resistance.
So I was looking at resistance on my meter.

The meter part is not the issue (it actually works) it is when I then replace the meter with the micro controller and examine the output of the pin Im seeing the "wave". I want to clean the output of the OI so I get 12,12,12,12,12 not 12,0,12,0,12,0
 

Papabravo

Joined Feb 24, 2006
22,083
Without a schematic diagram of the circuit your post is borderline incomprehensible. How's about whipping up a schematic of what we are talking about and giving us the part number of the processor, so we can pull up a datasheet to see what you are trying to describe.
 

djsfantasi

Joined Apr 11, 2010
9,237
I could probably deal with this in software but would rather provide the micro controller with a clean signal
It’s your project. But if I had a microcontroller, I’d use it. The software solution is fairly simple. I’d create an array of the input values for several readings that wrapped around. Once you fill the array, start again at the beginning.
Then, I’d average the array contents. When the average is 6, the device is on. Otherwise if the average is 0, the device is off. You can treat intermediate values however you want. You only need about four or more readings. It should be an even number.
 

Thread Starter

JackPollack

Joined Feb 29, 2016
34
I couldn't get the leaky integrator circuit to work with this. I think the signal is too low. I went with
djsfantasi suggestion and just did it in software. I just took the inverse of his suggestion since 10 samples of off would be '0' anything in the range of 50 (I actually used >40) would indicate an on state.

Thank you djsfantasi
 

MisterBill2

Joined Jan 23, 2018
27,555
The capacitor in the leaky integrator in post #6 is too large and the resistor is too small. Try 0.01mfd and 100K ohms, or even 470K ohms.
The response time requirement is not stated and so I ignored it.
 

MisterBill2

Joined Jan 23, 2018
27,555
Actually, a better approach will be to feed the PWM signal into the rising edge trigger input of a re-trigger-able monostable timer, like the CD4538. The response will be as close to instant as CMOS logic can provide, with true and compliment outputs and two per IC.

And I do not want to argue about RC time constants for unspecified signals.
 
Top