Notifications
Clear all

Arduino with Stepper and LiquidCrystal Issue

Page 13 / 21

Voltage
(@voltage)
Estimable Member
Joined: 10 months ago
Posts: 169
Topic starter  

Rats! I am getting that stray '\302' error again and tried copying the code twice. From what I read yesterday when I had that error it is something to do with a cut/paste issue (like invisible characters). I will try some more...

 

edit: Got it. Just closed and opened a new sketch.

Thanks,
Voltage


ReplyQuote
Voltage
(@voltage)
Estimable Member
Joined: 10 months ago
Posts: 169
Topic starter  

Ok, the test is not working. I start it and no motion at all. Then I turn the pot all the way opposite and the stepper runs probably at the fast setting. Turn it the other way and click click click and the output shaft just twitches. Anywhere on the pot does nothing but twitch except for the one position all the way to the left. I cannot change direction with the stop button and the output shows -0.5 RPM.

edit: After playing with the project some more it is acting weird. I can stop it and turn the pot to the right and try it but it won't start. If I stop it and turn it to the left and try again it will only start when the pot is down to 5 or 6 on the diameter. But then it won't run at 0.5 so it's buggy.

Thanks,
Voltage


ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 11 months ago
Posts: 1764
 
Posted by: @voltage

Ok, I will give it a test here in a minute. Actually MadMisha's name need to be at the top of the comments as he wrote this, then you modified it, and I tested it. 😎 

Agreed, change the top comment section from

//****************************************
//     sketch_aug06e-Mod-5
//*************************************

to

 

//*************************************
//     sketch_aug06e-Mod-6
//
//      base sketch by MadMisha
//      mods by Will
//      tested/verified by Voltage
//****************************************

 

 

I was kidnapped by mimes.
They did unspeakable things to me.


ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 11 months ago
Posts: 1764
 
Posted by: @voltage

Ok, the test is not working. I start it and no motion at all. Then I turn the pot all the way opposite and the stepper runs probably at the fast setting. Turn it the other way and click click click and the output shaft just twitches. Anywhere on the pot does nothing but twitch except for the one position all the way to the left. I cannot change direction with the stop button and the output shows -0.5 RPM.

edit: After playing with the project some more it is acting weird. I can stop it and turn the pot to the right and try it but it won't start. If I stop it and turn it to the left and try again it will only start when the pot is down to 5 or 6 on the diameter. But then it won't run at 0.5 so it's buggy.

When it starts , go is off so it shouldn't move. I think you'll need to push either the backward or forward button to start it.

It looks like pressing stop (when go is false) only changes direction, but never actually starts. Please try starting stand then pressing the forward button.

I was kidnapped by mimes.
They did unspeakable things to me.


ReplyQuote
Voltage
(@voltage)
Estimable Member
Joined: 10 months ago
Posts: 169
Topic starter  
Posted by: @madmisha

@voltage @will

Ok, I have a test. I want to see how bad of a delay there is using the buttons on the shield. It will also let us know how some of the following things interact: Switch case(great if we want/need to add more buttons), screen update as a function, screen update without the interrupt changing the cursor location, digital selection of speed.

 

I do not know what version you have so if you have the 1.0 instead of the 1.1 do the comment and uncomment in the asterisks.

 

Display will only show the 50-1000 value right now so that you see that it is working properly. Small increment go up and down 1 and large up by 10. It is easy to drop in the formulas later that you both have been working on.

 

Select Button: Start and Stop

Left Button: Change direction

Right Button: How fast it increments when changing value(can be adjusted or changed to digit instead)

Up Button: Increment up based on slow or fast that is selected by right button

Down Button: Increment down based on slow or fast that is selected by right button

 

Up and down could eventually change it by the finest parameter when go is active. So diameter at first but after it starts it will adjust RPM? Or something like that. Whatever mean you want.

 

There is another method of doing this if you like the concept but it doesn't register the presses right. Or a delay is not right.

 

 

