Work in progress

 

Node-RED is a free and open source flow based programming tool for event-driven applications that provides a browser-based editor that makes it easy to wire together program flows using the wide range of predefined nodes that perform a specific action.

The integration of EEZ BB3 with Node-RED allows the creation of complex automation tasks quickly and without the need for common procedural programming. This makes this solution suitable for use in ATE environments for benchtop development, lab testing automation or manufacturing floor quality assurance.

An additional advantage of this combination is that it is end-to-end open source and cross-platform which facilitates deployment in different environments and facilitates the sharing of test procedures.

Node-RED also includes support for Git which further simplifies team development and sharing.

This chapter will describe how to install Node-RED and a simple flow example to automate relay contact testing. The flow used is available at https://github.com/eez-open/node-red-relay-loop-test

17.1. Node-RED installation

Unlike the MicroPython integration described in the Scripting with MicroPython chapter where the MicroPython script is executed autonomously on EEZ BB3, in the case of Node-RED you will need to have a computer on which to execute it. To communicate with EEZ BB3 it will be necessary to establish a connection via the Ethernet interface. For this reason, it will be necessary to install Node-RED first.

Details of the installation can be found on the official Node-RED website at the following link https://nodered.org/docs/getting-started/local

In short, the installation can be summarized in the following few steps:

1

Node-RED requires a supported version of NodeJS.

Download and install NodeJS for your operating system available at https://nodejs.org/en/download/

 

2

Open a terminal application (in Windows this is called the Command prompt) and start the Node-RED installation with the following command:

npm install -g --unsafe-perm node-red

Linux users requires root privileges, therefore the command has to include sudo:

sudo npm install -g --unsafe-perm node-red

The same command can be used later to upgrade Node-RED to the latest version.

 

3

The same procedure is needed to install the Node-RED dashboard. Windows user need to enter the following command:

npm install node-red-dashboard

On Linux system enter:

sudo npm install node-red-dashboard

4

Run the following command to ensure Node.js and npm are installed correctly:

node --version && npm –version

In response, you will receive versions number similar to:

v12.19.0

6.14.8

 

17.2. Node-RED running

Node-RED is also started from the terminal (command prompt). To start enter:

node-red

Note that the terminal in which you started Node-RED must be active at all times for normal operation. If you want to exit, first press Ctrl + C and wait for the prompt to appear. You can then close the terminal application or run Node-RED again.

 

Welcome text similar to the one shown below will appear on Linux:

 

bb3_man_node-red_started.png

 

Node-RED will also display the log of its activities in the terminal. The log output at the beginning provides information such as:

  • The versions of Node-RED and Node.js
  • Any errors hit when it tried to load the palette nodes
  • The location of Settings file and User Directory
  • The name of the flows file it is using, etc.

The first time you run node-RED on Windows, a firewall warning will appear. Confirm default settings by selecting the Allow access option.

 

bb3_man_node-red_firewall.png

 

The Node-RED editor can be accessed using an internet browser by typing

 

http://localhost:1880 or http://127.0.0.1:1880

 

bb3_man_node-red_editor.png

 

The Node-RED editor will be available at the same address if we add/ui to the end, i.e.

 

http://localhost:1880/ui or http://127.0.0.1:1880/ui

 

bb3_man_node-red_dashboard.png

 

Please note that, by default, the Node-RED editor is not secured – anyone who can access its IP address can access the editor and deploy changes.

This will not be a problem as long as everything is running on local and trusted network.

For more details on how to secure Node-RED editor and dashboard visit: https://nodered.org/docs/user-guide/runtime/securing-node-red

 

17.3. Working with projects

On the Node-RED official website, projects are presented as a new way to manage flow files. Rather than treat flows as a simple pair of files, they represent everything you need to create a redistributable Node-RED application.

It is important to know that projects are backed by a Git repository, meaning all of the files are fully version controlled and allow developers to use familiar workflows to collaborate with others.

Working with projects is not enabled by default and this is possible primarily because the git is required to be installed. Information about this can be seen when starting Node-RED:

 

bb3_man_node-red_project_off.png

 

To enable projects it will be necessary to install git first. Git is also free and open source and can be downloaded from https://git-scm.com/downloads.

More information about the installation is available at https://git-scm.com/book/en/v2/Getting-Started-Installing-Git.

 

Close Node-RED before starting the Git installation.

 

For Ubuntu, this PPA provides the latest stable upstream Git version:

sudo add-apt-repository ppa:git-core/ppa

sudo apt update

sudo apt install git

