(Solved) DIY Arduino FrontEnd Bench PSU (Software Issue on second Project code )

Hi All!
Warm (literally) Greetings from Namibia.

I have not posted here in a while and things have changed a lot.
So please forgive me if I am posting this in the wrong place.

A bit of background, I am busy building an in-line "bench PSU"
that will use a laptop power brick or similar to turn it into a small bench PSU.

The first part I have working flawlessly, I will post that code first so that you may suggest changes where things are to long or something could be done differently, I am a COMPLETE NOVIC!!!!

Both projects are using an Arduino Mega.

THIS ONE IS FINE NO ISSUES WORKING AS EXPECTED


////////////////////////////////////// Digital FrontEnd PSU \\\\\\\\\\\\\\\\\\\\\\\\

/*
 This programe with the neccessary circuitry will allow you to turn any 
 brick type powersupply into a bench PSU.
 */
 
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);


////////////////////////// Serial Debugging  on = 1 or off = 0 \\\\\\\\\\\\\\\\\\\\\\

#define DEBUG 0

#if DEBUG == 1
#define debug(x) Serial.print(x)
#define debugln(x) Serial.println(x)
#else
#define debug(x)
#define debugln(x)
#endif



///////////////////////////////////// Set AREF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

const float AREF = 5.06;// Measure this with a DMM

///////////////////////////////// Main Voltage InPut \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

int a;                   // averaging integer place holder for main input
const int mainRail = A1; //Input voltage Pin
float Vin;               // place holder for the data coming in on A1
float mainVprint;        // Converted info to print on screen
float lastmainVprint;
long ADCmainVal;         // Place holder for average amount
int mainVcount = 100;    // number of readings to average


float R1 = 24599.7; // 20K + 4K7 =24K7 Ohms Meter reads 24K6 Ohms - 0.3 Ohms for meter leads
float R2 =  4639.7;  // 4K7 Ohms Meter reads 4K64 Ohms - 0.3 Ohms for meter leads
float mainVOffset = 0.9860627177700348;

/////////////////////////////// Arduino VIN Supply voltage on that pin \\\\\\\\\\\\\\\\\\\\\\\\\

int b;
const int ARDrail = A0;
float ARDVin;
float ARDmainprint;
float lastARDmainprint;
long ARDadcVal;
int ARDVcount = 100;

const float ARDOffset = 0.992156862745098;



///////////////////////////////  V read  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

int e;
const int outputV = A5; // output terminals Read
float VoltIn;
float inVoltPrint;
float lastinVoltPrint;
long involtADCval;
int involtcount = 100;


float R3 = 24599.7; // 20K + 4K7 =24K7 Ohms Meter reads 24K6 Ohms - 0.3 Ohms for meter leads
float R4 =  4679.7;  // 4K7 Ohms Meter reads 4K64 Ohms - 0.3 Ohms for meter leads

float inVOffset = 0.9334298118668596;

////////////////////////////  I Read  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

int f;
const int outputA = A4; // output terminals Read
float AmpsIn;
float inAmpPrint;
float lastinAmpPrint;
long inAMPADCval;
int inAMPcount = 100;
const float inAMPmap;

float inAMPOffset = 0.71428571428571434;



////////////////////////////Current Adjust Input\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

int c;
const int adjCurrent = A2; // I used Red Knob
float adjCurrIn;
float adjCurrPrint;
float lastadjCurrPrint;
long currADCval;
int currAcount = 100;

const float currentOffset = 0.5204460966542751;


//////////////////////////// Voltage Adjust Input \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

int d;
const int adjVoltage = A3; // I used Yellow Knob
float adjVoltIn;
float adjVoltPrint;
float lastadjVoltPrint;
long voltADCval;
int voltVcount = 100;

const float voltOffset = 2.7593984962406022;


///////////////////////////// Output Pins Config \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

int PWMAoutput = 9; // Output Pin for Iset
int ampsOutPWM; // conversion holder for internal ADC to DAC
int PWMVoutput = 10; // Output Pin for Vset
int voltsOutPWM; // conversion holder for internal ADC to DAC