//Shield button test. Ripped off of:
//Voltage Version sketch_aug06e-Will-Mod-4
//Test of accelstepper with LCD and shield buttons

#include <AccelStepper.h>
#include <LiquidCrystal.h>

//Define pins
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5
int driverPUL = 12;    // PUL- pin
int driverDIR = 13;    // DIR- pin
//int spd = A1;          // Potentiometer
//int dia, old_dia = 0;  // Last pot reading
bool go = false;  //Is it running
bool dirFor = true; //Direction to go in
int smInc = 1;      //Small increase
int lgInc = 10;      //Large increase
bool slChange = true; //Slow change
int drive = 70;     //Raw Speed Number
//float sps;             // Sets per second for this diameter
//float RPM;             // RPM for this diameter 

AccelStepper stepper(1,driverPUL,driverDIR); // This needs to change in any example(Mode, Pul, Dir)

LiquidCrystal lcd(8,9,4,5,6,7); //Setup LCD

//Shield buttons read (IF VERSION 1.0 SHIELD, LET ME KNOW!)
int read_LCD_buttons() {
 adc_key_in = analogRead(0);      // read the value from the sensor
 // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
 // we add approx 50 to those values and check to see if we are close
 if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
 
 
 //********************Block comment here is need changing based on version******
 // For V1.1 us this threshold
 if (adc_key_in < 50)   return btnRIGHT;
 if (adc_key_in < 250)  return btnUP;
 if (adc_key_in < 450)  return btnDOWN;
 if (adc_key_in < 650)  return btnLEFT;
 if (adc_key_in < 850)  return btnSELECT;
 //********************End Block comment*************************************

//*************Uncomment if you have the V1.0***********************************
  // For V1.0 comment the other threshold and use the one below:
/*
 if (adc_key_in < 50)   return btnRIGHT;
 if (adc_key_in < 195)  return btnUP;
 if (adc_key_in < 380)  return btnDOWN;
 if (adc_key_in < 555)  return btnLEFT;
 if (adc_key_in < 790)  return btnSELECT;
*/
//************************End of uncomment*****************************************

return btnNONE;  // when all others fail
}

void screen() {
  lcd.setCursor(5,0);                               // Update LCD
  lcd.print("      ");                              //Only a test
  lcd.setCursor(5,0);
  lcd.print(drive);
  lcd.setCursor(5,1);
  lcd.print("      ");
  lcd.setCursor(5,1);
  lcd.print( (dirFor) ? drive : -drive);
}

void setup() {  
   stepper.setMaxSpeed(1000);
   stepper.setMinPulseWidth(2.7);
   stepper.setSpeed(drive);

   lcd.begin(16, 2);
   lcd.setCursor(1,0);
   lcd.print("Dia:");
   lcd.setCursor(1,1);
   lcd.print("RPM:");
}

void loop() {
  if (go){
    stepper.runSpeed();
  } else {
    stepper.stop();
  }
  int lcd_key = read_LCD_buttons();

  switch (lcd_key)               // depending on which button was pushed, we perform an action
  {
   case btnRIGHT:
     {
     !slChange;
     break;
     }
   case btnLEFT:
     {
     !dirFor;
     break;
     }
   case btnUP:
     {
     if(slChange){
      if(drive <= (1000 - smInc)){
        drive = drive + smInc;
      }   
     } else if (drive <= (1000 - lgInc)){
        drive = drive + lgInc;
     }
     if (dirFor){
        stepper.setSpeed(drive);
     } else {
        stepper.setSpeed(!drive);
     }
     screen();
     break;
     }
   case btnDOWN:
     {
     if(slChange){
      if(drive >= (1000 + smInc)){
        drive = drive - smInc;
      }   
     } else if (drive >= (50 + lgInc)){
        drive = drive - lgInc;
     }
      if (dirFor){
        stepper.setSpeed(drive);
     } else {
        stepper.setSpeed(!drive);
     }
     screen();
     break;
     }
   case btnSELECT:
     {
     !go;
     break;
     }
     case btnNONE:
     {
     break;
     }
  }  
}

 

 

