Help with EEPROM.get please.

Hello,

I'm trying to add code to this template sketch to add EEPROM functionality which will save and restore encoder pulse counts in order to restore user settings on start up.

At the moment, for testing purposes I am just trying to EEPROM.put and EEPROM.get param1_pulses (int32_t) to address 10.

I can successfully write to EEPROM and have verified this using a modified version of the EEPROM.get example but cannot 'assign' the int32_t stored in address 10 to param1_pulses in my sketch. How can I do this please?

Full code pasted below, pertinent bits extracted here:

const int SAVE = 6;

int32_t param1_pulses = 0;

void setup()
{
  pinMode(PIN_LED, OUTPUT);
  pinMode (SAVE, INPUT);

  EEPROM.get(10, param1_pulses);
}
void loop()
{
  
  if(digitalRead(SAVE)==LOW)  
  {
    digitalWrite(PIN_LED, HIGH);
    delay(50);  // debounce
    EEPROM.put(10, param1_pulses);
  }
   lcd.begin(8, 2);
   lcd.print(param1_pulses);
}

Many thanks.

/*
 AIDA Template2 Sketch
 	
 This sketch is a Template to start coding with
 Aida DSP.
 This sketch was written for Arduino, and will not work on other boards.
 	
 The circuit:
 
 Audio:
 * Input range 2.0Vrms (5.66Vpp, 8.23dBu)
 * Output range 0.9Vrms (2.5Vpp, 1.30dBu) 
 
 PC:
 * Please connect with PuTTY on Arduino USB Serial with a PC for a minimal user interface
 
 NOTE:
 Attenuation Out/In = 2.264, to have out = in you must provide 7.097dB of gain through DSP algorithm
 or externally with active LPF filter.
 
 created November 2014
 by Massimo Pennazio
 
 This example code is in the public domain.
 
 */

#include <Arduino.h>
#include <pins_arduino.h>
#include <Wire.h>
#include "AidaDSP.h"
#include <LiquidCrystal.h>
#include <EEPROM.h>

LiquidCrystal lcd(12, 11, 10, 9, 8, 7); //RS, E, D4, D5, D6, D7

const int SAVE = 6;

#define EVER (;;)

// DEFINES I/O
#define PIN_LED  13

// DEFINES USER INTERFACE
#define MAX 20.00
#define MIN -40.00

#define ON 1
#define OFF 0

// FUNCTION PROTOTYPES
void spettacolino(void);
void clearAndHome(void);

// GLOBAL VARIABLES

// UI
uint8_t bypass = OFF;
uint8_t oldbypass = OFF;
uint8_t func_counter = 0;
uint8_t old_func_counter = 0;
uint8_t push_e_count = 0;
uint8_t push_e_function = 0;
uint8_t restore = 0;

uint16_t param2_index = 1;

int32_t param1_pulses = 0;
int32_t param2_pulses = 0;
int32_t param3_pulses = 0;
int32_t param4_pulses = 0;

uint32_t timec=0, prevtimec=0;

float param1_value = 0.00;
float param3_value = 0.00;
float param4_value = 0.00;

void setup()
{
  // put your setup code here, to run once:

  // I/O
  pinMode(PIN_LED, OUTPUT);
  pinMode (SAVE, INPUT);

  EEPROM.get(10, param1_pulses);
   
  // open the USBSerial port
  Serial.begin(115200);
  clearAndHome();
  Serial.println(F("Aida DSP control with ARDUINO")); // Welcome message
  Serial.println(F("0x00"));    // Print DSP I2C address

  InitAida(); // Initialize DSP board 
  // ... download of program ... (see other examples to know what to do here)
  spettacolino();
}

void loop()
{
  // put your main code here, to run repeatedly:

  if(digitalRead(SAVE)==LOW)  
  {
    digitalWrite(PIN_LED, HIGH);
    delay(50);  // debounce
    EEPROM.put(10, param1_pulses);
  }

   lcd.begin(8, 2);
   lcd.print(param1_pulses);

  if(digitalRead(ENC_PUSH)==LOW)  
  {
    digitalWrite(PIN_LED, HIGH);
    delay(50);  // debounce
    if(digitalRead(ENC_PUSH)==LOW)
    {
      push_e_count++;
    }   
  }
  else
  {
    if(push_e_count>0 && push_e_count<10)
      push_e_function = 1;
    else if(push_e_count>10 && push_e_count<30)
      push_e_function = 2;
    else
      push_e_function = 0;  // No function triggered on switch
    push_e_count = 0;
    digitalWrite(PIN_LED, LOW);
  }
  
  if(push_e_function==1)
  {
    func_counter--;
    if(func_counter==255)
      func_counter=3;
  }
  else if(push_e_function==2)
  {
    bypass ^=1; 
  }

  timec = millis();
  if(timec-prevtimec >= 1000)  // Here we manage control interface every second
  { 
    clearAndHome();    // !!!Warning use with real terminal emulation program
    Serial.println(F("********************************"));
    Serial.println(F("*    User control interface    *"));
    Serial.println(F("*    AIDA Template2 Sketch     *"));
    Serial.println(F("********************************"));
    Serial.println(F(""));
    Serial.print(F(" Encoder pulses: "));
    Serial.println(getPulses(), DEC);
    Serial.println(F(""));
    
    if(oldbypass != bypass)
    {
      if(bypass == ON)
      {
        // Do something, call Aida DSP API
      }
      else
      {
        // Do something, call Aida DSP API
      }
      oldbypass = bypass;
    }

    if(old_func_counter != func_counter)
    {
      restore = 1;
      old_func_counter = func_counter;
    }
    switch(func_counter)
    {
    case 0: // PARAM1
    
      if(restore)
      {
        restore = 0;
        setPulses(param1_pulses);
      }
      param1_pulses = getPulses();
      param1_value = processencoder(MIN, MAX, param1_pulses);
      // Do something, call Aida DSP API
      break;
    case 1: // PARAM2
      if(restore)
      {
        restore = 0;
        setPulses(param2_pulses);
      }
      param2_pulses = getPulses();
      param2_index = selectorwithencoder(param2_pulses, 2); 
      switch(param2_index) 
      {
        case 1:
          // Do something, call Aida DSP API
          break;
        case 2:
          // Do something, call Aida DSP API
          break;
        case 3:
          // Do something, call Aida DSP API
          break;
        case 4:
          // Do something, call Aida DSP API
          break;
      }
      break;
    case 2: // PARAM3
      if(restore)
      {
        restore = 0;
        setPulses(param3_pulses);
      }
      param3_pulses = getPulses();
      param3_value = processencoder(MIN, MAX, param3_pulses);
      // Do something, call Aida DSP API
      break;
    case 3: // Color
      if(restore)
      {
        restore = 0;
        setPulses(param4_pulses);
      }
      param4_pulses = getPulses();
      param4_value = processencoder(MIN, MAX, param4_pulses);
      // Do something, call Aida DSP API
      break;
    } // End switch func_counter

    // Display information for user
    print_menu_putty();

    prevtimec = timec;
  } // End if 1000ms tick
} // End void loop