In the case of Windows, you will need to download the installation and run the installation wizard. In principle, you can proceed to confirm all the default options. However, there is a possibility that after installing git you will not be able to run from the command prompt (because its location is not added to the PATH environment variable). If this happens you will need to reinstall Git and select the following option in the Adjusting your PATH environment step:

 

bb3_man_git_win_install.png

 

To check that the git is installed and can be run (i.e. that in the case of Windows the PATH environment variable is correctly modified) it will be enough to type in the command line:

git

The final step to enabling projects is to modify the Node-RED settings.js configuration file.

The location of this file on linux is in the user home folder in the .node-red subfolder. Therefore you can use the following command:

cd ~/.node-red

It's similar with Windows: look for it in Users\<user name>\.Node-red

In the editorTheme:projects:enabled section within the module.exports block, it is necessary to replace false with true:

// Customising the editor

editorTheme: {

projects: {

// To enable the Projects feature, set this value to true

enabled: true

After saving the change, run Node-RED once again and this time the following dialog will appear in the Node-RED editor (at 127.0.0.1:1880):

 

bb3_man_node-red_project_open.png

 

Now we can start making our test flow. Here, select the Create project option and type relay-loop-test as the project name. An empty workspace will open. The available nodes will be displayed in the list on the left. Since there are a large number of them you can use the Collapse or Expand options at the bottom left. In this case, you can get to the desired node by using the Search field at the top left.

 

bb3_man_node-red_nodes.png

 

bb3_man_node-red_nodes2.png

 

The workspace editor allows you to work with multiple tabs and the first tab is called Flow 1. We can change its name as needed. Let's say we change it to Main. This will require a double click on the tab name (i.e. Flow 1) when a new dialog will open and we can enter a new name.

 

Since Node-RED editor is a web browser application, it will not be able to right-click on any option.

 

bb3_man_flow_rename.png

Fig. 1: Change flow name

17.4. Test scope and features

The scope of this example is to test changing states of one set of relay contacts at the time. The wiring diagram is shown in Fig. . One output from the power module (DCP or DCM) will be used to power the relay coil. A DOUT1 output will be used to test the state change, which will be fed to the DIN1 input via the relay contact. To increase immunity to external interference on DIN1 we will use a pull-down resistor.

 

bb3_man_node-red_wiring_diagram.png

Fig. 2: Wiring diagram

 

The Node-RED dashboard will be used to interact with the test flow in which we want to have the following:

  • Ethernet connection control
  • Module identification in the first slot
  • Setting the relay voltage (D.U.T.) and the break between the two tests
  • Counters for Passed, Failed and Total number of tests
  • Start and stop control and counter deletion
  • Graphical display of results

 

Add a comment

One of the prominent features of BB3 is support for MicroPython scripting. Thanks to MicroPython scripting it will be possible to add new functionality without intervening in the BB3 firmware and compromising its performance. Scripting opens up the possibility of creating a whole range of new applications from tasks to automate the programming of individual peripheral modules, to useful utilities such as various parameter calculators that do not require working with modules at all, but can be useful and at hand.

MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimized to run on MCUs such as STM32 used in BB3. MicroPython aims to be as compatible with normal Python as possible to allow you to transfer code with ease from the desktop to a MCU or embedded system. For more information, visit the official micropython.org website.

This chapter will describe the procedure for creating a front-end GUI, deployment, and running a MicroPython script.

 

16.1. Distinctive features of BB3 MicroPython implementations

In order to avoid misunderstandings and wrong expectations, the specifics of the MicroPython implementation should be explained first.

The implementation of MicroPython often means that MicroPython will take control of all hardware resources and processes. This is not the case with BB3 and it was done on purpose. Execution of the MicroPython script takes place in a separate thread controlled by FreeRTOS and has a lower priority than the main thread that is in charge of all vital system functions. This ensures that a faulty script cannot compromise basic functionality and can be aborted from the main thread.

When the execution of the MicroPython script is complete, its thread goes to sleep until the next call.

Although the lack of direct access to hardware resources from the MicroPython script may seem like a serious limitation, access is still possible but indirectly by using a large number of implemented SCPI commands and queries that cover all important aspects of working with hardware resources of the BB3 chassis and installed peripheral modules.

For this reason, to work effectively with MicroPython scripts, it is recommended to familiarize yourself with the SCPI command set, which is described in the EEZ BB3 SCPI reference guide.

 

The BB3 MicroPython implementation has another distinctive feature, and that is the ability to manage user interaction via a GUI in run time using custom made pages.

The creation of new GUI pages is made possible thanks to the EEZ Studio application, which is also used to create the entire BB3 GUI for the color TFT touch-screen display.

A step-by-step procedure on how to create a simple EEZ Studio project that the MicroPython script will be able to use in run time to interact with the user will be described below.

 

16.2. Sample MicroPython script

As an example of using MicroPython scripting, it will be shown how to create a user form that will appear on the display and through which it will be possible to change the voltage on the first channel of the available power module. The required procedure is divided into three sections: creating an EEZ Studio project, writing a MicroPython script and MicroPython script deployment and execution.

16.2.1. Creating an EEZ Studio project

As a first step, make sure you have the latest version of EEZ Studio, which you can download at https://github.com/eez-open/studio/releases and install it on your computer.

 

bb3_man_mp_open_project.png


Fig. 1: Open new project

 

Start EEZ Studio and select the New Project option from the File menu (Fig. 1). A new window will open displaying the Setting general page as shown in Fig. 2.

 

bb3_man_mp_project_general_page.png

Fig. 2: Newly added project Settings general page

 

General settings contain the following parameters that will need to be defined:

  • Project version – project version number
  • Namespace – not currently used
  • Master project – path to EEZ BB3 master firmware project
  • Project features – determines which features will be used in the project.

Before you define the general parameters of the project, first save it to the desired destination. The extension of the EEZ Studio project is .eez-project and Linux users need to enter the name and extension when saving, in our case it will be Hello World.eez-project. When a project is saved its name will appear instead of untitled in the window header.

 

Now we can define the version of the project, which should be V2. Next, define the path to the master firmware of the project, i.e. to modular-psu-firmware.eez-project which can be found at the following link: https://github.com/eez-open/modular-psu-firmware/blob/master/modular-psu-firmware.eez-project. The easiest way is to copy the master project to the folder where the saved and newly created project is located. Access to the master project is required in order to gain access to styles, color themes and fonts so that the page we will create is in line with other content on the screen.

It remains to define the Project features that will be used to interact via the TFT touch-screen display. Since such interaction is based on the event-driven principle it will be necessary to define the following: GUI layout, allowed actions and data to be exchanged during the action (event). Therefore we need to choose (using Add button) the following three features: GUI, Action and Data.

If we have well defined all the above parameters, the General settings page will look like in Fig. 3.

 

bb3_man_mp_project_general_settings.png

Fig. 3: General settings page with defined project parameters

 

Note that each of the selected Project features has added a new tab on the left side through which it will be possible to access the parameters of the selected feature.

To get the functional page that will be called from the MicroPython script it will be necessary to define the parameters via these three tabs that have appeared.

We will first define the names of the actions. For example, input_voltage to enter the desired output voltage, set_voltage to set the output voltage and close to close the page and stop execution of the MicroPython script. Use the + option to add all above mentioned actions by name, and leave default values of the other action parameters (i.e. Description and Used in). Once the action list is added it should look like in Fig. 4.

 

bb3_man_mp_set_actions.png

Fig. 4: List of defined actions

 

In the next tab we will define the data to be used for the actions. A minimum of three parameters will need to be defined for each data: name, type, and default value. These will be can_set_voltage as Boolean, default 0 (false) and voltage as Float, default 3.0  V. The default value will appear in the GUI item when it is assigned a specific data. Properties of both data are shown in Fig. 5.

 

bb3_man_mp_set_data.png

Fig. 5: Defined project data

 

The GUI section is the most complex and before describing the creation of the page, it is necessary to explain what it contains. The section without any defined page is shown in Fig. 6.

This section is divided into two subsections: Pages (Layouts) and Bitmaps which have corresponding tab icons. In our example, we will not use bitmaps, so that subsection will not be described.

 

This section can also contain other subsections such as Fonts and Styles, however in our example this is not applicable because we chose to inherit the fonts and styles from the master project.

 

Pages (Layouts) consists of the following sections:

  • Pages (Layouts) – a list of names of defined pages
  • Page structure – the tree structure of all widgets used. It can be used to quickly move widgets within a structure
  • Page preview – a central space that has no title, and will get a tab with the name of the page for each selected page. It displays selected page widgets and can be used to select and move one or more selected widgets
  • Properties – displays all parameters of the selected widget
  • Widget palette – a menu with all currently implemented widgets. In our example, we will use the two most commonly used widgets: Container and Text.
  • Themes – color theme list. In our example they are inherited from the master project

The procedure for defining a page is as follows: add a new page, insert the necessary widgets, and assign actions and data to the widgets as needed. We will add a new page using the + option in the Pages (Layouts) section.

 

bb3_man_mp_gui_page_empty.png

Fig. 6: Empty GUI feature section

 

The new items Page will appear and its Properties will be displayed. This will look like Fig. 7 (Checks and Themes sections are minimized for a simplified view). In Properties we can also see that the name is Page and we can change it to something else, say Main for which we will use [...] button at the right of the Name field.

 

We can now start inserting the widgets one by one. To do this, select the widget from the Widgets palette and drag & drop it to the central section (it may or may not be inside the page area since the final coordinates will be defined later).

 

As the first widget we will take one Container which, as its name suggests, is used to contain several other widgets (including other containers) which simplify the organization of widgets and their manipulation.

 

The container may or may not have a defined name, and for its size and position we will use Position and size properties, so we will set:

  • Width204
  • Height90
  • Left138, if we want a container of these dimensions to appear in the middle, but we can also enter here equation like (480 - 204) / 2 since these fields accept basic mathematical operations (480 because it is the width of the page, 204 because it is the chosen width of the container and we divide by 2 to center it).
  • Top75

Note that the Pin to edge, Fix size and Preview options are intended for automatic positioning and have not yet been implemented.

 

We will add a few widgets to this container. Adding a widget to an existing container can be done by dragging it in the desired container into the Page structure tree on the left. When positioning inside a tree structure, make sure that the purple marker is indented under the container to which you want the widget to belong (see Fig. 9).

 

If no container is created, you can select one or more of existing widgets and insert it into the new container that will be created on that occasion. To do this, use the Put in container option from the right mouse button menu.

 

bb3_man_mp_gui_new_page.png

Fig. 7: Newly created GUI page

 

We will add the following widgets to the same container:

  • TextLeft: 0, Top: 0, Width: 84, Height: 40 (Absolute position will become 138, 75)
  • TextLeft: 84, Top: 0, Width: 120, Height: 40 (Absolute position will become 222, 75)
  • ButtonLeft: 84, Top: 50, Width: 120, Height: 40 (Absolute position will become 222, 125)

In addition, we will create another container that will define the status line in which the exit option will appear, for this we will need:

  • ContainerName: Status line, Left: 0, Top: 240, Width: 480, Height: 32 (Absolute position will become 0, 240)
  • TextLeft: 0, Top: 0, Width: 41, Height: 32 (Absolute position will become 0, 240)
  • TextLeft: 41, Top: 0, Width: 439, Height: 32 (Absolute position will become 41, 240)

In the next step, we can define additional widget properties: their Style (i.e. fonts and colors) and Specific properties. Since we have chosen to inherit styles from the master project, only the styles defined there as exportable (i.e. have a defined Id in properties) will be available when [...] button is selected to the right of the Normal style input field. A new window will then open with a list of all available styles as shown in Fig. 10.

Using this option for widgets from the first container we will set the following:

  • TextNormal style: default_M_left, Text: Voltage:
  • TextNormal style: edit_value_active_S_center, Text: (change to blank). The Text property can be left filled with default value (i.e. Text), but in that case the default value of the data that we will associate with that widget (3.0 V) will not be displayed on the page.
  • ButtonNormal style: button_M, Disabled style: button_M_disabled, Text: Set

For the widgets from the 2nd container we will set the following:

  • TextNormal style: status_icon_enabled, Text: E (please note that this style uses an icon font so the letter E is used because the Exit icon corresponds to that position)
  • TextNormal style: status_title, Text: Hello World

 

bb3_man_mp_gui_add_container.png

Fig. 8: Adding container widget

 

If you have done well so far you should have a fully defined page as shown in Fig. 11. It remains to set the action and data on certain widgets which we will do in the next step.

 

First container:

  • Voltage: text widget is informative, and no action is expected on it. Therefore, its Data and Action fields should be left blank.
  • The second text widget will be used to display the existing voltage and set the new voltage value at the CH1 output. For this reason, we will choose voltage for Data, and input_voltage for the Action, which we defined at the very beginning. To select Data and Action, we will use the corresponding [...] options to the right of the Data and actions properties input fields.
  • We will use the Set button widget to confirm the entry and execute the part of the MicroPython script that will set the entered value. We leave the Data blank. As Action we choose set_voltage. This widget has another additional action property and that is Enabled. If there is a criterion during the execution of the MicroPython script that the button is enabled, we will be able to touch it, for which we will select the can_set_voltage from list of actions.

 

bb3_man_mp_gui_add_into_container.png

Fig. 9: Inserting new widget into container

 

Second container:

  • The E text widget will be used to return from this page to the main page, which also means stopping further execution of the MicroPython script so the output voltage will not be set to the new value. For this reason, we will select here close as Action. Data field should be left blank.
  • Hello world text widget is informative, and no action is expected on it. Therefore, its Data and Action fields should be left blank.

This completes the creation of the page to be used to interact with the MicroPython script. All we have to do is write a MicroPython script and deployment to BB3 which will be described below.

 

bb3_man_mp_gui_styles.png

Fig. 10: Inherited Styles selection

 

bb3_man_mp_gui_set_styles.png

Fig. 11: Page view with all widgets and defined styles

 

16.2.2. MicroPython script

EEZ Studio does not currently offer the creation and editing of text files. Therefore, you can use your favorite text editor to write the MicroPython script listed below. The name of the MicroPython file should be Hello world.py to match the name of the EEZ Studio project.

 

Code

Explanation

# Hello, World!

 

The text that will appear as a description of the MicroPython script when displayed on BB3 (see File manager section).

from eez import scpi

 

Include scpi function from eez module

def input_voltage():

global voltage, max_voltage

value = scpi('DISP:INPUT? "",NUMBER,VOLT,0.0,' + str(max_voltage) + '.0,' + str(voltage))

This is the implementation of the input_voltage action defined in the EEZ studio project. When one click on the voltage widget this function will be launched.

 

The SCPI command DIAG:INPUT? opens the input dialog on the screen where voltage can be entered.

if value != None:

voltage = float(value)

scpi('DISP:DIALog:DATA "voltage",FLOAT,VOLT,' + str(voltage))

scpi('DISP:DIALog:DATA "can_set_voltage",INT,1')

 

If voltage is entered then two data items are set: voltage to the entered value and can_set_voltage to 1 which means that voltage is entered and can be set on the channel, which results in the Set button widget being enabled.

def set_voltage():

scpi("INST ch1")

scpi("VOLT " + str(voltage))

 

Select CH1 as set its output voltage.

def main():

global voltage, max_voltage

scpi("INST ch1")

voltage = scpi("VOLT?")

max_voltage = scpi("VOLT? MAX")

Main program loop. SCPI command INST is used to select CH1 on power module and two SCPI queries that return currently set voltage (VOLT?) and max allowed voltage (VOLT? MAX).

scpi("DISP:DIAL:OPEN \"/Scripts/Hello World.res\"")

Invoke Hello World.res file using the DISP:DIAL:OPEN that contains page created in EEZ Studio as discussed above.

try:

scpi('DISP:DIAL:DATA "voltage",FLOAT,VOLT,' + str(voltage))

 

while True:

action = scpi("DISP:DIALog:ACTIon?")

if action == "input_voltage":

input_voltage()

elif action == "set_voltage":

set_voltage()

break

elif action == "close" or action == 0:

break

This is a dispatcher that asks via the SCPI command DISP:DIALOG:ACTION? which action the GUI requires to be performed.

The dispatcher is executed in a loop: when it receives from the GUI which action to perform, it executes it and asks again what the next action is.

If the detected action is close or 0 (this means that the firmware has requested closing the dialog) then the dispatcher loop is broken and goes to finally section described below.

finally:

scpi("DISP:DIAL:CLOS")

 

main()

Execute SCPI command DISP:DIAL:CLOS to close last dialog window opened with the DISP:DIAL:OPEN command.

This section will be also executed in case of an error, i.e. exception.

16.2.3. MicroPython script deployment and execution

Once we are done with the EEZ Studio project and the MicroPython script we are ready for deployment. In order for the page created in EEZ Studio to be used successfully on BB3, it must not contain any errors and should be "compiled". The Check and Build options are used for this, and Fig. 12. shows the result of the Build action in the Output tab. It will create in the same folder where the EEZ Studio project resource file Hello world.res.

 

bb3_man_mp_project_build.png

Fig. 12: EEZ Studio project Check and Build options

 

Hello world.py and Hello world.res files will now need to be downloaded to BB3 in the Scripts folder. We can also use EEZ Studio for this, but its ESW part used to communicate with SCPI instruments such as BB3. The procedure is the same as in the case of the Upgrade peripheral module firmware using GUI on BB3 section in Chapter 13. The download parameters of the MicroPython script are shown in Fig. 13. The same will need to be done for the resource file (Hello world.res ).

 

bb3_man_mp_download.png

Fig. 13: File transfer using EEZ Studio Send File option

 

During execution, if the MicroPython script has an error, a message will appear as in Fig. 14. The show debug trace log option leads to the event log viewer where more details about the error can be found (Fig. 15).

 

bb3_man_mp_error.png

Fig. 14: MicroPython script error message

 

bb3_man_mp_error_details.jpg

Fig. 15: MicroPython script error details in event log

 

The current implementation does not offer a script debugger or the ability to modify the script on the BB3 side. During development, all MicroPython script modifications will need to be made to the computer side and the changes will need to be downloaded as previously shown.

 

16.3. EEZ Python module

In our example the MicroPython script used eez module. The table below contains the names and descriptions of all the functions that the module contains. The current version of the module can be found at:

https://github.com/eez-open/modular-psu-firmware/blob/master/src/third_party/micropython/ports/bb3/mod/eez/README.md

 

For MicroPython references visit: http://docs.micropython.org/en/latest/reference/index.html

 

A list of currently implemented / enabled functions in BB3 firmware can be found at this link:

https://github.com/eez-open/modular-psu-firmware/blob/master/src/third_party/micropython/ports/bb3/mpconfigport.h

 

Function name

Description

eez.scpi(commandOrQuery)

Execute any SCPI command or query. If command is executed, then None is returned. If query is executed, then it returns query result as integer or string.

eez.getU(channelIndex)

Returns measured voltage as float for the given channel index.

 

This is the same as MEASure[:SCALar]:VOLTage[:DC]? query. Use this function instead of SCPI query when performance requirement is critical.

eez.setU(channelIndex, currentLevel)

This function sets the immediate voltage level for the given channel index.

 

It is equal to [SOURce[<n>]]:VOLTage[:LEVel][:IMMediate][:AMPLitude] command. Use this function instead of SCPI command when performance requirement is critical.

eez.getI(channelIndex)

Returns measured current as float for the given channel index.

 

This is the same as MEASure[:SCALar]:CURRent[:DC]? query. Use this function instead of SCPI query when performance requirement is critical.

eez.setI(channelIndex, currentLevel)

This function sets the immediate current level for the given channel index.

 

This is the same as [SOURce[<n>]]:CURRent[:LEVel][:IMMediate][:AMPLitude] command. Use this function instead of SCPI command when performance requirement is critical.

eez.getOutputMode(channelIndex)

For the given channel index, returns:

  • "CV" when channel is in Constant Voltage mode
  • "CC" when channel is in Constant Current mode
  • "UR" when channel is neither in Constant Voltage or Constant Current mode

This is the same as OUTPut:MODE? query. Use this function instead of SCPI query when performance requirement is critical.

eez.dlogTraceData(value, ...)

For current DLOG trace file, this function adds one point in time for each defined Y-axis. It expects one or more value arguments depending of how much Y-axis values are defined for currently started DLOG trace.

 

This is the same as SENSe:DLOG:TRACe[:DATA] command. Use this function instead of SCPI command when performance requirement is critical.

 

16.4. MicroPython script examples

EEZ Studio communicates with SCPI instruments using the so-called IEXT (Instrument EXTension). IEXT for BB3 includes, among other things, several MicroPython scripts that can be easily transferred to BB3, as well as later updated if newer versions of BB3 IEXT include changes to MicroPython scripts. EEZ Studio projects and MicroPython scripts can be found at https://github.com/eez-open/modular-psu-firmware/tree/master/scripts

 

Script name

Description

Curve Tracer

Plot output characteristic for BJTs and MOSFETs

Diode Tester

Determines diode reverse breakdown voltage

Hello World

The script used in the example previously described in this chapter

Module Initialization

EEZ peripheral module initialization utility

Op-Amp Calculator

This calculator helps calculate values of the op-amp configured as inverting, non-inverting or differential amplifier

Parallel and Series Calculator

Calculates parallel resistance/inductance or capacitance is series

Voltage Divider Calculator

This calculator helps calculate values of resistive voltage divider

 

Add a comment

 

Current version

r1B3

Status

Completed, ready for production

PCB manufactured

Yes (r1B2)

PCB assembled

Yes (r1B2)

BOM

Yes (TME, Mouser, Digikey, Farnell, RS)

File repository

https://github.com/eez-open/dib-prel6

(include Eagle, Gerber and BOM files)

License

TAPR v1.0

Contributions

C4.1 (Collective Code Construction Contract)

 

prel6_r1b2.jpg

Fig. 1: PREL6 r1B2

Feature list

  • On-board STM32F030C6T6 ARM Cortex-M0 Value line MCU, 32 KiB Flash, 48 MHz, LQFP-48 package
  • 2 x 16-pin dual row 3.81 mm connectors
  • 4 x SPDT relays, max. 8 A / 230 Vac
  • 2 x SPST relays, max. 8 A / 230 Vac
  • On-board +3.3 V LDO
  • Firmware download via UART
  • Optional SWD for debugging
  • I2C EEPROM for storing board specific parameters
  • Dimensions: 146 x 95 mm, 2-layer PCB

PREL6 is a simple module designed to control up to six power circuits using standard DPDT (Double-Pole Double-Throw) relays for currents up to 8 A per contact. The module has two 16-pin 3.81 mm connectors on the front panel thanks to which it is possible to quickly and easily connect the wires without the need for an additional breakout box. 8-way pluggable female terminal connector blocks in low-profile push-in and screw-fasten variants can be used to connect the wires (Fig. 2).

 

eez-bb3-terminal-blocks-types.png

Fig. 2: Pluggable terminal block variants

Although they are DPDT relays (form C), the two channels (K1 and K6) have only two contacts exposed which makes them SPST (form A) due to the limited number of pins on front panel connectors (X3, X4) because two pins per contract were used for the central four channels (K2 to K5) .

The distance between the lines on the PCB is no less than 0.89 mm (35 mils), which for coated conductors can enable work with AC mains of 230 Vac (according to IPC2221 recommendations).

 

Fig. 3: PREL6 block diagram

EEZ DIB interface

The PREL6 module interface with the MCU module is accomplished over the 28-pin 0.1” right angled header (X2).

On-board I2C EEPROM (IC3) provides storage for module-specific information such as its ID, working hours counters and relay switch cycles. Its address is defined by RN2-2 to RN2-4 pull-up resistors and ground connections on the backplane.

 

The STM32F030C6T6, a mainstream ARM Cortex-M0 Value line MCU with 32 KiB Flash, 48 MHz (IC1) is used to control power relays and to communicate with the master MCU on the MCU module.

UART and BOOT0 are used to program its flash memory, a process that is controlled by the master MCU and can be easily done via a touchscreen screen without the need for an external programmer/ debugger (ST-Link or similar).

 

The powering of the MCU and all logic is done via 3.3 V LDO (IC4) which uses +5 V from DIB.

 

Fig. 4: MCU pin assignment (CubeMX) for r1B2 version

 

Fig. 5: DIB, power, EEPROM and MCU

Power relays

Low power MOSFETs (Q1 to Q6) are used to drive the relays, whose inputs also have pull-down resistors (R2-R7) for better immunity.

Relay coil suppression is accomplished by a combination of rectifier (D1 to D6) and zener (ZD1 to ZD6) diodes. This affords the best compromise both to coil switch protection (MOSFET) and relay switching performance and reliability.

Finally, the contacts are additionally protected by varistors (VAR1 to VAR8, one per contact position), which will help in case of inductive load switching.

 

Relays when active consume 80 mA, so the max. consumption is 480 mA or 2.4 W on +5 V power rail. For this reason, it is not recommended to use more than two such modules in a single BB3 enclosure.

 

Fig. 6: Power relays

 

Add a comment

 

Current version

r1B5

Status

Work in progress

PCB manufactured

Yes (r1B2)

PCB assembled

Yes (r1B2)

BOM

Yes (TME, Mouser, Digikey, Farnell, RS)

File repository

https://github.com/eez-open/dib-mio168

(include Eagle, Gerber and BOM files)

License

TAPR v1.0

Contributions

C4.1 (Collective Code Construction Contract)

 

Fig. 1: MIO168 r1B2 prototype

Feature list

  • On-board STM32F446ZCT6 high-performance foundation line MCU, ARM Cortex-M4 with DSP and FPU, 256 KiB Flash, LQFP-144 package
  • 2 x 16-pin dual row 3.81 mm I/O connectors
  • 8 x protected digital inputs (3.3/5/24 V), 2 x fast/slow, 6 x slow
  • 8 x digital outputs (low-side) with multiple protections and FAULT detection, 550 mA per channel (current limit 1 A)
  • 2 x PWM outputs, protected
  • 4 x analog bipolar inputs with protection. Voltage or current selection per channel. 14-bit ADC, replaceable with pin compatible 12- or 16-bit version. Switchable bias for NTC sensors on first two channels
  • 2 x analog bipolar outputs (+/-5 V, +/-10 V, 0-5 V, 0-10 V). Voltage or current output with protection. 12-bit DAC, replaceable with pin compatible 14- or 16-bit version
  • 2 x analog bipolar outputs +/-10 V. 12-bit DAC, replaceable with pin compatible 14- or 16-bit version
  • On-board isolated +/-15 V (2W) power supply with +/-12 V, +5 V and +3.3 V LDOs
  • Firmware download via SPI
  • Optional SWD for debugging
  • Optional Micro SD card
  • I2C EEPROM for storing board specific parameters
  • Dimensions: 146 x 95 mm, 4-layer PCB

 

Fig. 2: Isolated DIB, EEPROM, isolated power rails

 

 

Fig. 3: MCU, optional micro SD card

 

Fig. 4: Voltage/Current output DACs

 

Fig. 5: Dual voltage output DAC, four low-side switches, 2 x PWM outputs

 

Fig. 6: 8 digital dual range inputs

 

Fig. 7: Four voltage/current analog input ADC

 

Add a comment

 

Current version

r1B3

Status

Completed, ready for production

PCB manufactured

Yes (r1B2)

PCB assembled

Yes (r1B2)

BOM

-

File repository

https://github.com/eez-open/dib-smx46

(include Eagle, Gerber and BOM files)

License

TAPR v1.0

Contributions

C4.1 (Collective Code Construction Contract)

 

Fig. 1: SMX46 r1B2 prototype

Feature list

  • On-board STM32F030C6T6 ARM Cortex-M0 Value line MCU, 32 KiB Flash, 48 MHz CPU, LQFP-48 package
  • 2 x 16-pin dual row 3.81 mm connectors
  • 4 x 6 switch matrix (24 two-wire crosspoints), max. 2 A
  • 1 x power relay, max. 8 A / 230 Vac
  • 2 x analog output 0 – 10 V, 10 mV set resolution (12-bit)
  • On-board +3.3 V LDO
  • Firmware download via UART
  • Optional SWD for debugging
  • I2C EEPROM for storing board specific parameters
  • Dimensions: 146 x 95 mm, 2-layer PCB

The SMX46 module offers a switch matrix of 24 signal 2-wire crosspoints organized into 4 rows and 6 columns. Additional functionalities are two analog outputs and one power relay with two SPDT (form C) switches.

The module has two 16-pin 3.81 mm connectors on the front panel thanks to which it is possible to quickly and easily connect the wires without the need for an additional breakout box. 8-way pluggable female terminal connector blocks in low-profile push-in and screw-fasten variants can be used to connect the wires.

 

Fig. 2: SMX46 block diagram

EEZ DIB interface

The SMX46 module interface with the MCU module is accomplished over the 28-pin 0.1” right angled header (X2).

On-board I2C EEPROM (IC3) provides storage for module-specific information such as its ID, analog outputs calibration data, working hours counters and relay switch cycles. Its address is defined by RN2-2 to RN2-4 pull-up resistors and ground connections on the backplane.

 

The STM32F030C6T6, a mainstream ARM Cortex-M0 Value line MCU with 32 KiB Flash, 48 MHz (IC1) is used to control power relays and to communicate with the master MCU on the MCU module.

UART and BOOT0 are used to program its flash memory, a process that is controlled by the master MCU and can be easily done via a touchscreen screen without the need for an external programmer/ debugger (ST-Link or similar). 3-state buffer (IC2) is used to control the UART TX output which can only be active while downloading the firmware to flash memory.

 

The powering of the MCU and all logic is done via 3.3 V LDO (IC4) which uses +5 V from DIB.

Fig. 3: MCU pin assignment (CubeMX) for r1B2 version

 

Fig. 4: DIB, power, EEPROM and MCU

Switch matrix and power relay

Two wire crosspoints switch matrix were made by contacting the signal relays K1 to K24 as shown in Fig. 5.

Matrix line pairs are exposed on the front panel connectors X3 and X4 and are denoted by the suffixes A and B: the columns have designations from X1A/X1B to X6A/X6B, and the rows Y1A/Y1B to Y4A/Y4B.

Low power MOSFETs (Q2 to Q25) are used to drive the switch matrix relays, whose inputs also have pull-down resistors (RN2-RN8, Fig. 4) for better immunity.

Relay coil suppression is accomplished by a combination of rectifier (D2 to D25) and zener (ZD2 to ZD25) diodes. This affords the best compromise both to coil switch protection (MOSFET) and relay switching performance and reliability. The relays are powered by +12 V which is filtered with C3.

 

The on-board power module (K1) offers switching of two additional circuits.

Analog outputs

The MCU used does not offer DAC outputs so PWM is used to generate analog signals. Conversion of PWM to analog signals is accomplished with DC filtering and additional ripple cancellation (IC5) as proposed by Stephen Woodward (see EDN article Cancel PWM DAC ripple with analog subtraction, November 28, 2017).

Since the PWM amplitude is +3.3 V, the generated analog signal cannot exceed this voltage. For this reason, a non-inverted op-amp (IC6) with a gain of about 3.13 is used so that the max non calibrated output voltage is just over 10 V (10.3 V).

The output current is limited by using R6 + R7 and R12 + R13, and TVS1 and TVS2 are used for overvoltage protection.

 

Fig. 5: Switch matrix, analog outputs and power relay

 

Fig. 6: Switch matrix signal relays

 

Add a comment

Subcategories