Are there any coding examples of letting a spool on a stepper feed a line and controlling that for example 10mm line is fed using a rotary encoder on the line each time I press a button?
Of course the simplest way would be feeding the line itself with the stepper but in my case I need to rotate the actual spool with the stepper and let the stepper rotate as much as it takes to feed a certain distance regardless of how much line is rolled on the spool (different diameter). Using the rotary encoder to turn stepper off when a preset value of pulses (mm) is reached.
Tried to search how to do this but can not find anything like this. Hope it’s pretty simple even for the newbie that I am.
The code should be straightforward if you have a suitable mechanical system to cause the line to operate the encoder. Like this pseudo code
set the length
calculate the equivalent number of encoder pulses
set pulse count to 0
start
read the encoder
if pulse count < than limit
move motor 1 step
increment pulse count
repeat from start
Hi and thank you all for your kind replies to take this forward.
Actually the line and spool is just an example of the actual problem with not getting a linear motion even if the stepper moves constant.
I made a very simple drawing of my idea, a lifting table that uses a ball screw connected to a stepper. But as the lifting table is a “scissor-type” the movement is not linear in comparison with the stepper movement.
My idea is to set a line from the bottom part, let the line go through a rotary encoder of the upper part and let a spring set the tension of the line. The purpose of the encoder is to measure the correct height of the table.
So that I could press a button and let the table move for example 5mm each time
I understand that the time to move those 5mm will be different in different heights of the table but that´s ok
Thanx for great help Robin2 and dougp. Didn’t know about the Sick measuring system. Seems great but I guess that it’s probably a bit pricy?
Your pseudo code looks great Robin but since I’m a total newbie into Arduino programming I will give it a try but will probably get stuck in the coding
Haven’t bought the rotary sensor yet but will do and then give the programming a go.
It would be highly appreciated if anyone, that knows what to look for, by chance find any code that helps out or an example that could be copy and pasted.
Wretan:
Didn’t know about the Sick measuring system. Seems great but I guess that it’s probably a bit pricy?
I wasn't recommending Sick, I'm sure others make them. It was just offered as suggested search term. Yes, industrial grade equipment costs more than hobby gear. Is it worth your time to develop your own vs. buying off the shelf?
If you do then post the program that represents your best attempt and tell us in detail what it actually does and what you want it to do that is different. It will make it much easier to focus on the parts you need help with rather than wasting time on things that you can do.