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

Motor PWM (micro reset in 100V)

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



Joined: 21 Aug 2014
Posts: 15

View user's profile Send private message

Motor PWM (micro reset in 100V)
PostPosted: Sun Aug 23, 2015 12:13 am     Reply with quote

Hello guys.
My micro is dsPIC30F4011 and I'm having a problem with my micro.
I'm using the micro to control an IM (Induction Motor), and I'm just using MPWM pins of the micro.
MPWM outputs are okay at the start, but when I increase the DC bus voltage to 110V my micro shut down (I have a LED on the micro and it turns off).
At this situation (DC bus = 110v) when I try to reset the micro by making MCLR pin low, MPWM output come back for a second and micro shut down again, but when I reduce the voltage to 80V I can reset my micro and output come back.
I have another problem too which I think it's connected to the last problem.
When I program the micro with my programmer (PICKIT3) and my programmer is connected to the circuit everything is fine, but when I disconnect the programmer and I switch off the microcontroller power supply, my micro doesn't start working on the power supply switch on, and I should reset the micro after switching on the supply to make my micro run.
But I don't have this problem when my programmer is connected and my micro works on the power supply switch on.
Here is my code.
Code:

#include <30F4011.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOBROWNOUT
#FUSES PWMPIN
#FUSES LPOL_HIGH
#FUSES HPOL_HIGH


#device ICSP=1
#use delay(crystal=8MHz)

#DEFINE PHASE_SHIFT_120 0X5555
#DEFINE PHASE_SHIFT_240 0XAAAA


int SineTable[512]={99, 100, 101, 103, 104, 105, 106, 107, 109, 110, 111, 112, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 127, 128, 129, 130, 131, 132, 133, 135, 136, 137, 138, 139, 140, 141, 142, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 165, 166, 167, 168, 169, 170, 171, 172, 172, 173, 174, 175, 176, 176, 177, 178, 179, 179, 180, 181, 181, 182, 183, 183, 184, 185, 185, 186, 186, 187, 187, 188, 188, 189, 190, 190, 190, 191, 191, 192, 192, 193, 193, 193, 194, 194, 194, 195, 195, 195, 196, 196, 196, 196, 197, 197, 197, 197, 197, 197, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 197, 197, 197, 197, 197, 197, 196, 196, 196, 196, 195, 195, 195, 194, 194, 194, 193, 193, 193, 192, 192, 191, 191, 190, 190, 190, 189, 188, 188, 187, 187, 186, 186, 185, 185, 184, 183, 183, 182, 181, 181, 180, 179, 179, 178, 177, 176, 176, 175, 174, 173, 172, 172, 171, 170, 169, 168, 167, 166, 165, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 142, 141, 140, 139, 138, 137, 136, 135, 133, 132, 131, 130, 129, 128, 127, 125, 124, 123, 122, 121, 120, 118, 117, 116, 115, 114, 112, 111, 110, 109, 107, 106, 105, 104, 103, 101, 100, 99, 98, 97, 95, 94, 93, 92, 91, 89, 88, 87, 86, 84, 83, 82, 81, 80, 78, 77, 76, 75, 74, 73, 71, 70, 69, 68, 67, 66, 65, 63, 62, 61, 60, 59, 58, 57, 56, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 33, 32, 31, 30, 29, 28, 27, 26, 26, 25, 24, 23, 22, 22, 21, 20, 19, 19, 18, 17, 17, 16, 15, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 8, 8, 8, 7, 7, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 15, 16, 17, 17, 18, 19, 19, 20, 21, 22, 22, 23, 24, 25, 26, 26, 27, 28, 29, 30, 31, 32, 33, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 86, 87, 88, 89, 91, 92, 93, 94, 95, 97, 98};

int16 i = 0;
int16 Phase1,Phase2,Phase3,Temp1,Temp2,Temp3;

#INT_PWM1
void  pwm1_isr(void)
{
if (i>=0XFFFF)
   i=0;

 i += 328;
}

void main()
{   

         
 
   setup_motor_pwm(1,MPWM_FREE_RUN,1,1,99);
   
   set_motor_unit(1,1,MPWM_ENABLE,4,4);
   set_motor_unit(1,2,MPWM_ENABLE,4,4);
   set_motor_unit(1,3,MPWM_ENABLE,4,4);


   
   enable_interrupts(INT_PWM1);
      enable_interrupts(INTR_GLOBAL); 

   while(TRUE)
   {
         Temp1 = i;
         Temp2 = i + PHASE_SHIFT_120;
         Temp3 = i + PHASE_SHIFT_240;
         
         Phase1 = (Temp1)>>7;
         Phase2 = (Temp2)>>7;
         Phase3 = (Temp3)>>7;
         
      
         set_motor_pwm_duty(1,1,SineTable[Phase1]);
         set_motor_pwm_duty(1,2,SineTable[Phase2]);
         set_motor_pwm_duty(1,3,SineTable[Phase3]);
         

      //TODO: User Code
   }

}

My circuit is very simple and I'm just using the MPWM pins of the micro for a three phase H-Bridge, my switch driver is HCPL316J and my switches are IRFP460.
Any one know what is the problem?
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 5:32 am     Reply with quote

Electrical noise.

With anything involving switching into inductors (motors are both inductors and also generators), your supply/switching circuit has to contain the circuitry to handle both the high voltages when the drive switches off, and the massive changes in the actual load on the rail, with the passage of time.
It has to have a path somewhere to handle/control these or they _will_ find a route back through the drive pins.