void spettacolino()
{
  byte i;
  byte status = 0x00;

  for(i=0;i<6;i++)
  {
    status ^= 1;
    digitalWrite(PIN_LED, status);
    delay(250);
  }
}

void clearAndHome(void)
{
  Serial.write(0x1b); // ESC
  Serial.print(F("[2J")); // clear screen
  Serial.write(0x1b); // ESC
  Serial.print(F("[H")); // cursor to home
}

void print_menu_putty(void)
{
  // Print menu
  Serial.print(F(" Effect status: "));
  if(bypass)
    Serial.println(F("bypass"));
  else
    Serial.println(F("on"));
  Serial.println(F(""));  
  if(func_counter==0)
    Serial.print(F("    "));
  Serial.print(F(" Param 1: "));
  Serial.print(param1_value, 1);
  Serial.println(F(""));
  if(func_counter==1)
    Serial.print(F("    "));
  Serial.print(F(" Param 2: "));
  if(param2_index==1)
    Serial.println(F("one"));
  if(param2_index==2)
    Serial.println(F("two"));
  if(param2_index==3)
    Serial.println(F("three"));
  if(param2_index==4)
    Serial.println(F("four"));
  if(func_counter==2)
    Serial.print(F("    "));
  Serial.print(F(" Param 3: "));
  Serial.print(param3_value, 1);
  Serial.println(F(""));
  if(func_counter==3)
    Serial.print(F("    "));
  Serial.print(F(" Param 4: "));
  Serial.print(param4_value, 1);
  Serial.println(F(""));
  Serial.println(F(""));
  Serial.print(F(" Active item: "));
  Serial.println(func_counter, DEC);
}

I can successfully write to EEPROM and have verified this using a modified version of the EEPROM.get example but cannot 'assign' the int32_t stored in address 10 to param1_pulses in my sketch. How can I do this please?

The assignment is automatically done with EEPROM.get(10, param1_pulses). The value will be there in param1_pulses to use as you like. When I use EEPROM.put() to store a value of int32_t = 123456789 at address ten, I can print it in the lcd and Serial monitor just fine.

#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7);//my lcd connections
#include <EEPROM.h>

int32_t param1_pulses;

void setup() {

  lcd.begin(16,2);
  int eeAddress = 10; //EEPROM address to start reading from

  Serial.begin(9600);
  
  Serial.print("Read int32_t from EEPROM: ");

  EEPROM.get(eeAddress, param1_pulses);
  Serial.println(param1_pulses);
  lcd.print(param1_pulses);

}

void loop() {

}

I don't know where the function getPulses() is located, but i think that somehow it is stepping on the value of param1_pulses you want to "assign".

Hi, thanks.

The .cpp file that is called is located here: AidaDSP/AidaDSP.cpp at master · AidaDSP/AidaDSP · GitHub And the .h is here AidaDSP/AidaDSP.h at master · AidaDSP/AidaDSP · GitHub

Encoder management section from the .cpp is pasted below, does this give any clues as to why the setting doesn't 'load'?

/**
 * Interrupt for encoder management
 */
void enc_manager(void)
{
  uint8_t change = 0;
  
  chA = digitalRead(ENCA);
  chB = digitalRead(ENCB);
  
  prev_state = curr_state;
  curr_state = (chA<<1 | chB); // 2-bit state
  
  //Entered a new valid state.
  #ifdef ENC_RES_X1
    if(chB == 1 && chA == 0)
      Pulses--;
    else
      Pulses++;
  #endif
  #ifdef ENC_RES_X4
    if (((curr_state ^ prev_state) != INVALID) && (curr_state != prev_state))
    {
      //2 bit state. Right hand bit of prev XOR left hand bit of current
      //gives 0 if clockwise rotation and 1 if counter clockwise rotation.
      change = (prev_state & PREV_MASK) ^ ((curr_state & CURR_MASK) >> 1);
      if (change == 0)
        Pulses--;
      else
        Pulses++;
    }
    else
    {
      // Error
    }
  #endif  
}