@madmisha

I tried this code and had the instructions with me but it only partially works.

Select button, Left button, Right button appear to do nothing.

Up button works where both sets of number rapidly increase all the way to 1000. I got it to decrement a little but not reliably.

select + down puts a 70 on both number lines but that's it. And then after hitting a bunch of different buttons I was able to get the up button to increment in random steps of 20 and sometimes more than 20 but random.

Here is what my V1 display looks like:

https://tinyurl.com/4sf3zfpp

Thanks,
Voltage


ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 11 months ago
Posts: 1764
 
Posted by: @voltage

Ok, the test is not working. I start it and no motion at all. Then I turn the pot all the way opposite and the stepper runs probably at the fast setting. Turn it the other way and click click click and the output shaft just twitches. Anywhere on the pot does nothing but twitch except for the one position all the way to the left. I cannot change direction with the stop button and the output shows -0.5 RPM.

edit: After playing with the project some more it is acting weird. I can stop it and turn the pot to the right and try it but it won't start. If I stop it and turn it to the left and try again it will only start when the pot is down to 5 or 6 on the diameter. But then it won't run at 0.5 so it's buggy.

I think I found the problem, I didn't correct finalSPE for the diameter being in hundredths of an inch (doh!)

please change the line

float finalSPE = finalSPR/8/3.14159265; // Steps per eighth per 1" diameter

to

float finalSPE = 100*finalSPR/8/3.14159265; // Steps per eighth per 1" diameter

 

I was kidnapped by mimes.
They did unspeakable things to me.


ReplyQuote
Voltage
(@voltage)
Estimable Member
Joined: 10 months ago
Posts: 169
Topic starter  
Posted by: @will
Posted by: @voltage

Ok, the test is not working. I start it and no motion at all. Then I turn the pot all the way opposite and the stepper runs probably at the fast setting. Turn it the other way and click click click and the output shaft just twitches. Anywhere on the pot does nothing but twitch except for the one position all the way to the left. I cannot change direction with the stop button and the output shows -0.5 RPM.

edit: After playing with the project some more it is acting weird. I can stop it and turn the pot to the right and try it but it won't start. If I stop it and turn it to the left and try again it will only start when the pot is down to 5 or 6 on the diameter. But then it won't run at 0.5 so it's buggy.

I think I found the problem, I didn't correct finalSPE for the diameter being in hundredths of an inch (doh!)

please change the line

float finalSPE = finalSPR/8/3.14159265; // Steps per eighth per 1" diameter

to

float finalSPE = 100*finalSPR/8/3.14159265; // Steps per eighth per 1" diameter

 

Ok, will do...Thanks.

 

edit: Ok tested it. Looks good except 2 things. One the display reads from 0,50 sometimes but others 0.52 or 0,53 when moving back and forth. On the other end 11.97 or 11.98. Minor detail not really an issue,. But I cannot change from Left to Right anymore using the Stop button with 2 presses like before.

 

Edit: Also, if I stop it and then start it the rpms are not at the same setting as before I stop it. I was going to do the test with the 4.76 but it starts at a faster speed when I stop and restart it. Tried a few times.

 

edit 2: The display looks great with no flicker though. 🙂

 

Thanks,
Voltage


ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 11 months ago
Posts: 1764
 
Posted by: @voltage
Posted by: @madmisha
//Shield button test. Ripped off of:
//Voltage Version sketch_aug06e-Will-Mod-4
//Test of accelstepper with LCD and shield buttons

#include <AccelStepper.h>
#include <LiquidCrystal.h>

//Define pins
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5
int driverPUL = 12;    // PUL- pin
int driverDIR = 13;    // DIR- pin
//int spd = A1;          // Potentiometer
//int dia, old_dia = 0;  // Last pot reading
bool go = false;  //Is it running
bool dirFor = true; //Direction to go in
int smInc = 1;      //Small increase
int lgInc = 10;      //Large increase
bool slChange = true; //Slow change
int drive = 70;     //Raw Speed Number
//float sps;             // Sets per second for this diameter
//float RPM;             // RPM for this diameter 

