2020-12-09 10:19 AM
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.
Solved! Go to Solution.
2021-09-20 12:43 AM - edited 2024-03-05 05:37 PM
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:
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:
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
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?
2020-12-11 01:45 AM
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.
Best regards
Stephane
2020-12-11 04:05 AM
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.
2020-12-14 05:46 AM
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
2020-12-16 01:47 AM
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
2021-04-08 02:11 AM - edited 2024-02-27 02:23 AM
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.
2021-09-19 04:15 PM
@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?
2021-09-19 06:08 PM
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:
2021-09-19 08:29 PM
Thanks for the prompt feedback. I do not have the setup tab! I downloaded STM32cubeMonitor V1.1.0 today.
2021-09-19 08:42 PM
I didn't try new version yet, I'll try it later, hope somebody can comment sooner.