Use Arduino to Run 24v Motor with Microswitch

Hi there,

I'm looking to control a number of 24 volt dc motors with an Arduino. The motors need to do a full 360 degree turn when activated. When rotating the microswitch is depressed, and not depressed when it reaches it's home position. I've attached a circuit pic. Having some trouble working out how the microswitch signals the controller when to stop sending 24 volts to the motor. Then I need to find the best code to modify so the arduino can control it correctly. I'm a bit puzzled as to why I measured 4 volts dc in the circuit before and after the motor is activated by the original controller.

Images from Original Post so we don't have to download them. See this Simple Image Guide

...R

azor32:
Having some trouble working out how the microswitch signals the controller when to stop sending 24 volts to the motor.

That sounds like the mechanism used in a screen wiper motor to make it park at the right position.

In a screen wiper when you turn on the wiper-switch it provides power to the motor in parallel with the microswitch - effectively overriding the OFF position of the microswitch so the motor moves. Then, if you turn off the wiper-switch when the wipers are not at the park position the microswitch keeps supplying power until the park position is reached.

If that has any relevance then you need to tell us what role you want the Arduino to play.

...R

Neither of those pictures help with answering your question about the 4V readings. FOr that you will need to draw and post a wiring drawing.

What is the microswitch connected to?

Too many people try to jump to programming without thinking through the process if done by hand (ie., without programming). This may be a bit hard to explain but will result in a well working circuit. You can test this before hand as well. The goal is to run the power for the motor through the DPST microswitch in such a way that the motor stops itself.

Without the Arduino:
24V Power to Microswitch COM
Microswitch NC (normally closed) contact to motor power.
Motor ground to 24V ground.
and
Connect 24V power to a push button switch, then from the switch to the motor power.

When the motor is home, the microswitch is open stopping the motor from getting power. Pressing the push button switch bypasses the microswitch and causes the motor to run. As soon as the microswitch closes, release the pushbutton and the motor will continue until it rotates to the home position and cause the microswitch to open again.

Swap the push button with a relay and connect to your Arduino. Close the relay long enough to get the micro switch to close and then open the relay. If you need to know the position of the microswitch, connect the microswitch NO contact use a zener diode-resistor-optocoupler combination to reduce from 24V signal to 5V for the Arduino to read on a digital input pin.

Robin2:
If that has any relevance then you need to tell us what role you want the Arduino to play.

...R

It's taking over the role of vending machine controller for a compact vending machine.

adwsystems:
Without the Arduino:
24V Power to Microswitch COM
Microswitch NC (normally closed) contact to motor power.
Motor ground to 24V ground.
and Connect 24V power to a push button switch, then from the switch to the motor power.

When the motor is home, the microswitch is open stopping the motor from getting power. Pressing the push button switch bypasses the microswitch and causes the motor to run. As soon as the microswitch closes, release the pushbutton and the motor will continue until it rotates to the home position and cause the microswitch to open again.

I don't have a switch handy, but with 24v going directly from a power supply the microswitch didn't stop the motor from getting power in the home position. Testing the microswitch with a multimeter, it read a closed circuit when the button was or wasn't pressed. I don't have an oscilloscope to check what might be getting sent back to the vending machine controller to switch off the 24v supply.

azor32:
Testing the microswitch with a multimeter, it read a closed circuit when the button was or wasn't pressed.

If you are checking continuity (ohms) from COM to NO then it should be open when not pressed and closed when pressed. If this is not the case, then the switch is kaput. (You should also check COM to NC with the opposite actions on the switch)

azor32:
It's taking over the role of vending machine controller for a compact vending machine.

That does not tell me if my description of the process has any relevance,

Neither does it answer my question about the role of the Arduino in relation to the motor.

...R

Robin2:
That does not tell me if my description of the process has any relevance,

Neither does it answer my question about the role of the Arduino in relation to the motor.

...R

