reed switch controlled stepper motor

Dear all,

i really am stuck in coding right now, maybe because it has been 2 years and i became rusty. So perhaps one of you has an idea to help me further on this.

My goal:
I am building a delta 3d printer. it has 3 arms which move along a 2040 aluminium extrusion.
One of the arms will be my position guide for the extruder height (extruder: device which supplies material to the printer) I have made a strip with 8 reed switches over 500mm. The extruder needs to variate in height within those 500mm.
So, when the printer arm moves, it will trigger the reed switch closest to it. next the extruder should be adjusted in height. What i want to achieve is that the extruder will always have the same distance to the printhead(approximately). i use a 17HS4401S stepper with T8/2mm attached, DRV8825 driver.

My problem/question:
Can i assign a specific position to each of the reed switches?? So,when switch 1 is HIGH, the extruder moves to 600mm, when switch 2 is HIGH to 650mm, when switch 3 is HIGH to 700mm, but when switch 2 is HIGH again it needs to move back down to 650mm.

I can code this for one direction when i assign a certain amount of steps and a direction to each switch, but can't get my head around what to do with the other direction.

i have used an IF statement for each swithc looking like this:
if (reelSwitch1 = HIGH) && (reelSwitch2 = LOW) && (reelSwitch3 = LOW) && (reelSwitch4 = LOW) && (reelSwitch5 = LOW) && (reelSwitch6 = LOW) && (reelSwitch7 = LOW) && (reelSwitch8 = LOW))
{ digitalWrite (Step = )
digitalWrite (Dir = )

If there is a better or easier way, please tell me.

Kindest regards,

Touriya

Fundamental mistake:

 if (reelSwitch1 = HIGH)

= for assignment, == for comparison. See the if structure reference.

As well as what @groundFungus has said ...

I can't form a mental image of how you plan to use the reed switches. I have a cheap 3D printer that uses a microswitch to detect the home position for each axis. The print bed needs to be levelled so that the extruder nozzle is clear of bed by about the thickness of a piece of printer paper at all positions across the bed.

I can't imagine that a similar level of precision could be achieved with (say) two microswitches on one axis and I wonder if reed-switches are as precise as microswitches.

Can you post a diagram of the machine you plan to build showing how the reed switches will be located and used. See this Simple Image Upload Guide

...R

Not sure I'm understanding the concept either. But the way I have it in my head I think you need to add another variable. Something like "moveUp". So when your switch goes high the first time, your motor will move up and set moveUp=true. Then if that switch is high and moveUp is true, move the other direction and set moveUp=false.

But, like I said, I may not be understanding what you want to accomplish.

@Robin2: thanks for your reply!

Let me be clear about this: this hasn't got anything to do with homing the printer.

I will place the strip with reed switched vertical, parallel to the carriage movement( also vertical)
On the carriage i have placed a magnet.
So as the carriage moves up and down it will trigger one of the reed switches.

This movement and the reed switches will be the inputs for a stepper motor that will move an extruder up and down accordingly.

I have calculated that i need 31,25 revs on the stepper motor per every reed switch. The hard part for me is getting the Arduino to determine whether the stepper motor has to move the 31,25 revs clockwise or counterclockwise.

I have drawn a little thing

Touriya:
Let me be clear about this: this hasn't got anything to do with homing the printer.

I will place the strip with reed switched vertical, parallel to the carriage movement( also vertical)
On the carriage i have placed a magnet.
So as the carriage moves up and down it will trigger one of the reed switches.

This movement and the reed switches will be the inputs for a stepper motor that will move an extruder up and down accordingly.

I understand the individual words but not the whole thing taken together.

Why would one want to move an extruder up and down an imprecise distance using reed-switch triggers?

It is so much easier to give useful advice when you provide a good overall description of the project.

...R

PS ... your diagram is on its side.

Robin2:
Why would one want to move an extruder up and down an imprecise distance using reed-switch triggers?

...R

PS ... your diagram is on its side.

Don't forget i am a newbie, gentlemen.

Why would i want the extruder to move up and down?? Because it is a delta printer! the extruder will be located at the center of the printer, so central to it's three arms. The up and downward movement is to keep enough clearance between extruder and printhead. it is all experimental. It is not the first printer i built. Just some idea i have that i want to try out. The movement of the extruder will be precise, as i let it turn a certain amount of steps each time.

And yes, the diagram is on it's side. i rotated it before uploading, but the arduino website has a mind of its own... but as i said, i'm just a newbie.

Touriya:
to keep enough clearance between extruder and printhead

I have been assuming when you used the word “extruder” that you meant the printhead - after that’s where the extrusion happens.

But I still don’t get the overall picture of your proposed machine. Please post a sketch that illustrates the whole thing.

…R

No, let's skip this.
Your response to my question has really discouraged me to try this.
i now use a rotary encoder which does the same thing.

Please be considerate when you try to "help" people.

Touriya:
Please be considerate when you try to "help" people.

In what way was I not considerate?

What sort of response were you expecting?

...R

I’m guessing it is a bowden type of printer, with the hot end remote from the filament pusher. Long bowden cables are poor for performance so the bowden is shortened to the point that the pusher (extruder) must follow the print head, but imprecisely.

Just a guess…

MorganS:
Just a guess...

I had been hoping that the OP would save you from the trouble of having to make a guess on his behalf.

...R

@MorganS: absolutely right. And as it is a delta printer there is room(height) for a moving extruder.

This instead of a extruder which is hanging on the arm-carriages(like on a tevo little monster)

I have now used a rotary encoder to translate the carriage movement into a height for the extruder. I could have just used the stepper motor signals from the printer itself, but where is the fun in that?

Touriya