AccelStepper stepper(1,driverPUL,driverDIR); // This needs to change in any example(Mode, Pul, Dir)

LiquidCrystal lcd(8,9,4,5,6,7); //Setup LCD

//Shield buttons read (IF VERSION 1.0 SHIELD, LET ME KNOW!)
int read_LCD_buttons() {
 adc_key_in = analogRead(0);      // read the value from the sensor
 // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
 // we add approx 50 to those values and check to see if we are close
 if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
 
 
 //********************Block comment here is need changing based on version******
 // For V1.1 us this threshold
 if (adc_key_in < 50)   return btnRIGHT;
 if (adc_key_in < 250)  return btnUP;
 if (adc_key_in < 450)  return btnDOWN;
 if (adc_key_in < 650)  return btnLEFT;
 if (adc_key_in < 850)  return btnSELECT;
 //********************End Block comment*************************************

//*************Uncomment if you have the V1.0***********************************
  // For V1.0 comment the other threshold and use the one below:
/*
 if (adc_key_in < 50)   return btnRIGHT;
 if (adc_key_in < 195)  return btnUP;
 if (adc_key_in < 380)  return btnDOWN;
 if (adc_key_in < 555)  return btnLEFT;
 if (adc_key_in < 790)  return btnSELECT;
*/
//************************End of uncomment**************************************

return btnNONE;  // when all others fail
}

void screen() {
  lcd.setCursor(5,0);                               // Update LCD
  lcd.print("      ");                              //Only a test
  lcd.setCursor(5,0);
  lcd.print(drive);
  lcd.setCursor(5,1);
  lcd.print("      ");
***************** I had to add an extra blank to this to cover the old value
 lcd.setCursor(5,1);  lcd.print( (dirFor) ? drive : -drive); } void setup() {     stepper.setMaxSpeed(1000);   stepper.setMinPulseWidth(2.7);   stepper.setSpeed(drive);   lcd.begin(16, 2);   lcd.setCursor(1,0);   lcd.print("Dia:");   lcd.setCursor(1,1);   lcd.print("RPM:"); } void loop() {  if (go){    stepper.runSpeed();  } else {    stepper.stop();  }  int lcd_key = read_LCD_buttons();  switch (lcd_key)               // depending on which button was pushed, we perform an action  {   case btnRIGHT:     {     !slChange;
***************** were you trying to set s1Change to !s1Change ? ******
    break;     }   case btnLEFT:     {     !dirFor;
***************** were you trying to set dirFor to !dirFor ? ******


    break;     }   case btnUP:     {     if(slChange){      if(drive <= (1000 - smInc)){        drive = drive + smInc;
***************** easier to say drive = min(1000,drive + smInc) ?

     }        } else if (drive <= (1000 - lgInc)){        drive = drive + lgInc;
***************** easier to say drive = min(1000,drive + lgInc) ?


   }     if (dirFor){        stepper.setSpeed(drive);     } else {        stepper.setSpeed(!drive);
***************** using a logical NOT operation on an int ? ?
***************** did you mean stepper.setSpeed(-drive) ?

    }     screen();     break;     }   case btnDOWN:     {     if(slChange){      if(drive >= (1000 + smInc)){
       drive = drive - smInc;
***************** not sure what you're testing drive for large value and then
subtracting the value ...
***************** did you mean drive=max(50,drive-smInc) ?

     }        } else if (drive >= (50 + lgInc)){        drive = drive - lgInc;
***************** easier to say drive=max(50,drive-lgInc) ?     }      if (dirFor){        stepper.setSpeed(drive);     } else {        stepper.setSpeed(!drive); ***************** using a logical NOT operation on an int ? ?
***************** did you mean stepper.setSpeed(-drive) ?
    }     screen();     break;     }   case btnSELECT:     {     !go;     break;     }     case btnNONE:     {     break;     }  }   }

