Invert the logic of a reset switch

134 views
Skip to first unread message

Caroline Longnecker

unread,
Aug 16, 2020, 9:09:09 PM8/16/20
to Area515 - Des Moines Maker Space
I have a pendant for the piranha, but I realized the reset switch is NC, and I need it to be NO, or at least behave like a NO switch (it's connected to the MCU reset pin, which is NO). I was looking around on the internet, and it looks like you can't really do this without power, which is fine, I can grab power off of one of the pins of the controller, but I don't know how to hook it up. I know you can use a transistor as a NOT gate, but that typically means you are switching between something being tied to ground or tied to VCC, right? In this case it's not connected, not sure if that means it's tied to VCC since it's a reset pin? Other than that, which type of transistor should I use? I'd like to use something that, if it fails, is likely to leave it in a reset state vs powered on.

Caroline

Ray Scheufler

unread,
Aug 16, 2020, 9:27:51 PM8/16/20
to Des Moines Hackerspace
First, how much of the circuit do you control? Is this a board that already exists and you are adding the pendant? Are you laying out the board yourself?

Go back to the root of how the reset pin works on a microcontroller. When the pin is high the processor runs. When the pin is low the processor doesnt run. Traditionally a board is wired up with a pullup resistor between the reset pin and voltage. For in circuit programming, the programmer also generally has a pin connected to reset so that it can get the device into a known state. (Also on older pic micros the reset pin would be where "high" voltage is applied to help with flash reset).

You said that you have a normally closed switch. I assume that this means that unpressed it is closed, when you press it then it latches and the contact opens, and you have to twist it to get the contact to close again. If you have full design control of the board, you can just rout the reset pullup resistor through your kill switch. That way the pin is floating (internal pull down) when the button gets smashed. If you dont have design control, you are looking for how to drive the reset pin low. Fortunately that is pretty easy to do with a low side n fet. I'll leave it as an exercise for the reader to figure out if the gate should be pulled up or down with a resistor. The switch goes to the other power rail. This can easily "invert" your signal because you only need the pulldown capability. To do a proper invert you would need push and pull transistors but that is unnecessary for your application. Any get should do. I'd dig around for something like a 2n7000 because we should have some at the space.

Ray Scheufler 


On Sun, Aug 16, 2020, 8:09 PM Caroline Longnecker <cvri...@gmail.com> wrote:
I have a pendant for the piranha, but I realized the reset switch is NC, and I need it to be NO, or at least behave like a NO switch (it's connected to the MCU reset pin, which is NO). I was looking around on the internet, and it looks like you can't really do this without power, which is fine, I can grab power off of one of the pins of the controller, but I don't know how to hook it up. I know you can use a transistor as a NOT gate, but that typically means you are switching between something being tied to ground or tied to VCC, right? In this case it's not connected, not sure if that means it's tied to VCC since it's a reset pin? Other than that, which type of transistor should I use? I'd like to use something that, if it fails, is likely to leave it in a reset state vs powered on.

Caroline

--
You received this message because you are subscribed to the Google Groups "Area515 - Des Moines Maker Space" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dsmhackerspac...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dsmhackerspace/0JO6FQ.0CA80RHBYGGI3%40gmail.com.

Caroline Longnecker

unread,
Aug 16, 2020, 9:36:06 PM8/16/20
to dsmhack...@googlegroups.com
I'm laying out the board myself. There was one in it, but the useful buttons are superglued shut, and I'm not 100% sure how the reset switch is wired (looks like it's just directly connected). 

I figured that's probably how it works, but I've never looked into it before.

Thanks Ray, that should get me started on it. 

Caroline

Ray Scheufler

unread,
Aug 17, 2020, 10:19:09 AM8/17/20
to Des Moines Hackerspace
If you want a second set of eyes, I can review your schematic before you start layout.

Ray Scheufler

Caroline Longnecker

unread,
Aug 18, 2020, 6:19:51 PM8/18/20
to dsmhack...@googlegroups.com
After some digging I found some 2n7000s, they were mixed up with a bunch of assorted transistors. I found a suggested diagram online, but when I was thinking through it it didn't make sense. Round 2 makes more sense to me. If 5V is connected to gate (when the button is up and closed),  RESET will want to be tied to 5V rather than GND because of the lower impedance, but when the button is open, gate is tied to ground which shuts off the transistor and causes the lowest impedance path to be ground (I'm assuming there is a 4.7k pullup installed on the board, which is why I chose lower values so more current will flow that way). I could remove the pullup resistor, but that would cause the board to behave erratically if the pendant is ever removed, so I'd rather keep it like this. Let me know if there are more ideal values for R1-R3.

Caroline

Ray Scheufler

unread,
Aug 18, 2020, 6:47:46 PM8/18/20
to Des Moines Hackerspace
I'm not sure your circuit would work. I avoid having resistors between a fet source pin and ground. It can work but makes the math harder and is more for analog signals (I'm not an analog engineer).  I've got a couple of options that should work. 

Option 1 is sketchy non transistor. The 100k pulldown keeps the micro in reset when the switch is open or not present. When the switch is closed the 1k resistor pulls the pin up to Vcc and the micro comes out of reset. This may play havoc with a programmer as it can't drive reset like it wants to.

Option 2 is probably better. The reset pin is normally pulled up by the rightmost resistor (pic usually wants this to be 4.7k). The 2n7000 can pull the reset line low. The pullup resistor on the gate force's the transistor to conduct when the switch is open or not present. Probably should be in the 10k range. When the switch is closed the gate gets pulled to ground and the transistor stops conducting. Probably also want a 100 ohm resistor in series with the switch just to limit the current when charging the fet.

Ray Scheufler 

20200818_174044.jpg
geary-pasted-image-1214971986.png

Caroline Longnecker

unread,
Aug 18, 2020, 7:01:00 PM8/18/20
to dsmhack...@googlegroups.com

Ray Scheufler

unread,
Aug 18, 2020, 7:26:57 PM8/18/20
to Des Moines Hackerspace
Yes. When the switch is open, r1 will pull the gate up to vcc which will make the transistor conduct which will pull the reset line low. When the switch is closed, r3 pulls the gate to ground much harder (around 50mv) which makes the transistor stop conducting so r2 can pull the reset line to vcc. R3 limits the rush current when closing the switch. You can do the math for what the time constant is for the r1 to pull the gate up to voltage and make the micro reset. It is 1/rc where r is 10k and c is the gate capacitance of the fet (factsheet will tell you). You probably need 3 times the time constant to charge enough to switch.

R1 should be small to make the switch happen quickly.
R3 should be much smaller than r1 so that when the switch is closed the gate is close to ground.
R1 plus r3 will be "waste" current when the micro is on (want a high value)
R2 should be whatever your microcontroller datasheet recommends (pic is 4.7k)

When you reprogram the micro you either need the pendant plugged in or a jumper on its contacts so the micro can come out of reset as the programmer demands.

One advantage to this circuit is that it could be applied to a stock arduino. You assume that r2 already exists on the board and just add the other resistors and get as they are.  Makes it easy to add external reset to an existing circuit.

Ray Scheufler 

geary-pasted-image-4118132390.png

Caroline Longnecker

unread,
Aug 18, 2020, 8:12:04 PM8/18/20
to dsmhack...@googlegroups.com
This is a Grbl style board with an ATmega32u4 I think, whatever comes standard on the uno. It essentially has R2 already installed. Am I able to remove R2 and the connection between VCC and RESET on my board since this connection exists on the controller? My first instinct is no, because I don't see the connection in my sheet, but if I think about it for a bit it seems like I can, since that does exist already elsewhere.

Caroline

Ray Scheufler

unread,
Aug 18, 2020, 8:16:28 PM8/18/20
to Des Moines Hackerspace
I would expect that you can remove r2 (open circuit, not short) and be fine. The board without your addition will have a pullup. Your addition will add an additional mechanism to pull the micro into reset.

Ray Scheufler 

Caroline Longnecker

unread,
Aug 18, 2020, 8:19:20 PM8/18/20
to dsmhack...@googlegroups.com

Ray Scheufler

unread,
Aug 18, 2020, 8:20:46 PM8/18/20
to Des Moines Hackerspace
Yes, assuming reset is a pin on an arduino (or other already operating board) and not just a bare pin on the mcu.

Ray Scheufler 

geary-pasted-image-282395721.png

Caroline Longnecker

unread,
Aug 18, 2020, 8:31:39 PM8/18/20
to dsmhack...@googlegroups.com
http://www.panucatt.com/product_p/gm1pro.htm This is the controller. It has multiple reset inputs, I'm assuming all of them route to the same place. I'm planning on using the RST input in the terminal blocks, looks like they recommend using the pin headers for Emergency Stop buttons, but assuming the other reset works identically, it should be fine. I'm 90% sure it does, as the pin headers aren't jumpered, which should mean it operates logically the same as the other input.

Caroline

Ray Scheufler

unread,
Aug 18, 2020, 8:42:40 PM8/18/20
to Des Moines Hackerspace
I believe you are correct. You should be able to verify with a multimeter. I would expect to have very low resistance between all reset breakouts and the reset pin on the micro (pin 1 on dip or soic packages generally, look at the datasheet otherwise). I would also expect you to be able to measure the pullup resistance between that pin and the Vcc rail.

Ray Scheufler 

Caroline Longnecker

unread,
Aug 18, 2020, 8:48:59 PM8/18/20
to dsmhack...@googlegroups.com

Jeff Hagerman

unread,
Aug 19, 2020, 11:39:18 AM8/19/20
to dsmhack...@googlegroups.com
I envy the knowledge but then, the two of you don't actually exist in permanent human form outside of your computer homes I suppose. 😲🤔🤫

Ray Scheufler

unread,
Aug 19, 2020, 11:54:10 AM8/19/20
to Des Moines Hackerspace
At some point when the world returns to a sense of normalcy I will make it back down to the space.  I have a young daughter that I really don't want to risk giving permanent lung issues to (since long term effects are so unknown I'd rather play it safe).  I had pneumonia a couple of times growing up so I know that breathing issues suck. 

I have a degree in computer engineering and have fabricated a number of different circuit boards.  I'm used to breaking down problems like this into reasonable pieces and understanding how they fit together.  If you want some "light" reading, most of my college textbooks are on the library shelves at the space.  They have all the information necessary to do proper formal analysis.  The trick is knowing when you need to do proper formal analysis and when you can just take shortcuts.  What Caroline needs is a basic NMOS inverter circuit (active pulldown, passive pullup).  Knowing that is a thing and the basic rules of layout to accomplish this are just a matter of having studied it and built a few things.

I also realised how difficult it is to explain a circuit without just drawing it out.  It was easier to sketch on paper and take a picture rather than dig out a CAD program.

Ray Scheufler

Jeff Hagerman

unread,
Aug 19, 2020, 12:12:13 PM8/19/20
to dsmhack...@googlegroups.com
We hold equal membership levels in the pneumonia club so, I can easily understand your hesitancy to contact. That's one reason that I work in the space late at night.

As far as the light reading...I appreciate the offer but, several years ago I realized that I won't learn enough about any of my interests to be proficient unless I focus on a few. 

Unfortunately, the space does not support my reason for college but, we won't go there.

Reply all
Reply to author
Forward
0 new messages