• AVR Freaks

PWM Microchip Blocks in Simulink - dsPIC33EP512MU810

Author
lato0525
New Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2017/01/30 08:43:04
  • Location: 0
  • Status: offline
2017/02/13 01:43:10 (permalink)
0

PWM Microchip Blocks in Simulink - dsPIC33EP512MU810

Hi,
 
I am using the dsPIC33EP512MU810 processor, along with MPLAB x IDE v3.50 and XC 16.
 
I am using Simulink Microchip block in order to generate a PWM. I have the following simulink model with the configurations showed in the images. The blocks in the bottom are just to check if the c code is being generated by toggling some IO-pins where I connected some leds.
 
My problem is that I am not generating any PWM when I am measuring with my osciloscope. As I am new with this feature of Simulink-Microchip I don´t know if I have configurated wrong. Please tell me where do I have my error, or how I should configurate it if for example I want a PWM with a frequency of 1000 Hz and a duty cycle of 0.5.
 
Leds are working!
 
Thanks

Attached Image(s)

#1
Constantin Cristi
New Member
  • Total Posts : 9
  • Reward points : 0
  • Joined: 2016/08/07 22:39:53
  • Location: 0
  • Status: offline
Re: PWM Microchip Blocks in Simulink - dsPIC33EP512MU810 2017/02/13 03:09:38 (permalink)
1 (1)
Hi,
 
In the "Examples" folder within the Blockset, there are many interesting demos. If you are new with the Blockset, you can always start with examples provided. The model I find very useful for you is called "Microstick_II_PlusDevBoard_33EP128MC202_ExternalMode_R2015b". Please make sure that the Master block is properly configured (I see that your MCU runs at 3.69 MIPS, which seems a bit peculiar). 
Good luck! Smile
post edited by Constantin Cristi - 2017/02/13 03:12:37
#2
Lubin
Moderator
  • Total Posts : 442
  • Reward points : 5
  • Joined: 2007/03/31 07:38:15
  • Location: Bayonne, France
  • Status: offline
Re: PWM Microchip Blocks in Simulink - dsPIC33EP512MU810 2017/02/13 04:30:53 (permalink)
4 (2)
Hi,
 
Blocks input are integers and do not represent physical values.
In your case, the PWM input block must be scaled. 
The blockset set a Variable PWM1max in your Matlab workspace.
PWM1max value represent the max duty cycle (here 0.0001s).
 
Multiply your physical value (in s) with PWM1max, connect the result (unsigned integer) to your PWM block.
As Cristi mention, you could find others examples, either on this forum, of within the blockset. (type picInfo and follow links to copy examples in your working folder)
 
Lubin
 
 
#3
Jump to:
© 2020 APG vNext Commercial Version 4.5