***************** you use 1000 in a lot of places, suggest you make it a variable
or a #define in case it needs to be changed later

Some questions and suggestions about the code (see ****************...)

I was kidnapped by mimes.
They did unspeakable things to me.


ReplyQuote
MadMisha
(@madmisha)
Reputable Member
Joined: 2 years ago
Posts: 319
 

Sorry, I stayed up really late last night reading contracts and riders. Then making list of all the things to do and look for. Plus, I am on the west coast.

 

@voltage

Did you comment out the first section and uncomment the second? I was really hoping that would work.

Also, I hope you weren't using 2 buttons at once. The change by 10 and change by 1 (right button) is just a toggle. you should have been able to hit select(go and stop toggle) and up and down to change value. If you wanted it to change faster, tap the right button and then up and down will change it by a 10.

 

This might be an indication of how lon stepper.runSpeed() takes to run.

 

If it doesn't work, that's fine.

 

I actually don't care if my name is on it or not. It's all code and it meant to be open source.

 

Edit: I posted my rough sketch with the notes I was going to need to fill in there. Did I mention it was a rough day? Ok, This should be right and I did make some changes based off of Will's suggestions. It should also be set up for version 1.

 

//Shield button test. Ripped off of:
//Voltage Version sketch_aug06e-Will-Mod-4
//Test of accelstepper with LCD and shield buttons

#include <AccelStepper.h>
#include <LiquidCrystal.h>

//Define pins
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5
int driverPUL = 12;    // PUL- pin
int driverDIR = 13;    // DIR- pin
//int spd = A1;          // Potentiometer
//int dia, old_dia = 0;  // Last pot reading
bool go = false;  //Is it running
bool dirFor = true; //Direction to go in
int smInc = 1;      //Small increase
int lgInc = 10;      //Large increase
bool slChange = true; //Slow change
int drive = 70;     //Raw Speed Number
int minSp = 50;     //Minimum Speed
int maxSp = 1000;   //Max Speed
//float sps;             // Sets per second for this diameter
//float RPM;             // RPM for this diameter 

AccelStepper stepper(1,driverPUL,driverDIR); // This needs to change in any example(Mode, Pul, Dir)

LiquidCrystal lcd(8,9,4,5,6,7); //Setup LCD

//Shield buttons read (IF VERSION 1.0 SHIELD, LET ME KNOW!)
int read_LCD_buttons() {
 adc_key_in = analogRead(0);      // read the value from the sensor
 // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
 // we add approx 50 to those values and check to see if we are close
 if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
 
 
 /*
 // For V1.1 us this threshold
 if (adc_key_in < 50)   return btnRIGHT;
 if (adc_key_in < 250)  return btnUP;
 if (adc_key_in < 450)  return btnDOWN;
 if (adc_key_in < 650)  return btnLEFT;
 if (adc_key_in < 850)  return btnSELECT;
 */

  // For V1.0

 if (adc_key_in < 50)   return btnRIGHT;
 if (adc_key_in < 195)  return btnUP;
 if (adc_key_in < 380)  return btnDOWN;
 if (adc_key_in < 555)  return btnLEFT;
 if (adc_key_in < 790)  return btnSELECT;


return btnNONE;  // when all others fail
}

void screen() {
  lcd.setCursor(5,0);                               // Update LCD
  lcd.print("      ");                              //Only a test
  lcd.setCursor(5,0);
  lcd.print(drive);
  lcd.setCursor(5,1);
  lcd.print("      ");
  lcd.setCursor(5,1);
  lcd.print( (dirFor) ? drive : -drive);
}

void setup() {  
   stepper.setMaxSpeed(1000);
   stepper.setMinPulseWidth(2.7);
   stepper.setSpeed(drive);

   lcd.begin(16, 2);
   lcd.setCursor(1,0);
   lcd.print("Dia:");
   lcd.setCursor(1,1);
   lcd.print("RPM:");
}

