Arduino stepper motor control with Simulink

徘徊边缘 提交于 2019-12-02 08:56:49

问题


Hi Im quite new in Arduino and electronics so bear with me.

I have a project to control a step motor using Matlab and Simulink. For now I just want to get the thing up and running. I have hooked up the schematic tested it with a simple code for a step motor and it works (this has been done without Matlab). My problem is how can i get the motor to run using Simulink and Matlab?

When i try to Run the Simulink model i get this

My step motor driver board is ULN2003APG

and my motor is

.

I have downloaded the Arduino Hardware Support Package for Matlab and have already uploaded the server program to Arduino to enable communication between Matlab and Arduino.

I have no idea what might be causing the error that i get. Any help would be greatly appreciated!

If there are any existing guides or any examples covering such topics u can redirect me to them.

(If there is a need to write a new driver for the board please send me some tutorial where I can read about that.)

Thanks in advance.

EDIT!

Here are step by step the things that I do to try and get my Simulink model to run:

1: Complete the steps in this tutorial.

2: Download MATLAB Support Package for Arduino.

3: Connect the arduino uno to PC, open the Arduino IDE and upload adioes.pde from step 2.

4: Open Matlab change working path (if not it gives an error)

5: Open existing example from downloaded MATLAB Support Package for Arduino ...\ArduinoIO\examples\stepper_sim.mdl

6: Change COMPORT and click Tools/Run on Target Hardware/Prepare to run and after that Tools/Run on Target Hardware/Run

After that I get my error.

Here is a nother image of the simulink model:


回答1:


From your file name it looks like you have downloaded this from a file exchange submission "MATLAB Support Package for Arduino (aka ArduinoIO Package)". Based on one of the comments in that submission this package does not support code generation. It can be run only using Simulink "normal" mode. For other targets which require code generation you need tlc files and you will see this error.




回答2:


I believe the error window already tells you what is the problem. You need to move the file msfun_arduino_io_setup.tlc to you project's working directory. We can only have this much sight in your project with what you have given to us. If there is, you need to give more information, for instance SS of your Simulink Model.

Besides all, I suggest you to download Arduino Support Package and other add-ins, extensions and files from Matlab itself if you can.




回答3:


I've finaly managed to get the stepper motor running using Simulink. Unfortunately I had to change the driver board to do that. It seems there isn't a driver from Matlab for this board or it's just not compatible (not sure).

I've bought an adafruit motor shield v2 and things worked perfectly. It no longer give's that error about a missing .tlc file.

Cheers !



来源:https://stackoverflow.com/questions/22938827/arduino-stepper-motor-control-with-simulink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!