Creating a PWM (dc motor) using simulink. Help.

Hello guys...

Im working in a graduate job, where I need to use the Arduino and the Simulink together. I need to create a mesh PWM on Simulink to control a dc motor, but Im not getting to do one of examples that there is in folder of the Arduino Target Simulink.

I have done all the install process of the ardunio library on simulink, but when I try run the model "demo_arduino_blink" doesn't happen nothing with simulink or the Arduino. The Led on the board doesn't blink.
When I run the model "demo_arduino_pil" its execution happens normaly.
I have tested the arduino hardware using the Ardunio Environmental 0021 (software) and all the tests were ok.
I have followed all the steps to configurate the Arduino library for Simulink and I think that everything is ok.
I`m using the Arduino Duemilanove 328P, the Matlab 2010a and Windows 7.
I already used the "mex sfunar_digitalOutput.c" to fix a problem that happened with windows 7. This command is used to convert from the 64 bits to 32 bits for Matlab 2010a.

Please, I have a date to delivery my job and I haven't more time. I need help.

Thank you.

What do you see in the command window when you build and download the blink model? Are there any errors or do you get the message to say that it downloaded successfully?

Do you see the Tx/Rx LEDs flashing during the download (indicating that the serial connection is active)?

Hi David

Thank you for your reply.
Then, when I run this demo_arduino_blink, the led's TX/RX don't flash. The comunication doesn't work.
I don't know what happened. On the window command don't appear nothing, only a bip (warning sound of windows 7).

One more time thank you.

led's TX/RX don't flash

These are controlled by the USB drivers in the PC not by the arduino.

from MATLAB, try

edit arduino.runAvrDude

put a break point in this file and check that it really does get to the point where it's trying to download. If you look for the "system" command in this file, that's where it calls out to invoke avrdude from the Windows prompt. Does it get that far? What happens if you run exactly the same avrdude command (i.e. from the same folder with the same arguments) but outside of MATLAB?

Dave

Hi Dave,

Then I put the command on the MATLAB and I executed the "demo_arduino_blink". I put the break point on the download line and I waited for see what could happened, but when I ran the demo, appeared this message:

edit arduino.runAvrDude
demo_arduino_blink
Warning: Connectivity configuration "Arduino connectivity config using serial" has already been registered. Check that there are not multiple sl_customization.m files on the MATLAB path that specify the same connectivity configuration name. , this custom registration is not loaded.

How can I fix this error?

Best Regards...

Alex

Dave,

The arduino.runAvrDude doesn't running. Why? It shouldn't run when I execute the demo?

Dave, I set the "Arduino Target Simulink" path on Matlab, executing this commands:

cd c:\ARDUINO_TARGET
addpath(fullfile(pwd,'arduino'),fullfile(pwd,'blocks'),fullfile(pwd,'demos'))
savepath
sl_refresh_customizations
arduino.Prefs.setArduinoPath('c:\Program Files\arduino\arduino-0018')
arduino.Prefs.setMcu('atmega328p')
comPorts=arduino.Prefs.searchForComPort;
arduino.Prefs.setComPort(comPorts{1});

Is correct? I don't Know why the demos don't run!!!

Thank you

Taking one step at a time. About this warning:

Warning: Connectivity configuration "Arduino connectivity config using serial" has already been registered. Check that there are not multiple sl_customization.m files on the MATLAB path that specify the same connectivity configuration name. , this custom registration is not loaded.

It looks like you may have more than one copy of the files on your MATLAB path. From the MATLAB command window, try

which -all arduino/sl_customization.m

to find out all the instances of this file on your path.

Hi Dave.

I fix the problem with your help and the problem and communication is running.

Thank you very much.

Now I'm trying communicate a PID control for a motor on the simulink and send it by serial for arduino board.
But when I try send the data, happens a error with this message: The serial send block doesn't can use in time continuous.
If I try to corrected it trought the " Simulation --> Simulation Parameters--> Real time --> Interface in Simulink, appear other error saying that I can't work with the function of the PID controler without be on time continuous in Simulink.

What can I do to fix the problem?

Thank for attention.

Hello Im trying to add (Arduino Uno) target in Simulink:

arduino.Prefs.setArduinoPath('c:\Program Files\arduino**arduino-0021'**)
I setup everything but the problem is when Im trying to build demo_arduino_blink this error appear
The call to arduino_make_rtw_hook, during the after_make hook generated the following error:
Download failed. Check your serial connection and and run the command arduino.Prefs.getMcu to check you have specified the correct MCU.
The build process will terminate as a result.

Download failed. Check your serial connection and and run the command arduino.Prefs.getMcu to check you have specified the correct MCU.
when Im checking Mcu:

arduino.Prefs.getMcu

ans =

atmega328p

when Im checking the COM this is a result:
arduino.Prefs.setComPort('COM3');

arduino.Prefs.searchForComPort

ans =

''
???

Im using MacBook Pro Windows7 64bits
If anyone knows whats a problem please help me I have to finish this project for my graduation
THANX

Have you got your PID control to work with simulink and arduino??