void loop() {
  if (go){
    stepper.runSpeed();
  } else {
    stepper.stop();
  }
  int lcd_key = read_LCD_buttons();

  switch (lcd_key)               // depending on which button was pushed, we perform an action
  {
   case btnRIGHT:
     {
     slChange = !slChange;
     break;
     }
   case btnLEFT:
     {
     dirFor = !dirFor;
     break;
     }
   case btnUP:
     {
     if(slChange){
      if(drive <= (maxSp - smInc)){
        drive = drive + smInc;
      }   
     } else if (drive <= (maxSp - lgInc)){
        drive = drive + lgInc;
     }
     if (dirFor){
        stepper.setSpeed(drive);
     } else {
        stepper.setSpeed(-drive);
     }
     screen();
     break;
     }
   case btnDOWN:
     {
     if(slChange){
      if(drive >= (minSp + smInc)){
        drive = drive - smInc;
      }   
     } else if (drive >= (minSp + lgInc)){
        drive = drive - lgInc;
     }
      if (dirFor){
        stepper.setSpeed(drive);
     } else {
        stepper.setSpeed(-drive);
     }
     screen();
     break;
     }
   case btnSELECT:
     {
     !go;
     break;
     }
     case btnNONE:
     {
     break;
     }
  }  
}

 

 


ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 11 months ago
Posts: 1764
 
Posted by: @voltage

Ok, will do...Thanks.

 

edit: Ok tested it. Looks good except 2 things. One the display reads from 0,50 sometimes but others 0.52 or 0,53 when moving back and forth. On the other end 11.97 or 11.98. Minor detail not really an issue,. But I cannot change from Left to Right anymore using the Stop button with 2 presses like before.

 

Edit: Also, if I stop it and then start it the rpms are not at the same setting as before I stop it. I was going to do the test with the 4.76 but it starts at a faster speed when I stop and restart it. Tried a few times.

 

edit 2: The display looks great with no flicker though. 🙂

 

The "unavailable" values are due to the pot's graininess plus I added a test to see if the new pot reading is at least 5 units away from the last pot reading, (This is to preventing the updates required by small jitters from the pot). I can remove their it's a problem. But with a pot you'll probably never get an accurate reading over a full range of 1200 with any <360 degree potentiometer you can afford 🙂

As for the stop button, all it does is stop it's going and reverse direction if it's not. But reversing direction doesn't start it running again. If you'd like it do the reverse, then change

void stpmotor (){

  if(go){
    stepper.stop();
    go = false;
  } else {
    dirFor = !dirFor;
  }  
}

 

to 

void stpmotor (){

  if(go){
    stepper.stop();
    go = false;
  } else {
    dirFor = !dirFor;
    go = true;
  }  
}

 Adding the command go = true;

 I'm not sure about the speed change after stopping. I'll have another look at that.

I was kidnapped by mimes.
They did unspeakable things to me.


ReplyQuote
Voltage
(@voltage)
Estimable Member
Joined: 10 months ago
Posts: 169
Topic starter  
Posted by: @madmisha

Sorry, I stayed up really late last night reading contracts and riders. Then making list of all the things to do and look for. Plus, I am on the west coast.

 

@voltage

Did you comment out the first section and uncomment the second? I was really hoping that would work.

Also, I hope you weren't using 2 buttons at once. The change by 10 and change by 1 (right button) is just a toggle. you should have been able to hit select(go and stop toggle) and up and down to change value. If you wanted it to change faster, tap the right button and then up and down will change it by a 10.

 

This might be an indication of how lon stepper.runSpeed() takes to run.

 

If it doesn't work, that's fine.

 

I actually don't care if my name is on it or not. It's all code and it meant to be open source.

