cancel
Showing results for 
Search instead for 
Did you mean: 

How to watch an array using STM32CubeMonitor?

xpp07
Senior

How should I configure STM32CubeMonitor to watch the flow of an array? I can either select the first position or expand the array but then the graph will be a mess. See below.

0693W000006FCraQAG.png0693W000006FCrfQAG.png

1 ACCEPTED SOLUTION

Accepted Solutions

Update 2024 If download links are broken, check attachments below this message (*.7z archive). 

Update 2023 (STM32CubeMonitor 1.6.0) Watching multiple 1D arrays + better code:

New version available (cubearrays v1.0)! Now all arrays are automatically parsed and stored in global variables. Step-by-step instructions:

  1. Download cubearrays here: nodes10.zip (use nodes from "cubearrays" directory)
  2. Open STM32CubeMonitor, find three stripes / hamburger in up-right corner and press it to open menu → Import
  3. In "Import nodes" windows select "Local" → STM32CubeMonitor_BasicFlow.json → press Import button
  4. Delete "show notification", "myChart" and "Clear Graphs" nodes
  5. Three stripes / hamurger → Import → Clipboard tab → "select a file to import" button → find and select cubearrays10.json → Import button
  6. Connect variables node upper output to "CubeArrays v1.0" function input node
  7. Double-click "CubeArrays v1.0" function node, select "On Message" tab, scroll down to const arrayNames=["arrayName1","arrayName2",...
  8. Replace "arrayName1", "arrayName2" by actual array names put in quotes (case sensitive!)
  9. Double-click Chart #1, write first array element count in "OR points" field
  10. If you added Chart node by yourself, set "Set X-axis Label" to "custom" and enter "x"
  11. Set Y-axis min and max values according to your requirements. For uint8_t it would be min: 0, max: 255
  12. Configure Chart #2 and Chart 3 in the same manner
  13. Double-click myProbe_Out node, select your STLink probe. If list is empty, press pencil button, select your ST-Link, write some Name, press "Add" button → "Done"
  14. Double-click myProbe_In node, select your ST-Link probe → "Done"
  15. Compile your project, find debug directory with ELF file
  16. Double-click "myVariables" node → Pencil button near "Executable"
  17. Paste ELF file folder path to "Folder" field → Press "File" drop-down list and select your project .elf file
  18. Press "Expand Variable List" → write first array name in lower-right "filter" field and press "Select All" button
  19. Select all elements of second and third array using same approach: write name in filter → press "Select All"
  20. Write some text in "Name" field, this will enable "Add" button
  21. After pressing "Add" button large arrays cause significant delay before STM32CubeMonitor user interface become responsive
  22. Press Deploy button → Dashboard button → in opened window START ACQUISTION button
  23. Correct chart configurations if some graphs are out of scale

Example using cubearray10.json in STM32CubeMonitor v1.6.0:
Three arrays - https://youtu.be/_tnx1ZxkiY8

Old version:

Just tried in latest version (1.2.0), please check this short explanatory video https://youtu.be/VAxnharGr_M

Note that script is written in previous version, probably 1.1.0 and worked without a problem too. It turns out I wrote it in 1.2.0. Some steps of explanatory video:

  1. Top right corner menu button → Import → Library → Stm32CubeMonitor_BasicFlow.json
  2. Deleted previous unused tab "Basic_Flow"
  3. Top right corner menu button → Import → Clipboard → "select a file to import" → sigview2.json
  4. "Some of nodes you are importing already exist in your workspace" → Import copy
  5. Delete "Mychart" and "Clear Graphs" nodes by selecting them using mouse right-click and pressing "Del" on keyboard
  6. Connect "myVariables" node output to newly imported "function" and "switch" nodes as shown on screenshot/in video
  7. Select ST-link in "myProbe_Out" and "myProbe_In" nodes
  8. In upper "myVariables" node press "Add new exe-config..." → select path to *.ELF in your project directory
  9. Set checkbox "expand Variable List" to expand array elements to separate variables
  10. In filter textfield write "testBuffer" (case sensitive)
  11. Press "Select All" button to select all elements of testBuffer[0],testBuffer[1],testBuffer[2],... array
  12. Put some name for executable in "Name" textfield, so "Add" button will become available, press "Add" button
  13. Update 2021: double-click "switch" and change name to mach name in your source code / axf file. If your array is named someArray, then you put here someArray[9]. "9" index is used because of alphabetical sorting it is the last array element during readout for 1024 elements. You can see it in "variables"
  14. Press "DEPLOY" button
  15. Press "DASHBOARD" button → in new window press "START ACQUISTION"
  16. You can see array is displayed correctly as sine graph.

 

Most important steps: select ST_Link, import Stm32CubeMonitor_BasicFlow.json example and combine it with sigview2.json. Add all array elements as separate variables to the list. If array name and size in your code matches testBuffer in Node-RED script, then everything must work after pressing deploy→dashboard→start.

 

Update 2021: watching array with different name/size

Assume we have an array ADC_BUFF1 with values ranging from -1 to +1

float32_t ADC_BUFF1[256]; 
//...
for (int i=0; i<256; i++)
{
	ADC_BUFF1[i]=sin(2.0*M_PI/256*i);
}
 

To make it work

  1. double-click first function
  2. open setup tab
  3. replace 1024 with 256 in for (var i=0;i<256;i++)
  4. double-click "switch"
  5. replace text with ADC_BUFF1[9]
  6. double-click "chart"
  7. replace 1024 with 256, set Y-axis min/max to -1 1

 

0693W00000FCashQAD.jpg 

I see that Setup and Close tabs are missing on your screenshot, I do not know why. Those tabs are common for function nodes in Node-RED, for example:

https://discourse.nodered.org/t/setup-in-a-function-node/39445

 

What happens if you put empty function node and double-click on it? Still no Setup/Close tabs?

Disappointed with crowdfunding projects? Make a lasting, meaningful impact as a Tech Sponsor instead: Visit TechSponsor.io to Start Your Journey!

View solution in original post

14 REPLIES 14
stephane.legargeant
ST Employee

Hello

The graph has not been designed to display arrays with so many entries. I guess you don't want to have one hundred of curves in one chart.

There should be some better options with node-RED.

  • How many data do you have in the array ?
  • How do you want to display it ? All values should make one curve in a chart or in a table ?
  • Does the values evolves in real time ?

Best regards

Stephane

Thanks for your response. The array is 220 elements. I would like to have both options, either see them as one curve or in a table. The values do evolve in real time.

Hello

STM32CubeMonitor was not designed to handle array of data. Data are managed as individual elements, and there is no way to group it. The first issue is to select all the symbol, and then the display is not adapted.

There are some workarounds to display the data :

1) Export the data in a file, and convert it to csv file. Then use excel or other tool to analyze it. (see other posts on this topics for details)

