counter woes wc8


I have been using a webcontrol v03.02.18b5, for about half a year now and really like it.   It's reliably doing everything I want it to, except for the counter.  I have not been able to get it to properly read the pulses from my S0 kwh meter, which gives one ttl pulse per watt hour.  It does show an increasing count over time, but the value increments erratically, and remains static for a long time between the changes, usually some hours, much longer than the typical interval between the pulses, which can be computed from the displayed kwh value and a clock, or observed from the flash of an led on the meter.  The accumulated values in the counter are not at all linear with the watt hours being recorded by the meter, they appear to be just random.  The meter is new & I do not believe that is malfunctioning.

I am now about to purchase a wc32, along with one of Ross' IO boards.  I need to know what's up with the counters before I buy

Some six months ago I came here because of this issue and saw this post...

How to count pulse from water flow or energy meter ?   Started by Thomas Parvais , Oct 11 2012 04:45 PM
(seems I can't post a link, even one to this forum, so that's all there is for reference...else apparently I might be accused of trying to circumvent the restriction)

...which ended with Efried asking "What is the required wiring for being able to use S0 interface from meters with the WC pulse counter ? Is there a sketch hidden somewhere here?"

for which he received the reply "It stated in the latest user guide"  CAI_Support Cocoonut Posted 08 December 2014 - 05:12 PM

I had the latest user guide at that time, and the string S0 was nowhere in it, nor was there any explanation I could find that came close to answering this question.  I didn't want to necro the post so I left without an answer.

Now that I am needing to buy another board, I am checking again & I see that Efried himself came back a couple months later and made the very same observation that I would have, "could you please state were S0 is mentioned? Not here: (no links allowed, not even one to cainetworks)".  Nearly four months later his question remains unanswered.

If there is some kind of buffering or pullup or pulldown or bypass or other 'wiring' necessary to successfully utilize this function, can the secret please be revealed?

I would truly like an answer to this question from the CAI support staff, who have been very helpful in this forum but have declined to answer this question, or have it in the manual as claimed.  This seems like a fairly reasonable use of this board in home automation, people like to know how much power they are using thruout the day, especially with time of use billing, and some kind of info or example on how to use the webcontrol with an S0 meter could be a good thing to actually have in the user guide.  I just checked WebControlPLCUserGuide3-03-19.pdf, which says "Doc last modified:  6/18/2015"; seems pretty 'latest'.  A search for S0 or kwh still gets nothing, and none of the references to 'counter' provide any clue that I can find.

When I registered, I was asked to provide a url where I found this forum, and there was a remark about how helpful it is for CAI to know.  It surely wasn't found on the cainetworks support page (url not allowed) where it should be, and where, at the bottom, is a phone number, "WebControl at +1 714-550-0910" which is still out of service, 'message 6001', since when I first tried six months ago

I've considered updating the firmware, but the link in this post
WC8 PLC 3.02.19 firmware Started by CAI_Support , Feb 28 2015 12:59 PM
simply opens the cainetworks home page, no firmware.
I don't know what an S0 meter is, but any of the thousands f energy meters I have encountered with pulse outputs have dry contact outputs.
This means you would usually have to tie the output to common on the WC8 and a digital input. Then you will need a pullup resistor. I would use a 4.7k ohm resistor for that job unless you are running longer wires than I would try a 1k ties up to +Vcc on the WC8.
If the output is a 3 wire contact (KYZ) then the pulses off one side K-Y or K-Z will be twice the value of Kp, Ki, or Ke value.
3 wire contacts alternate closing K-Y then K-Z for a secure count input so o erroneous pulses are counted. You only  need to use one unless you need the security.
Also, in metering pulses a change in line state equals one Kp, Ke, or Ki pulse value, unlike electronic pulses which entail the full cycle ON-OFF. Pulses may be slightly erratic because they may result for counter divider circuits inside the meter and may not be a modulus of zero in the division factors.
Thank you Larry for your time and reply

