[Solved] Reset a variable at fixed frequency
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-06 9:06 AM
Hi all,
I have a data streaming firmware and to keep the stream alive I must reset a counter before it reaches a fixed value.
Is there a way to perform this operation with CubeMonitor while monitoring other values?
Thank you
Walter
Solved! Go to Solution.
- Labels:
-
STM32CubeMonitor
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-06 11:22 AM
Thanks your your answer. I have modified your flow accordingly, please find attached flow.
Here are the updates done in the flow :
- The main update concerns the way the data_sample_not_pinged_count & stream_status are written. Instead of using a write panel, I use 2 template nodes which forces the values for these 2 variables from the flow editor. These 2 template nodes are triggered by :
- the start button for stream_status.
- an inject node which is resetting data_sample_not_pinged_count every 1 second.
- Detailed explanations on how to write values programatically are provided in this thread :https://community.st.com/s/question/0D53W000000ayg1SAA/hello-how-is-it-possible-to-change-a-variable-by-pressing-a-buttoni-just-can-change-a-variable-by-using-the-write-panel-butregards.
- Then I remove some useless nodes (write node, variable node that were used to write the data_sample_not_pinged_count & stream_status variables)
- Finally I also remove one useless switch node, as you can have several rules inside a single switch.
There are plenty of good document to read. The first one is the STM32CubeMonitor wiki available at
https://wiki.st.com/stm32mcu/wiki/STM32CubeMonitor:STM32CubeMonitor_overview. It is updated on regular basis with questions/answer coming from the this forum.
If you want more explanation on node-red framework, there is the node-red website which provides plenty of information from beginner to expert : https://nodered.org/docs/
Hope it answers your question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-06 9:12 AM
Hi Walter,
Yes it should be possible since your know the counter address.
Indeed as STM32CubeMonitor is able to read but also write some values at various addresses, then you can implement a logic in your flow that reset your counter when a condition is reached.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-06 9:19 AM
I think that I could use the "trigger" function, but I do not know how to use it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-06 9:27 AM
Not sure the trigger can fit your needs. Could you please explain a bit more what you want to achieve and share your current flow such so that we can better help you ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-06 9:37 AM
The FW works in this way:
1) The host sends the "Start data acquisition" command over USB and that sets a variable to 1 to indicate that the stream is started
2) During the data acquisition the host must send a ping before 6 seconds to avoid that the stream stops, the ping resets a counter that is increased at 400Hz
I must simulate this behavior:
1) set the "start stream" variable to 1
2) reset the counter to zero before it reaches the value 2400
The shared flows does exactly what I said, but I must continuously press the "Write" button on the dashboard to keep the stream alive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-06 9:46 AM
Thanks will have a look and keep you informed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-06 10:19 AM
I have few questions / clarification on your current flow/logic :
- starting the stream is done by setting sensStreamStatus.stream_status to 1. Correct ?
- you need to reset the counter be setting systemStatus.data_sample_not_pinged_count to 1 (or 0??) every 6 seconds. Correct ?
- do you really want to be able to write sensStreamStatus.stream_status & systemStatus.data_sample_not_pinged_count from the dashboard write widget or is it fine to do it only from the flow editor interface ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-06 10:43 AM
- correct
- correct. Usually the host sends a ping every 1 second to reset `systemStatus.data_sample_not_pinged_count` to zero
- I do not need the dashboard. I only added it because it's the only way that I not to set the variables
I'm really new to nodered. Is there a good documentation to read about it that is helpful to better understand Stm32CubeMonitor?
Thank you again for your help
Walter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-06 11:22 AM
Thanks your your answer. I have modified your flow accordingly, please find attached flow.
Here are the updates done in the flow :
- The main update concerns the way the data_sample_not_pinged_count & stream_status are written. Instead of using a write panel, I use 2 template nodes which forces the values for these 2 variables from the flow editor. These 2 template nodes are triggered by :
- the start button for stream_status.
- an inject node which is resetting data_sample_not_pinged_count every 1 second.
- Detailed explanations on how to write values programatically are provided in this thread :https://community.st.com/s/question/0D53W000000ayg1SAA/hello-how-is-it-possible-to-change-a-variable-by-pressing-a-buttoni-just-can-change-a-variable-by-using-the-write-panel-butregards.
- Then I remove some useless nodes (write node, variable node that were used to write the data_sample_not_pinged_count & stream_status variables)
- Finally I also remove one useless switch node, as you can have several rules inside a single switch.
There are plenty of good document to read. The first one is the STM32CubeMonitor wiki available at
https://wiki.st.com/stm32mcu/wiki/STM32CubeMonitor:STM32CubeMonitor_overview. It is updated on regular basis with questions/answer coming from the this forum.
If you want more explanation on node-red framework, there is the node-red website which provides plenty of information from beginner to expert : https://nodered.org/docs/
Hope it answers your question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-06 11:59 PM
Thank you @Thierry​
it works as expected =)
