Reversing a sensor polarity

Go To Last Post
23 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Before I implement some DIY sensor reversing circuit on my 3d printer I thought I should talk about it here just to be safe. I'd hate to break something on it.

So, I am trying to use the auto bed leveling of my delta printer to cut my own PCBs. The way this works is you auto bed level and use alligator clips as sensor - sensing continuity when the bit touches the copper board to be milled.

 

 

Unfortunately, I found out that the polarity of that sensor on my printer is reversed - the sensor thinks it is triggered when there IS continuity. There is no easy way to reverse the polarity through software on my printer so I though I should make a hardware that reverses it

 

 

After some thought I came up with the next schematic. I am no expert though - that is why I am posting before I do something irreversible to my printer.

 

 

Am I doing something wrong that I am unaware of?

 

EDIT1: The 5V on the sensing side is probably a pulled-up input

 

EDIT2: I am afraid that current could flow through the milling side and through that resistor to ground thus keeping the sensor "open". Should I be using an opto-coupler? I couldn't measure the pull up resistor value

This topic has a solution.

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

Last Edited: Mon. Jan 25, 2021 - 08:39 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not on the right computer to draw you a schematic.

 

And I hate using PNP bipolar transistors, everything is backwards from a right proper NPN!

 

That said, if you use a bipolar transistor as an inverter you will likely need a resistor is series in the base lead.

 

I'd use an NPN or an NFet, whatever else I have lying around to do this.

If nobody else has posted a schematic for you, I'll do so tomorrow.

 

BTW, if you have any low level logic gates chips you could also use them, (e.g. a single NAND gate).

 

As this is a microcontroller forum, I feel obligated to complicate the project and use a micro, and an LED, of course!

 

You could use any micro, but a 6-Pin or 8-Pin Tiny would be fine for this.

You set one pin as the input and read the input signal.

You set one bit as the output, to drive the rest of the circuit.

The Main Loop reads the input and outputs the opposite level signal.

 

Pseudo Code:

 

Do

  If PinA.1 = 1 then

    PortA.2 = 0

  Else

    PortA.2 = 1

  End If

Loop

 

And the output pin can drive an LED, (with a series resistor), also!

 

JC

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you so much for helping! I did think about using a microcontroller but my problem was --> how will I provide the same source voltage to it as the printer has?

I do have some attiny13. I also have some quad NOR gate ICs. Right now I am messing around with an opto-coupler. I'll wait for your post! Have a good day

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That alligator clip on the bit might work for a while BUT (1) I would expect it to be noisy - at the very least use a capacitor to slow the detection of contact loss and (2) I would expect a pretty short life. What you are trying to make is a "slip ring". The commercial ones specify a maximum RPM and a life that depends on the rotational speed. I would look for some part of the equipment that does NOT rotate but is connected, maybe by bearings, to the shaft. Yes, most bearings will have lubrication and may be electrically noisy, but the reliability should be a LOT better.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The clips are removed after the auto leveling is complete. The test is done while the shaft is not rotating. Could that still be a problem?

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Then that should not be a problem!

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok! Thanks for the info though. If I ever need it to be rotating I need a "slip ring" - got it.

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

how will I provide the same source voltage to it as the printer has?

Your drawing shows the print as supplying a 5V signal / supply to the sensor / limit switch.

 

I would therefore expect that if you powered your Tiny13 with 5V, and connected a common ground between the T13 and the printer, you would be fine. 

 

Is the "sensor" / limit switch (drill bit, etc), that you are adding in addition to the limit switches that are already part of the printer, or are they truly extra, additional, input signals?

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The sensor that I am working on is the minimum Z sensor that senses when the head touches the print bed. About the 5V - as I mention in my 1st edit this is probably not a 5V rail but an input pin pulled up through a resistor of unknown value. So I don't know if it could be used to power a microcontroller.

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tested the schematic that I proposed on the first post and it is actually working for a resistor of about 50KOhms! I am surprised in a good way

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unfortunately, I found out that the polarity of that sensor on my printer is reversed - the sensor thinks it is triggered when there IS continuity.

 

Sorry, I'm a little confused.

