The contributors are listed in CONTRIB.TXT. This project uses the GPL v3 license, see LICENSE.TXT. EEZ psu-firmware uses the C4.1 (Collective Code Construction Contract) process for contributions. To report an issue, use the EEZ psu-firmware issue tracker.
If you consider to join us in software development please check first if anything from this list you found interesting.
This project has Arduino/Genuino sketch for Mega2560 (8-bit, AVR) (not supported in M3 and newer releases!) and Due (32-bit, ARM) boards and accompanying libraries for the open hardware EEZ H24005 power supply firmware.
The unique feature of this project is a fully featured software simulator that can be used to evaluate all firmware features without having physical power supply on disposal. The simulator can be complied to run on major platforms such as Windows, Linux or Mac. It shares all the code with the Arduino Sketch plus emulation layer for the Arduino API, Ethernet library and digital controls used for programming and monitoring power supply.
Firmware key features:
- SCPI 1999.0 command set for remote control over Serial (via USB) and TCP
- Multiple Power channels profiles
- Voltage, current and power settings and continous monitoring
- Voltage and current calibration
- Tracking and coupling (series, parallel) mode
- Programming lists of voltage, current and dwell time
- Incremental encoder
- Multiple input modes using touchscreen (keypad, step, slider)
- Multiple presentation modes (numeric, bar graphs, YT view)
- Various protection mechanisms: OVP (Over Voltage Protection), OCP (Over Current Protection), OPP (Over Power Protection) and OTP (Over Temperature Protection)
- System date and time (RTC, NTP)
- EEPROM based storage for device configuration, calibration parameters and 10 user profiles
- Local GUI control using TFT touch display
- SD card support
We recommend Arduino IDE version 1.6.x or newer to compile and deploy Arduino sketch to the EEZ bench power supply.
- Download zip archive from the github repository.
- Copy folders
eez_psu_sketch
andlibraries
from the zip archive into Arduino folder on your computer. Arduino folder is e.g.My Documents\Arduino
on Windows orDocuments/Arduino
on Linux and Mac. - Download Ethernet2 library from here and copy it to the
libraries
folder. - Download SdFat library from here and copy it to the
libraries
folder. - Open
eez_psu_sketch.ino
in Arduino IDE. - Go to
Tools->Board
and selectArduino Due (Native USB Port)
. IfArduino Due (Native USB Port)
is not present in the list of boards then go toTools->Board->Boards Manager
and click onArduino SAM Boards
then click on the Install button. When install is done close the Board Manager then go toTools->Board
and selectArduino Due (Native USB Port)
. - Plug a USB cable between the PSU and your PC then go to
Tools->Port
and select the COM port for your PSU. - Check if everything is correct with Verify button.
- Make sure that Verify after code upload option is not set (more details here) in File... Preferences and upload the sketch using Upload button.
- Remote control can be accessed via Telnet client such as putty (connection type: raw, port: 5025) or serial client that comes with Arduino IDE or any other you like.
Here we will explain how to build simulator from source code on Windows, Linux and Mac.
If you are on Windows, there is a pre-build version:
After you build and run simulator, a mouse is used as simulation of finger on the TFT touchscreen display.
Console window can be used to enter SCPI commands SCPI reference manual. SCPI commands can be also send by starting a telnet session to the port 5025:
telnet localhost 5025
To build simulator from the source code you need Visual Studio 2015. You can use Community Edition which is a free version of Visual Studio 2015. Visual Studio solution for the simulator is in simulator\\platform\\Win32\\eez_psu_sim.sln
. Open solution then build and execute simulator with F5
.
Here are the steps to build simulator on Linux:
sudo apt-get install -y git libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev
git clone https://github.com/eez-open/psu-firmware
cd psu-firmware/simulator/platform/linux/
make
Start simulator with:
./eez_psu_sim
Just as in case of Arduino sketch mentioned above that runs on real hardware you can access simulator using telnet client (use localhost or 127.0.0.1 for connection).
Mac users will require Brew for building. If you don't have it you can download and install it from here.
Here are the steps to build simulator on Mac:
brew install sdl2 sdl2_image sdl2_ttf
git clone https://github.com/eez-open/psu-firmware
cd psu-firmware/simulator/platform/linux/
make
Start simulator with:
./eez_psu_sim
Just as in case of Arduino sketch mentioned above that runs on real hardware you can access simulator using telnet client (use localhost or 127.0.0.1 for connection).
EEZ bench power supply sketch source code can be divided into following layers:
-
Board
Talks directly to the hardware, i.e. Arduino Shield +BP module (EEPROM, RTC, Ethernet, TLC5925) and post-regulators (ADC, DAC, IO Expander). Part of this layer is eez_psu_lib, a small Arduino library with definition of all pins used by EEZ bench power supply. This layer depends on Arduino platform API and third party UIPEthernet library.
-
Core
Implementation of EEZ bench power supply firmware functionality, for example Channel abstraction. It doesn't work directly with the hardware but uses the board layer, so it doesn't depends on Arduino platform API.
-
Control
This layer is using Core layer to implement local and remote control.
Local control is GUI based using TFT touch display. Special tool was developed to assist creation of GUI interface. This layer depends on third party library (UTFT_Pro derived from Rinky-Dink Electronics UTFT) that we use to draw graphical primitives.
Remote control is based on SCPI protocol. Check SCPI reference manual for available commands. This layer depends on third party scpi-parser library.
Additionally, simulator introduces two additional layers:
-
Simulator Emulation Layer
This layer is simulator's replacement for the Arduino platform and consists of:
- Arduino platform API emulation.
- SPI peripherals emulation.
- UIPEthernet library emulation.
-
GUI Front Panel
Communication between layers is unidirectional with some exceptions:
-
Ethernet and Serial to SCPI.
This is used to feed SCPI with the input received on serial and TCP port.
-
IO Expander to Core.
IO Expander interrupt handler sends GPIO register and ADC snapshot to the Core layer.
Here are the components of the board layer (all the files are in eez_psu_sketch
folder):
- Arduino shield
- Board (
board.cpp
andboard.h
)- Post-regulator (power channel) power up and down
- LED's: CV and CC
- BP (
bp.cpp
andbp.h
)- LED's: standby, output and sense
- Buzzer (
buzzer.cpp
andbuzzer.h
)- sound tone(frequency, duration) function
- EEPROM (
eeprom.cpp
andeeprom.h
)- read and write
- Ethernet (
ethernet.cpp
andethernet.h
)- SCPI over TCP server on port 5025
- Requires third party library UIPEthernet or Ethernet2
- RTC (
rtc.cpp
andrtc.h
)- system date and time
- Serial (
serial_psu.cpp
andserial_psu.h
)- SCPI over Serial
- Debug output
- Temp. sensors (
temp_sensor.cpp
andtemp_sensor.h
)- MAIN temp. sensor read over analog pin
- FAN control
- Board (
- Post-regulator (power supply channel)
- ADC (
adc.cpp
andadc.h
)- Channel's ADC
- DAC (
dac.cpp
anddac.h
)- Channel's DAC
- IOExp (
ioexp.cpp
andioexp.h
)- ADC interrupt
- DP (down-programmer) disable
- CC (Constant current) and CV (Constant voltage)
- PWRGOOD
- OE (output enable)
- ADC (
Arduino library eez_psu_lib
is also a part of the board layer and it is located in libraries\eez_psu_lib
folder.
Here are some components of the core layer (all the files are in eez_psu_sketch
folder):
- PSU (
psu.cpp
andpsu.h
)- power up
- power down (stand-by mode)
- reset
- test
- Update device related SCPI registers
- Channel (
channel.cpp
andchannel.h
)- set voltage and current
- measure voltage and current
- apply calibration parameters
- output enable/disable
- remote sensing enable/disable
- DP enable/disable
- OVP, OCP and OPP
- Update channel related SCPI registers
- Calibration (
calibration.cpp
andcalibration.h
)- Calibration procedure
- Profile (
profile.cpp
andprofile.h
)- Save
- Recall
- Temperature (
temperature.cpp
andtemperature.h
)- OTP
- Measurement
- Date and time (
datetime.cpp
anddatetime.h
)- Set system datetime
- Check the validity of datetime
- Store datetime persistently in EEPROM
- Debug (
debug.cpp
anddebug.h
)- Debugging helper functions
- Util (
util.cpp
andutil.h
)- Miscellaneous functions
- Sound (
sound.cpp
andsound.h
)- Beep
- Power up and power down (stand-by) tunes
- Persistent configuration (
persist_conf.cpp
andpersist_conf.h
)- Store/restore persistent configuration
Implementation of the GUI is based on MVC (Model View Controller) architecture.
In MVC architecture, Model is where all the data that is displayed on the screen comes from and our Model is implemented in the Core layer.
View defines how everything looks on the screen. In our case, View is defined declaratively and definitions are created with the special tool we call EEZ Studio (it is not public yet!).
This tool creates JSON based eez-project file which contains definitions of GUI pages, styles, bitmaps and fonts along with data and action definitions.
JSON file is then compiled to C++ source code files (gui_document.cpp
, gui_document.h
, actions.cpp
and actions.h
)
that are included as an integral part of the sketch.
Controller is the glue code between Model and View. It is implemented in the all the files that start with "gui_" prefix.
Also, there is some utility code that is used, for example, to interact with the hardware:
lcd.cpp
,lcd.h
and UTFT_Pro is used to draw graphical primitives on the screen.touch.cpp
andtouch.h
is used to get data from the touch hardware. Input from the touch hardware is filtered usingtouch_filter.cpp
andtouch_filter.h
- check this and this video.font.cpp
andfont.h
is used to to access font definitions created with EEZ Studio.
We are using third party SCPI parser and have our own branch where command definitions could be in AVR PROGMEM that helps preserve some memory space when Arduino Mega board is used (check avr_progmem branch).
There are two entry points for the SCPI commands: serial port and TCP server. Check serial_psu.cpp
and serial_psu.h
to see how SCPI commands are received on serial port, and ethernet.cpp
and ethernet.h
for the TCP server.
Files scpi_psu.cpp
and scpi_psu.h
are about SCPI parser initialization and input handling.
Also, here is defined the scpi_psu_t structure for storing SCPI parser context data specific to EEZ bench power supply.
Parameter types that are repeatedly used in multiple commands (like channel number) are handled in scpi_params.cpp
and scpi_params.h
.
Registers are set/get in scpi_params.cpp
and scpi_params.h
.
All other files that starts with scpi_
in eez_psu_sketch/
directory are about implementing various SCPI commands. Every SCPI subsystem (like APPLy, SOURce, MEASure, SYSTem, etc.) has its own pair of scpi_.cpp and scpi_.h files.
We emulate only what we use:
pinMode
,digitalRead
,digitalWrite
,analogRead
,analogWrite
digitalPinToInterrupt
,attachInterrupt
tone
millis
,micros
,delay
,delayMicroseconds
Serial
SPI
Check the files Arduino.h
, arduino_impl.cpp
, arduino_impl.h
, SPI.h
from the simulator\src\arduino
folder.
For the tone
function we have two different implementations:
- for the Win32 platform in file
simulator\platform\win32\eez_psu_sim\tone.cpp
- and for the Linux and Mac platform in file
simulator\platform\linux\src\tone.cpp
The following devices are controlled via SPI bus:
- ADS1120 for 15-bit ADC
- DAC8552 for 16-bit DAC
- MCP23S08 for I/O 8-bit Expander or 16-bit expander (MCP23S17)
- ENC28J60 and W5500 for Ethernet
- AT25256B for 256kb EEPROM
- PCA21125 for RTC
- TLC5925 for BP (Binding Posts) option
These peripherals are emulated in simulator, check the files chips.cpp
and chips.h
in simulator/src/chips
.
UIPEthernet library interface is defined in files UIPClient.h
, UIPEthernet.h
and UIPServer.h
; this interface is is implemented in file uipethernet_impl.cpp and this implementation is based on platform interface defined in ethernet_platform.h. There are two implementations of this platform interface:
- for the Win32 platform in file
simulator\platform\win32\eez_psu_sim\ethernet_win32.cpp
- and for the Linux and Mac platform in file
simulator\platform\linux\src\ethernet_linux.cpp
Implementation files are in simulator/src/front_panel
.
Implementation is using eez_imgui
dynamic library.
This library is dynamically loaded at runtime, so that simulator can run even if this library is missing (check the simulator/src/dll.h
for platform independent dynamic library loading).
eez_imgui
library is very simple immediate mode GUI library that supports top level window with following widgets:
- Image
- On/off image (displays different images depending on boolean flag)
- Text
- Button