Author Topic: Non-Volatile Memory - Set Default Value only editable through Service App  (Read 11518 times)

Offline GreaseMonkey

  • PLUS+1 Developer
  • ***
  • Posts: 22
  • Karma: +0/-0
  • The fastest way to do anything is once
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. 

Offline Tor

  • Administrator
  • PLUS+1 Guru
  • *
  • Posts: 296
  • Karma: +28/-1
Re: Non-Volatile Memory - Set Default Value only editable through Service App
« Reply #1 on: September 29, 2023, 07:45:54 AM »
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
Best regards,
Tor
PLUS+1® SW PAE Team

Offline sverreo

  • PLUS+1 Developer
  • ***
  • Posts: 21
  • Karma: +1/-0
Re: Non-Volatile Memory - Set Default Value only editable through Service App
« Reply #2 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 transistion only the first time the software is downloaded.

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

Offline GreaseMonkey

  • PLUS+1 Developer
  • ***
  • Posts: 22
  • Karma: +0/-0
  • The fastest way to do anything is once
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. 

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.

Sverreo,

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

-Robbie

Offline GreaseMonkey

  • PLUS+1 Developer
  • ***
  • Posts: 22
  • Karma: +0/-0
  • The fastest way to do anything is once
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. 

Offline sverreo

  • PLUS+1 Developer
  • ***
  • Posts: 21
  • Karma: +1/-0
The "Read" input should only be true if you want to read from the NV memory and set this to the output VAL.
I dont see any reason for this to always be TRUE?

If you set "In-enable" and don't "WRITE" this to NV memory, you can reset the output to the last written value using a positive transition on "Read"

Offline spittet

  • PLUS+1 Guru
  • *****
  • Posts: 118
  • Karma: +6/-1
If you want the value to be modified only from Service Tool, I would suggest to simply use the "Non-volatile Memory Dynamic Input" component. With this component, you do not have to deal with anything about read/write/default.

Simply place the component in the program and use it's value where you need it.

After you downloaded the program into the controller, maybe it will have garbage in it, but simply setting a value with Service Tool will set it correctly (you are connected to Service Tool anyway as you are downloading the firmware to the controller, so it's not a big hassle).

Sam

Offline GreaseMonkey

  • PLUS+1 Developer
  • ***
  • Posts: 22
  • Karma: +0/-0
  • The fastest way to do anything is once
Re: Non-Volatile Memory - Set Default Value only editable through Service App
« Reply #7 on: December 29, 2023, 11:12:26 PM »
If you want the value to be modified only from Service Tool, I would suggest to simply use the "Non-volatile Memory Dynamic Input" component. With this component, you do not have to deal with anything about read/write/default.

Simply place the component in the program and use it's value where you need it.

After you downloaded the program into the controller, maybe it will have garbage in it, but simply setting a value with Service Tool will set it correctly (you are connected to Service Tool anyway as you are downloading the firmware to the controller, so it's not a big hassle).

Sam

That solution would work, but it means the machine would not operate correctly unless you manually input all of the correct values using the service tool.  I'm controlling several pump EDC's, and I'm using the NVMe parameters to create modifier values that the user can use to adjust outputs up or down from their defaults.  All of these modifiers start at 100% by default, and then can be adjusted to increase or decrease the current flow to each EDC to tune machine operations.  On the vast majority of builds, these values will not change from their defaults.  By using the code I posted above, I am able to set defaults when I write the software, but easily edit them with the service tool. 

Offline Marbek_Elektronik

  • PLUS+1 Guru
  • *****
  • Posts: 352
  • Karma: +8/-0
    • Marbek Elektronik
I have 1 NV which checks if the software is new and then it sets all connected values to default and itself.
Marbek Elektronik, Dipl.-Ing. Bernd Konrad
Dienstleistung, Entwicklung, Herstellung