Welcome! Log In Create A New Profile

Advanced

Microswitch as end stop?

Posted by droftarts 
Microswitch as end stop?
May 18, 2011 11:48AM
Hi, I have just received my Gen6 electronics from Camiel at mendel-parts.com to be installed on my 1X2 repstrap. However, I'd like to use microswitches for endstops, but I'm not that au fait with electronics. What specification of microswitch can I use without having to add any extra resistors?
Re: Microswitch as end stop?
May 18, 2011 12:37PM
I'm pretty sure that they all need pull up resistors. you could set the firmware to pull up internal pin resistors.

if the firmware uses arduino in code in void setup write something like this below

pinMode(endstopXYZ, INPUT); sets pin as input

digitalWrite(endstopXYZ, HIGH); // when an input is set high this enables pull up 10k resistors

most limit switches have 3 pins. one side release contact when pressed.
from what i have read you want the limit switches to ground out until pressed. this keeps noise suppressed.

you will want to dual read each pin that you use the pull ups for. for some reason it reduces false reads from the logic.

value=digitalRead(endstopXYZ);
value=digitalRead(endstopXYZ); //whatever code you use just read the pin twice.


otherwise you will want 10k resistors to pull up to 5v

i know i read somewhere a setup of mechanical limit switches. nophead posted his results as well. [hydraraptor.blogspot.com]

Edited 1 time(s). Last edit at 05/18/2011 12:38PM by jamesdanielv.
Re: Microswitch as end stop?
May 18, 2011 01:10PM
There is a section of the Gen6 WiKi that talks about using micro-switches. You don't need any resistors.

I use a micro-switch for my bed-mapping application to check for flatness by switching out the Z-Opto for a microswitch and it works fine.

The only thing I'd suggest is that you check the endstop pin-out listed on the Wiki with the schematic. I recollect that it didn't match my hardware.

Regards,

James


--
Check out my blog: AdventuresIn3-DPrinting
Re: Microswitch as end stop?
May 18, 2011 01:51PM
Thanks for the help, especially confirming that I don't need to add any resistors. I have looked at the Gen6 wiki page and think I understand how it should be wired up, but it is more that I am bewildered by the choice of microswitches when I look at RS-online or Farnells. What sort of amperage range should I be looking at (I assume 5A because the board runs on 12V DC from a 60W 'power brick')? How much contact force (presumably light)? And pins to solder wires on to will be easier, I guess. Any advantage having the lever type rather than button? I come up with something like this for £1.11 each:
[uk.farnell.com]
Is it likely to be suitable?
Re: Microswitch as end stop?
May 18, 2011 03:26PM
I wouldn't worry about high-power versions, you are replacing an opto switch, they only draw a few mA's. The high amps are for the steppers and heater. What you've selected is bound to be fine. All it needs to do is repeatably detect when the end of travel has been met. Even with my opto-end stops I can be a few steps off even if I'm not skipping steps.

With my micro-switch bed mapping approach I find that there is a bigger variance on measurements at the end stop with the micro-switches than the opto's. But, in real use all you are doing is homing things at the beginning of the print, accuracy to within a few steps each time is sufficient.

