Menu

No parameters are changed

2024-10-14
2024-10-18
  • Carlos Izquierdo Vázquez

    Hello Robert
    I am trying to change the firmware parameters with the windows application but the parameters are not saved... sometimes they are... what can happen?

     

    Last edit: Carlos Izquierdo Vázquez 2024-10-14
  • brownrb

    brownrb - 2024-10-15

    Hi Carlos

    Important settings are saved in permanent storage. At boot time, these settings are read from permanent storage into a memory based area. ( load_settings() in myRotator_2024_xx.ino )

    When you change a setting, the setting is changed in the memory based area, and a timer interval in seconds starts counting, 1.. 2.. 3 etc

    When the count reaches 30s (this can be changed) the changed value is copied from the memory area into permanent storage.

    The permanent storage has a limited number of "writes" and once exceeded, some areas may no longer be written to. The maximum number is about 10,000, and the nano chip with average usage should last about ...

    see below for calculations..

    the permanent storage is "part" of the Arduino Nano chip, so that would be replaced (hence my notes about building these with header risers to allow replacement of the nano chip (user guide pdf pg57).

    The firmware was written by me to break the permanent storage into blocks, such that the settings are saved starting with block 0. The next boot up then uses Block 1, etc etc, so that one particular block is not being written to all the time. The block number starts at 1.. 33 and when it reachs the maximum block number of 33, the next block will be 1. Then 2, then 3 etc , then 33, then 1, then 2 etc

    Ok, but what does all that mean?

    If you make a change, and then reboot the controller, or turn if off, or it crashes before the 10s time interval, then changes will not be saved.

    When the time comes to save the settings (after 30s), if the focuser is moving, the change is not saved, In these cases, the timer flag still stays set, and then when the focuser stops, a new 10s count starts again.

    How to find/change the save time interval.
    myrotator_defines.h file

    #define DEFAULTSAVETIME 30000L  // 30s wait before saving Rotator 
    

    The default is 30s. To change it then change the 30000L to a different value. A lower value increases the number of writes and hence burns out the permanent storage faster (if you change it to 5000L hen expect to burn out that memory much much quicker).

    In my controllers, I set this save time to 30000L (30s)

    Can I make a change and then save it quickly
    Yes, but that has to used sparingly because again, every write is 1 less,

    In the Windows application menu (user guide PDF pdf 135),
    Settings, Write Settings (EEPROM)
    will write the current memory settings into permanent storage (again do this when focuser is not moving). Dont do that yet.

    How can I use this of I think changes are not being saved?
    So we have come full circle back to beginning. You suspect that a setting is not being changed. How do you test to see if that is what is happening?

    USING NEW WINDOWS APPLICATION 2_4_0_8
    Change a setting that you think is not being saved or remembered. Lets settle on Reverse.
    1. Use the Windows application Motor tab. (Alt+M)
    2. Check the box Reverse
    3. Click the Set button (this sends the Reverse state to the Controller)
    4. Uncheck the box Reverse (this is not sent to the controller)
    5. Click the Get button to get the controller settings
    6. The reverse check box should switch to checked meaning Reverse is enabled

    This tests the fact that the controller settings are being changed correctly.
    It does not test if the change was written to permanent storage (because that happens after a delay expires).

    Test if memory storage values are written to permanent memory.
    make sure focuser is not moving
    Use Get button again to check that the setting is still enabled.
    Using the Settings Menu, click Write Settings (EEPROM).
    Now the values are written to permanent storage.
    Because these permanent values are ONLY READ once at boot up, we must reboot the controller. So use the settings menu to do the reboot.

    Windows App Settings menu: Reboot Controller

    After clicking reboot, go to the Connection tab and disconnect the connection.

    Wait a few seconds then click Connect button.

    Once connected, go to the Motor tab (ALT+M).
    Click Get button.
    The reverse state should be checked.

    If you find a particular setting that cannot be changed, please let me know.

    Regards
    Robert.

    CALCULATIONS

    #define DEFAULTSAVETIME 30000L  // 30s wait before saving Rotator settings to EEPROM
    #define EEPROMSIZE 1024         // ATMEGA328P 1024 EEPROM
    
    struct config_t {
      int validdata;  // if this is 0xEE 238d then data is valid
      int Angle;      // use 0-360 degrees at 1 degree resolution
      int BacklashCCWSteps;
      int BacklashCWSteps;
      int StepsPerMotorShaft360;
      int StepMode;
      long MotorSpeedDelay;
      long StepsPerRotator360;
      double StepSize;  // The minimum StepSize, in degrees, 1.0
      byte BacklashCCWEnable;
      byte BacklashCWEnable;
      byte Direction;
      byte HomeSensor;  // 1 if Home Sensor is enabled
      byte MotorPower;
      byte MotorSpeed;
      byte Reverse;
    };
    

    Sizeof char = 1
    Sizeof int = 2
    Sizeof long = 4
    Sizeof float = 4
    Sizeof double = 4

    Work out size of rotator struct that holds controller settings
    Bytes 7 (1) 7
    ints 6 (3) 12
    long 2 (4) 8
    double 1 (4) 4
    Total bytes = 31

    Size of EEPROM
    1,024

    Number of blocks within EEPROM
    1,024 / 31 = 33

    Total number of writes
    10,000

    Total number of available Block writes
    (Each block can be written 10,000 times)
    10,000 * 33 = 330,000

    Each session uses 500 writes
    Say we use rotator every day for a year, how many writes?
    500 * 365 = 182,500

    How many years will the chip EEPROM last?
    330,000 / 182,500 = 1.8 years

    Say we use the rotator 3 times a week, how many writes?
    500 * 3 * 52 = 78,000
    how many years will that last?
    330,000 / 78,000 = 4.23 years

    based on a write delay of 30s
    If the write delay is lowered to 5s, then many more writes will occur.
    Because, in 30s there is likely to be multiple setting changes. This is likely to lead to a single write that includes other settings.

    When using a lower write interval of 5s, this may result in multiple writes of a single change, depending on which settings change and the time of change.

     
  • Carlos Izquierdo Vázquez

    What a good explanation!
    When you say write limit, do you mean number of firmware changes? or to changes of state in the rotator (turns)
    Greetings and thank you very much as always!

     
  • brownrb

    brownrb - 2024-10-18

    Hi Carlos

    When you say write limit, do you mean number of firmware changes?

    Every time you program the device that counts as 1
    Everytime you write a setting (or multiple settings at once) that counts as 1

    In earlier firmware versions there was counter implemented in firmware that kept track of the number of writes.

    Some Internet links will say 100,000. Some state 10,000. Some say different values for Flash (where the program is stored) and EPROM (where settings are stored).

    The chip used in the controller is ATMega328P, and this is what the data sheet says
    High endurance non-volatile memory segments
    ● 32K bytes of in-system self-programmable flash program memory
    ● 1Kbytes EEPROM
    ● 2Kbytes internal SRAM
    ● Write/erase cycles: 10,000 flash/100,000 EEPROM

    But
    The program you upload is stored in Flash Memory (size = 32Kb, erase/writes=10,000)
    The settings for the application are stored in EEPROM (size=1Kb, erase/writes=100,00)

    I previously stated that the EEPROM where settings are stored has a limit of 10,000 and based all the calculations on that.

    So what is it for EEPROM? 100,000 or 10,000.

    Good question,
    For genuine Arduino Nano ATMega328P, Flash=10,000 and EEPROM=100,000
    Flash Size 32Kb
    EEPROM Size 1Kb

    For cheap clones, Flash=10,000 and EEPROM varies.
    Flash Size 32Kb
    EEPROM Size 1Kb

    Many had noticed that the manufacturer stamp on the chips of clones was NOT the same as a genuine ATMega328P. So, back in 2014 I ran some tests doing repeated writes/erases on the EEPROM of clones. I found many, not all, gave up around 10,000 write/erases for EEPROM. Sizes were the same. So I settled on a worse case at the time for EEPROM of 10,000. I have not repeated those earlier tests from the same sellers, and it could well be that the figures for EEPROM are different now. Another finding was the Flash writes to program memory were sometimes less than 10,000 or sometimes a lot higher than 10,000.

    I have some controllers with those chips (built in 2014) and they are still running file today. Many of those are focusers, dew controllers that have had their firmware updated many many times since the first firmware was written. Before that, they were updated hundreds of times with beta changes and tests. And they are still chugging along. 10 years later.

    Regards
    Robert

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.