I didn't test the last version but I did the two on the one post above. When the RPM comes down from 15, after you go past 10, the 9 shows up as a 90 and the counts down from 90, 89, 87, etc
That's because you need to write blanks over the area to clear out the last result. You'll see me writing blanks over the speed area in my old code.
I was kidnapped by mimes.
They did unspeakable things to me.
Maybe it's worth moving all of the LCD display commands into a subroutine. That way it'll be easy to update from anywhere and the data will always be placed in the same area.
That wouldn't solve the problem. The interrupt could happen anywhere. That's why I just put all the randomly updating values on the second line in the last iteration and ended the interrupt with the cursor beginning on the second line. If it happens to be on the wrong value to write, it should write over it in the next loop.
You'll need to use blanks overwrite any datum which may change to a shorter length (like speeds) since @voltage is already observing some field contamination.
I was kidnapped by mimes.
They did unspeakable things to me.
I didn't test the last version but I did the two on the one post above. When the RPM comes down from 15, after you go past 10, the 9 shows up as a 90 and the counts down from 90, 89, 87, etc
Ok, another one to try:
//Test of accelstepper with LCD and pot#include<AccelStepper.h>#include<LiquidCrystal.h>//Define pinsintLEFT_PIN=11;intSTOP_PIN=2;intRIGHT_PIN=3;intdriverPUL=12;// PUL- pinintdriverDIR=13;// DIR- pinintspd=A1;// Potentiometerboolgo=false;//Is it runningbooldirFor=true;//Direction to go inAccelStepperstepper(1,driverPUL,driverDIR);// This needs to change in any example(Mode, Pul, Dir)LiquidCrystallcd(8,9,4,5,6,7);//Setup LCD//Interupt Handlersvoidformotor(){dirFor=true;go=true;}voidbacmotor(){lcd.setCursor(7,0);if(dirFor){lcd.print("Right");}else{lcd.print("Left ");}go=true;lcd.setCursor(0,1);}voidstpmotor(){if(go){stepper.stop();go=false;}else{dirFor=!dirFor;lcd.setCursor(7,0);if(dirFor){lcd.print("Right");}else{lcd.print("Left ");}}lcd.setCursor(0,1);}voidsetup(){//pinMode(LEFT_PIN, INPUT_PULLUP);pinMode(STOP_PIN,INPUT_PULLUP);pinMode(RIGHT_PIN,INPUT_PULLUP);//attachInterrupt(digitalPinToInterrupt(LEFT_PIN), formotor, FALLING);attachInterrupt(digitalPinToInterrupt(RIGHT_PIN),bacmotor,FALLING);attachInterrupt(digitalPinToInterrupt(STOP_PIN),stpmotor,FALLING);//stepper.setPinsInverted(false, true, false);stepper.setMaxSpeed(1000);stepper.setMinPulseWidth(2.7);lcd.begin(16,2);lcd.setCursor(1,0);lcd.print("Speed:");lcd.setCursor(13,0);lcd.print("RPM");lcd.setCursor(7,0);if(dirFor){lcd.print("Right");}else{lcd.print("Left ");}}voidloop(){intsp_pot=map((analogRead(spd)),0,1023,50,1000);if(go==true){if(dirFor==true){stepper.setSpeed(sp_pot);}else{stepper.setSpeed((sp_pot*-1));}stepper.runSpeed();lcd.setCursor(0,1);lcd.print(((sp_pot/4.25)/400)*3);stepper.runSpeed();lcd.setCursor(12,1);lcd.print(map(sp_pot,0,1000,0,15)+" ");stepper.runSpeed();}else{stepper.stop();lcd.setCursor(0,1);lcd.print(((sp_pot/4.25)/400)*3);lcd.setCursor(12,1);lcd.print(map(sp_pot,0,1000,0,15)+" ");}}
@will The diameter you be in place of the speed, if that was not needed. That way it would show Diameter and RPM. But RPM matters and changes based on the diameter of the part. So the it would be a calculation of the current RPM and what size of part would be needed for that RPM. So if you adjusted it to the size of the part, it would be spinning at the correct speed. Did that make sense at all?
I'm not sure why you're displaying anything but the RPM as speed. I doubt if @Voltage would be interested in that since I believe he's only concerned about RPM.
Only because that's what the original had. If we verify that the RPMs are working out correctly, that can always change to a diameter reading.
OK, I see.
How/where will the diameter be read in ?
I just need the final calculated RPM's of the final drive shaft which has either a platter or a lathe chuck mounted. The way I get set up is by using a piece of masking tape that I draw 1/8" increments on it and tape it to the circumference of the part. Then I hold my torch tip over the tape and run the unit while counting seconds (1,001, 1,002, 1,003) and set the speed to about 1/8" per second. Then once the part is welded and the timing is good I can note that a 3" diameter pipe has a good starting point of "x" rpm's.
@will The diameter you be in place of the speed, if that was not needed. That way it would show Diameter and RPM. But RPM matters and changes based on the diameter of the part. So the it would be a calculation of the current RPM and what size of part would be needed for that RPM. So if you adjusted it to the size of the part, it would be spinning at the correct speed. Did that make sense at all?
So what we're really trying to do is come up with a chuck's rotational speed which results in a fixed speed for a point on the circumference of the work piece ?
I was kidnapped by mimes.
They did unspeakable things to me.
So what we're really trying to do is come up with a chuck's rotational speed which results in a fixed speed for a point on the circumference of the work piece ?
Exactly! It will take some fooling around but I bet it can be done.
So, shall we switch over to using the pot to enter the diameter and then calculate the RPMs needed to produce a rotation of 1/8" per second on the surface ?
That should be pretty easy to do.
I was kidnapped by mimes.
They did unspeakable things to me.
So what we're really trying to do is come up with a chuck's rotational speed which results in a fixed speed for a point on the circumference of the work piece ?
Exactly! It will take some fooling around but I bet it can be done.
Correct. It's still up to the end user welding to figure out and fine tune things for it to work. Small diameter and large diameter at the same exact rpm are way different. Like watching a 33 1/3 record spin on a turntable, the outer edge is going faster. Anyway, on the last update the LCD has gone goofy. Maybe too much info. Speed: XXX RPMS is all I need on one line. That is what I had and always worked before. 😀 Here are some pics of the LCD freaking out and I can make it happen with successive STOP(Direction Change) button presses.
So, shall we switch over to using the pot to enter the diameter and then calculate the RPMs needed to produce a rotation of 1/8" per second on the surface ?
That should be pretty easy to do.
I guess we could try and see how it works but in welding there are a lot of different things going on. If you weld aluminum for example it will be different than welding steel but maybe that will work. Lets try and see what happens. 😎
//Test of accelstepper with LCD and pot#include<AccelStepper.h>#include<LiquidCrystal.h>//Define pinsintLEFT_PIN=11;intSTOP_PIN=2;intRIGHT_PIN=3;intdriverPUL=12;// PUL- pinintdriverDIR=13;// DIR- pinintspd=A1;// Potentiometerboolgo=false;//Is it runningbooldirFor=true;//Direction to go inAccelStepperstepper(1,driverPUL,driverDIR);// This needs to change in any example(Mode, Pul, Dir)LiquidCrystallcd(8,9,4,5,6,7);//Setup LCD//Interupt Handlersvoidformotor(){dirFor=true;go=true;}voidbacmotor(){lcd.setCursor(7,0);if(dirFor){lcd.print("Right");}else{lcd.print("Left ");}go=true;lcd.setCursor(0,1);}voidstpmotor(){if(go){stepper.stop();go=false;}else{dirFor=!dirFor;lcd.setCursor(7,0);if(dirFor){lcd.print("Right");}else{lcd.print("Left ");}}lcd.setCursor(0,1);}voidsetup(){//pinMode(LEFT_PIN, INPUT_PULLUP);pinMode(STOP_PIN,INPUT_PULLUP);pinMode(RIGHT_PIN,INPUT_PULLUP);//attachInterrupt(digitalPinToInterrupt(LEFT_PIN), formotor, FALLING);attachInterrupt(digitalPinToInterrupt(RIGHT_PIN),bacmotor,FALLING);attachInterrupt(digitalPinToInterrupt(STOP_PIN),stpmotor,FALLING);//stepper.setPinsInverted(false, true, false);stepper.setMaxSpeed(1000);stepper.setMinPulseWidth(2.7);lcd.begin(16,2);lcd.setCursor(1,0);lcd.print("Speed:");lcd.setCursor(13,0);lcd.print("RPM");lcd.setCursor(7,0);if(dirFor){lcd.print("Right");}else{lcd.print("Left ");}}voidloop(){intsp_pot=map((analogRead(spd)),0,1023,50,1000);if(go==true){if(dirFor==true){stepper.setSpeed(sp_pot);}else{stepper.setSpeed((sp_pot*-1));}stepper.runSpeed();lcd.setCursor(0,1);lcd.print(((sp_pot/4.25)/400)*3);stepper.runSpeed();lcd.setCursor(12,1);lcd.print(" ";stepper.runSpeed();lcd.setCursor(12,1);lcd.print(map(sp_pot,0,1000,0,15));stepper.runSpeed();}else{stepper.stop();lcd.setCursor(0,1);lcd.print(((sp_pot/4.25)/400)*3);lcd.setCursor(12,1);lcd.print(" ";lcd.setCursor(12,1);lcd.print(map(sp_pot,0,1000,0,15));}}
So, shall we switch over to using the pot to enter the diameter and then calculate the RPMs needed to produce a rotation of 1/8" per second on the surface ?
That should be pretty easy to do.
I guess we could try and see how it works but in welding there are a lot of different things going on. If you weld aluminum for example it will be different than welding steel but maybe that will work. Lets try and see what happens. 😎
You'll still be able to vary the speed by changing the diameter up or down to speed up or slow down the rotation speed.
MadMisha, do you think there's enough time savings in using interrupts, or could this revert to if statements in the loop ?
I was kidnapped by mimes.
They did unspeakable things to me.
MadMisha, do you think there's enough time savings in using interrupts, or could this revert to if statements in the loop ?
As long as you use stepper.runSpeed() any time you get the chance, it should be ok. But not having to check buttons all the time is usually better. Or possible missing them can be a pain too.
//Test of accelstepper with LCD and pot#include<AccelStepper.h>#include<LiquidCrystal.h>//Define pinsintLEFT_PIN=11;intSTOP_PIN=2;intRIGHT_PIN=3;intdriverPUL=12;// PUL- pinintdriverDIR=13;// DIR- pinintspd=A1;// Potentiometerboolgo=false;//Is it runningbooldirFor=true;//Direction to go inAccelStepperstepper(1,driverPUL,driverDIR);// This needs to change in any example(Mode, Pul, Dir)LiquidCrystallcd(8,9,4,5,6,7);//Setup LCD//Interupt Handlersvoidformotor(){dirFor=true;go=true;}voidbacmotor(){lcd.setCursor(7,0);if(dirFor){lcd.print("Right");}else{lcd.print("Left ");}go=true;lcd.setCursor(0,1);}voidstpmotor(){if(go){stepper.stop();go=false;}else{dirFor=!dirFor;lcd.setCursor(7,0);if(dirFor){lcd.print("Right");}else{lcd.print("Left ");}}lcd.setCursor(0,1);}voidsetup(){//pinMode(LEFT_PIN, INPUT_PULLUP);pinMode(STOP_PIN,INPUT_PULLUP);pinMode(RIGHT_PIN,INPUT_PULLUP);//attachInterrupt(digitalPinToInterrupt(LEFT_PIN), formotor, FALLING);attachInterrupt(digitalPinToInterrupt(RIGHT_PIN),bacmotor,FALLING);attachInterrupt(digitalPinToInterrupt(STOP_PIN),stpmotor,FALLING);//stepper.setPinsInverted(false, true, false);stepper.setMaxSpeed(1000);stepper.setMinPulseWidth(2.7);lcd.begin(16,2);lcd.setCursor(1,0);lcd.print("Speed:");lcd.setCursor(13,0);lcd.print("RPM");lcd.setCursor(7,0);if(dirFor){lcd.print("Right");}else{lcd.print("Left ");}}voidloop(){intsp_pot=map((analogRead(spd)),0,1023,50,1000);if(go==true){if(dirFor==true){stepper.setSpeed(sp_pot);}else{stepper.setSpeed((sp_pot*-1));}stepper.runSpeed();lcd.setCursor(0,1);lcd.print(((sp_pot/4.25)/400)*3);stepper.runSpeed();lcd.setCursor(12,1);lcd.print(" ";stepper.runSpeed();lcd.setCursor(12,1);lcd.print(map(sp_pot,0,1000,0,15));stepper.runSpeed();}else{stepper.stop();lcd.setCursor(0,1);lcd.print(((sp_pot/4.25)/400)*3);lcd.setCursor(12,1);lcd.print(" ";lcd.setCursor(12,1);lcd.print(map(sp_pot,0,1000,0,15));}}
Image above is from my first build of this and how the LCD display outputted the RPM's.
This version has the LCD all messed up. The compiled code when uploaded to the UNO shows the RPM number lower right in red or some other color. Did you program that like that?
I think it may be best to just set it like I used to have it:
We use cookies on the DroneBot Workshop Forums to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.