// Methods for get/set encoder's pulses value
int32_t getPulses(void)
{
 return Pulses;
}

void setPulses(int32_t value)
{
 Pulses = value;
}

The library encoder management looks reasonable. Have you degugged the encoder and its setup with an independent program? Do you have pullup resistors on the encoder output? It looks like the library is putting the encoders on digital 2 and digital 3 with interrupts. Are you wired to those pins?

I think that you need to work your way through each bit of the program, add debugging serial(or lcd) prints where there are none.

  1. Have you confirmed that the encoder is working and the pulse count changes, when it is turned, and is reported with getPulses()?

What does this section of code tell you?

timec = millis();
  if(timec-prevtimec >= 1000)  // Here we manage control interface every second
  { 
    clearAndHome();    // !!!Warning use with real terminal emulation program
    Serial.println(F("********************************"));
    Serial.println(F("*    User control interface    *"));
    Serial.println(F("*    AIDA Template2 Sketch     *"));
    Serial.println(F("********************************"));
    Serial.println(F(""));
    Serial.print(F(" Encoder pulses: "));
    Serial.println(getPulses(), DEC);
    Serial.println(F(""));

2)What is the value of param1_pulses here?

if(digitalRead(SAVE)==LOW)  
  {
    digitalWrite(PIN_LED, HIGH);
    delay(50);  // debounce
    EEPROM.put(10, param1_pulses);
  }
  1. in setup() what is the value of param1_pulses when you read it? What do you see if you have written the value to register 10 in a separate eeprom.put() routine.
void setup()
{
  // put your setup code here, to run once:

  // I/O
  pinMode(PIN_LED, OUTPUT);
  pinMode (SAVE, INPUT);

  EEPROM.get(10, param1_pulses);
   
  // open the USBSerial port
  Serial.begin(115200);
  clearAndHome();
  Serial.println(F("Aida DSP control with ARDUINO")); // Welcome message
  Serial.println(F("0x00"));    // Print DSP I2C address

  InitAida(); // Initialize DSP board 
  // ... download of program ... (see other examples to know what to do here)
  spettacolino();
}

I would focus on the value param1_pulses at every step you get at it in the program. I have confidence that eeprom.put(10, param1_pulses) and eeprom.get(10, param1_pulses) will write it and read it and the value will be in a variable called param1_pulses.

Thanks again,

I worked out I needed the line

setPulses(EEPROM.get(10,param1_pulses));

This now works.

However, it only works for one paramx_pulses, when trying to save param2_pulses 'setPulses' assigns param2_pulses value to param1_pulses, presumably because param1_pulses is the active pulse counter in the switch case menu. Cannot think how to resolve this, any ideas?

when trying to save param2_pulses 'setPulses' assigns param2_pulses value to param1_pulses, presumably because param1_pulses is the active pulse counter in the switch case menu.

That does not make sense to me. There is only one encoder and one value of "Pulses" for its counts. You can assign that value to paramX_pulses.

From AidaDSP.,cpp

// Methods for get/set encoder's pulses value
int32_t getPulses(void)
{
	return Pulses;
}

void setPulses(int32_t value)
{
	Pulses = value;
}

I have three questions--

1)Can you confirm that the value of Pulses increases and decreases with turning the encoder?

2)Can you confirm with Serial debugging prints that you can step through the switch case menu when you press the ENCODER_PUSH button which I think should be connected to pin 4?

3)Are you trying to save four different values in the eeprom? Are they at different addresses incremented by four?

cattledog:
That does not make sense to me. There is only one encoder and one value of "Pulses" for its counts. You can assign that value to paramX_pulses.

Each switch case has it's own paramx_value, for which the pulses count is independent of other cases. Whilst there is only one 'pulses' it is effectively reset in each switch case. This may be what just said, just (hopefully) clarifying.

  1. Yes.
  2. Yes.
  3. I will be trying to save many more than 4 but at the moment it's just two. See extracted bits below.
void setup()
{
setPulses(EEPROM.get(0,param1_pulses));
setPulses(EEPROM.get(4,param2_pulses));
}
void loop()
{
    if(digitalRead(SAVE)==LOW)  
  {
    digitalWrite(PIN_LED, HIGH);
    delay(50);  // debounce
    EEPROM.put(0, param1_pulses);
    EEPROM.put(4, param2_pulses);
  }
}

when trying to save param2_pulses 'setPulses' assigns param2_pulses value to param1_pulses

I can't see what you are saying. setPulses can only assign the number you give it to Pulses. It does not touch the values in paramX_pulses.

getPulses() provides the value in Pulses for assignment to paramX_pulses.

param1_pulses = getPulses();
 param2_pulses = getPulses();

I'm sorry, but I am not understanding the specific nature of the problem you are experiencing.

I may well be wrong in what I think is happening!

For someone reason when trying to recall param1_pulses it is assigned the number saved as param2_pulses. If I exchange param1_pulses for param3_pulses like below, it works properly. Weird.