If you can't figure out exactly how to connect the micro-switches up, drop me a PM and I'll send you the details of my config (it's not in front of me at the moment)

JB


--
Check out my blog: AdventuresIn3-DPrinting
Re: Microswitch as end stop?
May 19, 2011 01:22AM
the ones you listed [uk.farnell.com] will work fine as mechanical endstops. the rollers on this are not necessarily needed, but also not bad. of course you will want specifics about hooking up limit switches as well. i did not see in detail how they are hooked up on gen6 wiki page.

if one was to use different switches, one would need to know what pin goes to common for example. also if you update the firmware what mods are necessary to the firmware.

here is the only instruction i see for limit switches on that page.



quote "In this example the 1, 2, 4 pin of the switch will be respectedly connected to the 4, 5, 3 pin on the board "

jim_blag: would you mind updating the wiki with information such as diagrams as to how the pin out would be for the limit switches. you seem quite knowledgeable about gen6. this would also help the entire community.
Re: Microswitch as end stop?
May 19, 2011 04:11AM
If you use a micro switch with a lever then it will be less accurate because the movement of the plunger is less than the movement of the end of the lever. I use the version with just a plunger.


[www.hydraraptor.blogspot.com]
Re: Microswitch as end stop?
May 19, 2011 09:11AM
@jim_blag - thanks for the advice. I read your blog, really good stuff, keep up the good work! I expect to be referring to it in the coming weeks...
@jamesdanielv - The pin out for the gen6 is on the wiki, 1 - Emitter Cathode, 2 - Emitter Anode, 3 - Detector Ground, 4 - Detector Vo, 5 - Detector Vcc. On the microswitches I have ordered, the pins are marked 'C' (Common Ground) which goes to pin 3, 'NO' (Open, I guess) which I assume connects to pin 4, and NC (Closed, I guess) which will go to pin 5. I'll check with a multi meter, but even if it's wrong, I don't think it will blow up the electronics! I'll add a bit to the wiki once I have tested. WRONG!
@nophead - This is all your fault. If I hadn't spent a whole day reading your blog and getting excited that a boyhood dream could become a reality, I wouldn't be here asking annoying questions! But thank you, your blog was an inspiration and very enjoyable. I read your comments regarding lever microswitches on jim_blag's blog, and realise the lever makes measurement far less precise, but does allow for a little more tolerance. However, the lever should be removable, once I'm happy that the various carriages aren't going to slam into the frame at 150mm/s!

Edited 1 time(s). Last edit at 05/19/2011 10:08AM by droftarts.
Re: Microswitch as end stop?
May 19, 2011 10:04AM
The correct configuration for the micro-switch is:

Common - Detector Vout (pin 4)
Normally Open - Detector GND(see comment below for pin #)
Normally Closed - Detector Vcc (see comment below for pin #)

This is where I think the Wiki is wrong, on my schematic of the Gen6 board, I see the following pin-out for the opto's (it could be Camiel changed the configuration between board revisions, but I doubt it):


Pin 1 - Emitter +Vcc
Pin 2 - Emitter - GND
Pin 3 - Detector +Vcc
Pin 4 - Detector - Vout
Pin 5 - Detector - GND

The Wiki implies pin 3 and 5 are swapped. It won't make a difference to your micro-switch, it will just mean that the Z-axis won't go down when it should and will when you press the micro-switch, but if you were wiring your own opto's you'd probably let the magic smoke out.

I'll figure out this Wiki thing later on and update the page.

Regards,

James

Edited 1 time(s). Last edit at 05/19/2011 08:14PM by jim_blag.


--
Check out my blog: AdventuresIn3-DPrinting
Re: Microswitch as end stop?
May 19, 2011 10:33AM
Thanks James, I've edited my earlier post so it doesn't lead other people down the wrong path, now I realise I was thinking about it the wrong way around. I'll update once I've actually received and tested my microswitches! I told you I'm not very electronics savvy, didn't I?!
Re: Microswitch as end stop?
May 19, 2011 08:15PM
Now that I've got home and looked at my micro-switch set-up, I got the connections wrong! I shouldn't do things from memory, it's not what it used to be.

I've edited my post above to reflect the correct information.

JB


--
Check out my blog: AdventuresIn3-DPrinting
Re: Microswitch as end stop?
May 19, 2011 08:31PM
Wiki updated.

JB


--
Check out my blog: AdventuresIn3-DPrinting
Re: Microswitch as end stop?
May 20, 2011 10:03PM
Finally, some progress! RS-online supplied various goodies today, so I wired up a microswitch and motor, attached them to the X-axis headers, found a power supply that didn't supply too many amps (it's an old external SCSI drive case, but I'm not sure exactly how many amps it's supplying, probably around 8A), plugged in, crossed fingers and.... a green light came on!

With power to the board, the motor locked solid (is it supposed to? I guess so, though it whines a bit and gets warm over time). I attached a USB cable (another light!) to a Windows XP virtual machine (I'm a Mac), it recognised the board and loaded various drivers. Downloaded and installed repsnapper on WinXP, selected the right port, and using the jog settings on the Print tab in repsnapper I was able to get the motor to turn! Woot!

However, while it moved happily in the positive direction, it would only turn in the negative direction with the microswitch pressed. The microswitch is wired as jim_blag suggested:
Microswitch terminal C (Common) to pin 4 (Detector - Vo)
Microswitch terminal NO (Normally Open) to pin 5 (Detector - GND)
Microswitch terminal NC (Normally Closed) to pin 3 (Detector +Vcc)

So, something is still wrong here. From the picture on the side of the microswitch, C is connected to NC with the switch in the normal position. C is connected to NO when the switch is pressed. Which two board pins am I trying to connect in each situation?
Re: Microswitch as end stop?
May 20, 2011 11:06PM
Ok, the firmware is thinking the endstop has been hit. I vaguely recall Camiel did mention he changed the style of end-stops now, so there are two firmware versions a non-inverting and an inverting version.

Switch the wires to pins 3 and 5, that should get it working.

JB
Re: Microswitch as end stop?
May 21, 2011 06:39AM
Hooray! Swapping wires to pins 3 and 5 works. Thanks for the help! In fact, the original instructions for microswitches on the wiki page were correct, too, and what I've ended up with, but greatly lacks in explanation. On one side of my microswitch I have C, NC and NO, which correspond to numbers printed on the other side of the microswitch 1, 2 and 3. On the wiki it says to connect 1 (C) to pin 4, 2 (NC) to pin 5 and 4 (I don't have 4, so use 3/NO) to pin 3.

I also did a little testing. Shorting pins 3 and 4 does nothing (Detector Vcc to Detector Vo). Shorting pins 3 and 5 causes the board to stop (Detector Vcc to ground - all the lights go off, loses connection to host - probably not good!). Shorting pins 4 and 5 allows the motor movement in both directions (Vo to Ground). It would be worth changing the wiki, as I think your microswitch guide is the wrong way round. It should be:
Common is connected to Detector Vo (pin 4)
NC is connected to Detector Ground (pin 5)
NO is connected to Detector Vcc (pin 3)
It's either that or the pin out for pin 3 and 4 are the wrong way round (Detector Vcc <-> Detector Vo). I looked at the Gen6 board schematic pdf, but couldn't understand what was the correct way, apart from pins 2 and 5 definitely being ground.
Re: Microswitch as end stop?
May 21, 2011 07:04AM
jim_blag Wrote:
-------------------------------------------------------
> I vaguely recall Camiel did mention he changed the style of end-stops now, so there are
> two firmware versions a non-inverting and an inverting version.

Found this in the downloads section of the mendel-parts website:
16-12-2010: Inverted x-dir (for new x-end-motor-bracket) and some small finetune settings and our new optos are non-inverting, so we have two types of firmware now, one for old optos being shipped untill 16-12-2010 and one for the "new" optos shipped after 16-12-2010

So the wiring instructions above may be different for people who bought early Gen6 boards, but correct going forward.
Re: Microswitch as end stop?
May 27, 2011 03:23AM
I've updated the Wiki to reflect the various versions and the shipping dates.

JB


--
Check out my blog: AdventuresIn3-DPrinting
Re: Microswitch as end stop?
May 27, 2011 05:23PM
jim_blag Wrote:
-------------------------------------------------------
> I've updated the Wiki to reflect the various versions and the shipping dates.
> JB

I think that's about as comprehensive as it could possibly be! My microswitches are working fine, though mounting the Z-axis one is a pain to get right. I removed the lever for greater accuracy, but I doubt it will ever be perfect enough to just 'home all' and expect to start printing.

On a side note, I finally bought some PLA as I hope to commission my repstrap this weekend. I bought it from www.reprapltd.com the shop run by Adrian Bowyer. As I'm local, I dropped into Bath University and picked it up, and bumped into Adrian who was just about to have his lunch. We had a very pleasurable 20-minute chat, and I picked his brains about bits and pieces. I'll report back how I fair with his PLA, but it is lovely white glossy stuff, so I hope it will look good. Though his range isn't extensive, his prices for filament and printed kits are very reasonable compared to other UK sellers.
Sorry, only registered users may post in this forum.

Click here to login