Page 1 of 1

Sampling rate

Posted: Tue Jul 03, 2018 2:14 am
by Memo
Good day!

I am interested in acquiring a couple of SmartPower2 devices to use with my ODROID XU4 to obtain energy consumption of an execution that may take a few hundred milliseconds.

I heard the default sampling rate is 1 Hz, which is too coarse for what I need. I also heard you can increase it to up to 20 Hz, which is still far from perfect, but much more viable.

I would like to know 2 things:

1 - How much can I increase the sampling, and what accuracy will the energy value that is reported have?
2 - Can I obtain the output via UART (with a USB cable connected to a computer) in a way that the computer is not required to connect to a different network? I plan on hooking it up to a server, so I can run my benchmarks (remotely) in the datacenter the computer is in.

Thank you for your time to read and respond to my questions. I hope the SmartPower2 is the adequate solution for my problem.
Cheers!

Re: Sampling rate

Posted: Tue Jul 03, 2018 7:57 am
by odroid
Try the latest firmware v1.4 for UART access.
viewtopic.php?f=86&t=30870#p224167
https://wiki.odroid.com/accessory/power ... ousb_cable

BTW, could you build the SmartPower2 firmware?
https://wiki.odroid.com/accessory/power ... d_firmware
If yes, we will try to let you know which code should be changed to adjust the sample rate.

Re: Sampling rate

Posted: Tue Jul 03, 2018 12:34 pm
by Memo
I believe so, given that I use Ubuntu 16 LTS.

But before I get to that, I need to consider my alternatives regarding sampling rate and achievable accuracy. Could you clarify how accurate the energy consumption metric is, and how high I can get the sampling rate without sacrificing accuracy?

Thank you.

Re: Sampling rate

Posted: Tue Jul 03, 2018 2:03 pm
by odroid
Read the INA231 datasheet page 14 and let me know your estimated error rate in 20Hz(~4.7ms) sampling rate.
http://www.ti.com/lit/ds/symlink/ina231.pdf

Re: Sampling rate

Posted: Thu May 16, 2019 1:00 am
by raditya160053
odroid wrote:
Tue Jul 03, 2018 7:57 am
Try the latest firmware v1.4 for UART access.
viewtopic.php?f=86&t=30870#p224167
https://wiki.odroid.com/accessory/power ... ousb_cable

BTW, could you build the SmartPower2 firmware?
https://wiki.odroid.com/accessory/power ... d_firmware
If yes, we will try to let you know which code should be changed to adjust the sample rate.
Hi, I already have v1.4 firmware on my smartpower 2, but I'm not able to build the firmware using platformio.
I downloaded the firmware from github, but on github they only have v1.1. I created an issue for this on the platformio community forum as well: https://community.platformio.org/t/floa ... umped/7797

Please let me know how I can fix that and how I can increase the sampling rate.

Re: Sampling rate

Posted: Thu May 16, 2019 6:30 pm
by lsc1117
I have uploaded the v1.4 firmware.
https://github.com/hardkernel/smartpower2/releases

And because of the build issue, we changed the build platform from "platformio" to "Arduino IDE".
You should get a new arduino branch for building on Arduino IDE. The folder structure has changed slightly.
https://github.com/hardkernel/smartpower2

Please refer this wiki page.
https://wiki.odroid.com/accessory/power ... d_firmware

Re: Sampling rate

Posted: Fri May 17, 2019 5:00 am
by raditya160053
Hi @lsc1117, I tried it with the instructions above and it's working, I'm able to build and upload it. Thanks for that.
I'll make a complete report about how to increase the sampling rate for smartpower2 and post it here.

Thanks a lot!

Re: Sampling rate

Posted: Fri May 17, 2019 4:56 pm
by lsc1117
You can also use the platformio now.

We fixed the build_flags parameter on smartpower2 v1.5.
https://github.com/hardkernel/smartpowe ... 1c9bf58f63

Re: Sampling rate

Posted: Wed Jun 12, 2019 8:16 am
by odroidpower
raditya160053 wrote:
Fri May 17, 2019 5:00 am
Hi @lsc1117, I tried it with the instructions above and it's working, I'm able to build and upload it. Thanks for that.
I'll make a complete report about how to increase the sampling rate for smartpower2 and post it here.

Thanks a lot!
Hi any updates on the complete report on how to change the sampling rate?

I plan on doing the same, but with an Android OS. I saw in the wiki something that says it doesn't work with anything newer than Android 2.2?
All of the Android images are 4.4 +

Re: Sampling rate

Posted: Wed Jun 12, 2019 11:39 am
by raditya160053
odroidpower wrote:
Wed Jun 12, 2019 8:16 am
raditya160053 wrote:
Fri May 17, 2019 5:00 am
Hi @lsc1117, I tried it with the instructions above and it's working, I'm able to build and upload it. Thanks for that.
I'll make a complete report about how to increase the sampling rate for smartpower2 and post it here.