2) Reorganize the data to send it to a bar chart. Node-RED chart is able to display a bar chart from data not based on time. Then the array value can be displayed.

Best regards

Stephane

JGuel.2
Associate

Hello,

You can try to loop trough your buffer and assign each value to a variable then watch this variable in CubeMonitor. It worked fine for me.

Best regards

Jude

Georgy Moshkin
Senior II

Here is working example of watching 1D array in STM32CubeMonitor: sigview.zip

after downloading,

1) import sigview2.json file to your flow, add two connections as showed on !view-me!.png image. Fix all the errors, delete unused stuff.

2) Add test array to your buffer as in main.c, build

3) Add array elements to your STM32CubeMonitor configuration with "Expand Variable List" checkbox checked, filter variable name by entering "testBuffer" and press "Select All" button under the list.

 

Signal array is filled on MCU using:

for(int i=0;i<512;i++) {
     testBuffer[i]=(int16_t)roundf(32767*sinf(2.0*M_PI*1000/44100*i));
}

In STM32CubeMonitor/Node-RED:

 

function 1:

setup tab: creating global variable globalArr

function tab: parsing msg.payload.variablename to get array element index, putting array element to global array

this function gathers single array elements from probe to one global array

global.set("globalArr["+idx+"]", msg.payload.variabledata[0].y);

switch:

works only when variable name is "testBuffer[9]" (not testBuffer[511] because of alphabetical order)

 

function 2:

creates msg.payload for chart only when switch is triggered, so chart is updated only when one full array read out is complete

tmpArr.push({"x": i, "y": global.get("globalArr")[i]});

It works pretty well. There may be some errors, started to learn this tool and Node-RED yesterday. It is possible to parse array names and put them on different charts. If somebody improves this please let me know.

 

0693W000008yy90QAA.png

Disappointed with crowdfunding projects? Make a lasting, meaningful impact as a Tech Sponsor instead: Visit TechSponsor.io to Start Your Journey!
ADunc.1
Senior

@Georgy Moshkin​ Thanks for this answer. It looks like exactly what I needed.

Unfortunately I have one little problem I cannot solve. The line "global.set("globalArr["+idx+"]", msg.payload.variabledata[0].y);" causes an error "Error: Invalid property expression: unexpected N at position 10". I think this is because I have not defined the global array globalArr. You say "setup tab: creating global variable globalArr". I cant seem to find a place to do this. Can you give more details please?

Double click on "f | function" rectangle → "Edit function node" window appear with three tabs in it: "Setup" / "Function" / "Close".

By default second tab is opened "Function" with main source code, you need to open "Setup" tab:

0693W00000DnfoMQAR.jpg0693W00000DnfnxQAB.jpg

Disappointed with crowdfunding projects? Make a lasting, meaningful impact as a Tech Sponsor instead: Visit TechSponsor.io to Start Your Journey!
ADunc.1
Senior

Thanks for the prompt feedback. I do not have the setup tab! I downloaded STM32cubeMonitor V1.1.0 today.

0693W00000Dng2EQAR.png

I didn't try new version yet, I'll try it later, hope somebody can comment sooner.

Disappointed with crowdfunding projects? Make a lasting, meaningful impact as a Tech Sponsor instead: Visit TechSponsor.io to Start Your Journey!