I believe the S0 interface is simply an open collector switch, that in my meter toggles 1000 times per kwh. It's a pair of small terminals on the meter, marked - & +.  I'm using a shortish < 1m shielded twisted pair cable with the ground braid connected to the earth ground at the meter end, and open at the end near the wc8 board.  The -minus terminal wire breaks out of the braid very close to the 9vdc ground pin 2 on the wc8 and is connected there.   The +signal wire goes into the counter input, TTL1, pin 5 in J12.  The wire pair is 20ga copper and the braid is tinned copper with foil underneath, overkill but I had some from an RF project and it was the right length.  I have had a 4.7k from the counter pin to +9vdc pin 1 with no joy, and there doesn't seem to be any change in the erratic count behavior at all, with or without it.  The meter is a DDS238-4 110v 60hz single phase.

I haven't wanted to fiddle with it beyond this point because it seems like it should work, and I don't want to pop my board experimenting outside of w/e the envelope is w/o hearing from CAI how it should be wired. I've grown very attached to all the rest of the data pouring in so reliably, and the automation it's providing on the output channels, and I don't yet have a spare wc8 in stock as a standby if something bad happens.  Not that I would care to blow one up even if I did

I did try an alternate method to collect the power data, with an ACS712 current sensor at the meter fed into one of the analog inputs, but never had any success with that either.  It wasn't ever my original intent to use one, and I need all three analog inputs for other sensors, but since the counter isn't working yet I made the attempt.  Mostly I really need to see the counter working, because the wc32 has a couple of them and I will need both, one for another kwh meter and one for fluid flow.  The flow sensor is also open collector output
klaatu said:
I believe the S0 interface is simply an open collector switch, that in my meter toggles 1000 times per kwh. It's a pair of small terminals on the meter, marked - & +.  I'm using a shortish < 1m shielded twisted pair cable with the ground braid connected to the earth ground at the meter end, and open at the end near the wc8 board.  The -minus terminal wire breaks out of the braid very close to the 9vdc ground pin 2 on the wc8 and is connected there.   The +signal wire goes into the counter input, TTL1, pin 5 in J12. 
Please check the specs of your meter very very carefully. I would *EXPECT* that the + terminal will go to Vcc, and the - terminal will go to the TTL input.
If it's wired as pull-up, don't add any extra pullup resistors, as that will reduce, not increase, your noise immunity.
The pull-down resistors on the WC8 inputs are fairly soft. You MAY even find you need an extra pullDOWN resistor, perhaps 1K-4K7 from TTL input to ground.
I've used the counter inputs for the last 18 months off a flux-gate magnetometer running at around 50KHz with no stability problems.
thank you kindly Ross.  I not suggesting that the counter isn't up to the task, I'm sure it does work if the pulse source is properly connected to it.  I just haven't had that info yet, and it certainly is not in the wc8 user guide.

Unfortunately for me, the 'specs' on this meter consists of a simple diagram that shows a small box outline inside the meter, containing a line drawing of a pulse, and a pair of lines leading from the sides of the box to the exterior terminals on the meter, one with a +plus and one with a -minus.  That's it.  There was also 'S0 - DIN 43864' printed near the diagram so I am using that to presume open collector.  On the meter face itself is '1600 imp/kwh', but others using this same meter have reported that it is actually 1 pulse/watt hour, and that value is also seen in some of the listings for it, including the one I purchased it from.  I dunno what to make of that until I can get some steady counts and compare the values to the reading on the lcd.  There may be something more somewhere, but if so it is surely in mandarin, and probably not any more informative.