////////////////////////////// Setup initial program \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

void setup() {

  TCCR2B = TCCR2B & B11111000 | B00000001; // Pins 9 and 10 PWM frequency of 31372.55Hz for Mega



  analogReference (EXTERNAL);



  /////////PWM analoge output\\\\\\\
  pinMode (PWMAoutput, OUTPUT);
  pinMode (PWMAoutput, LOW);
  pinMode (PWMVoutput, OUTPUT);
  pinMode (PWMVoutput, LOW);




  //////////////////////////////////////// LCD setup \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


  lcd.init ();
  lcd.backlight ();
  lcd.setCursor (0, 0);
  lcd.print ("   GAP Front End");
  lcd.setCursor(0, 1);
  lcd.print ("    Digital PSU");
  lcd.setCursor(0, 2);
  lcd.print("       V1.0");
  delay (3500);
  lcd.clear ();
  Serial.begin(115200);

}

/////////////////////////////////////////// Main Program \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

void loop() {





  PsuVin(); // Analog Readings.
  ardVin(); // Analog Readings.
  Vread();  // Analog Readings.
  Iread();  // Analog Readings.

  Vset();      // VSet is an analog function 
  ISet();      // ISet is an analog function 
  CCmode();    // CCmode is the analog functionality of the CC, CV, and OUTPUT SHORTED alarms
  PwmAWrite(); // Both these functions are used for the PWM output from ADC to DAC
  PwmVWrite(); // Both these functions are used for the PWM output from ADC to DAC


}


void PsuVin() {
  for (a = 0; a < mainVcount; a++) {
    ADCmainVal = ADCmainVal + analogRead (mainRail);
    delay (1);
  }
  ADCmainVal = ADCmainVal  / mainVcount;
  Vin = ADCmainVal;
  mainVprint = (Vin * AREF) / 1024.0 / (R2 / (R1 + R2)) * mainVOffset;
  if (mainVprint != lastmainVprint) {

    debug ("adc PSU in value: ");
    debug (ADCmainVal);
    debug (" Psu Volts in: ");
    debugln (mainVprint);
    debugln ();

    lcd. setCursor (0, 0);
    lcd. print ("In ");
    lcd. print  (mainVprint);

    lastmainVprint = mainVprint;

  }
}

void ardVin() {
  for (b = 0; b < ARDVcount; b++) {
    ARDadcVal = ARDadcVal + analogRead (ARDrail);
    delay (1);
  }
  ARDadcVal = ARDadcVal  / ARDVcount;
  ARDVin = ARDadcVal;
  ARDmainprint = ARDVin * (AREF / 1024) * ARDOffset;
  if (ARDmainprint != lastARDmainprint) {

    debug ("adc Arduino in value: ");
    debug (ARDadcVal);
    debug (" Arduino Volts in: ");
    debugln (ARDmainprint);
    debugln ();

    lcd. setCursor (12, 0);
    lcd. print ("ARD ");
    lcd. print  (ARDmainprint);

    lastARDmainprint = ARDmainprint;

  }
}


void Vread() {


  for (e = 0; e < involtcount; e++) {
    involtADCval = involtADCval + analogRead (outputV);
    delay (1);
  }
  involtADCval = involtADCval  / involtcount;
  VoltIn = involtADCval;
  inVoltPrint = (VoltIn * AREF) / 1024.0 / (R4 / (R3 + R4)) * inVOffset;
  if (inVoltPrint != lastinVoltPrint) {

    debug ("adc Voltage value: ");
    debug (involtADCval);
    debug (" Voltage Output read: ");
    debugln (inVoltPrint);
    debugln ();

    lcd. setCursor (0, 3);
    lcd. print ("VR ");
    lcd. setCursor (3, 3);
    lcd. print ("     ");
    lcd. setCursor (3, 3);
    lcd. print  (inVoltPrint);

    lastinVoltPrint = inVoltPrint;

  }
}

