CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with dsPIC30f4011 in complementary mode

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
JONNATHAN_R



Joined: 14 Jul 2014
Posts: 3

View user's profile Send private message

Problem with dsPIC30f4011 in complementary mode
PostPosted: Mon Jul 14, 2014 7:01 pm     Reply with quote

I am doing a position control system using complementary PWM mode, however I have had multiple problems to configure the additional module, the last configuration I have is this:

Configuration:
Code:
set_motor_unit(pwm,unit,options, active_deadtime, inactive_deadtime);
set_motor_unit(1,1,MPWM_ENABLE,0,0); //
setup_motor_pwm(pwm,options, timebase);
setup_motor_pwm(1,MPWM_FREE_RUN,999);

Code:
set_motor_pmw_duty(pwm,group,time);
set_motor_pwm_duty(1,1,q);

q = cycle is useful here is where I should define whether or PWM1 PWM2 mode is activated complementary.

The compiler does not throw me any error. The code is extensive but the only part that fails is the complementary PWM mode. I've been working on this week,

I appreciate your help...
Mad Mad
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Tue Jul 15, 2014 8:25 am     Reply with quote

What compiler version?.
You talk about 'q' affecting the complementary mode, in your posted bits. It doesn't.

Complementary mode is selected in the set_motor_unit command, and is the default. The pin pair is then activated by the set_motor_unit command.

As a comment, you ought to think again about having the dead time as zero. Unless the switch 'off' time of each half circuit is guaranteed to be faster than the switch 'on' time, you need some deadtime.

Further comment, the duty cycle numbers are 2* the timebase numbers (CPU clock versus instruction clock). This is why the timebase register is 15bit, and the period register 16bit.

You are using the simplified (3 variable) version of setup_motor_pwm. I'd always explicitly set the prescaler, otherwise it may not give what you expect.

However I suspect the one that is causing your problems, may be OVDCON.
Add a word define to access this:
#word OVDCON=getenv("SFR:OVDCON")
and make sure you have the bits set to use the PWM.
OVDCON=0x300; //For your two bits - should be the default.
Some older compiler versions did not set this correctly.

Make sure you have programmed the polarity you want for the bits and how you want them to start set, in the fuses.

Get the manual 70062E from the MicroChip site.
JONNATHAN_R



Joined: 14 Jul 2014
Posts: 3

View user's profile Send private message

PostPosted: Tue Jul 15, 2014 9:41 am     Reply with quote

Dear thanks for your answer,

I am using ccs xc16, I have done the following:
Postcaler leave 4 prescaler and, add 200 ns timeout according to calculations using crystal 20 MHz.

I have read the Manual 70062E.

Do not know about
Quote:
#word OVDCON=getenv("SFR:OVDCON")
and make sure you have the bits set to use the PWM.
OVDCON=0x300; //For your two bits - should be the default.

I can not load records directly xc16.

Appreciate your help, and then the new configuration.
Code:

setup_motor_pwm(1,MPWM_FREE_RUN,4,4,999);
set_motor_unit(1,1,MPWM_ENABLE,200,200);
set_motor_pwm_duty(1,0,q);

where q = the useful cycle, I have not had much luck.
Thanks.
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Jul 15, 2014 6:23 pm     Reply with quote

CCS is NOT xc16!. This is not the xc16 forum.
You need to got to the microchip xc16 forum.
http://www.microchip.com/forums/f250.aspx
_________________
Google and Forum Search are some of your best tools!!!!
JONNATHAN_R



Joined: 14 Jul 2014
Posts: 3

View user's profile Send private message

PostPosted: Tue Jul 15, 2014 6:29 pm     Reply with quote

greeting

You're right I can not program in CCS xc16, I am using MPLABXC16, to which I refer is that I take as a guide the CCS manual programming.

Thank you
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Wed Jul 16, 2014 7:37 am     Reply with quote

Microchip XC16, is not CCS C. All the commands are different, which is why they won't work for you...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group