I measured the impedance of the wc8 inputs at nearly exactly 10K. I'll try your wiring suggestion and keep the pulldown in mind.  thanks for sharing your time & expectation, it's not intuitive to me that it would be like that, but since the alternative hasn't been working, I'm warming up to it
For the hw rev 2.2.2 board, the latest firmware download is at
About the counter for pulses, that is not reset unless you reset it in PLC code.  For WC8 frequency counter, it is calculated in half second interval.  If your frequency is lower than that, you will need to use pulse counter to count pulses, then divide the time to calculate that way.
WC32 IO board for TTL input has optical isolator chip. That requires couple ma current to drive it. Please let us know if you need any more information.
klaatu said:
Unfortunately for me, the 'specs' on this meter consists of a simple diagram that shows a small box outline inside the meter, containing a line drawing of a pulse, and a pair of lines leading from the sides of the box to the exterior terminals on the meter, one with a +plus and one with a -minus.
If yours is like this, and +SO goes to the anode of a diode, and -SO goes to the emitter of an NPN transistor (this might loosely be classed an "open collector" output, from the point of view of the +SO terminal), then certainly the +SO will need to go to the positive supply, and the -SO will be the most-negative side of the circuit. When the opto turns on, the emitter-collector junction will go low-resistance and the -SO pin will pull to within about 0.8V of Vcc (what's on +SO), thus pulling the counter pin high.
When the opto drive turns off, E-C junction will go highZ, -SO (the counter input) will pull low (or as low as the leakage through the opto output transistor will allow), hence my comment about possibly needing to pull the counter input low somewhat harder. 10K is probably adequate however.
You COULD, strictly speaking, connect -SO to ground, +SO to the counter input pin, and a much harder pull-up resistor, say 2K2 to Vcc.
This may help reduce noise pickup on the counter input pin.
Edit: On page 4 of that PDF is a diagram quite clearly showing +24V to the SO+ connection on the power meters, and the SO- connection going to the "sensing device" which then connects to ground, so my initial suspicion based only on the labeling, looks to have been right.
Maybe really late in the game but are you sure you have the input programmed as a counter?
If I remember correctly IP1 it has a software switch in the setup.
Yes, in the I/O Setup screen, it has selection to be:
Counter enable on TTL input 1
Frequency Measurement Enable on TTL input 1
or TTL Input 1 Enable.
By default, TTL input 1 is acting as TTL input only.  If you want to measure as pulse counter or frequency counter, you will need to configure it through browser interface.  The pulse counter counts a complete cycle when low to high and high to low. It can count up to 2MHz frequency pulses. Since it is a hardware counter, it is very accurate.

Thanks for all the replies.

I did resolve the problem and have nice steady counts now.  As there seemed to be no advised caution against trying things either way, I was emboldened to do the try-everything testing method.  Typically this is what I would have done on my own, but since I don't know how resilient this board is, and am already depending on it for steady data and ongoing process control, I was waiting for enough intel to proceed in a hopefully knowlegeable manner and not wind up in tears.

I had been following examples from other people using these cheap S0 submeters, particularly a couple raspberry pi projects where the leads were simply connected to GPIO and GND, and GPIO has an onboard pullup.  They were saying 4.7k and I thought I shouldn't need to go any lower than that with my short fat cable, but it was too high and the result was a lot of phantom counts.  I hadn't realized the resistor value would be so sensitive in this way, thank you Ross for pointing that out earlier.

I started by removing the meter and just manually inputting pulses by hand, touching wires together.  There was really a lot of bounce.  A single momentary tap might put in 100-500 counts, which did surprise me.  Then I tried various wirings/resistors with the meter.  Connecting the +plus marked lead from the meter to +5v and the -minus to the counter input wouldn't give any counts at all, no matter what resistor went where.

So I went back to the raspberry wiring, like I originally had, +plus going into the counter, and -minus to gnd, starting with no pullup, to make sure I at least was seeing counts again.  Then I put a 10k trimpot between the counter input and +5v, and started dialing down the resistance while watching the system status page.  The result of this is that a 2.2k resistor gives stable counts, one per pulse.  I could watch the led flash on the meter, and see the count increment by 1.  Yay, finally.  Above even ~3.5k, multiple counts per pulse.

In doing all this, I also noticed that my terminal block was touchy about making a stable contact to the wiring; tightening the screw down as hard as it would go, then flexing the resistor lead just a little to test, could produce some creepy wiggle.  So hard to get good cheap parts these days.   So I think that at least part of the original syndrome may have been due to a less than perfect connection and this really high bounce feature for this input.  I made a connector/ribbon cable/terminal block for J12, and am looking forward to not having to do that again by getting the IO board for the wc32.

Larry I figured someone would offer that, never too late for a good ongoing game  :)   Yes, I had it set as a counter, that much is in the toolbox.  or foolbox, maybe.  The last time I had one hand on a pullup resistor and a finger in a ttl input, I was writing code in fortran to run on a pdp11 mini.  on punchcards.  and playing with a z80.  So these memories are a little dim but still floating about in the matrix, needing only their circumstances to reemerge