void Iread() {


  for (f = 0; f < inAMPcount; f++) {
    inAMPADCval = inAMPADCval + analogRead (outputA);
    delay (1);
  }
  inAMPADCval = inAMPADCval  / inAMPcount;
  AmpsIn = inAMPADCval;
  inAmpPrint = AmpsIn * (AREF / 1024) * inAMPOffset;
  if (inAmpPrint != lastinAmpPrint) {

    debug ("adc Current value: ");
    debug (inAMPADCval);
    debug (" Current read: ");
    debugln (inAmpPrint);
    debugln ();
    debugln ();
    debugln ();
    debugln ();

    lcd. setCursor (12, 3);
    lcd. print ("IR ");
    lcd. setCursor (15, 3);
    lcd. print ("    ");
    lcd. setCursor (15, 3);
    lcd. print  (inAmpPrint);

    lastinAmpPrint = inAmpPrint;

  }
}



void ISet() {      //NB!! Analog Knobs Iset, 

  for (c = 0; c < currAcount; c++) {
    currADCval = currADCval + analogRead (adjCurrent);

  }
  currADCval = currADCval  / currAcount;
  adjCurrIn = currADCval;
  adjCurrPrint = adjCurrIn * (AREF / 1024) * currentOffset;
  if (adjCurrPrint != lastadjCurrPrint) {

    debug ("adc Current setpoint value: ");
    debug (currADCval);
    debug (" Current Setpoint: ");
    debugln (adjCurrPrint);
    debugln ();

    lcd. setCursor (12, 1);
    lcd. print ("IS ");
    lcd. setCursor (15, 1);
    lcd. print ("    ");
    lcd. setCursor (15, 1);
    lcd. print  (adjCurrPrint);

    lastadjCurrPrint = adjCurrPrint;

  }
}

void Vset() {     //NB!! Analog Knobs Vset, 


  for (d = 0; d < voltVcount; d++) {
    voltADCval = voltADCval + analogRead (adjVoltage);
    delay (1);
  }
  voltADCval = voltADCval  / voltVcount;
  adjVoltIn = voltADCval;
  adjVoltPrint = adjVoltIn * (AREF / 1024) * voltOffset;
  if (adjVoltPrint != lastadjVoltPrint) {

    debug ("adc Voltage setpoint value: ");
    debug (voltADCval);
    debug (" Voltage setpoint: ");
    debugln (adjVoltPrint);
    debugln ();

    lcd. setCursor (0, 1);
    lcd. print ("VS ");
    lcd. setCursor (3, 1);
    lcd. print ("     ");
    lcd. setCursor (3, 1);
    lcd. print  (adjVoltPrint);

    lastadjVoltPrint = adjVoltPrint;

  }
}

////////////////////////////// PWM output for Analog usage only \\\\\\\\\\\\\\\\\\\

void PwmAWrite() {

  currADCval = analogRead (adjCurrent);

  ampsOutPWM = map (currADCval, 0, 1023, 0, 255);
  analogWrite (PWMAoutput, ampsOutPWM);
}

void PwmVWrite() {

  voltADCval = analogRead (adjVoltage);

  voltsOutPWM = map (voltADCval, 0, 1023, 0, 255);
  analogWrite (PWMVoutput, voltsOutPWM);
}

void CCmode() {
  if (adjCurrIn < 1033) {
    lcd.setCursor (0, 2);
    lcd.print ("     CC Active!     ");
  }
  else {
    lcd.setCursor (0, 2);
    lcd.print ("     CV Active      ");
  }
  if (adjCurrIn == 0 && adjVoltIn == 0) {
    lcd.setCursor(0, 2);
    lcd.print ("  No Active Limits  ");
  }
  else if (AmpsIn >= 385 && VoltIn <= 25) {
    lcd.setCursor(0, 2);
    lcd.print ("CHECK OUTPUT SHORTED");
  }
}

This works with no issues and as expected.

PROBLEM PART BELOW

The second one however........... Not so much, I am trying to use encoders on this one.

