Maker Pro
Maker Pro

DC-Micromotors directions CW/CCW

Firstdesgin

Jan 4, 2016
10
Joined
Jan 4, 2016
Messages
10
Hi All, fairly new to the site but have some back round knowledge of electronics. I am Looking to do a little project that requires some fairly straight forward electronics i believe.

Basically what i want to do is have two electric membrane switches, both Normal open, when pushed and released the motor starts and keeps running till the end point.
The First one powers the motor clockwise until it comes to the end point and triggers the end stop/reset button
The second switch powers the motor Anti-clockwise until it returns to the other end stop/reset button

How would this be achieved?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
This is a basic setup for this task:
upload_2016-1-5_10-38-16.png

The MOSFETs form an H-bridge that allows the motor to run in both directions.
The FlipFlops store the last state of a pressed pushbutton. The Q and not-Q outputs drive the transistors of teh h-bridge to run the motor in the desired direction.
Once the end-position has been reached, the end switch resets the respective FlipFlop and the motor stops running.
The diodes are there to prevent a short circuit of the h-bridge in case someone presses a button while the motor is running in th eopposite direction. By the diodes the respective FlipFlop is reset and the motor simply reverses direction.

This basic circuit can be refined to include better protection of the h-bridge, LEDs to display the current active direction of the motor, improved prevention against unwanted activation of butons etc. It's up to you...
 

Firstdesgin

Jan 4, 2016
10
Joined
Jan 4, 2016
Messages
10
Hi Harald, this is exactly what i was looking for, this is for test purpose, the idea of led's for when the motor is moving in either directions is great.
One Question, do you have resistors between Vcc and the S on both Flipflops?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Ah, I see, the question was "why" (missing that little word made your question useless).
These resistors are pull-up resistors to ensure a logic high level when the button/switch is open.
 

Firstdesgin

Jan 4, 2016
10
Joined
Jan 4, 2016
Messages
10
Apologizes about my wording. Yes i understand the idea behind the pull-up resistors which is good.

I think i will go ahead and test this, as for improving prevention against unwanted activation of buttons which will be inportment in this case what would you suggest. If the motor is traveling one direction and the second button is pressed i dont want the motor to stop until it hits the end point

How would i over come this?

Plus maybe if i wanted to use button 1 to turn the motor but can also use the same button to pause the motor(stop) and then press the same button 1 again and the motor keeps traveling in the same direction till the end stop?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
If the motor is traveling one direction and the second button is pressed i dont want the motor to stop until it hits the end point
Connect the start buttons crosswise to the outputs of the other FlipFlops such that the buttons can be active (logic low) only if the other FlipFlop is inactive:
upload_2016-1-5_12-11-10.png
 

Firstdesgin

Jan 4, 2016
10
Joined
Jan 4, 2016
Messages
10
Thats great.

If i wanted to use button 1 to turn the motor but can i also use the same button to pause the motor(stop) and then press the same button 1 again and the motor keeps traveling in the same direction till the end stop? is this possible?

Can all these be achieved in a controller if i wanted to scale things down?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
What you wish can be done but is above a simple logic circuit. I suggest you use a microcontroller and write a program that reads the button states (don't forget to debounce the buttons) and controls the motor accordingly. When you use one of the current paltforms (Raspberyy Pi, Arduino etc.) you even don't have to build the motor driver h-bridge as you can buy the off-the-shelf as so called "shields".
 

Colin Mitchell

Aug 31, 2014
1,416
Joined
Aug 31, 2014
Messages
1,416
"If i wanted to use button 1 to turn the motor but can i also use the same button to pause the motor(stop) and then press the same button 1 again and the motor keeps traveling in the same direction till the end stop? is this possible?"

You just need a microcontroller and 12 months of programming experience.
 

Firstdesgin

Jan 4, 2016
10
Joined
Jan 4, 2016
Messages
10
upload_2016-1-6_8-30-7.png
So would you suggest the logic behind programming the microcontroller would be beyond the average person?

The set up above is what im kinda after. Button 1 CW turns the motor on until it comes to the end stop, but would be nice if button 1 could be pressed to pause the motor, then button 1 pressed again to contuine CW until endstop. Then button 2 CCW does the same only in reverse CCW
 

Colin Mitchell

Aug 31, 2014
1,416
Joined
Aug 31, 2014
Messages
1,416
You have to set up all your requirements before you start, not just the vague requirements you have listed so far.

Maybe it would be better to use a servo.
 

Firstdesgin

Jan 4, 2016
10
Joined
Jan 4, 2016
Messages
10
by requirements you mean the actually components that will used, like end-stops/reset switches what type of buttons, power supply?
yes i was looking at stepper motors aswell but trying to keep costs down, but a stepper motor would make things easier?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
So would you suggest the logic behind programming the microcontroller would be beyond the average person?
Definitely not. Imho Colin is exaggerating a bit. Depending on your prior experience with programming, especially microcontroller programming I'd estimate that you can have the required program up and running in 1 day to 1 week.
Colin is right insofar as it is essential to have all requirements at hand before you start coding. This will allow you to lay out the program structure accordingly. Adding new functions to an existing program can be awkward if the foundations haven't been layd properly.

by requirements you mean the actually components that will used
Yes, those plus the functionality (user scenarios) i.e. which button presses will be allowed, which functions will be triggered by these presses, what the reaction of the system to not-allowed button presses is etc.
 

Firstdesgin

Jan 4, 2016
10
Joined
Jan 4, 2016
Messages
10
Yes, i have some previous experience in java and ladder logic so this could be helpful. What software would you recommend?

as the project is in the earlier stages i have not layed down the finally scenarios, still trying to figure out what will be best. but basically what i would like is to press one momentary push button to start motor running CW, the second button will not be available for use until the motor has reach the end stop, this same button 1 could still be used when motor is going cw as a pause, then press again to start. then when end stop is triggered button 1 become inactive and button 2 takes over and does the same only in reverse
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
What software would you recommend?
That depends on the controller you use. If, for example, you use an Arduino, I'd recommend the arduino IDE for starters. Other µC platforms (PIC, AVR, ...) come with their own IDEs.
More highly integrated minicomputers (e.g. raspberry Pi) can be programmed on board (raspberry Pi using the linux operating system and a variety of programing languages.

From a hardware point of view a Raspberry Pi is overkill, but from a software point of view it is a complete platform.
Probably an Arduino is what you're looking for. It is a small platform (available in different flavors (computing power etc.). An arduino micro or arduino nano should be sufficient for this project. They are programmed in a C/C++ like dialect called "sketch", complied on teh PC (within the IDE) and downloaded to the arduino.

Regardless of the platform you use, you'll need additional hardware to control the motor and to read the button states. The arduino platform offers off-the-shelf shields that allow you to easily connect the hardware. The software is up to you, but you'll find plenty of arduino related help on the internet.
 

Firstdesgin

Jan 4, 2016
10
Joined
Jan 4, 2016
Messages
10
Apologizes about the delay in getting back to you. I was looking into stepper motors and believe this may suit the job better as i can control the number of steps in both directions and program the microchip to read buttons etc. Would there be any down falls to this?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Stepper motors need a bit more control logic than a simple DC motor as you need to generate the correct sequence of control signals to step the motor. You will have to use a microcontroller for that. For the most popular platforms you'll find stepper driver hardware as well as software libraries that will support your project.
 

Firstdesgin

Jan 4, 2016
10
Joined
Jan 4, 2016
Messages
10
Yes, i understand more how stepper motors work. and the logic behind them to program the microchips. this may suit my needs more as i want to create a small prototype to be built into the top of the unit.
 
Top