I am trying to make a circuit that will read pulses from energy meter, I have seen emonTH and it uses interrupt service to capture pulses. I am trying to detect pulses using an LDR for now, but LDR is giving multiple interrupt for Falling edge when ever it detects a pulse from a led source. You guys have an optical sensor, I could not get the circuit diagram of your optical sensor on your website. Which sensor is preferred to detect optical pulses? Thanks
»
Re: Pulse counter for energy meter
This one is known to work.
If you are using a LDR and you are seeing multiple edges, is it possible that another light source is contributing to the LDR's response?
Re: Pulse counter for energy meter
Thanks Robert, I checked your link and I have also ordered it, to check how accurately it can detect pulses on my energy meter. Can you please share its circuit diagram and components list and which transistor you guys have used. LDR that I am using might have got some interference from ambient light as it is not covered. I will try to reduce other light sources affecting LDR, and I have also bought photo transistors ST-1k3lb and 2N5777 and I am trying to figure out how to use them. Circuit diagram of this optical sensor will be helpful.
Re: Pulse counter for energy meter
All the information we have is published on this website, or the linked Wiki or Github.
Re: Pulse counter for energy meter
When I tried to do some pulse recognition, I had some of these same issues.
Especially if you want to use logic levels, I found an LDR with a Darlington Pair transistor to work pretty well at smoothing out edges. This mostly worked for me if there was a visible light pulse I was detecting.
When I tried the IR pulse on my meter, I had to switch to an IR Photo Transistor and sacked the Darlington Pair. I used an arduino to read the pulses from the IR-PT, but still had trouble detecting the edges of the pulse. I tried several ideas and was able to improve it a little using a median filter in software. I started a github for it, but guess I never finished. It really was just a mishmash of other things I found from people.
Basically, as the light I was detecting changed state, because of whatever reasons (noise on the line, actual detected fluctuations), it was hard to tell when the LED had completely changed state. If the On was 5v and Off was 0v, there was fluctuations that happened throughout that might cause voltage to rise and fall through a threshold many times in one sample.
I'm no expert, but if you are dealing with an analog value and trying to detect the pulse edge, what I really wanted to look in to was a software Schmitt Trigger. It just seemed that it answered the bill. Something that set two thresholds, say at 20% and 80% that were far enough apart that 'noise' wouldnt cause a false reading of crossing the threshold.
If you are having trouble getting a steady wave off your sensor, there's some things to think about....
Re: Pulse counter for energy meter
What seems to work for a reed switch is polling: read the input state at regular intervals and when you see a suitable sequence of 0s & 1s, declare an edge detected. This depends on the transitions lasting less than the polling interval, and the pulse frequency & M/S ratio being suitably long in comparison to allow you to detect a stable 0 and 1 state either side of the edge.
What I'd question if you're seeing fluctuations, is whether you had too much gain in the system?
Re: Pulse counter for energy meter
I agree, there could be a problem with my system.
But just for conversations sake, what I was trying to do was separate low from high (of course). If I used ONE threshold, say 50%, I would assume a high value once the wave went above that. However, I would occasionally (or actually, quite often each period) get a blip or two below 50% as the wave climbed above that threshold. Nothing I tried (median filter) would take those out. I had a 10ms pulse length, I knew that, but at max current on the meter I was reading, I knew I was getting to the point where I had very little window between pulses, so I was trying to avoid timers.
I knew what I wanted, I just didnt know what it was called. As I said, the Darlington Pair cleaned everything up pretty nice, but making my photo-transistor one of them seemed a little more difficult than just putting it in software, since thats where my abilities lie.
Here was my thinking, assuming a 5v system and a 20% and 80% band on a Schmitt Trigger.
Once I came off 0 volts and climbed above 1v, I was in transition. I would wait until I climbed above 4v (80%) before assuming 'HIGH'. Even though it was a simple system, discrete values on the sample varied quite a bit. I'd do the same on the transition from high to low. I just never got around to writing the code. It works 'well enough' for now....
I know now tho that my problem was a bunch of things. An op amp probably would have solved everything, including making full use of the 10-bit ADC (my max value was less than 400). I am not using a pull-up (or down) resistor, which I dont even know if it would help. A capacitor would likely help as well. My problem is I obviously didnt pay enough attention in school or I'd know these things, so I am enjoying learning these new things 30 years later.
The same goes for my learning on the emon arduino shield. Its about getting a bare bones idea working, and then tweaking to make it better and learn as I go along. This month its resistors. Maybe in a few months I'll wade in to capacitors. :-) The problem is, a lot of the time "good enough" is settled for and its more fun to move on to the next project. Which is why my github projects are in an undecipherable state of disrepair....