The problem, If I comment out or disable the other processes in the void loop the the encoders work and display data as expected, when enabling even one of the other processes then the encoders stop working, I have tried to do attach Interrupt in the void setup but I am either doing it completely wrong or I'm just a (something)head.... Or possibly both.....
After putting in an attatchIntterupt then the code does "sort of" go to the routine, sometimes it prints the first two characters and then just completely stops working, no more serial monitor activity or it just completely stops does not print any characters and then no more serial activity...

Any Help would be appreciated:


//////////////////////////////////////Digital FrontEnd PSU ,Encoderrs\\\\\\\\\\\\\\\\\\\\\\\\

/*
 This programe with the neccessary circuitry will allow you to turn any 
 brick type powersupply into a bench PSU.
 */
 


#include <rotary.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);


//////////////////////////Serial Debugging  on 1 or off 0 \\\\\\\\\\\\\\\\\\\\\\

#define DEBUG 1

#if DEBUG == 1
#define debug(x) Serial.print(x)
#define debugln(x) Serial.println(x)
#else
#define debug(x)
#define debugln(x)
#endif


////////////////////////////////// Encoder setup Amps \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

// Rotary encoder is wired with the common to ground and the two
// outputs to pins 2 and 4.

Rotary rotary1 = Rotary(2, 4);



int counter1 = 0;     // Counter that will be incremented or decremented by rotation.
int oldcounter1 = 0;  // Place holder for old value

float AmpsSet;
float oldAmpsset;

float AmpsSetstep = 0.019607843137255;


////////////////////////////////////  Encoder setup Volts  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

// Rotary encoder is wired with the common to ground and the two
// outputs to pins 3 and 5.

Rotary rotary2 = Rotary(3, 5);

int counter2 = 0;
int oldcounter2 = 0;

float VoltsSet;
float oldVoltset;

float VoltSetstep = 0.057490196078431;

///////////////////////////////////// Set AREF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

const float AREF = 5.06;// Measure this with a DMM

///////////////////////////////// Main Voltage InPut\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

int a;                   // averaging integer place holder for main input
const int mainRail = A1; //Input voltage Pin
float Vin;               // place holder for the data coming in on A1
float mainVprint;        // Converted info to print on screen
float lastmainVprint;
long ADCmainVal;         // Place holder for average amount
int mainVcount = 100;    // number of readings to average


float R1 = 24599.7; // 20K + 4K7 =24K7 Ohms Meter reads 24K6 Ohms - 0.3 Ohms for meter leads
float R2 =  4639.7;  // 4K7 Ohms Meter reads 4K64 Ohms - 0.3 Ohms for meter leads
float mainVOffset = 0.9860627177700348;

/////////////////////////////// Arduino VIN Supply voltage on that pin \\\\\\\\\\\\\\\\\\\\\\\\\

int b;
const int ARDrail = A0;
float ARDVin;
float ARDmainprint;
float lastARDmainprint;
long ARDadcVal;
int ARDVcount = 100;

const float ARDOffset = 0.992156862745098;



///////////////////////////////  V read  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

int e;
const int outputV = A5; // output terminals Read
float VoltIn;
float inVoltPrint;
float lastinVoltPrint;
long involtADCval;
int involtcount = 100;


float R3 = 24599.7; // 20K + 4K7 =24K7 Ohms Meter reads 24K6 Ohms - 0.3 Ohms for meter leads
float R4 =  4679.7;  // 4K7 Ohms Meter reads 4K64 Ohms - 0.3 Ohms for meter leads

float inVOffset = 0.9334298118668596;

////////////////////////////  I Read  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

int f;
const int outputA = A4; // output terminals Read
float AmpsIn;
float inAmpPrint;
float lastinAmpPrint;
long inAMPADCval;
int inAMPcount = 100;
const float inAMPmap;

float inAMPOffset = 0.71428571428571434;



////////////////////////////// Setup initial program\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

