Wiring problems

Hi, I have a question about some general wiring of my arduino, power supply and a switch.

English is not my native language, so I hope I my problem well enough for some of you to understand.

I have a 12v dc power supply that runs a 12v motor through a micro switch (NC COM NO). When the sircuit is closed, the motor runs, but when the sircuit is open I want it to pull a digital pin on the arduino LOW (I ofcource use ground from the power supply through the micro switch). Can I just use the ground from the power supply to pull the pin LOW? Or will it damage something. I use the same power supply to power the arduino UNO.
I’m thinking of using a pullup resistor from the 5v on the arduino to keep the pin from floating, will that be OK? And if so, any suggestions on resistor size?

As you probably figured out, I have no qlue when it comes to

Thank you all in advance

It should work, but put some resistance in series at least 22K with the input pin. Wire with COM to ground, th NO to the motor and the NC to the arduino via a resistor. Put the pull up resistor on the switch side of the resistor. There is a lot of room in the resistor value, something you have greater then 12K should work just fine. If you want create a schematic, not a frizzy thing and post it. You can get KiCad free of charge but be nice and leave a donation, it is a great CAD package but not a turn it on and go thing.

Here's the general idea. It's fine to use the Arduino 5v pin to pull the data pin high, but you will need a resistor since one position of the switch shorts to ground. The diode is optional but may prolong the life of your switch. Make sure the switch is a break-before-make type (most common except in some audio equipment).

The resistor and connection to the Arduino 5v pin can be eliminated by configuring the input pin using the internal pullup resistor:
pinMode(x, INPUT_PULLUP);
where x is the number of the pin you're using as an input.
S.

schematic.gif

schematic.gif

Thank you for the reply. It is something like the schematic from srturner I was thinking of but not sure if I could do it.

Correct me if I’m wrong (and I probably am), but isn’t the two answers I’ve gotten two different answers?
If I go for the schematics from srturner and use the internal pullup of the arduino, I don’t need any resistor at all, but gilshultz mention 22k in series and 12k resistor.

frodv:
Thank you for the reply. It is something like the schematic from srturner I was thinking of but not sure if I could do it.

Looks like a good way to do it - provided there's nothing in the way of connecting the motor GND and Arduino GND together, as that connection is implied.

Correct me if I’m wrong (and I probably am), but isn’t the two answers I’ve gotten two different answers?

Appears to be basically the same thing to me. That 22k resistor is just extra protection, not strictly necessary.

A flyback diode across the motor winding is mandatory - the 1N4148 may not be suitable depending on the motor, the diode must be rated to handle the full motor current and that is a small signal diode.

Reply#1 offers about 22V protection to the input (wrong connection, etc) ... your choice.

frodv:
Correct me if I’m wrong (and I probably am), but isn’t the two answers I’ve gotten two different answers?
If I go for the schematics from srturner and use the internal pullup of the arduino, I don’t need any resistor at all, but gilshultz mention 22k in series and 12k resistor.

The differences are minor variations on the same theme. All of them should work. The extra resistors add some protection in the event of unforeseen mistakes. As an example, if you used a make-before-break (shorting) switch in my diagram, you could potentially damage your Arduino. Those kind of switches are not very common but they do exist.
S.

And I can use the same 12v power supply to power the Arduino Uno?!

frodv:
And I can use the same 12v power supply to power the Arduino Uno?!

Conceptually, yes. Small DC motors are notorious for producing lots of electrical noise, and that could interfere with the Arduino's operation. Only experiment will tell for sure. It wouldn't hurt to add extra bypassing to the Arduino's power supply input (i.e. 0.1 uF and 1.0 uF capacitors across the supply voltage, located at the Arudino).
S

Given the microswitch is handling an inductive load I'd be a little wary of EMI issues using
the same switch.

The 1N4148 looks a little weak for a free-wheel diode unless the motor is tiny, its pulse rating
is 0.4A or something like that.

The motor I’m planing on using is an old windshield wiper motor. It is going to drive a conveyor belt.

frodv:
The motor I’m planing on using is an old windshield wiper motor. It is going to drive a conveyor belt.

You might want to measure the current draw of that motor. It could easily be >1A, in which case the 1N4148 is definitely underrated. You would want to go with something like 1N4001 or 1N5402 or ....
S.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.