| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| asmboy 
 
 
 Joined: 20 Nov 2007
 Posts: 2128
 Location: albany ny
 
 
			      
 
 | 
			
				| pic hardware may vary - the same  code  - different results |  
				|  Posted: Wed Sep 12, 2012 11:49 am |   |  
				| 
 |  
				| I have a code module that does low side PWM, effective "buck" modulation, of  a 36v load, using a fast 10a N channel mosfet, with a gate capacitance of about 400pf. 
 The code  has been in use for several years now using a 16F886 @ 8 MHZ on internal clock.
 
 So far so good.
 
 I recently re-purposed it to drive the same load but using a 16HV616  in a 'mini' version of the product.
 
 In the original code, run on the 886, when I wanted to zero out the load I would execute:
 
 and after rechecking the old design, there is no output voltage.
 
 The 16HV616 version had an odd residual 30 mv when shut down,
 and on closer inspection the buck storage inductor was being tickled with a ~ 130 ns pulse, and producing just a tiny discontinuous ringing voltage - in spite of the 0 setting.
 
 The cure was simple.
 
 Instead of     set_pwm1_duty(0);
 
 I switched to   setup_ccp1(CCP_OFF);
 
 Which cures it, but the CCP hardware in the HV616 seems to switch on for 1 cycle  of the master Fosc clock (1/4 of a full inst cycle) - and then crisply back off, but not in the 886.
 
 Be it  a genuine silicon error or  not- I know the ONLY way I am going to
 shut off the CCP PWM channel going forward.
 
 Comments ??
 |  | 
	
		|  | 
	
		| temtronic 
 
 
 Joined: 01 Jul 2010
 Posts: 9588
 Location: Greensville,Ontario
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Sep 12, 2012 2:11 pm |   |  
				| 
 |  
				| my comments.. 1) I wonder why you changed processors (and PCBs)? You had a great working unit only to spend $$time in R&D to make a new board that doesn't do the job. Sigh...been there done that.
 I find it very very hard to justify 'jumping ship', making a 'mini' when you have a tried and true product.
 Will you save bags of $$$ after factoring in R&D,headaches,loss sleep,etc.?
 
 2) changing silicon is a risky prospect, as you've found out. You've found one 'gotcha'...think they'll be others ?
 
 curious like my cat.
 jay
 |  | 
	
		|  | 
	
		| asmboy 
 
 
 Joined: 20 Nov 2007
 Posts: 2128
 Location: albany ny
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Wed Sep 12, 2012 4:54 pm |   |  
				| 
 |  
				|  	  | Quote: |  	  | I wonder why you changed processors (and PCBs)?
 
 | 
 
 The original 886 version supported TWO PWM modulated devices, numerous solenoid valves  and analog monitoring circuitry - all under pic control.
 
 A new simple variant of the product was required that had to be smaller and cheaper to build. Closed loop feedback was added for speed control, and the original design's other features made for a larger PCB too.
 
 The CUSTOMER for the design did not need or want all that stuff in  the 'mini' product and was willing to source the $$ to do a new one. What is not to like there ??
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Sep 13, 2012 12:53 am |   |  
				| 
 |  
				| Old story. If you are using more than 8bits on the PWM at any point, then 'set_pwm1_duty(0)' is _not_ guaranteed to make the output zero. You need 'set_pwm1_duty(0L)'. The effect will depend on what is in the two low bits of the PWM. That it worked on the old chip, was 'luck'.
 Sending set_pwm1_duty(0), only updates the high eight bits of the PWM registers. If there is a value in the low two bits you will still get an output...
 
 Best Wishes
 |  | 
	
		|  | 
	
		| FvM 
 
 
 Joined: 27 Aug 2008
 Posts: 2337
 Location: Germany
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Sep 13, 2012 9:20 am |   |  
				| 
 |  
				| Unfortunately the specific behaviour of set_pwm_duty() isn't described in the CCS C online help and wrongly described (MSB instead of LSB) in the pdf manual. 
 
  	  | Quote: |  	  | Writes the 10-bit value to the PWM to set the duty. An 8-bit value may be used if the most significant bits are not required. | 
 
 IMHO it's a strange way of function overload, apart from missing or incorrect documentation.
 |  | 
	
		|  | 
	
		| asmboy 
 
 
 Joined: 20 Nov 2007
 Posts: 2128
 Location: albany ny
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Thu Sep 13, 2012 9:52 am |   |  
				| 
 |  
				|  	  | Code: |  	  | setup_ccp1(CCP_OFF);
 
 | 
 
 after careful checking - there seems to be no glitching associated
 with this method of shutting off the pwm and is a very simple software trap for a zero argument
 
 
 actually i KNEW not to use an 8bit value though.
 AND
 i should have been more accurate in my posting.
 
 what i listed was simplified ( i thought) for simplicity:
 the ACTUAL code that fails is this:
 
 unsigned int16 pwmval;
 .....
 pwmval=0;
 set_pwm1_duty(pwmval);
 
 
 ie:
 i HAVE been using a long int - that when it becomes ( or is set to )  zero still glitches with the HV616 , but NOT with the 16F886 ( and this morning )
 checked with  18F2620 also
 
 using the HV616 - i can nicely resolve the pulse timing difference between an argument of '1' and zero  as well.
 
 with my timer prescalar i do get the full 10 bit resolution as expected -
 
 only the HV616 seems to do this cute trick
 |  | 
	
		|  | 
	
		| newguy 
 
 
 Joined: 24 Jun 2004
 Posts: 1924
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Sep 13, 2012 10:45 am |   |  
				| 
 |  
				| I hope you've reported this to Microchip (I'm assuming they're unaware of this and that it's not mentioned in that chip's errata already). |  | 
	
		|  | 
	
		| FvM 
 
 
 Joined: 27 Aug 2008
 Posts: 2337
 Location: Germany
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Sep 13, 2012 11:18 pm |   |  
				| 
 |  
				|  	  | Quote: |  	  | using the HV616 - i can nicely resolve the pulse timing difference between an argument of '1' and zero as well. | 
 You say, the glitch is only a fraction of '1' pulse width?
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Sep 14, 2012 4:38 am |   |  
				| 
 |  
				| I think he is seeing exactly one master clock cycle (125nSec at 8MHz). He says: "a ~ 130 ns pulse",
 
 which would correspond exactly.
 This is why I felt it was the low bit of the register not being cleared.
 
 Things that get possible:
 
 This is an ECCP, not a CCP. It's be interesting to try setting it up as a single output ECCP, rather than using the PWM 'compatibility' mode, and see if this changes things.
 
 It's also be interesting to try manually clearing the two low bits of the PWM duty cycle, to see if there is a code problem here.
 
 If it was staying low, rather than high, I'd suspect that the ECCP dead band delay was somehow getting invoked, but this shouldn't affect compatibility mode, and would give a low, not a high pulse. It would though be interesting to see if clearing this register had an effect.
 
 'No output', is explicitly in the data sheet for both the chips:
 
 "The CCP1 pin is set. (Exception: If the PWM duty
 cycle = 0%, the pin will not be set.)".
 
 Best Wishes
 |  | 
	
		|  | 
	
		| asmboy 
 
 
 Joined: 20 Nov 2007
 Posts: 2128
 Location: albany ny
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Fri Sep 14, 2012 12:22 pm |   |  
				| 
 |  
				|  	  | Quote: |  	  | a single output ECCP, rather than using the PWM 'compatibility' mode, and see if this changes things. 
 It's also be interesting to try manually clearing the two low bits of the PWM duty cycle, to see if there is a code problem here.
 
 | 
 
 Excellent ideas.
 I have to be away for a few days but will test these ideas when I am back.
 |  | 
	
		|  | 
	
		| asmboy 
 
 
 Joined: 20 Nov 2007
 Posts: 2128
 Location: albany ny
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Tue Sep 18, 2012 7:00 pm |   |  
				| 
 |  
				| as fate would have it - i am having a devil  of a time trying to configure the HV616 in ECCP compat mode with ONLY channel one output active
 all other possible EPWM pins on the part are of course used for other stuff
 and i am rather paranoid about accidentally activating one of the other EPWM outputs in the extended mode .
 
 so my puzzle is  which CCS setup argument actually commands
 "Single output; P1A modulated; P1B, P1C, P1D assigned as port pins"
 
 
 NONE of the hex equivalent arguments for setup in the device file seem to set the CCP1CON register as i 'think' it ought to be for EPWM :
 
 i get   0x0C   as the argument to use but of course thats what i have been using in standard mode ....
 
 #define CCP_PWM                         0xC
 
 yet  the data sheet seems to be saying it IS selecting EPWM already ..??
 
 the CCP_PWM_PLUS_1 does not seem to do it for the HV616 and since i have functional, deliverable code - my interest in potentially damaging a working prototype with errant programming has been a factor in trying to find out more. .....
 |  | 
	
		|  | 
	
		|  |