Almost certainly some of the former is being dumped into the supply rail. probably through the MPWM pins and the internal protection diodes. The extra smoothing & ground present when the programmer is present is helping a little, but the real solution is to handle these yourself before they reach the processor.
The currents and voltages will rise as the supply rises, so the problem gets worse.
af19



Joined: 21 Aug 2014
Posts: 15

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 10:07 am     Reply with quote

Ttelmah wrote:
Electrical noise.

With anything involving switching into inductors (motors are both inductors and also generators), your supply/switching circuit has to contain the circuitry to handle both the high voltages when the drive switches off, and the massive changes in the actual load on the rail, with the passage of time.
It has to have a path somewhere to handle/control these or they _will_ find a route back through the drive pins.

Almost certainly some of the former is being dumped into the supply rail. probably through the MPWM pins and the internal protection diodes. The extra smoothing & ground present when the programmer is present is helping a little, but the real solution is to handle these yourself before they reach the processor.
The currents and voltages will rise as the supply rises, so the problem gets worse.

Thanks for the reply.
I created a 1hz blink project with above fuse bits and I still have the second problem (micro doesn't start when programmer is not connected and I switch on the microcontroller's power supply)
what do you think is the problem?
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 10:20 am     Reply with quote

What circuit do you have on the MCLR pin?.
af19



Joined: 21 Aug 2014
Posts: 15

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 10:39 am     Reply with quote

Ttelmah wrote:
What circuit do you have on the MCLR pin?.

I just have a 10k pull up resistor.
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 10:43 am     Reply with quote

Double check your ground connection. The classic 'reasons' for this, are 1: MCLR. 2: Power. 3: Still compiling in DEBUG mode.

Remember if you are compiling through MPLAB, this defaults to selecting DEBUG.
af19



Joined: 21 Aug 2014
Posts: 15

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 10:58 am     Reply with quote

Ttelmah wrote:
Double check your ground connection. The classic 'reasons' for this, are 1: MCLR. 2: Power. 3: Still compiling in DEBUG mode.

Remember if you are compiling through MPLAB, this defaults to selecting DEBUG.

I tested programming in release mode and my second problem solved!! Lol
But now I have another problem, in release mode for the first time after programming everything works fine and I have a good PWM. After switching off and on the power supply I get PWM but it has changed and is out of shape. It should be a SPWM but the output have changed and it just doesn't look like the last output and it has changed a lot!!
PWM output gets okay when I re-program the micro but it goes bad after another switching on and off (even when the programmer is connected)!!
This problem is making me crazy!
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 12:24 pm     Reply with quote

A 10k pullup is a little on the large side in a noisy environment. 4.7k would provide a "stronger" pullup that noise would have a tougher time pulling down.

Do you have the brownout fuse enabled? If so, what specific value? Can you set it to a lower value?
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 1:55 pm     Reply with quote

Unfortunately, you have to be careful, if using MCLR for ICD. Many on the debug interfaces can't pull down a resistor below 10K (some even recommend 22K!....).
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 2:08 pm     Reply with quote

True. I use only the CCS ICDs (ICD-U64 and the load-n-go), and I used to only use a 47k /MCLR pullup on all PIC projects until I had issues with a board that controls a welder resetting during a weld. I dropped that resistor to a 22k, then to a 10k, then finally settled on a 4.7k. That was the only value that wouldn't allow the processor to spontaneously reset. Happily, both ICDs can still program it without issue.

It should also be said that my /MCLR circuitry is very minimalistic: just the pullup resistor.
af19



Joined: 21 Aug 2014
Posts: 15

View user's profile Send private message

PostPosted: Mon Aug 24, 2015 11:13 pm     Reply with quote

newguy wrote:
A 10k pullup is a little on the large side in a noisy environment. 4.7k would provide a "stronger" pullup that noise would have a tougher time pulling down.

Do you have the brownout fuse enabled? If so, what specific value? Can you set it to a lower value?

I set my pull up to 3.3K and now I don't have resets any more!! Smile
But my second problem still exists. When I'm in debug mode every time I power up the circuit I should reset my micro to get started, and when I'm in release mode for the first time after programming I have desired output. But after the first switching on and off the power supply, my PWMs shape gets bad and I should re-program the micro to make the PWM work good. (Even reset the micro doesn't solve PWM).
What do you think is causing this problem?
af19



Joined: 21 Aug 2014
Posts: 15

View user's profile Send private message

PostPosted: Tue Aug 25, 2015 12:00 am     Reply with quote

I found something which I think it is causing the bad PWM output.
I erased
Code:
 #FUSES CKSFSM
and my PWM output got bad, so I think it's the part of the code which is making my PWM shape to be okay.
But I don't know why in release mode after the first switch on and off the PWM get bad, and I should reprogram the chip to make the output good.
What is your idea?
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Tue Aug 25, 2015 12:53 am     Reply with quote

I go back to my original reply:

"Electrical noise."

You have got major noise problems. CKSFSM only has an effect, if the master processor oscillator, is seen as being erratic. It stands for 'Clock Fail Safe Monitoring'. If the master oscillator misses pulses or stops, the processor switches to the internal oscillator to keep running.

The same applies to your MCLR problem. Sounds here like RF pick-up on the tracks to the ICD header.

Realistically you need to look carefully at the layout of your board (ground plane etc.), how traces (and sections of the plane) carrying high currents are routed, the decoupling round the chips, etc. etc..
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