Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
Example using motor PWM with DSPIC30F2010 |
Posted: Mon Dec 23, 2013 8:41 pm |
|
|
Example using motor PWM with DSPIC30F2010:
Just for sharing with people who needs it:
It´s a little confuse understanding how motor pwm works, but, for example, it is possible to adjust it for several configurations.
In the example below I set it for generating two different PWM with inverted outputs. The other 4 PWM pins of DSPIC30F2010 remain disabled(can be used for others things or io ports).
Code: | //MOTOR PWM(using example)
setup_timer1(TMR_INTERNAL,3333); //setups PWM frequency
setup_motor_pwm(1,MPWM_FREE_RUN,1,0,255); //setups PWM
//
set_motor_unit(1,1,MPWM_ENABLE_L,1,1); //setups first PWM
set_motor_pwm_duty(1,1,20); //Adjusts first pwm duty
set_motor_unit(1,2,MPWM_ENABLE_L,1,1); //setups second PWM
set_motor_pwm_duty(1,2,100); //Adjusts second pwm duty |
Good luck folks!! ;)
Have a very merry Xmas *<:o) _________________ Eduardo Guilherme Brandt |
|