Ampm Posted January 5, 2010 Share Posted January 5, 2010 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 More sharing options...
AzeoTech Posted January 8, 2010 Share Posted January 8, 2010 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 More sharing options...
Ampm Posted February 23, 2010 Author Share Posted February 23, 2010 Hi Thanks I copied the code but i can't get it to work i get this error message 02/23/10 10:24:53.153 C1112 Tried to do a GetTime() on a value without any time associated: Line 2k Any ideas Thanks Andy Link to comment Share on other sites More sharing options...
AzeoTech Posted February 23, 2010 Share Posted February 23, 2010 sorry, that was a typo on my part. The if() line should read: if ((meter.time[0] % 86400 < 8*3600) || (meter.time[0] % 86400 > 18*3600)) temp is empty so doing an if() on it makes no sense! Link to comment Share on other sites More sharing options...
Ampm Posted February 24, 2010 Author Share Posted February 24, 2010 Thanks a lot i'll give it a go Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.