Notifications
Clear all

Arduino with Stepper and LiquidCrystal Issue

308 Posts
5 Users
12 Likes
23.8 K Views
(@voltage)
Member
Joined: 3 years ago
Posts: 187
Topic starter  

Thanks,
Voltage


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

   
ReplyQuote
(@voltage)
Member
Joined: 3 years ago
Posts: 187
Topic starter  

Thanks,
Voltage


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 
Posted by: @voltage

o I assume I can use any 2 of the available pins 5,6,7,8,9, and 10 correct?

Remember that your screen needs pins 4-9 and since it is a shield, you will have to stick with that. So unless you have something hooked up that I didn't account for(or plan on using SPI with this project), you have 10-13. Worse case scenario, you could use an analog pin.

Those squiggly lines are the pins that can output PWM signals. That shouldn't matter in this case.


   
ReplyQuote
(@voltage)
Member
Joined: 3 years ago
Posts: 187
Topic starter  
Posted by: @madmisha
Posted by: @voltage

o I assume I can use any 2 of the available pins 5,6,7,8,9, and 10 correct?

Remember that your screen needs pins 4-9 and since it is a shield, you will have to stick with that. So unless you have something hooked up that I didn't account for(or plan on using SPI with this project), you have 10-13. Worse case scenario, you could use an analog pin.

Those squiggly lines are the pins that can output PWM signals. That shouldn't matter in this case.

Glad I asked. Pin 11 is in use but 12 and 13 are free. I will use those. 😀 

 

Thanks,
Voltage


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2507
 

@voltage

As discussed offline, i've prepared a variant of the sketch which doesn't require a library for the stepper. It is based on @madmisha's code (from before the accelStepper library use). 

Since you said that speed would never be changed while the motor is already rotating, this version only reads the speed potentiometer and updates the LCD when it is NOT moving. It starts with go=false and waits until the go button is pressed and then rotates continuously (i.e. go=true) until the go button is pressed again (go=false), which then stops rotation and allows the speed to be reset. It may also require a further update to bounce-proof the go button.

Because this thread has a lot of code and tests already suggested, I'd rather wait until you've tried @madmisha's latest suggestions and the dust has settled before bringing in another bunch of code 🙂

Anything seems possible when you don't know what you're talking about.


   
MadMisha reacted
ReplyQuote
(@voltage)
Member
Joined: 3 years ago
Posts: 187
Topic starter  
Posted by: @will

@voltage

As discussed offline, i've prepared a variant of the sketch which doesn't require a library for the stepper. It is based on @madmisha's code (from before the accelStepper library use). 

Since you said that speed would never be changed while the motor is already rotating, this version only reads the speed potentiometer and updates the LCD when it is NOT moving. It starts with go=false and waits until the go button is pressed and then rotates continuously (i.e. go=true) until the go button is pressed again (go=false), which then stops rotation and allows the speed to be reset. It may also require a further update to bounce-proof the go button.

Because this thread has a lot of code and tests already suggested, I'd rather wait until you've tried @madmisha's latest suggestions and the dust has settled before bringing in another bunch of code 🙂

Hi Will,

  Sounds good to me. As far as the speed not "needing" to be changed  when the motor is running is just an option I wanted to see if it solves the other issue of the interrupt causing the thump. It is a work around of sorts but may be all I need. The only issue is getting the right speed for the diameter of the part but that is ok with me. I am just learning and that is how I learn. The original author has an update where you can use a foot pedal to control the speed but that can complicate things even more if you already use a foot pedal for the welding input. But I am happy and excited to see what you came up with as it may be 100% the answer once diameters and rpms are established and noted or marked on the control panel. Thanks for all the help. I will be doing the other tests tomorrow with madmisha's latest code and will report back then.

 

Thanks,
Voltage


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2507
 

@voltage

Good, hopefully @madmisha's stuff will work well enough to render mine unneeded.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

@voltage

Depending on the quality of the potentiometer, you might be getting some variance. Have you thought of just setting it in a digital fashion? If there is an equation that will get you the speed you need, you could just adjust the diameter of the part using buttons or an encoder and it would set the speed based on that. It can still be speed based if you need it to.