void setup() {
  TCCR2B = TCCR2B & B11111000 | B00000001;// Pins 9 and 10 PWM frequency of 31372.55Hz for Mega

  attachInterrupt(digitalPinToInterrupt(2), EncAmps, CHANGE);

  analogReference (EXTERNAL);



  //////////////////////////////////////// LCD setup \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


  lcd.init ();
  lcd.backlight ();
  lcd.setCursor (0, 0);
  lcd.print ("   GAP Front End");
  lcd.setCursor(0, 1);
  lcd.print ("    Digital PSU");
  lcd.setCursor(0, 2);
  lcd.print("       V1.0");
  delay (3500);
  lcd.clear ();
  Serial.begin(115200);

}

/////////////////////////////////////////// Main Program \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

void loop() {




  EncAmps();
  EncVolts();
  //  EncIPWM();  // Still to Write
  //  EncVPWM();  // Still to Write

    PsuVin();   // Analog Readings.From Input Supply
    ardVin();   // Analog Readings.From Input Rail for Arduino
  //  Vread();    // Analog Readings. When External PSU is connected
  //  Iread();    // Analog Readings. When External PSU is connected




}

////////////////////////////// Encoder Stuff \\\\\\\\\\\\\\\\\\\\\\\\\

// Read 1st Encoder EncAmps, Get the value, do not allow value over or under set
// constrain values, covert values to set amounts remember those values and only
// print when updated....


void EncAmps() {

  unsigned char result1 = rotary1.process();

  if (result1 == DIR_CW) {
    counter1++;

    AmpsSet = counter1 * AmpsSetstep;

    counter1 = constrain (counter1, 0, 255);

    debug ("Counter 1: ");
    debug (counter1);
    debugln ();
    // debug ("Amps converted: ");
    // debug (AmpsSet);
    // debug ("   ");
    // debugln ();
    // debugln ();

   // lcd. setCursor (12, 1);
   // lcd. print ("IS ");
   // lcd. setCursor (15, 1);
   // lcd. print ("    ");
   // lcd. setCursor (15, 1);
   // lcd. print  (AmpsSet);

    oldcounter1 = counter1;

  } else if (result1 == DIR_CCW) {
    counter1--;

    AmpsSet = counter1 * AmpsSetstep;

    counter1 = constrain (counter1, 0, 255);

    debug ("Counter 1: ");
    debug (counter1);
    debugln ();
    //  debug ("Amps converted: ");
    //  debug (AmpsSet);
    //  debug ("   ");
    //  debugln ();
    //  debugln ();

   // lcd. setCursor (12, 1);
   // lcd. print ("IS ");
   // lcd. setCursor (15, 1);
   // lcd. print ("    ");
   // lcd. setCursor (15, 1);
   // lcd. print  (AmpsSet);

    oldcounter1 = counter1;

  }
}

// Read 2nd Encoder EncVolts, Get the value, do not allow value over or under set
// constrain values, covert values to set amounts remember those values and only
// print when updated....

void EncVolts() {
  unsigned char result2 = rotary2.process();

  if (result2 == DIR_CW) {
    counter2++;

    VoltsSet = counter2 * VoltSetstep;

    counter2 = constrain (counter2, 0, 255);


    debug ("Counter 2: ");
    debug (counter2);
    debugln ();
    //  debug ("Volts Converted: ");
    //  debug (VoltsSet);
    //  debugln ();
    //  debugln ();

    // lcd. setCursor (0, 1);
    // lcd. print ("VS ");
    // lcd. setCursor (3, 1);
    // lcd. print ("     ");
    // lcd. setCursor (3, 1);
    // lcd. print  (VoltsSet);

    oldcounter2 = counter2;



  } else if (result2 == DIR_CCW) {
    counter2--;

    VoltsSet = counter2 * VoltSetstep;

    counter2 = constrain (counter2, 0, 255);


    debug ("Counter 2: ");
    debug (counter2);
    debugln ();
    //  debug ("Volts Converted: ");
    //  debug (VoltsSet);
    //  debugln ();
    //  debugln ();

    //  lcd. setCursor (0, 1);
    //  lcd. print ("VS ");
    //  lcd. setCursor (3, 1);
    //  lcd. print ("     ");
    //  lcd. setCursor (3, 1);
    //  lcd. print  (VoltsSet);

    oldcounter2 = counter2;


  }
}