void setup()
{
setPulses(EEPROM.get(0,param3_pulses));
setPulses(EEPROM.get(4,param2_pulses));
}
void loop()
{
    if(digitalRead(SAVE)==LOW)  
  {
    digitalWrite(PIN_LED, HIGH);
    delay(50);  // debounce
    EEPROM.put(0, param3_pulses);
    EEPROM.put(4, param2_pulses);

   lcd.begin(8, 2);
   lcd.print(param3_pulses);
   lcd.setCursor(0, 2);
   lcd.print(param2_pulses);

  }
}
{
setPulses(EEPROM.get(0,param3_pulses));
setPulses(EEPROM.get(4,param2_pulses));
}

param3_pulses contains the value stored in eeprom registers 0:3
param2_pulses contains the value stored in eeprom registers 4:7

The value in Pulses contains the value in param2_pulses, that is the values that were stored in eeprom 4:7 You have overwritten the param3_pulses value in Pulses.

EEPROM.put(0, param3_pulses);
EEPROM.put(4, param2_pulses);

Now you put the values back where they came from. They should not be changed.

Are you saying that if the words "param3_pulses" is changed to be "param1_pulses" something is different happens.

Are you starting with known numbers stored in the eeprom?

cattledog:
Are you saying that if the words "param3_pulses" is changed to be "param1_pulses" something is different happens.

Are you starting with known numbers stored in the eeprom?

Correct, param3_pulses works properly but param1_pulses does not!

I'm verifying the numbers stored in the EEPROM with a separate sketch. So yeah, I'm starting with known numbers stored in the EEPROM. This test sketch returns the correct value for param1_pulses, but the main sketch does not.

This test sketch returns the correct value for param1_pulses, but the main sketch does not.

OK, lets start working with the main sketch. I've managed to install the Aida library, and I can actually run the template sketch but without any Aida DSP hardware. I had to disable an i2c block write function related to the modified Wire.h they use, but I don't believe that change is related to the EEPROM access.

I am using the standard IDE serial monitor and the serial output seems fine.

This was my preload into the eeprom

#include <EEPROM.h>

void setup() {
  uint32_t a = 12345678;
  uint32_t b = 34567890;
  uint32_t c = 56789012;
  uint32_t d = 78901234;

  EEPROM.put(0, a);
  EEPROM.put(4, b);
  EEPROM.put(8, c);
  EEPROM.put(12, d);
}
void loop() {
}

Here is a modified setup() from the main code

#include <Arduino.h>
#include <pins_arduino.h>
#include <Wire.h>
#include "AidaDSP.h"
#include <LiquidCrystal.h>
#include <EEPROM.h>

LiquidCrystal lcd(12, 11, 10, 9, 8, 7); //RS, E, D4, D5, D6, D7

const int SAVE = 6;

#define EVER (;;)

// DEFINES I/O
#define PIN_LED  13

// DEFINES USER INTERFACE
#define MAX 20.00
#define MIN -40.00

#define ON 1
#define OFF 0

// FUNCTION PROTOTYPES
void spettacolino(void);
void clearAndHome(void);

// GLOBAL VARIABLES

// UI
uint8_t bypass = OFF;
uint8_t oldbypass = OFF;
uint8_t func_counter = 0;
uint8_t old_func_counter = 0;
uint8_t push_e_count = 0;
uint8_t push_e_function = 0;
uint8_t restore = 0;

uint16_t param2_index = 1;

int32_t param1_pulses = 0;
int32_t param2_pulses = 0;
int32_t param3_pulses = 0;
int32_t param4_pulses = 0;

uint32_t timec = 0, prevtimec = 0;

float param1_value = 0.00;
float param3_value = 0.00;
float param4_value = 0.00;

void setup()
{
  // put your setup code here, to run once:

  // I/O
  pinMode(PIN_LED, OUTPUT);
  pinMode (SAVE, INPUT);

  // open the USBSerial port
  Serial.begin(115200);
  clearAndHome();
  Serial.println(F("Aida DSP control with ARDUINO")); // Welcome message
  Serial.println(F("0x00"));    // Print DSP I2C address

  InitAida(); // Initialize DSP board
  // ... download of program ... (see other examples to know what to do here)
  spettacolino();

  EEPROM.get(0, param1_pulses);
  EEPROM.get(4, param2_pulses);
  EEPROM.get(8, param3_pulses);
  EEPROM.get(12, param4_pulses);
  Serial.println(param1_pulses);
  Serial.println(param2_pulses);
  Serial.println(param3_pulses);
  Serial.println(param4_pulses);
}
void loop() {}

//functions required to get through setup()

void spettacolino()
{
  byte i;
  byte status = 0x00;

  for (i = 0; i < 6; i++)
  {
    status ^= 1;
    digitalWrite(PIN_LED, status);
    delay(250);
  }
}

void clearAndHome(void)
{
  Serial.write(0x1b); // ESC
  Serial.print(F("[2J")); // clear screen
  Serial.write(0x1b); // ESC
  Serial.print(F("[H")); // cursor to home
}

My serial printout shows the values I preloaded. Can you see the same? If not, what are they?

If you can confirm that we are good to this point, then we can next examine every place the code touches the paramX_pulses variables.

Wow, thank you.

Have run both your sketches and can confirm the correct values show in serial monitor.

OK. Is this further than you've gotten before, other things work, and we are done, or do we need to focus on param1_pulses through the process, until it is saved again?

If the program is not working right, can you give me more direction as to what your trouble shooting so far has found.

Not quite done yet! Param1_pulses is still assigned the number saved as param2_pulses in the main sketch.

Maybe the easiest thing way to illustrate is if you can see the problem first hand.

So, first sketch to load numbers into EEPROM.