Ross those meters are similar to mine, but I have LCD and those are counter wheels, their internal circuitry may also be a little retro, I dunno.  This statement "...SO interface (open collector)according DIN 43864.." is everywhere in search results, creating enough pollution that I wasn't able to find exactly what the DIN 43864 spec actually is.

But anyway, you certainly nailed it!!
rossw said:
You COULD, strictly speaking, connect -SO to ground, +SO to the counter input pin, and a much harder pull-up resistor, say 2K2 to Vcc.
This may help reduce noise pickup on the counter input pin.

Thank you CAI Support for the firmware link.  But is there some reason that the unwashed masses buying their shiny new wc8 from ebay can't just go to downloads/ and see the file(s) ?  We have to know the filename, or come here and ask?  After first finding out, on some site other than yours, just where here is?  It's kinda non-standard, and a bit confusing, along with multiple links to outdated manuals, and disconnected support phone numbers.  Never a second chance to make a first impression.
CAI_Support said:
About the counter for pulses, that is not reset unless you reset it in PLC code.
I have to take issue with this statement.  The value in the counter is not entirely persistent.  When I added my local ntp server in Network Setup, doing so erased the existing Counter value, set it back to zer0.  I am pulling the whole getall data string into sqlite once a minute, so it isn't the entire end of the world, I could recover the value, but does it really need to be that way?  Using the counter to record accumulated power usage, it would be nicely convenient if it actually didn't get erased when I have to make a change somewhere in the settings.  Unless I change it to a freq meter, or normal input.

As far as the wc32 IO board optoisos needing some drive for the counter pulses, thanks for pointing that out, I hadn't thought of it yet.  If you have some specific recommendation for successfully getting pulses from open collecter sensors thru the inputs, then please share if you will.  I'm about to invest and will need both counters to work, might as well get all the parts now, and it would be nifty not to go too long without counts in the new board
When save network configuration, board must restart its firmware, which cause all RAM/VAR/counter value reset.  Save NTP setting in the Network Configuration screen is that restart reason.  Hope this helps.
For opto isolator, you can reduce the pull up resistor so that it is enough to trigger the isolator input.
For firmware update, for different revision board, there are different firmware. We don't mind email discuss with customers to verify their board revision then point them to the proper download link. Older firmware link could be removed from our site over the time.
Glad to see it works for you.
okey dokey.  then since there isn't any popup or other apparent advisory that warns "this will erase all ram/var/counter values...are you sure?", I guess I need to make a formal request for the factory WC8 GUI HTML source and tools for making the self GUI image.  Then I can at least add this useful info to the giant button that is otherwise empty except for the little 'Send' word.

If there are any other settings that are going to do this, it would be really neat to know what they are as well.  This board appears to be so reliable that I can easily forget everything about it between any needs for servicing, and having pointed reminders in plain sight can be a good thing.  The manual WebControlPLCUserGuide3-02-18a.pdf for my revision doesn't seem to include any mention of this on page 5 where it talks about the network settings.

