element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Experimenting with Supercapacitors
  • Challenges & Projects
  • Design Challenges
  • Experimenting with Supercapacitors
  • More
  • Cancel
Experimenting with Supercapacitors
Blog Supercapacitor energy storage system - extra credit blog 3 ([another] capacitance meter)
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Experimenting with Supercapacitors to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: JWx
  • Date Created: 11 Sep 2023 3:03 PM Date Created
  • Views 859 views
  • Likes 9 likes
  • Comments 5 comments
  • experimenting with supercapacitors
  • octave
  • arduino
Related
Recommended

Supercapacitor energy storage system - extra credit blog 3 ([another] capacitance meter)

JWx
JWx
11 Sep 2023
Supercapacitor energy storage system - extra credit blog 3 ([another] capacitance meter)

Inspired by the recent E14 LabView RoadTest I have decided to test Octave (open source Matlab replacement) Arduino integration for capacitor measurement.

Having obtained LattePanda v.1 during previous design challenge, I have decided to use it for this project. Theoretically, it is ideal candidate as it has Arduino board integrated with Intel Atom based SBC.

It is some sort of trade-off of course - main board has limited performance (using low-powered Intel Atom CPU) and using integrated Arduino Leonardo board raises cost of possible damage: standalone Arduino can be cheaply replaced, but damage to the builtin Arduino is not easy to repair.

Considering this I have decided to use hybrid approach at first - using Panda with external Arduino Uno. This way, if something happens to the board during development, it can be easily replaced, with the option to use integrated Arduino Leonardo when design stabilizes.

From the state described in "Experimenting with Waterproof Connectors" I have upgraded installed Ubuntu Linux all the way to 22.04 LTS (long time support version), that has gone seamless until the last step: upgrade from 20.04 to 22.04, when - it seems - refusal of upgrade process to upgrade kernel version have made my SBC unbootable (kernel was not seeing proper initrd file and system was not starting). Booting from rescue media and manually installing current kernel have resolved the issue. There is still problem with local X11 login (introduced during first upgrade - from 16.04 to 18.04), but as I am doing X11 forwarding through ssh sessions (and not logging in into GUI using local terminal) it has low priority for now.

As X11 server for MS Windows I am using MobaXterm - I find it a much better choice to - for example - Cygwin: it is portable, standalone application, not installing all sort of stuff to the machine. Screenshot below shows X11 forwarding using mobaXterm - after connecting using SSH, GUI applications (in this example - xterm) can be directly executed and they are displayed in separate windows on local machine (no need to forward full desktop as in - for example - VNC).

mobaxterm

To get Octave from official Ubuntu repositories one can issue following command (logging as root or execting sudo -s first to get access to the root shell):

#apt-get install octave octave-arduino octave-optim

This command installs Octave v. 6.4 - slightly dated but working better for my purpose than brand new 8.3 - that for some reason stops recognizing Arduino board after each script run, forcing manual reconnection on my MS Windows laptop.

Octave can be started in GUI mode (it defaults to the CLI when started without parameters in my setup) using following command:

#octave --force-gui&

Now it is time to prepare Arduino board for use by programming it with required code.

Full documentation of Arduino integration for Octave can be found at https://wiki.octave.org/Arduino_package

To flash Arduino board with correct firmware one can issue from inside Octave command prompt following command:

>>arduinosetup

which starts locally installed Arduino IDE with required stretch. One is supposed to select a connected (and supported by the software) Arduino board, then flash it, but first an additional library needs to be installed (compilation will fail without downloading and installing Servo library from within Arduino IDE).

When flashing is finished, Arduino is accessible from Octave and can be used as data source.

For example, using following schematics (where relay is in fact relay module for arduino - complete with overvoltage protection diode and a driving circuit)

arduino schematics

and Octave script like below

pkg load arduino
ar = arduino;

switch_pin="D7"
input_pin= "A2"
power_pin="A3"
step=0.1
iterations = 500

[...]

#read supply voltage

power_voltage = readVoltage(ar, power_pin)

in = readVoltage(ar, "A2");

#switch to charging mode
writeDigitalPin(ar, switch_pin, 0);
tic();

#charging cycle

while (i < iterations)
  in = readVoltage(ar, "A2");
  t2=toc();
  if in < power_voltage * 0.632
    t_ch = t2;
    v_ch = in;
  endif
  data_chr = [data_chr, in];
  x1_axis = [x1_axis, t2];
  pause (step);
  i = i + 1;
endwhile

[...]

plot(x1_axis, data_chr, x2_axis, data_dis);

one can get charge/discharge plots of capacitor (like below), giving foundation for more advanced experiments.

charging_voltage_plot

  • Sign in to reply
  • JWx
    JWx over 1 year ago in reply to dougw

    but - free!!!! as in speech and as in beer...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 1 year ago

    GNU Octave - somewhat similar to and somewhat compatible with Matlab

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 1 year ago

    Cool. Now I have to check out Octave.....

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • JWx
    JWx over 1 year ago in reply to michaelkellett

    it is really simple now but not as fast as one would wish - I will try to show it in the next part, showing more advanced use case...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • michaelkellett
    michaelkellett over 1 year ago

    Good stuff. I haven't used/looked at Octave for ages.

    It's quite fun that it can poke at the Arduino so easily.

    I'm inspired to have a go when I get  a moment.

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube