The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
I notice a difference in results, but it should not be.
Hello,
I am using my Netduino for solar logging.
I had notice these days that there was een difference in output between my Solar Inverter wattage output and the netduino output. My question is why?
I log the time between 2 electrical pulse with a KWH counter in the electrical box.
'wait for the first pulse
dtStartTime = DateTime.Now
Do
If portElectricPulse_D13.Read() 'wait for the pulse'
Hi Ellen,
If I understand this correctly; you need to measure the time between two pulses. Am I right in that?
What kind of timeframe should I think of, in ns, µs, ms, seconds, minutes?
Ps. nice project you're building!
I had an idea to do something similar, but ended up buying a CT sensor-based meter which sent out the data I need via serial.
The original idea, before "economics" got in the way, had been to put a photosensor over the LED on the generation meter. It flashes once per Wh so the time between flashes gets shorter as the sun gets brighter.
For Stefan: On a 4 kWp system generating at full capacity, you'd expect the light to be flashing approx once per second (4000 times every 3600 seconds). The difference between 1803 and 1804 watts equates to a time difference of 277.7778 µs between the rate of flashing.
For Ellen: Can't see what's wrong with your code - it's as if the internal clock spent half an hour running 1½ seconds too fast.
If I understand this correctly; you need to measure the time between two pulses. Am I right in that?
What kind of timeframe should I think of, in ns, µs, ms, seconds, minutes?
Ps. nice project you're building!
Hello Stefan,
The pulse meter give 2000 pulse per KiloWatt so 3600 seconds in 1 hour / 2000 give 1.8 seconds per pulse/KW. And I update the cosm server every 20 seconds.
There must be some kind of something wrong. It is between lets say 1610 Watt and 1803 watt.
Have a look at my afternoon image (the gap), and the afternoon mirror the morning, the two should be identical:
I have seen issues with the implicit casting of values in code like yours. You should consider explicitly casting everything. So, for instance, the 1800 should be either 1800.0 or 1800d.
Also, add a Debug.Print statement or write to a log to verify that the input and output of the CType statement is working as expected. Don't assume that it is...
I wonder if there's a pattern in the gaps. Is it recurring every xx minutes for example? You're using a Netduino Plus, and pushing the data over the web.
I could imagine a delay in your main loop can happen when another thread becomes active. This could be a native thread, like a dhcp renew. Or the process of uploading the data took some more time.
You're not using an interruptport right now, are you? If you did, the timestamp sent with the event parameter is not affected from delays in your code.
It's not a delay causing the problem - she's using dtEndTime as the basis for all the calculations, all in the same thread. Once that's assigned, the ND can hang for 20 minutes - the output should still be the same for all three graphs. Similarly, it's not a missed pulse. If the ND did not "see" the pulse sent from the meter, you would get an erratic graph as a result, but all three methods would produce the same error.
The calculation based on dtEndTime.Ticks produces the desired result.
The ones based on dtEndTime.TimeOfDay and (indirectly) dtEndTime.Seconds & dtEndTime.Milliseconds produce periodically erratic results. It's as if the ND is forgetting the basis for conversion between Ticks and Seconds, and then recovering.
Just an addition to everything has been written above.
The "Seconds", "MIlliseconds", etc properties yield the value of the respective field in the resulting DateTime structure, and *NOT* the total time elapsed.
For instance, when you subtract two timestamps such as 09:10:11 minus 09:09:10, that yields a TimeSpan of 00:01:01. The "Seconds" property gives just one second, not 61.
Instead, the TotalSeconds gives 61.
Have a look here (regular .Net): http://msdn.microsof...m.timespan.aspx
"Ticks" are heavy to use (it's a "long"), but they give an exact representation of the whole TimeSpan value.
Cheers
Biggest fault of Netduino? It runs by electricity.
Minutes should be included, for completeness, but if there's more than a minute between pulses, Ellen's solar system would be outputting just 30 Watts. Depending on the inverter model, that's probably not even be enough to allow it to switch on.
It's not the cause of the problems she's seeing above.
So as I understand, (the bottom line) when you want calculate with time very precisely, you need to use dateTime.Now.Ticks
All the other methods results in capricious output.
I had to look up capricious*, but yes. It would appear that the results are unreliable, but I'm sure they're not supposed to be. My only evidence for suggesting this is what you've posted in this thread: I've done no time-critical work yet.
* The first hits that came up basically described my ex