void PsuVin() {
  for (a = 0; a < mainVcount; a++) {
    ADCmainVal = ADCmainVal + analogRead (mainRail);
    delay (1);
  }
  ADCmainVal = ADCmainVal  / mainVcount;
  Vin = ADCmainVal;
  mainVprint = (Vin * AREF) / 1024.0 / (R2 / (R1 + R2)) * mainVOffset;
  if (mainVprint != lastmainVprint) {

    debug ("adc PSU in value: ");
    debug (ADCmainVal);
    debug (" Psu Volts in: ");
    debugln (mainVprint);
    debugln ();

    lcd. setCursor (0, 0);
    lcd. print ("In ");
    lcd. print  (mainVprint);

    lastmainVprint = mainVprint;

  }
}

void ardVin() {
  for (b = 0; b < ARDVcount; b++) {
    ARDadcVal = ARDadcVal + analogRead (ARDrail);
    delay (1);
  }
  ARDadcVal = ARDadcVal  / ARDVcount;
  ARDVin = ARDadcVal;
  ARDmainprint = ARDVin * (AREF / 1024) * ARDOffset;
  if (ARDmainprint != lastARDmainprint) {

    debug ("adc Arduino in value: ");
    debug (ARDadcVal);
    debug (" Arduino Volts in: ");
    debugln (ARDmainprint);
    debugln ();

    lcd. setCursor (12, 0);
    lcd. print ("ARD ");
    lcd. print  (ARDmainprint);

    lastARDmainprint = ARDmainprint;

  }
}


void Vread() {


  for (e = 0; e < involtcount; e++) {
    involtADCval = involtADCval + analogRead (outputV);
    delay (1);
  }
  involtADCval = involtADCval  / involtcount;
  VoltIn = involtADCval;
  inVoltPrint = (VoltIn * AREF) / 1024.0 / (R4 / (R3 + R4)) * inVOffset;
  if (inVoltPrint != lastinVoltPrint) {

    debug ("adc Voltage value: ");
    debug (involtADCval);
    debug (" Voltage Output read: ");
    debugln (inVoltPrint);
    debugln ();

    lcd. setCursor (0, 3);
    lcd. print ("VR ");
    lcd. setCursor (3, 3);
    lcd. print ("     ");
    lcd. setCursor (3, 3);
    lcd. print  (inVoltPrint);

    lastinVoltPrint = inVoltPrint;

  }
}

void Iread() {


  for (f = 0; f < inAMPcount; f++) {
    inAMPADCval = inAMPADCval + analogRead (outputA);
    delay (1);
  }
  inAMPADCval = inAMPADCval  / inAMPcount;
  AmpsIn = inAMPADCval;
  inAmpPrint = AmpsIn * (AREF / 1024) * inAMPOffset;
  if (inAmpPrint != lastinAmpPrint) {

    debug ("adc Current value: ");
    debug (inAMPADCval);
    debug (" Current read: ");
    debugln (inAmpPrint);
    debugln ();
    debugln ();
    debugln ();
    debugln ();

    lcd. setCursor (12, 3);
    lcd. print ("IR ");
    lcd. setCursor (15, 3);
    lcd. print ("    ");
    lcd. setCursor (15, 3);
    lcd. print  (inAmpPrint);

    lastinAmpPrint = inAmpPrint;

  }
}

Any Help is welcome I am a bit lost here.

Regards
Charles

The idea was correct but you must not call the complete subroutine as that one contains calls to the output serial stuff and display on the LCD which both might need interrupts to work (interrupts are disabled during interrupt handlers).

Hi @pylon.

As I said, I am a noob. But I have sorted it.

Syntax is a bitch on heat when it comes to coding and I suck at it, but, I was able to narrow down the problems.

Syntax was most of it, but left the debug stuff as this is disabled when I don't need it, I wrote a new function for the lcd stuff, and also rewrote the encoder bits, have rewired them to run with both legs on their own set of hardware interrupts for each encoder and done away with the libraries.

Will post the new code when I am done in case anyone has any other input as to simpler methods or better implantation.

Regards
Charles