Regarding the firmware, there isn't any change log inside the firmware zip.  On your webcontrol/webcontrol-changelog page, the info stops at 09/1/2013 V3.2.17e, shortly before my current version.  How do I discover what later firmware revisions have done?  I'm asking because I seem to recall you once mentioning that you were removing the RTC in some version subsequent to the one I am currently running, and at that time I was still considering the possibility of utilizing one, despite the apparent consensus that it just wasn't all that great.  Now I intend to add the ds2450, I need a few more analog inputs, and I'd like to make sure it too hasn't fallen into disfavor before I flash, as well as just read in general what has changed in case there is anything else that I would rather not lose
Thanks for your request.
Only network configuration requires to restart for changes to take in effect. Other configuration does not, so that other configuration will not cause RAM stored value being clean out.
WC8 board can not add custom GUI, due to its EEPROM storage size and RAM size. Only WC32 supports custom HTML GUI.
Yes, latest firmware removed DS2450 and DS2417 Realtime clock chip supports, due to Dallas no longer making DS2450 and DS2417 realtime clock module is not as easy to obtain then the one on the I2C bus and SPI bus.  Users can get I2C and SPI realtime clock module easily over the internet sellers, then use few lines of PLC code to get realtime clock module working.  There are few examples we posted on this forum about how to talking to those chips.  Similar to the additional analog inputs, there are I2C ADC modules on the market, it is not too hard to program them through PLC.  On the other hand, if you still have DS2450 and DS2417 module, you can load up firmware supports them. The version supports them does not support I2C and SPI due to memory limitation.
Thank you for the response.  That's weird, because I'm fairly certain I saw some reference to it early on, before the wc32 made its debut on ebay, along with some disclaimer to the effect of "you're on your own if you want to do this, but here are the tools...".  But if this is the way it is now, I'll just use greasemonkey or some other css trick to add the warning text to the page or button.  I appreciate you letting me know that it is only on the network settings page.

As far as utilizing the SPI/I2C bus, that's great but I have the older hardware w/o the nice new terminal block for it, the feature set for it in my manual looks kinda thin, and honestly, the reason I chose the wc8 to begin with is it saved me the time of delving into arduino land to get the job done.  The wc8 is a fair bit more turnkey, I'm incredibly busy in an unbelieveably diverse range of activities, and my time is my most precious resource.  I already have some ds2450 on hand, they are still on ebay for less than $5, and despite their known quirkiness I am thinking it would take less time for me to add one to the 1 wire bus than crying for help trying to learn how to use an I2C ADC module, and how to program it, regardless of how few lines of code it might take.  I don't really care about or need the RTC anymore, and it has an even quirkier history anyway, I only referenced it as an example that I knew you were pulling support for some devices in later firmwares.  I'm looking at these empty ai5-ai8 data fields, and the ds2450 seems the quickest and simplest way to add my sensors and see the data there.  Maybe later I will get the newer hardware revision and have time to grok the SPI bus, but likely if I do figure it out I may tend to gravitate toward an arduino solution that gives me more eventual flexibility.

Still, I do think it's great that you added the support for it, and I was tempted to get one of the 2.3.8 boards and add the extra functions I need that way, but the wc32 will hopefully take less time to deploy, as long as it is sufficiently mature and I don't find myself in a beta test.  Primarily I need at least 10 output channels, and I have potential uses for the extras so it seems the way to go.

Since I don't seem to have access to any documentation on firmware after V3.2.17e in 2013, I guess I need to ask, does my current firmware v03.02.18b5 still support the ds2450?  The manual references it as available, "6.8  External Analog Chip DS2450" but my board does have the older pin header for the SPI, and the manual also has section "4.6 I2C Support", so it appears it does have at least some support for both.  Therefore I am now confused, since I am reading what you just said as there is no I2C support in the firmware that still has ds2450 support.