Electrical Circuit Project: Two Motors + Button | Help Needed!

In summary: ).basically you need to create a state machine that monitors the button and if the button is held down for a set amount of time it will continue to run the first code.
  • #1
croc
5
0
hello,

I am absoloute dummy in electrical circuits, so please can you help me with my project?

My idea is circuit with two electromotors and button.
After 1st button press I need:
Motor 1 spins into certain position
After that motor 2 spins into certain position
After that motor 1 spin back to start position
Done

After 2nd button press I need:
Motor 1 spins Into certain position
After that motor 2 spin back into start position
After that motor 1 spin back to start position
Done

Afrer this another button press acts like 1st and another 2nd again, again...

Any idea? How to make this idea real ? I 'd use some gearbox but it is not possible for this project
 
Engineering news on Phys.org
  • #2
You have already described a state machine. You can implement it using digital circuits, but it is easier using a microcontroller.
 
  • #3
What do you mean by "spins into a certain position" ? Perhaps look at servos used for model cars/boats?
 
  • #4
well I "into position" I thought to open little doors :) here is the plan: I have little doors (plastic cover) that I want to connect to motor no.1 and little screen to pop up that's connected to motor n.2

So I want to push button
door opens
screen slides out
door closes again.

push button again
door opens
screen slides back
door closes

I think it is really simple :smile:
 
  • #5
croc said:
I think it is really simple :smile:
Yes it is, when you know how to do it.
Svein said:
You have already described a state machine. You can implement it using digital circuits, but it is easier using a microcontroller.
You must sketch a ( synchronous ) logic state machine like this:
http://ece224web.groups.et.byu.net/labs/08_4x7_Segment_Display/4x7_h3.gif [Broken]

and then you can design a logic circuit like this:
avFigure9.gif


. . . or you can implement it by relays or a μ-controller.

The important thing is, that when you sketch the logic diagram, you will have to consider what is going to happen if you press both buttons at the same time: Will the door be disintegrated ?
 
Last edited by a moderator:
  • #6
Wow thank you

I think μ-controller will be the best solution :D problem is I want only one brutton :)
 
  • #7
Trying to implement a discrete state machine in digital logic is not a flexible approach, and the design is very difficult for a beginner (both to design, and to implement)
(Nearly all digital designers implement state machines in an HDL and compile to a hardware solution in an FPGA or cell library)

Buy an arduino and a shield (IO board) to drive the motors. Choose the shield based on what kind of motors (servo, stepper, etc). You can easily implement what you are doing, and then adapt it to many other functions and projects. The challenge will be a steep learning curve in the beginning as you learn the hardware, the development environment, and the programming languages. There are MANY tutorials on line, and you will probably find example designs that are very close to what you want to do.

It is an extensive sharing community of do-it-yourselfers.

If you have trouble getting started, post further questions!
 
  • Like
Likes donpacino
  • #8
It you are just making one of these devices i would use an arduino to drive a pair of model car/plane servos. Avoids any need to build gears, limit switches etc.
 
  • #9
Thats exactly what I've thought, pair of model car/plane servos.
Thank you very much for ideas, yes I think I'll try that arduino.

I was checking models so I'd like to confirm with you before I buy it :)

Arduino micro (I need as small as possible)
2 rc car/plane servos
1 button

Thats all ?

Thank you :)
 
Last edited:
  • #10
Power supply.
 
  • #11
  • #12
Thank you sir :) ¨
Well, last few days I was watching youtube tutorials and reading tons of texts :D
I think I know how to connect servos, how to set positions on them etc. I think I know how to connect servos to arduino and code it. The only thing I don´t know is how to do buttons press changes. I´ve found only button hold changes...basically I have two pieces of code and want to start after button press not hold.
1st button press first piece of code.
2nd button press second piece of code.
3rd button press first piece of code again.
.
.
.

thats the only thing I don´t know yet :D maybe some boolean variable and if question :)
 
  • #13
Some hints:
  1. A pushbutton does not give a steady signal. It bounces (contact - no contact - contact etc.) for several milliseconds. Therefore the best way of detecting a true switch closure is to read it several times and require the level to be steady for a set number of times (if you read the switch every millisecond, the number should be 4 or 5, if you read it every 10ms 3 may be enough)
  2. Remember that pushing the button and releasing it are two separate transitions. You must require the button to be released before you can look for the next push.
  3. The easiest way to implement a state machine in C is to use the switch statement
 
  • #14
Svein said:
Some hints:
  1. A pushbutton does not give a steady signal. It bounces (contact - no contact - contact etc.) for several milliseconds. Therefore the best way of detecting a true switch closure is to read it several times and require the level to be steady for a set number of times (if you read the switch every millisecond, the number should be 4 or 5, if you read it every 10ms 3 may be enough)
  2. Remember that pushing the button and releasing it are two separate transitions. You must require the button to be released before you can look for the next push.
  3. The easiest way to implement a state machine in C is to use the switch statement
a note about debouncing. many people have written denouncing functions. ardunio might have a few built in (I cannot remember if I used a pre-built one native to aruidno's libraries, or I built one and added it to the library myself.)

As others have said, what you are trying to do has been done before. You can find all the info you need online. don't reinvent the wheel... unless you want to for fun.
 

What is an electrical circuit?

An electrical circuit is a path that allows electricity to flow through a closed loop. It typically consists of a power source, conductors, and loads, such as resistors, capacitors, or motors.

What is the purpose of using two motors in an electrical circuit project?

The use of two motors in an electrical circuit project allows for increased power and efficiency. It also allows for more complex movements or functions to be achieved, as each motor can be controlled separately.

What is the function of the button in this circuit project?

The button acts as a switch that can be pressed to complete or break the circuit, thus controlling the flow of electricity to the motors. This allows for greater control over the movement or function of the motors.

What safety precautions should be taken when working with electrical circuits?

When working with electrical circuits, it is important to always use insulated tools and wear protective gear, such as gloves and goggles. Make sure to turn off the power before making any adjustments or repairs, and never touch any live wires with your bare hands.

What are some troubleshooting tips for this electrical circuit project?

If the motors are not functioning properly, check to make sure all connections are secure and there are no loose wires. Also, ensure that the button is working correctly and is properly connected. If the issue persists, there may be a problem with the power source or the motors themselves.

Similar threads

Replies
11
Views
3K
  • Electrical Engineering
Replies
3
Views
1K
Replies
2
Views
1K
  • Electrical Engineering
Replies
12
Views
2K
  • Electrical Engineering
Replies
7
Views
4K
Replies
5
Views
2K
  • Electrical Engineering
Replies
16
Views
6K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
Replies
31
Views
3K
  • Mechanical Engineering
Replies
18
Views
2K
Back
Top