The normal Z-axis limit switch should "trigger" when the print head hits the table.

Depending upon how the switch is wired to the Input pin on the printer controller, that switch activation could be a signal that is normally low when printing, and goes high when the print head hits the table, or it could be a signal is is normally high when the printer is printing and goes low when the print head hits the table.

 

Your alligator clip switch clearly goes low when the print head, (or routing bit in this case), hits the table, (or PCB in this case).

 

So if the signal going low is backwards, (reversed) from what it usually does, then the printer's Z switch would normally go high when activated, (print head hits the table).

 

So, the switch could be a Normally Closed switch that goes Open when pressed, and has a pull-up resistor internal to the controller.

 

You have likely already done this, but you should check how the circuit works by using a DMM/Voltmeter to read the Z-axis signal input when in the normal, printing state, and when in the hitting the table top state.

 

You should also disconnect the two wires from the switch, (if possible to do so), and use an ohmmeter to see if the switch is Normally Open or Normally Closed, when in the normal printing state.

 

JC

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The sensor pull-up resistor and polarity are set in the firmware configuration.h file and is impossible to change them without reuploading the firmware with other settings (I use Marlin firmware). Although I haven't checked the pin state (sense+ or 5V in my schematics up top) its state must be the same during any process the printer does.
I did probe the original z min switch and it indeed is closed by default and open on trigger. Therefore as you said low signal on the pin means no contact and high = contact.

 

EDIT1:I messed up that last sentence before - had the "low" and "high" words swapped

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

Last Edited: Mon. Jan 25, 2021 - 06:22 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Make the detection sense controllable by a #define constant. Then you won't have to struggle. There really is no reason for the added circuit with the possible exception of protecting the port pin. You can do that with a pair of external diodes, one to Vcc and one to ground to limit the input voltage and a series resistor to limit current, say 1K or so. The internal pull-up is around 25K so the logic levels should still be obeyed.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am struggling in the idea of having to reupload firmware every time. Changing polarity in the firmware is actually pretty straight forward.
Could you draw a simple schematic so I understand?

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

'Tis easy

                                                         Vcc

                                                           |

                                                        DIODE

                                                           |

                                                           |

to spindle --------- RESISTOR ---------------------- to port pin

                                                           |

                                                           |

                                                        DIODE

                                                           |

                                                         GND

 

Sorry for the "text art". For some reason, I cannot upload an image. For both diodes, the cathode side is UP. Diodes can be small like 1N4148 or 1N914. Resistor maybe 1K, internal pull-up for that port pin is ON. This assumes that the board you are working is connected to the MCU ground.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank u!

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is my final solution:

 

 

I used a small piece of board to account for stress on the cable. Also managed to keep it all at roughly the diameter of the cable. The circuit is just as described on my first post and using a resistor of about 60KΩ. It pulls the pin down to 0V when the v-bit is not touching the board and for the high state (when the bit is touching the board) the pin goes to about 3.3V which is not the normal 5V  logic but more than enough to trigger it.

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am glad you have it working!

 

Please feel free to post a a photo of the printer routing the PCB, I would love to see it in action!

 

JC 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will post a photo in action tomorrow. Here is my first attempt in milling the top copper traces:

 

 

Unfortunately, some traces came out way thinner than they should be but the important part is that the milling depth is consistent throughout the board. I will have to mess around with Flatcam settings to get better results on those traces. This board is 36 by 52mm

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

Last Edited: Mon. Jan 25, 2021 - 08:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow, looks like a great first time pass!

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Heh yeah for a first time - can't complain

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

TO THE FINDER... THE ISLE OF KOHOLINT, IS BUT AN ILLUSION... HUMAN, MONSTER, SEA, SKY... A SCENE ON THE LID OF A SLEEPER'S EYE... AWAKE THE DREAMER, AND KOHOLINT WILL VANISH MUCH LIKE A BUBBLE ON A NEEDLE... CAST-AWAY, YOU SHOULD KNOW THE TRUTH!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How cool.

 

I love watching CNC machines, 3-D printers, and Pick & Place machines do their thing!

 

JC