#include <EEPROM.h>

void setup() {
  uint32_t param1_pulses = 12345678;
  uint32_t param2_pulses = 34567890;
  

  EEPROM.put(0, param1_pulses);
  EEPROM.put(4, param2_pulses);
 
}
void loop() {
}

Then the main sketch, this reads the numbers previously stored and displays them in serial monitor. You should see that param1_pulses = 34567890, whereas the number we saved was actually 12345678.

/*
 AIDA Template2 Sketch
 	
 This sketch is a Template to start coding with
 Aida DSP.
 This sketch was written for Arduino, and will not work on other boards.
 	
 The circuit:
 
 Audio:
 * Input range 2.0Vrms (5.66Vpp, 8.23dBu)
 * Output range 0.9Vrms (2.5Vpp, 1.30dBu) 
 
 PC:
 * Please connect with PuTTY on Arduino USB Serial with a PC for a minimal user interface
 
 NOTE:
 Attenuation Out/In = 2.264, to have out = in you must provide 7.097dB of gain through DSP algorithm
 or externally with active LPF filter.
 
 created November 2014
 by Massimo Pennazio
 
 This example code is in the public domain.
 
 */

#include <Arduino.h>
#include <pins_arduino.h>
#include <Wire.h>
#include "AidaDSP.h"
#include <LiquidCrystal.h>
#include <EEPROM.h>

LiquidCrystal lcd(12, 11, 10, 9, 8, 7); //RS, E, D4, D5, D6, D7

const int SAVE = 14;

#define EVER (;;)

// DEFINES I/O
#define PIN_LED  13

// DEFINES USER INTERFACE
#define MAX 20.00
#define MIN -40.00

#define ON 1
#define OFF 0

// FUNCTION PROTOTYPES
void spettacolino(void);
void clearAndHome(void);

// GLOBAL VARIABLES

// UI
uint8_t bypass = OFF;
uint8_t oldbypass = OFF;
uint8_t func_counter = 0;
uint8_t old_func_counter = 0;
uint8_t push_e_count = 0;
uint8_t push_e_function = 0;
uint8_t restore = 0;

uint16_t param2_index = 1;

int32_t param1_pulses = 0;
int32_t param2_pulses = 0;
int32_t param3_pulses = 0;
int32_t param4_pulses = 0;

uint32_t timec=0, prevtimec=0;

float param1_value = 0.00;
float param3_value = 0.00;
float param4_value = 0.00;


void setup()
{
  int eeAddress = 0;
  
  // put your setup code here, to run once:
setPulses(EEPROM.get(0, param1_pulses));
setPulses(EEPROM.get(4, param2_pulses));
//setPulses(EEPROM.get(8, param3_pulses));
//setPulses(EEPROM.get(12, param4_pulses));
  // I/O
  pinMode(PIN_LED, OUTPUT);
  pinMode (SAVE, INPUT);
  pinMode(6, OUTPUT);
  digitalWrite(6,HIGH);

  //EEPROM.get(0, param1_pulses);
   
  // open the USBSerial port
  Serial.begin(115200);
  clearAndHome();
  Serial.println(F("Aida DSP control with ARDUINO")); // Welcome message
  Serial.println(F("0x00"));    // Print DSP I2C address

  InitAida(); // Initialize DSP board 
  // ... download of program ... (see other examples to know what to do here)
  spettacolino();
}

void loop()
{
  // put your main code here, to run repeatedly:

  if(digitalRead(SAVE)==LOW)  
  {
    digitalWrite(PIN_LED, HIGH);
    delay(50);  // debounce
   // EEPROM.put(0, param1_pulses);
    //EEPROM.put(4, param2_pulses);
    //EEPROM.put(8, param3_pulses);
    //EEPROM.put(12, param4_pulses);
  }
//lcd.clear();
/*delay(100);
   lcd.begin(8, 2);
   lcd.setCursor(0, 0);
   lcd.print(param1_pulses);
lcd.setCursor(0,1);
      lcd.print(param2_pulses);
      */
      
      

  if(digitalRead(ENC_PUSH)==LOW)  
  {
    digitalWrite(PIN_LED, HIGH);
    delay(50);  // debounce
    if(digitalRead(ENC_PUSH)==LOW)
    {
      push_e_count++;
    }   
  }
  else
  {
    if(push_e_count>0 && push_e_count<10)
      push_e_function = 1;
    else if(push_e_count>10 && push_e_count<30)
      push_e_function = 2;
    else
      push_e_function = 0;  // No function triggered on switch
    push_e_count = 0;
    digitalWrite(PIN_LED, LOW);
  }
  
  if(push_e_function==1)
  {
    func_counter--;
    if(func_counter==255)
      func_counter=3;
  }
  else if(push_e_function==2)
  {
    bypass ^=1; 
  }

  timec = millis();
  if(timec-prevtimec >= 1000)  // Here we manage control interface every second
  { 
    clearAndHome();    // !!!Warning use with real terminal emulation program
    Serial.println(F("********************************"));
    Serial.println(F("*    User control interface    *"));
    Serial.println(F("*    AIDA Template2 Sketch     *"));
    Serial.println(F("********************************"));
    Serial.println(F(""));
    Serial.print(F(" Encoder pulses: "));
    Serial.println(getPulses(), DEC);
    Serial.println(F(""));

      Serial.println("param1_pulses=");
      Serial.println(param2_pulses);

      Serial.println("param2_pulses=");
      Serial.println(param2_pulses);
    
    if(oldbypass != bypass)
    {
      if(bypass == ON)
      {
        // Do something, call Aida DSP API
      }
      else
      {
        // Do something, call Aida DSP API
      }
      oldbypass = bypass;
    }

    if(old_func_counter != func_counter)
    {
      restore = 1;
      old_func_counter = func_counter;
    }
    switch(func_counter)
    {
    case 0: // PARAM1
    
      if(restore)
      {
        restore = 0;
        setPulses(param1_pulses);
      }
      param1_pulses = getPulses();
      param1_value = processencoder(MIN, MAX, param1_pulses);
      // Do something, call Aida DSP API
      break;
    case 1: // PARAM2
      if(restore)
      {
        restore = 0;
        setPulses(param2_pulses);
      }
      param2_pulses = getPulses();
      param2_index = selectorwithencoder(param2_pulses, 2); 
      switch(param2_index) 
      {
        case 1:
          // Do something, call Aida DSP API
          break;
        case 2:
          // Do something, call Aida DSP API
          break;
        case 3:
          // Do something, call Aida DSP API
          break;
        case 4:
          // Do something, call Aida DSP API
          break;
      }
      break;
    case 2: // PARAM3
      if(restore)
      {
        restore = 0;
        setPulses(param3_pulses);
      }
      param3_pulses = getPulses();
      param3_value = processencoder(MIN, MAX, param3_pulses);
      // Do something, call Aida DSP API
      break;
    case 3: // Color
      if(restore)
      {
        restore = 0;
        setPulses(param4_pulses);
      }
      param4_pulses = getPulses();
      param4_value = processencoder(MIN, MAX, param4_pulses);
      // Do something, call Aida DSP API
      break;
    } // End switch func_counter

    // Display information for user
    print_menu_putty();

    prevtimec = timec;
  } // End if 1000ms tick
} // End void loop