All of the sketches here really depend on timing. Accel Stepper needs you keep repeating the run command as many times as possible. So if it does not need to check the potentiometer every loop, buttons or a rotary encoder(rotary encoder is a quick thought and I would have to think more if this one is a good idea, it might not be. Might be better adjusting in the off state) would be better with an interrupt.

 

Edit: I just thought that alternately, you could increase the speed in any direction using the left right buttons you have(as well as starting it in that direction). Pressing it will increase the set speed or decrease it and the stop will reset it to 0. Or instead of resetting it to 0 and it just running the stop command, if it is in the stopped state, start it at the last speed. That way LCD could run from the button interrupt when the change occurred and the loop will solely be running the motor.


   
ReplyQuote
(@voltage)
Member
Joined: 3 years ago
Posts: 187
Topic starter  

Thanks,
Voltage


   
ReplyQuote
(@voltage)
Member
Joined: 3 years ago
Posts: 187
Topic starter  

So I kept thinking my problem would be with the

AccelStepper stepper(1,2,3);

But a 1 in the first position seemed correct and I tried using "DRIVER" but no change. I am using only 2 pins to the stepper driver as shown in the info below. I reloaded my previous code and after reassigning the 2 pins I changed it works as before.

Symbolic names for number of pins. Use this in the pins argument the AccelStepper constructor to provide a symbolic name for the number of pins to use.

Enumerator:
FUNCTION 

Use the functional interface, implementing your own driver functions (internal use only)

DRIVER 

Stepper Driver, 2 driver pins required.

FULL2WIRE 

2 wire stepper, 2 motor pins required

FULL3WIRE 

3 wire stepper, such as HDD spindle, 3 motor pins required

FULL4WIRE 

4 wire full stepper, 4 motor pins required

HALF3WIRE 

3 wire half stepper, such as HDD spindle, 3 motor pins required

HALF4WIRE 

4 wire half stepper, 4 motor pins required

Thanks,
Voltage


   
ReplyQuote
(@voltage)
Member
Joined: 3 years ago
Posts: 187
Topic starter  
Posted by: @madmisha

@voltage

Depending on the quality of the potentiometer, you might be getting some variance. Have you thought of just setting it in a digital fashion? If there is an equation that will get you the speed you need, you could just adjust the diameter of the part using buttons or an encoder and it would set the speed based on that. It can still be speed based if you need it to.

All of the sketches here really depend on timing. Accel Stepper needs you keep repeating the run command as many times as possible. So if it does not need to check the potentiometer every loop, buttons or a rotary encoder(rotary encoder is a quick thought and I would have to think more if this one is a good idea, it might not be. Might be better adjusting in the off state) would be better with an interrupt.

 

Edit: I just thought that alternately, you could increase the speed in any direction using the left right buttons you have(as well as starting it in that direction). Pressing it will increase the set speed or decrease it and the stop will reset it to 0. Or instead of resetting it to 0 and it just running the stop command, if it is in the stopped state, start it at the last speed. That way LCD could run from the button interrupt when the change occurred and the loop will solely be running the motor.

Madmisha,

  I am using a Bourns 10K 1 turn Pot (280 degree) but I like the digital button idea as it sounds doable with inexpensive parts. As far as a formula I use a piece of tape with 1/8 increments and dial the speed in by counting 1,001, 1,002, 1,003, etc and if the torch tip matches then it is in the ball park and maybe a minor adjustment will be needed dependent on other factors such as thickness, heat, filler diameter etc. The fomula is something like InchesPerMinute\Pi * DiameterOfPart.

I am all ears on the last comment you added but first I need to get it running. 🙂

 

Thanks,
Voltage


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2507
 

Anything seems possible when you don't know what you're talking about.


   
Voltage reacted
ReplyQuote
(@voltage)
Member
Joined: 3 years ago
Posts: 187
Topic starter  

@will

Thanks Will, I will give it a test right now. Fingers crossed. 😀 

 

Edit: I downloaded and verified and compiled but noticed you made an edit so I did it a second time just in case you changed so code. It does not work as the stepper never runs. The readout on the LCD displays from .1-3 RPM so that part works. Maybe it's the same thing where madmisha's code and yours doesn't work? I will see if I can spot anything but I am not the expert. 🙂

 

@Will. When you say the "Go" button I can use either the "Right" or "Left" for that correct? otherwise I only have a "Stop" button.

Thanks,
Voltage


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

   
ReplyQuote
Page 3 / 21