Hi,
On an X90CP174, is there a way to clear the DRAM (similar to a warm restart) without actually performing a restart/reboot?
Thanks!
Hi,
On an X90CP174, is there a way to clear the DRAM (similar to a warm restart) without actually performing a restart/reboot?
Thanks!
Hi Julie,
There isn’t a “Clear DRAM” button in Automation Studio, but one way you could achieve this would be by stopping and then starting a task via the Online → Compare → Software page. I believe that if you stop a task and then start it again, the variables in that task will reinitialize. This won’t affect global variables, however.
What do you need this for? Generally, the best way to reset everything is to just reboot the system. Then your variables will be re-initialized and your INIT routines will run.
If you are only looking to clear specific data on command, you could use the brsmemset function. This is helpful if you want to clear out temporary variable before redoing an operation for example. You could also confine the code you want to clear to a function or function block, and reset the data when the Enable input goes false.
The boot uptime is a minute too long for operation, so we are looking into a way too keep it on but reset everything like a reboot.
Ideally we would like to clear memory on command, brsmemset() would be nice, but i don’t really know how reference via addrres all the variable that would get reset during the reboot.
I tried stoping and restarting the task, but it doesn’t seems to reset the local variable.
For the moment, i have a action to reset all the local var for each of my task. Ideally, we are looking for a simpler solution.
This sounds to me like an error recovery problem. You wouldn’t want to reboot after every error, so your code needs to be able to reset itself and keep running.
Unfortunately, I don’t think you’ll find an easy “built-in” solution because what you need to do to reset depends on your program. Hopefully others will chime in with ideas as well, but my idea would be to create a “Reset” state somewhere in your programs that resets all of the variables you care about. If these variables are in structures, then you only need to pass the address of the structure to brsmemset. In order to reset, you can jump to the Reset state on a command. Your program can then reset and return to the first state in the sequence after this.
As a programmer, I want to have everything under control, including the values in my variables. So clearing the entire memory is not a solution for me because it might hide a workaround that helps recover from a buggy state caused by my program.
If you want to reset variables all at once, put them in a structure data type and use brmemset on the whole structure.
Thank you very much for the information. I understand that clearing the memory to fix a buggy state is not an optimal solution. However, this is not exactly what we are trying to achieve.
We have a code design for a controller mounted on a truck that was originally powered by the ignition. Now, we want to adapt the same code for a controller that will be powered directly by the battery. To maintain the original design intent, we are looking for a straightforward way to reuse the existing code while ensuring it resets it’s variable like the way a reboot would when the ignition signal falls to a low state.
It looks like there’s no quick way to do this, so we’re exploring the best alternative for resetting all local variables across multiple modules/packages.
Our initial idea is to add a reset action for each module to clear its local variables. If you know of a better approach, we’d love to hear it!
Hi there,
this pretty much sounds to me like you should/could move this to be a function block of which you change the input parameters depending on which usecase you currently have.
Doing that, I would move all internal variables to a variable with scope “VAR” and of a structure type named “Internal”. You could even clear them all at once, then
Generally speaking I would never clear “all” variables but only ever those I don’t control at all times - question is, why those would exist.
That means basically I don’t care if a variable still holds the value of a previous call if I don’t even access the content right now. And if I access it, I make sure that the step right before it is the one clearing or setting it to the value I need.
Maybe you have a little code abstract that you can showcase where we can see which variables it would be that you say would need clearing.
Best regards
The logic was written in Ladder many years ago without a clear structure or programming standard. Since it has been running in production for over 20 years, we prefer to keep it as is for now. The issue stems from numerous self-latching coils, which are the ones we need to reset. The idea behind resetting all variables is to avoid the tedious task of identifying each self-latching variable individually. I hope this explain better why this odd request!
Thanks again for your attention on this.
That’s definitely a situation I’ve seen before! Unfortunately, I don’t think there is a solution that doesn’t involve modifying the code in some way. This is especially true if some of the latched variables are global, as those are not tied to a single program.
This is just my opinion, but I recommend taking the time to understand what’s happening in the code and refactoring it into something more modular (especially if you plan to use it in other places). You don’t necessarily have to rewrite the whole thing, but anything that can be latched should also be easily unlatched with a command. A couple of ideas for this (based on the previous posts):
It’s great to have a program you know works without changes…until you need to change it and don’t remember how it works. If you have any questions about code organization, I’m sure plenty of people on the Community would be happy to help as well!