I am planning on making a controller board for a small goods lift. The motor is a standard 12VDC +/- 60W geared motor (windshield wiper motor). I had a look at a youtube video on how to make a low cost H-bridge that can handle up to 10A which would be sufficient for this application.
My knowledge on coding is close to zero, but I have fairly good mechanical knowledge to make the mechanism and my electronics experience is on a level that I think I could put the right components on a piece of vero board to make it work. So I need someone generous to help me write code to make this work.
I would like to have it work as follow:
The system should be activated with 1 push button. 1 press makes the motor turn (for argument sake clockwise) another press of the button will stop the motor and if you press again the motor will reverse direction (counter clockwise in this example)
There should also be 2 limit switch inputs, so lets say the top limit is reached, the the motor should stop and if the button is pressed, the the system should go the opposite direction/down and vice versa. Am I explaining the operation right?
Then a nice to have would be to have another two inputs for another 2 limit switches or even hall effect sensors placed just before the limit to have the motor slow down before it stops on the limit and when it starts, it starts slowly and ramps up to full speed when it passes the "slow down" sensor. This would just make the operation look smoother.
If I can get this right, phase two would be to make a shield pcb professionally for the uno with the h-bridge and all termination blocks on it for easy wiring.
One part is figuring out the program logic for starting, stopping, reverseing, etc - use LEDs and push
buttons to start with.
Another is driving an H-bridge, which is somewhat hardware specific (some H-bridges are 2 input, some 4,
and they vary about how to use PWM.
That motor is 60W nominal, beware the maximum (stall) current rating - its likely to be considerably
higher than 10A and the H-bridge has to survive this. You will need a suitably rated H-bridge module
or motor controller - I'd suggest looking at the range at pololu.com for an idea of what kind of thing
is available.
Vernon333:
The system should be activated with 1 push button. 1 press makes the motor turn (for argument sake clockwise) another press of the button will stop the motor and if you press again the motor will reverse direction (counter clockwise in this example)
It is certainly possible to write a program to make that happen. However I reckon it will be a bit of a nightmare for the user who may inadvertently press it the wrong number of times. I would suggest using 2 buttons - one for up and one for down, or using a 3 position centre-off toggle or slide switch.
I made it a 2 button system and got myself a few leds, resistors and a breadboard.
Got a bit of code sort of working, but need some help.
The buttons work, but it does not keep the trigger until the limit is reached, as soon as I release the button, the led goes of.
I would like it to be pressed once, motor switches on and turns in direction of what button I pressed until the limit is reached then stops and cant go further, only in the other direction.
To make it easy for people to help you please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum
Rather than this style
if (UpButtonState == LOW && UpperState == HIGH) {
you need to use the button press to set a variable for upward movement which only gets reset when it actually gets to the top. Something like
if (UpButtonState == LOW) {
moveUp = true;
}
if (moveUp == true) {
if (UpperState == HIGH) {
// code to move up
}
else {
moveUp = false;
}
}