1
\$\begingroup\$

I would like to count the number of flashes generated by a yellow LED in my Schneider Me4ZR power meter. This power meter produces 100 flashes for every kWh. I would like to use One Wire protocol to count via my PC. [EDIT] My consumption is in average around 4 pulses per minute. I already have a working 1-wire network in my house that consists of temperature sensors, contact sensors and voltage meters for light level measurements. Then network is connected to my PC via http://www.homechip.com/catalog/product_info.php?products_id=158. It is working well for all other sensors so this is not causing an issue. As mentioned it is also counting light impulses when they are stronger/longer.

I have built a one wire counter from parts that behaves like this counter.

I have then built a separate light detect circuit identical with this one: enter image description here

but I have replaced the LED with a 5V relay and protected the transistor with a diode connected to relay pins as shown here: description http://www.pcbheaven.com/circuitpages/images/darkswitch_1245000373.jpg. I have connected this circuit to the 1 wire counter.

The reason I chose a relay instead of another transistor was that with a transistor I got too many random clicks when the led got on. With a relay I can get a clean contact on/off.

The relay switches correctly when exposed to a bulb and the counter increments as expected. All ok so far.

When I place the photodiode in front of the LED it does not work ok. I can still hear the relay click but the counter is not incremented.

I assume that the pulse length is too short. One solution I guess will be to increase the pulse duration.

How can I check what the cause of the issue is and, if the answer is to extend to pulse duration, how can I do that easily?

\$\endgroup\$
  • 1
    \$\begingroup\$ Have you tried changing the value of R2 to increase the sensitivity of the light detector? Apart from that I don't think a mechanical switch (relay) is a good idea when it's going to switch multiple time per second. It's both slow and it's not going to last long. You should try an optocoupler (assuming you need the input-output isolation) \$\endgroup\$ – alexan_e Mar 19 '14 at 18:20
  • \$\begingroup\$ Can you please elaborate on I would like to use One Wire protocol to count via my PC. Is there a micocontroller involved (sensor->counter->mcu->pc) or some other PC card that will receive the I2C signal? \$\endgroup\$ – alexan_e Mar 19 '14 at 18:28
  • \$\begingroup\$ I guess we are to infer that you have a 1-wire adapter for your PC? Like: hobby-boards.com/store/products/1%252dWire-USB-Adaptor.html? And that your test consists of your sensor circuit operating the relay, the relay switching the input to the home-build 1-wire-counter, and then reading the result via 1-wire to the PC? If so, have you determined that your 1-wire counter --> PC works properly, independent of the sensor circuit and relay? \$\endgroup\$ – gwideman Mar 19 '14 at 23:17
  • \$\begingroup\$ I already have a working 1-wire network in my house that consists of temperature sensors, contact sensors and voltage meters for light level measurements. Then network is connected to my PC via homechip.com/catalog/product_info.php?products_id=158. It is working well for all other sensors so this is not causing an issue. As mentioned it is also counting light impulses when they are stronger/longer. \$\endgroup\$ – dancri77 Mar 20 '14 at 17:02
  • \$\begingroup\$ My energy consumption is around 4 pulses per minute, so I have assumed that the relay will not switch very often and will last for a while. Being inexpensive I could replace it when needed. \$\endgroup\$ – dancri77 Mar 20 '14 at 17:06
4
\$\begingroup\$

Step back a few layers and go back to your original problem, which is to count pulses emitted by a LED and be able to access the count information on a PC.

Apparently you get one pulse for every 10 W-h of electricity usage. Even if you were using 10 kW (that's a lot for a house), you'd get one pulse every 3.6 seconds. No problem there. However, you have to determine how long these pulses last. That will determine how sensitive to make the circuit and allow for some noise reduction.

I'd start with a light sensor, suitably condition the light level signal to feed it into a microcontroller, then most of the rest is firmware. Let's say you determine the pulses are 1/4 second (250 ms) long. I'd probably sample the light sensor every 1 ms in the micro, then do a little filtering looking for a square pulse of the expected duration. Even just a threshold detect based on recent ambient with a little hystersis is probably good enough.

Anyway, you get a signal inside the micro for every pulse. Have that increment a counter. You then need to send the counter value to the PC on demand somehow. The simplest was is to use serial. Use something like a MAX-232 chip to convert between the micro's UART and the PC COM port.

I don't see any point in using a 1-wire bus anywhere in this system. There is simply no need for one, and the PC can't speak 1-wire natively anyway.

There is certainly no reason to use a relay anywhere here. A relay will cause glitches, take significant power, and its output will bounce. You don't need isolation because you are only intercepting light from the power meter, which in effect gives you optical isolation from the power line.

\$\endgroup\$
  • \$\begingroup\$ I have not measured the pulse duration, not sure how to do it. It is clearly visible with my eye, probably as you suggested, around 200 ms long. The reason for using 1-wire was explained above in my other edit, I already have a working network with dedicated PC and other sensors which works well, and wiring in place, and a custom software to analyse all data from all sensors, so it's very easy to integrate this new sensor. Your suggested solution seems complicated for my level of knowledge in electronics, I am very beginner on this. \$\endgroup\$ – dancri77 Mar 20 '14 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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