4-20mA metering


sadyrbek

Recommended Posts

hi,

I have a water meters, outputs are 4-20mA.

And I think, it is easy to see instant consumption.

But, how can I show total consumption in Daqfactory?

I was using other scadas, and there are some ready blocks to metering.

Is it possible to write some codes?

I will use 4-20mA to modbus converters or other plc with protocol of modbus.

thanks,

best regards,

Link to comment
Share on other sites

Two possible ways:

1) if you want total consumption over arbitrary time frames, you can just do:

sum(myChannel[starttime, endtime])

where myChannel is your water meter channel, and starttime and endtime are time values in standard DAQFactory time units (seconds since 1970). So, for the last 24 hours it might be:

sum(myChannel[systime(), systime() - 86400])

2) you can totalize to another channel: create a new channel, device Type "Test", I/O type A to D, Timing = 0. In the code below I call it "myMeterTotal". Then in your meter channel's event, do something like this:

myMeterTotal.addValue(myMeterTotal[0] + myMeter[0])

where myMeter is your meter channel. Note that this won't work until you initialize the myMeterTotal channel to 0: myMeterTotal.addValue(0). I'd make the channel have a persist length of at least 1 so it remembers between restarts, then you only need to init once. Note, of course, that this won't totalize while DAQFactory is not running.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.