applying conversions at different times of day


Ampm

Recommended Posts

Hi i am using DAQF to read electricity meters i want to convert the KW reading to pound and pence, the day tarrif can just be multiplied by the appropriate amount but after say 6pm until 8am the tarrif changes how can i split up the channel into different chunks so i can apply different tarrifs at different times of day?

Thanks for any help

Link to comment
Share on other sites

I'd probably create a Test channel, called, say, Tariff, I/O type A/D, Timing = 0. Then in the event of the energy meter, put something like this:

private temp
if ((temp.time % 86400 < 8*3600) || (temp.time % 86400 > 18*3600))
   temp = 30
else
   temp = 20
endif
temp.time = meter.time[0]  // meter is the name of the meter channel
tariff.addvalue(temp)

% is modulus and doing % 86400 returns the seconds into the day.

Once you have this, you can use the tariff channel in calcs with the meter channel.

Link to comment
Share on other sites

  • 1 month later...

Archived

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