void spettacolino()
{
  byte i;
  byte status = 0x00;

  for(i=0;i<6;i++)
  {
    status ^= 1;
    digitalWrite(PIN_LED, status);
    delay(250);
  }
}

void clearAndHome(void)
{
  Serial.write(0x1b); // ESC
  Serial.print(F("[2J")); // clear screen
  Serial.write(0x1b); // ESC
  Serial.print(F("[H")); // cursor to home
}

void print_menu_putty(void)
{
  // Print menu
  Serial.print(F(" Effect status: "));
  if(bypass)
    Serial.println(F("bypass"));
  else
    Serial.println(F("on"));
  Serial.println(F(""));  
  if(func_counter==0)
    Serial.print(F("    "));
  Serial.print(F(" Param 1: "));
  Serial.print(param1_value, 1);
  Serial.println(F(""));
  if(func_counter==1)
    Serial.print(F("    "));
  Serial.print(F(" Param 2: "));
  if(param2_index==1)
    Serial.println(F("one"));
  if(param2_index==2)
    Serial.println(F("two"));
  if(param2_index==3)
    Serial.println(F("three"));
  if(param2_index==4)
    Serial.println(F("four"));
  if(func_counter==2)
    Serial.print(F("    "));
  Serial.print(F(" Param 3: "));
  Serial.print(param3_value, 1);
  Serial.println(F(""));
  if(func_counter==3)
    Serial.print(F("    "));
  Serial.print(F(" Param 4: "));
  Serial.print(param4_value, 1);
  Serial.println(F(""));
  Serial.println(F(""));
  Serial.print(F(" Active item: "));
  Serial.println(func_counter, DEC);
}
setPulses(EEPROM.get(0, param1_pulses));
setPulses(EEPROM.get(4, param2_pulses));

I mentioned before that you are overwriting the value of Pulses with param2_pulses and then assign the value back to param1_pulses if you do not use Restore. Are you setting restore = 1?