Thanks a lot!
Hi any updates on the complete report on how to change the sampling rate?

I plan on doing the same, but with an Android OS. I saw in the wiki something that says it doesn't work with anything newer than Android 2.2?
All of the Android images are 4.4 +
Hi, the report will take a little longer still. but for smartpower2 with ubuntu, I just cloned their update firmware(v1.4) code, changed one line that corresponds to time/frequency

Code: Select all

timerId = timer.setInterval(1, handler);
1 here means, sampling every 1 ms(by default it is 1000).
after the change I built it in arduino IDE and uploaded it to the smartpower2 via USB cable.
Instructions to upload firmware are given here: https://wiki.odroid.com/accessory/power ... rduino_ide

Re: Sampling rate

Posted: Mon Jul 01, 2019 8:46 pm
by odroidpower
Encountered trouble using MacOS, using v1.5 and all files from the instructions.

Downloaded Arduino IDE according to the instructions at https://wiki.odroid.com/accessory/power ... d_firmware
Only step I wasn't able to replicate is getting the “ESP8266 Sketch Data Upload” after the program restart. It just doesn't appear.

Tried uploading the firmware using platformio using "sudo platformio run --target upload", but got an error after Looking for upload port, saying "Error: Please specify `upload_port` for environment or use global `--upload-port` option." Used lsusb and the host detects the SmartPower2.

Any thoughts?

Re: Sampling rate

Posted: Tue Jul 02, 2019 7:12 pm
by odroidpower
Wasn't able to get it work on Mac, but switched over to my PC (Windows10) and was able to get it to work using the Arduino IDE, with SmartPower2 v1.5
Tips:
Follow the guide at https://wiki.odroid.com/accessory/power ... d_firmware

I made sure to install the correct drivers from https://www.silabs.com/products/develop ... cp-drivers

I set my sketchbook location as the smart-power2 v1.5 directory with all the files. I moved the files in the libraries directory in the smartpower2-1.5-arduino directory (with all the libraries) into the highest level libraries directory. That got rid of the "WebSockets.h file not found, xxx.h file not found, etc" errors.

Still wasn't able to get "ESP8266 Sketch Data Upload" to appear, even after restarting Arduino, so I just clicked upload. It worked, with the sample rate increasing, BUT wifi didn't work anymore. Solution was to redownload the ESP8266 uploader files at https://github.com/esp8266/arduino-esp8 ... 8266FS.zip
I replaced the files in the ESP8266FS directory in the tools directory of the smartpower2-1.5-arduino with the newly dowloaded ESP8266FS. Reflashed it, and it worked! (faster sample rate plus wifi working)!

Hopefully this can help someone, because 1 sample per second is way too slow for any academic purposes.

Re: Sampling rate

Posted: Thu Sep 19, 2019 6:25 am
by Skylar
Hi,

I was wondering will the smart power2 sample rate be able to increase to 100Hz?
Also what is the resolution for the measurement of voltage, current, and watts?
I have XU4 and I am trying to measure the energy waste while running the benchmark applications,
so I am still debating if I should get smart power 2 or not..
Thank you!

Re: Sampling rate

Posted: Fri Sep 20, 2019 11:41 am
by lsc1117
@Skylar

According to the http://www.ti.com/lit/ds/symlink/ina231.pdf page 5, the resolution of the ADC native is 16bit.
And you can increase the conversion time by setting the "CT bit".

You need to modify a configuration register that setting the CT bit.
https://github.com/hardkernel/smartpowe ... pp#L76-L77
In that code, the CT bit is "b111", if you chagne the bits to "b100", then the conversion time is 1.1ms.

I think, for the 100Hz you should remove other some code in the loop.
There are some bottleneck in that loop because of web APIs.

Re: Sampling rate

Posted: Fri Sep 20, 2019 1:31 pm
by Skylar
@lsc1117

Thank you for sharing the information.
Just to be more clarify, the circuit itself can reach 100 Hz by removing some codes in the loop,
but is there a Microcontroller that will limit the sample rate while transferring the data to the monitor?
What I am trying to say is that will we be able to see the measurement with sample rate 100 Hz on the monitor?
Thanks in advance :)

Re: Sampling rate

Posted: Fri Sep 20, 2019 4:38 pm
by lsc1117
Assuming the code is optimized for the 100Hz, there is no limit to transfer the data.
The I2C clock speed is 100 kHz at maximum. And the uart bandwidth also is okay.

Re: Sampling rate

Posted: Sun Oct 13, 2019 3:21 am
by ytrikoz
By increasing the speed and decreasing the averaging of the sampling, the accuracy decreases, even taking readings once per second, I am sure further 2 digits that the accuracy is no more than fluctuations and does not make sense.
Power is finite calculated by internal registers and will also depend on this.
I thought reducing the sampling time would only worsen the accuracy of the power change.
If you have reason to think otherwise, I can try to change according to your request, or rather, put this in the settings. What parameters would you like to control?