PLUS+1 Software > General controls

Non-Volatile Memory - Set Default Value only editable through Service App

(1/2) > >>

GreaseMonkey:
This is my first time using the "Non-volatile Memory Dynamic" feature, so please excuse my ignorance. 

My software controls several hydraulic pumps, and I would like to use non-volatile memory parameters to make the Max and Start current values for each pump EDC adjustable from the service application.  I'm trying to make the default multiplier parameter 100, and then set min as 50 and max as 200 to allow field techs to achieve 50%-200% output current. 

I'm trying to understand how I can use the "Non-volatile Memory Dynamic with Default" to achieve this.  I know that when the DEF ENABLE pin go true, it copies the default value to NVM.  My problem is that I only want to copy the default value to memory the very first time the module starts.  After that, it should stay the same unless someone edits it with the service tool.  It looks like the values in NVM default to the max value for the data type if they have never been written.  I could set the default values in the service application, but that would require someone to hook up the service tool and write initial values to NVM before the machine would function as intended.  It would be much better if my code could handle that initial setup instead of the service application. 

Thank you in advance.  I've attached a screenshot of my current setup, which never writes the default to memory. 

Tor:
Hello,

I guess you need a positive transition to write the value.
I have attached some examples below.
The examples are also available in the component manual. Mark the component, press F1. In the tree structure on the left, under the component, there are three examples on how to use the component.

Good Luck

sverreo:
Hi,

If you want a function that only writes the default values the first time the software runs on the controller you can use the "RunOnce" function block.
This function sets a transistion only the first time the software is downloaded.

Use the output on your "DEF ENABLE" input on the NV block.

GreaseMonkey:
Tor,

Thank you for the information, but that does not solve my problem.  The diagrams in the user manual cover many advanced cases, but do not show how to set up a simple default value that will be saved to NVM when the software is flashed to the module and then only be editable from the service tool.  If I create a positive transition to either the DEF ENABLE or WRITE_ pins in my code, the default value would overwrite any changes made from the service tool.  It looks like Sverreo's code below should solve the problem. 


--- Quote from: sverreo on September 29, 2023, 03:23:20 PM ---Hi,

If you want a function that only writes the default values the first time the software runs on the controller you can use the "RunOnce" function block.
This function sets a transition only the first time the software is downloaded.

Use the output on your "DEF ENABLE" input on the NV block.

--- End quote ---

Sverreo,

Thank you!  That looks like exactly what I need.  I'll get to work on implementing it. 

-Robbie

GreaseMonkey:
After some tinkering, I was able to get the desired result.  Connecting the RunOnce output to DEF_ENABLE did not work because DEF_ENABLE only copies the default value to the output, but does not write it to memory.  I also found that if the read input is True, it overrides the IN-ENABLE and DEF_ENABLE inputs and pulls the value from memory instead of the input or default. 

I ended up using the Non-volatile Memory Dynamic block without default because the default option seems to provide a second input that I don't need.  To make it work, I had to connect the IN-ENABLE and WRITE_ pins to the EE_Run_Once output, then connect the READ_ pin to a NOT block connected to the same EE_Run_Once output.  When EE_Run_Once is true, it copies the input value to the output and writes the output value to NVM.  When EE_Run_Once is false, the READ_ pin gets a true signal, enabling the block to read from the value stored in memory.  I've attached a screenshot for anybody that would like to see. 

Hopefully this helps somebody else in the future. 

Navigation

[0] Message Index

[#] Next page

Go to full version