That is fine, no need to be sorry. We all have things to do and life to live. 🙂 I did uncomment and comment the lines as you asked. I also verified I have a version 1 LCD display shield. I will rerun your sketch but I didn't press 2 buttons at the same time. I just followed the original instructions. Am I supposed to pushing all of the buttons on the LCD shield or some on it and others on the breadboard? Maybe I messed up? Anyhow I appreciate your time as always but now my wife will be home in a few minutes as she works until 2:30 on Saturdays CST, and I have to do like Will the other day and go running around to grocery stores and then workout and then eat supper. I will have time tomorrow after I walk the dog and eat breakfast so if I find anything to report I will be back at it tomorrow after 12:00 CST. Have a great day!

Thanks,
Voltage


ReplyQuote
MadMisha
(@madmisha)
Reputable Member
Joined: 2 years ago
Posts: 319
 
Posted by: @voltage

Am I supposed to pushing all of the buttons on the LCD shield or some on it and others on the breadboard?

Only use the buttons on the shield and no pot. I posted an updated version of the code above.

 

If it works it will give you a definitive and stable reading that would be easier to work with for the math you are doing right now.


ReplyQuote
Voltage
(@voltage)
Estimable Member
Joined: 10 months ago
Posts: 169
Topic starter  
Posted by: @will
Posted by: @voltage

Ok, will do...Thanks.

 

edit: Ok tested it. Looks good except 2 things. One the display reads from 0,50 sometimes but others 0.52 or 0,53 when moving back and forth. On the other end 11.97 or 11.98. Minor detail not really an issue,. But I cannot change from Left to Right anymore using the Stop button with 2 presses like before.

 

Edit: Also, if I stop it and then start it the rpms are not at the same setting as before I stop it. I was going to do the test with the 4.76 but it starts at a faster speed when I stop and restart it. Tried a few times.

 

edit 2: The display looks great with no flicker though. 🙂

 

The "unavailable" values are due to the pot's graininess plus I added a test to see if the new pot reading is at least 5 units away from the last pot reading, (This is to preventing the updates required by all jitters from the pot). I can remove their it's a problem. But with a pot you'll probably never get an accurate reading over a full range of 1200 with any <360 degree potentiometer you can afford 🙂

As for the stop button, all it does is stop it's going and reverse direction if it's not. But reversing direction doesn't starlit running again. If you'd like it do the reverse, then change

void stpmotor (){

  if(go){
    stepper.stop();
    go = false;
  } else {
    dirFor = !dirFor;
  }  
}

 

to 

void stpmotor (){

  if(go){
    stepper.stop();
    go = false;
  } else {
    dirFor = !dirFor;
    go = true;
  }  
}

 Adding the command go = true;

 I'm not sure about the speed change after stopping. I'll have another look at that.

Will, Ok on the new info. Like I told Madmisha I am going to have to clean up and get ready to do the grocery shopping with the wife shortly as she only works until 2:30 CST on Saturday. I will try these adjustments and report back but I already started moving off the kitchen counter. I loaded the last Mod 4 sketch and the stop button works fine for reversing. Run the stepper, hit the stop 2 times and the stepper runs the other direction. That is not happening with this last version. I will try the code change but later I will open the code on 2 monitors and start looking to see if I can spot anything. Thanks for all the effort and hard work. I will post back anything I find and tomorrow after 12:00 CST I will be ready to set up and test or we can wait till Monday. Have a great day and thanks again.

 

Thanks,
Voltage


ReplyQuote
Voltage
(@voltage)
Estimable Member
Joined: 10 months ago
Posts: 169
Topic starter  
Posted by: @madmisha
Posted by: @voltage

Am I supposed to pushing all of the buttons on the LCD shield or some on it and others on the breadboard?

Only use the buttons on the shield and no pot. I posted an updated version of the code above.

 

If it works it will give you a definitive and stable reading that would be easier to work with for the math you are doing right now.

Ok, that is what I was doing, just the buttons on the shield. I will post back later as I have to run. Thanks again!

 

Thanks,
Voltage


ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 11 months ago
Posts: 1764
 

@voltage

 

OK, have a good weekend 🙂

I was kidnapped by mimes.
They did unspeakable things to me.


ReplyQuote
Page 13 / 21