Help with creating a motor controller

3 visualizaciones (últimos 30 días)
Kevin Graebner
Kevin Graebner el 24 de Abr. de 2019
Respondida: Madhu Govindarajan el 24 de Abr. de 2019
Hello! hope you are all well.
i am very new to the matlab and simulink experience, have been playing around with simulink to control an arduino.
Yesterday i made a little test curcuit where i could control the power, and direction of a motor until a limit switch was hit which would stop it.
what i am after now is a single button that can start and stop the motor. Currently i have an enabeled subsystem with the input from a physical button going to the enable port and a pwm signal generator going to the output to run the motor.
This starts when i hit the button but does not always stop unless i time it just right or press it a few times.
is there a better way you would reccomend?
Next. What i am having the most difficulty with is figuring out a way to start the motor off in a direction until it hits a limit switch, then have it pause for 5-6 seconds and reverse directions until it hits another limit switch followed by another pause. i need this to be in a loop where it will just continually run.
All of your thoughts and opinions are greatly appreciated! hopefully this will provide some useful answers to others as well.
It seems there are several ways to hold a state in simulink, but im having a hard time figuring out how to make it fit this application.

Respuestas (1)

Madhu Govindarajan
Madhu Govindarajan el 24 de Abr. de 2019
Here are some thoughts:
1) I think your approach is good as it is. The update I would recommend is to increase the sampling time of the arduino digital input to something bigger like 0.5 seconds or 1 second. Then when you are pressing the switch, make sure you are holding it for at least that much time period. This would eliminate some of the issues.
2) I think the easiest way would be if your motor takes the same amount of time to go from one limit switch to the other, you can create a time-based loop in simulink and make the motor go back and forth. Another approach would be to trigger some sensor everytime the limit switch is pushed and use this to control the motor direction.
All said, Stateflow is a great tool for event-based modeling (which is what you are trying to do) so do take a look at that product.
HTH,
Madhu

Comunidades de usuarios

Más respuestas en  Power Electronics Control

Categorías

Más información sobre Arduino Hardware en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by