switch(func_counter)
    {
    case 0: // PARAM1
    
      if(restore)
      {
        restore = 0;
        setPulses(param1_pulses);
      }
      param1_pulses = getPulses();
      param1_value = processencoder(MIN, MAX, param1_pulses);
      // Do something, call Aida DSP API
      break;

This does not look right.

Serial.println("param1_pulses=");
      Serial.println(param2_pulses);

      Serial.println("param2_pulses=");
      Serial.println(param2_pulses);

cattledog:

setPulses(EEPROM.get(0, param1_pulses));

setPulses(EEPROM.get(4, param2_pulses));




I mentioned before that you are overwriting the value of Pulses with param2_pulses and then assign the value back to param1_pulses if you do not use Restore. Are you setting restore = 1?



switch(func_counter)
   {
   case 0: // PARAM1
   
     if(restore)
     {
       restore = 0;
       setPulses(param1_pulses);
     }
     param1_pulses = getPulses();
     param1_value = processencoder(MIN, MAX, param1_pulses);
     // Do something, call Aida DSP API
     break;

I think I misunderstood. Also do not currently understand. How do I use restore? I'm not knowingly setting restore = 1.

This does not look right.

It doesn't does it, my bad :-[ It should read as follows, returns the same result.

Serial.println("param1_pulses=");
      Serial.println(param1_pulses);

      Serial.println("param2_pulses=");
      Serial.println(param2_pulses);

How do I use restore? I'm not knowingly setting restore = 1.

Try adding restore = 1 at the start of any case where you want to have the value in Pulses == the eeprom values. You can also set up a button to define the state of restore if you want some flexibility.

For example

case 0: // PARAM1
      restore=1;
      if(restore)
      {
        restore = 0;
        setPulses(param1_pulses);
      }
      param1_pulses = getPulses();
      param1_value = processencoder(MIN, MAX, param1_pulses);
      // Do something, call Aida DSP API
      break;

I don't think you want to use setPulses() in the setup. Just read in the paramX_pulses values you want to use if you restore.

How is the value of Pulses (either restored, actual or updated values) used in the actual operation of the DSP.

Getting there! Setting restore=1 keeps the numbers as they should be and negates the need for setPulses in setup.

Next problem (sigh) is that whilst paramx_pulses is read correctly, it seems it does not assign that pulse value to it's respective 'Param x" until that switch case has been toggled with the switch, this can be seen in the serial monitor. (Have put restore=1 in each switch case as advised)

I.E

#include <EEPROM.h>

void setup() {
  uint32_t param1_pulses = 12;
  uint32_t param2_pulses = 34;
  uint32_t param3_pulses = 56;
  uint32_t param4_pulses = 78;  

  EEPROM.put(0, param1_pulses);
  EEPROM.put(4, param2_pulses);
  EEPROM.put(8, param3_pulses);
  EEPROM.put(12, param4_pulses);
 
}
void loop() {
}
/*
 AIDA Template2 Sketch
 	
 This sketch is a Template to start coding with
 Aida DSP.
 This sketch was written for Arduino, and will not work on other boards.
 	
 The circuit:
 
 Audio:
 * Input range 2.0Vrms (5.66Vpp, 8.23dBu)
 * Output range 0.9Vrms (2.5Vpp, 1.30dBu) 
 
 PC:
 * Please connect with PuTTY on Arduino USB Serial with a PC for a minimal user interface
 
 NOTE:
 Attenuation Out/In = 2.264, to have out = in you must provide 7.097dB of gain through DSP algorithm
 or externally with active LPF filter.
 
 created November 2014
 by Massimo Pennazio
 
 This example code is in the public domain.
 
 */

#include <Arduino.h>
#include <pins_arduino.h>
#include <Wire.h>
#include "AidaDSP.h"
#include <LiquidCrystal.h>
#include <EEPROM.h>

LiquidCrystal lcd(12, 11, 10, 9, 8, 7); //RS, E, D4, D5, D6, D7

const int SAVE = 14;

#define EVER (;;)

// DEFINES I/O
#define PIN_LED  13

// DEFINES USER INTERFACE
#define MAX 20.00
#define MIN -40.00

#define ON 1
#define OFF 0

// FUNCTION PROTOTYPES
void spettacolino(void);
void clearAndHome(void);

// GLOBAL VARIABLES

// UI
uint8_t bypass = OFF;
uint8_t oldbypass = OFF;
uint8_t func_counter = 0;
uint8_t old_func_counter = 0;
uint8_t push_e_count = 0;
uint8_t push_e_function = 0;
uint8_t restore = 0;

uint16_t param2_index = 1;

int32_t param1_pulses = 0;
int32_t param2_pulses = 0;
int32_t param3_pulses = 0;
int32_t param4_pulses = 0;

uint32_t timec=0, prevtimec=0;

float param1_value = 0.00;
float param3_value = 0.00;
float param4_value = 0.00;


void setup()
{
  int eeAddress = 0;
  
  // put your setup code here, to run once:
EEPROM.get(0, param1_pulses);
EEPROM.get(4, param2_pulses);
EEPROM.get(8, param3_pulses);
EEPROM.get(12, param4_pulses);

  // I/O
  pinMode(PIN_LED, OUTPUT);
  pinMode (SAVE, INPUT);
  pinMode(6, OUTPUT);
  digitalWrite(6,HIGH);

  //EEPROM.get(0, param1_pulses);
   
  // open the USBSerial port
  Serial.begin(115200);
  clearAndHome();
  Serial.println(F("Aida DSP control with ARDUINO")); // Welcome message
  Serial.println(F("0x00"));    // Print DSP I2C address

  InitAida(); // Initialize DSP board 
  // ... download of program ... (see other examples to know what to do here)
  spettacolino();
}

void loop()
{
  // put your main code here, to run repeatedly:

  if(digitalRead(SAVE)==LOW)  
  {
    digitalWrite(PIN_LED, HIGH);
    delay(50);  // debounce
   // EEPROM.put(0, param1_pulses);
    //EEPROM.put(4, param2_pulses);
    //EEPROM.put(8, param3_pulses);
    //EEPROM.put(12, param4_pulses);
  }
//lcd.clear();
/*delay(100);
   lcd.begin(8, 2);
   lcd.setCursor(0, 0);
   lcd.print(param1_pulses);
lcd.setCursor(0,1);
      lcd.print(param2_pulses);
      */
      
      

  if(digitalRead(ENC_PUSH)==LOW)  
  {
    digitalWrite(PIN_LED, HIGH);
    delay(50);  // debounce
    if(digitalRead(ENC_PUSH)==LOW)
    {
      push_e_count++;
    }   
  }
  else
  {
    if(push_e_count>0 && push_e_count<10)
      push_e_function = 1;
    else if(push_e_count>10 && push_e_count<30)
      push_e_function = 2;
    else
      push_e_function = 0;  // No function triggered on switch
    push_e_count = 0;
    digitalWrite(PIN_LED, LOW);
  }
  
  if(push_e_function==1)
  {
    func_counter--;
    if(func_counter==255)
      func_counter=3;
  }
  else if(push_e_function==2)
  {
    bypass ^=1; 
  }

  timec = millis();
  if(timec-prevtimec >= 1000)  // Here we manage control interface every second
  { 
    clearAndHome();    // !!!Warning use with real terminal emulation program
    Serial.println(F("********************************"));
    Serial.println(F("*    User control interface    *"));
    Serial.println(F("*    AIDA Template2 Sketch     *"));
    Serial.println(F("********************************"));
    Serial.println(F(""));
    Serial.print(F(" Encoder pulses: "));
    Serial.println(getPulses(), DEC);
    Serial.println(F(""));

      Serial.println("param1_pulses=");
      Serial.println(param1_pulses);

      Serial.println("param2_pulses=");
      Serial.println(param2_pulses);

      Serial.println("param3_pulses=");
      Serial.println(param3_pulses);

      Serial.println("param4_pulses=");
      Serial.println(param4_pulses);
    
    if(oldbypass != bypass)
    {
      if(bypass == ON)
      {
        // Do something, call Aida DSP API
      }
      else
      {
        // Do something, call Aida DSP API
      }
      oldbypass = bypass;
    }

    if(old_func_counter != func_counter)
    {
      restore = 1;
      old_func_counter = func_counter;
    }
    switch(func_counter)
    {
    case 0: // PARAM1
    restore=1;
      if(restore)
      {
        restore = 0;
        setPulses(param1_pulses);
      }
      param1_pulses = getPulses();
      param1_value = processencoder(MIN, MAX, param1_pulses);
      // Do something, call Aida DSP API
      break;
    case 1: // PARAM2
    restore=1;
      if(restore)
      {
        restore = 0;
        setPulses(param2_pulses);
      }
      param2_pulses = getPulses();
      param2_index = selectorwithencoder(param2_pulses, 2); 
      switch(param2_index) 
      {
        case 1:
          // Do something, call Aida DSP API
          break;
        case 2:
          // Do something, call Aida DSP API
          break;
        case 3:
          // Do something, call Aida DSP API
          break;
        case 4:
          // Do something, call Aida DSP API
          break;
      }
      break;
    case 2: // PARAM3
    restore=1;
      if(restore)
      {
        restore = 0;
        setPulses(param3_pulses);
      }
      param3_pulses = getPulses();
      param3_value = processencoder(MIN, MAX, param3_pulses);
      // Do something, call Aida DSP API
      break;
    case 3: // Color
    restore=1;
      if(restore)
      {
        restore = 0;
        setPulses(param4_pulses);
      }
      param4_pulses = getPulses();
      param4_value = processencoder(MIN, MAX, param4_pulses);
      // Do something, call Aida DSP API
      break;
    } // End switch func_counter

    // Display information for user
    print_menu_putty();

    prevtimec = timec;
  } // End if 1000ms tick
} // End void loop

void spettacolino()
{
  byte i;
  byte status = 0x00;

  for(i=0;i<6;i++)
  {
    status ^= 1;
    digitalWrite(PIN_LED, status);
    delay(250);
  }
}

void clearAndHome(void)
{
  Serial.write(0x1b); // ESC
  Serial.print(F("[2J")); // clear screen
  Serial.write(0x1b); // ESC
  Serial.print(F("[H")); // cursor to home
}

void print_menu_putty(void)
{
  // Print menu
  Serial.print(F(" Effect status: "));
  if(bypass)
    Serial.println(F("bypass"));
  else
    Serial.println(F("on"));
  Serial.println(F(""));  
  if(func_counter==0)
    Serial.print(F("    "));
  Serial.print(F(" Param 1: "));
  Serial.print(param1_value, 1);
  Serial.println(F(""));
  if(func_counter==1)
    Serial.print(F("    "));
  Serial.print(F(" Param 2: "));
  if(param2_index==1)
    Serial.println(F("one"));
  if(param2_index==2)
    Serial.println(F("two"));
  if(param2_index==3)
    Serial.println(F("three"));
  if(param2_index==4)
    Serial.println(F("four"));
  if(func_counter==2)
    Serial.print(F("    "));
  Serial.print(F(" Param 3: "));
  Serial.print(param3_value, 1);
  Serial.println(F(""));
  if(func_counter==3)
    Serial.print(F("    "));
  Serial.print(F(" Param 4: "));
  Serial.print(param4_value, 1);
  Serial.println(F(""));
  Serial.println(F(""));
  Serial.print(F(" Active item: "));
  Serial.println(func_counter, DEC);
}

Pulses are mapped to floats (paramx_value) which contain parameter values such as filter frequency, volume etc...Which are then sent to the DSP chip (after some clever stuff in the .cpp and .h).

it seems it does not assign that pulse value to it's respective 'Param x" until that switch case has been toggled with the switch,

Yes, that the way the sketch works.

2)Can you confirm with Serial debugging prints that you can step through the switch case menu when you press the ENCODER_PUSH button which I think should be connected to pin 4?
Yes.

You should be able to get into the switch cases with the button. You can certainly test each case by setting the value of func_counter which controls the switch. Default function counter is 0, so it enters the case0 for param1. I'd recommend some serial debugging on the value of funct_counter.

if(old_func_counter != func_counter)
    {
      restore = 1;
      old_func_counter = func_counter;
    }
    switch(func_counter)

It appears that the restore =1 is set when the func_counter is changed. Once you get the funct_counter working, you should be able to take the restore =1 out of the switch case argument.