I'll try to answer your questions. If I'm misunderstanding let me know. I'm not very knowledgeable about wind screen wipers but I'd imagine that whatever motor used would need to go back and forth with a variable speed control switch. My application is for a single direction 360 degree turn, once off activation. The activation (and deactivation) of the motor is to be controlled by an arduino. The purpose of which is to vend a food or drink item from a vending machine(spiral coil).

Once I can get this part of the process to work I need to put together a set of conditions that the arduino uses to vend based on user input and sufficient funds.

azor32:
I'll try to answer your questions. If I'm misunderstanding let me know. I'm not very knowledgeable about wind screen wipers but I'd imagine that whatever motor used would need to go back and forth with a variable speed control switch. My application is for a single direction 360 degree turn, once off activation. The activation (and deactivation) of the motor is to be controlled by an arduino. The purpose of which is to vend a food or drink item from a vending machine(spiral coil).

Once I can get this part of the process to work I need to put together a set of conditions that the arduino uses to vend based on user input and sufficient funds.

You do misunderstand, then. The motor only turns one way. The back and forth motion of the wiper is because of the crank mechanism attached to the gear box of the assembly. Do you have the gear mechanism still attached to the motor?

Paul

adwsystems:
If you are checking continuity (ohms) from COM to NO then it should be open when not pressed and closed when pressed. If this is not the case, then the switch is kaput. (You should also check COM to NC with the opposite actions on the switch)

Not sure if what I'm seeing is correct, but it looks like the NC and NO terminals on the microswitch are wired together. Running a probe from no/nc and a probe to com shows there is continuity, however there is a spike in resistance when pressing the button, and when releasing the button on the microswitch. Wonder if this could be what the regular vending machine controller is looking for to turn it off?

Paul_KD7HB:
You do misunderstand, then. The motor only turns one way. The back and forth motion of the wiper is because of the crank mechanism attached to the gear box of the assembly. Do you have the gear mechanism still attached to the motor?

Hi Paul, I had to remove the gear mechanisms in order to take the picture of the inner circuit of the dc motor housing. When assembled they turn the central hole which turns the coil.

azor32:
I'll try to answer your questions. If I'm misunderstanding let me know. I'm not very knowledgeable about wind screen wipers but I'd imagine that whatever motor used would need to go back and forth with a variable speed control switch.

Speed control is a modern development.

What I am trying to get from you is confirmation, or a definite denial, that I have properly described how the microswitch in your system is intended to work to control the position at which the motor stops. I fully realize it is not a windscreen wiper - but the principle seems to be similar.

...R

Let's forget the windscreen wiper idea. Got me confused! Does the shaft that presses on the push button of the micro-switch have a flat spot that releases the button as the shaft revolves?

Paul

Paul_KD7HB:
Let's forget the windscreen wiper idea. Got me confused! Does the shaft that presses on the push button of the micro-switch have a flat spot that releases the button as the shaft revolves?

Paul

The shaft has a flat spot for the button to release. I've attached a pic.

azor32:
The shaft has a flat spot for the button to release. I've attached a pic.

I guess I have not yet figured out what question you are asking in relation to the motor and its microswitch.

I don't know what you know and what you don't know, and need help with.

...R

azor32:
The shaft has a flat spot for the button to release. I've attached a pic.

But based on the previous reply, the contacts between COM and NO and COM and NC never switch. So what's the point?

If anyone else runs into the same problem, I was able to get to the bottom of the operation of this dc motor and its microswitch. The microswitch when open, switches the circuit path to include a 680 Ohm resistor. The addition of this resistor in the circuit momentarily (5ms or less) drops the current in the circuit to zero or near zero. I purchased an Adafruit ina219 sensor and added it to the circuit including a relay to switch on and off the dc motor. The sensor is able to detect when the current mA momentarily drops to 0 and stops the motor at the correct spot in the rotation.

Thank you everyone for your help. Got there in the end.

Aaron.