• AVR Freaks

Hot!MPLAB® Device Blocks for Simulink® - PWM problem

Author
Hanss8
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2020/04/16 13:57:21
  • Location: 0
  • Status: offline
2020/05/26 11:42:39 (permalink)
0

MPLAB® Device Blocks for Simulink® - PWM problem

Hello,
i am using MPLAB® Device Blocks for Simulink with dspic33ep512mu810. I want to send PWM signal to arduino H-bridge L9110s to control DC motor (https://www.dfrobot.com/product-1437.html). I multiplied required duty cycle with variable PWM2Max, but motor did not start with duty cycle lower than 0.5.
I will be grateful, if somebody could help me with this.
Thank you very much,
 
Hans

Attached Image(s)

#1
Lubin
Moderator
  • Total Posts : 427
  • Reward points : 5
  • Joined: 2007/03/31 07:38:15
  • Location: Bayonne, France
  • Status: offline
Re: MPLAB® Device Blocks for Simulink® - PWM problem 2020/05/26 11:54:02 (permalink)
0
Hans, you might show datatypes on your model. There is an option to show datatype on simulink lines.
Also, you might show blocks rate using the color (there is an option to color blocks depending on their rate).
 
If the constant 0.5 is set as an integer, it is likely to be rounded to 0.
Also, such constant has typically a sampling time of 'inf' (pink color with simulink standard color; FYI the PWM duty-tycle setting is set once at startup in such case.)
 
Lubin
#2
Hanss8
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2020/04/16 13:57:21
  • Location: 0
  • Status: offline
Re: MPLAB® Device Blocks for Simulink® - PWM problem 2020/05/26 17:12:00 (permalink)
0
Thank you for quick answer Lubin.
Here is screenshot with informations about data types and timing. So should I change sampling time or data type?
The PWM block requires unit16 data, am i right?
I would be thankful for any information.
Thanks,
 
Jan
 

Attached Image(s)

#3
Lubin
Moderator
  • Total Posts : 427
  • Reward points : 5
  • Joined: 2007/03/31 07:38:15
  • Location: Bayonne, France
  • Status: offline
Re: MPLAB® Device Blocks for Simulink® - PWM problem 2020/05/27 02:05:59 (permalink)
0
Hi Jan,
 
Remove the gain, connect directly the constant to the PWM block. Set the constant value to PWMmax/2.
 
0.5 defined as an uint16 will take value 0 or 1 depending on the rounding mode selected in the block.
 
Check simulink help for fixed point. Using the simulation feature is helpful to fully understand datatype casting etc...
 
Lubin
#4
Hanss8
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2020/04/16 13:57:21
  • Location: 0
  • Status: offline
Re: MPLAB® Device Blocks for Simulink® - PWM problem 2020/05/29 07:09:09 (permalink)
0
Thank you very much Lubin.
#5
Jump to:
© 2020 APG vNext Commercial Version 4.5