Sampling rate

Post Reply
Memo
Posts: 2
Joined: Tue Jul 03, 2018 2:07 am
languages_spoken: english,brazilian-portuguese
ODROIDs: XU4
Has thanked: 0
Been thanked: 0
Contact:

Sampling rate

Unread post by Memo » Tue Jul 03, 2018 2:14 am

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!

User avatar
odroid
Site Admin
Posts: 32540
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 186 times
Been thanked: 350 times
Contact:

Re: Sampling rate

Unread post by odroid » 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.

Memo
Posts: 2
Joined: Tue Jul 03, 2018 2:07 am
languages_spoken: english,brazilian-portuguese
ODROIDs: XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: Sampling rate

Unread post by Memo » Tue Jul 03, 2018 12:34 pm

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.

User avatar
odroid
Site Admin
Posts: 32540
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 186 times
Been thanked: 350 times
Contact:

Re: Sampling rate

Unread post by odroid » Tue Jul 03, 2018 2:03 pm

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

raditya160053
Posts: 10
Joined: Wed May 15, 2019 7:02 am
languages_spoken: english
ODROIDs: Odroid XU4, SmartPower2
Has thanked: 3 times
Been thanked: 0
Contact:

Re: Sampling rate

Unread post by raditya160053 » Thu May 16, 2019 1:00 am

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.

lsc1117
Posts: 161
Joined: Thu Aug 22, 2013 12:46 am
languages_spoken: english
Location: South Korea
Has thanked: 0
Been thanked: 9 times
Contact:

Re: Sampling rate

Unread post by lsc1117 » Thu May 16, 2019 6:30 pm

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

raditya160053
Posts: 10
Joined: Wed May 15, 2019 7:02 am
languages_spoken: english
ODROIDs: Odroid XU4, SmartPower2
Has thanked: 3 times
Been thanked: 0
Contact:

Re: Sampling rate

Unread post by raditya160053 » 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!

lsc1117
Posts: 161
Joined: Thu Aug 22, 2013 12:46 am
languages_spoken: english
Location: South Korea
Has thanked: 0
Been thanked: 9 times
Contact:

Re: Sampling rate

Unread post by lsc1117 » Fri May 17, 2019 4:56 pm

You can also use the platformio now.

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

odroidpower
Posts: 3
Joined: Wed Jun 12, 2019 8:13 am
languages_spoken: english
ODROIDs: ODROID-XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: Sampling rate

Unread post by odroidpower » 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 +

raditya160053
Posts: 10
Joined: Wed May 15, 2019 7:02 am
languages_spoken: english
ODROIDs: Odroid XU4, SmartPower2
Has thanked: 3 times
Been thanked: 0
Contact:

Re: Sampling rate

Unread post by raditya160053 » Wed Jun 12, 2019 11:39 am

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

odroidpower
Posts: 3
Joined: Wed Jun 12, 2019 8:13 am
languages_spoken: english
ODROIDs: ODROID-XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: Sampling rate

Unread post by odroidpower » Mon Jul 01, 2019 8:46 pm

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?

odroidpower
Posts: 3
Joined: Wed Jun 12, 2019 8:13 am
languages_spoken: english
ODROIDs: ODROID-XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: Sampling rate

Unread post by odroidpower » Tue Jul 02, 2019 7:12 pm

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.

Skylar
Posts: 4
Joined: Wed Sep 18, 2019 2:36 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: Sampling rate

Unread post by Skylar » Thu Sep 19, 2019 6:25 am

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!

lsc1117
Posts: 161
Joined: Thu Aug 22, 2013 12:46 am
languages_spoken: english
Location: South Korea
Has thanked: 0
Been thanked: 9 times
Contact:

Re: Sampling rate

Unread post by lsc1117 » Fri Sep 20, 2019 11:41 am

@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.

Skylar
Posts: 4
Joined: Wed Sep 18, 2019 2:36 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: Sampling rate

Unread post by Skylar » Fri Sep 20, 2019 1:31 pm

@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 :)

lsc1117
Posts: 161
Joined: Thu Aug 22, 2013 12:46 am
languages_spoken: english
Location: South Korea
Has thanked: 0
Been thanked: 9 times
Contact:

Re: Sampling rate

Unread post by lsc1117 » Fri Sep 20, 2019 4:38 pm

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.

ytrikoz
Posts: 45
Joined: Mon Jun 17, 2019 9:06 pm
languages_spoken: russian, english
ODROIDs: XU-4, CloudShell2, SmartPower2
Has thanked: 3 times
Been thanked: 9 times
Contact:

Re: Sampling rate

Unread post by ytrikoz » Sun Oct 13, 2019 3:21 am

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?

Post Reply

Return to “Smart Power”

Who is online

Users browsing this forum: No registered users and 0 guests