error generating code using blockset

Create new topics, add your comment, remark, bugs...
Posts: 1
Joined: Wed Apr 06, 2011 11:49 am

error generating code using blockset

Postby chetan » Wed Apr 20, 2011 11:15 am

dear sir ,
i am learning how to work on dspic33f for my project on vector control. so in the beginning i am using ur blockset to generate small porgrams for -
1) a/d converter (this program generates the mplab file without error)
2) sinusoidal pwm generator(this program generates a code which at the end gives a matlab error and the mplab file made cannot be built)

the following error report comes at the matlab command window :-

pwm1_main.o(.text+0x4):C:\Documents and Settings\Tapesh\My Documents\MATLAB\pwm1_dspic\sources\pwm1_main.c: undefined reference to `pwm1_SetEventsForThisBaseStep'
c:\program files\microchip\mplabc30\v3.25\bin\bin\..\bin/pic30-coff-ld.exe: link errors found, deleting executable `..\../pwm1.cof'
gmake: *** [..\../pwm1.cof] Error 255
### Real-Time Workshop build procedure for model: 'pwm1' aborted due to an error.

please look into and tell me if i am making any mistake in the simulink blockset .

i am sending the simulink model for a/d convertor (working),pwm1(not working) and the command window text after compilation.

thanking you
yours faithfully

matlab command window.txt
this is the command window text
(12.92 KiB) Downloaded 121 times
this is not working
(30.86 KiB) Downloaded 117 times
this model is working
(30.17 KiB) Downloaded 131 times

Posts: 5
Joined: Mon Jan 03, 2011 3:57 pm

Re: error generating code using blockset

Postby konsgn » Thu May 12, 2011 4:46 pm

I don't think you can use the Sumulink embedded PWM generator at such a high carrier frequency, especially since your timestep is set to 1ms. If you want to generate a PWM output from the PIC microcontroller look into using "Output Compare" and set the module to mode 5 where you set the up-time and the period of the OC block. I have attached a sample program that can be used to control a servo for a PIC32.

PS: Note that in the model, The input of AN0 is a Signed Integer which adds or subtracts from the servo neutral constant (1.5ms).
PPS: The servo neutral value is generated by multiplying the OC2max constant(which represents the value of 20ms) by .075 to get a constant that represents the neutral value of 1.5ms.
PPPS: If you get into using multiple PWM outputs, you will find that there can only be one OC block which you can specify multiple outputs by setting the output channels to something like the following: [1 2 3]
Working model to control servo.
(33.03 KiB) Downloaded 126 times

Return to “General Remark and Questions”

Who is online

Users browsing this forum: No registered users and 1 guest