Home     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science

### Author Topic: [HELP] Closed loop PIC PWM circuit  (Read 2907 times)

0 Members and 1 Guest are viewing this topic.

#### Nhilar

• Newbie
• Posts: 4
##### [HELP] Closed loop PIC PWM circuit
« on: January 05, 2014, 09:05:06 AM »
http://www.pcbheaven.com/circuitpages/Closed_Loop_Fan_Controller/

I am trying to build this circuit for use with this fan:

http://www.newark.com/sanyo-denki-sanace-fans/9sg1212p1g01/axial-fan-120mm-12vdc-4a/dp/96M1757

I build the circuit as described and it "sort-of" works.

It controls only the low speed of the fan, it will not max the fan speed out. (maybe only 10%)

So I scope the POT input to the ADC of the PIC, yup get a nice 0-5 volt input.

Check the pwm output to the fan (brown wire)...0-5v range only provides a small variation in PWM output (thus explaining why the fan speed variance is small)

Check the yellow tach signal going in, it corresponds with the what is being commanded...so within the small range of what is commanded, it seems to work.

I change the 5k pot to a 1M got and the range is expanded a little....

Any ideas?

I used the basic HEX file provided.

Nhilar

#### kam

• Hero Member
• Posts: 1849
##### Re: [HELP] Closed loop PIC PWM circuit
« Reply #1 on: January 05, 2014, 11:02:37 AM »
First thing that comes into my mind is the pulses per revolutions feedback. Since you have a scope, do this experiment: Let the fan run at full speed (6krpm) by floating the PWM wire. Let the feedback wire connected to the circuit and probe the feedback. Tell me the duty cycle and the frequency that you get from this wire. Maybe upload a screenshot as well.
The circuit works only for typical PC fans with 2 pulses per revolution.

#### Nhilar

• Newbie
• Posts: 4
##### Re: [HELP] Closed loop PIC PWM circuit
« Reply #2 on: January 05, 2014, 15:49:34 PM »
Will do, I'll see if I can take some pictures as-well.

All I really need is a simple PWM driver, but I can't seem to get the code correct.

Just the pot that sets the duty cycle of a 16khz signal and that output to the fan, no feedback required....

Much simpler than the example here..is there a HEX file for that around?

-Nhilar

#### Nhilar

• Newbie
• Posts: 4
##### Re: [HELP] Closed loop PIC PWM circuit
« Reply #3 on: January 05, 2014, 23:32:22 PM »
Okay, update

Picture seems difficult to take with my digital camera and the velman hand scope, the trace does not want to show up.

Anyway,

At full bore the fan tack is reading 51 kHz..

The data sheet however says it requires a 16 kHz pwm signal.

It may be my scope but the actual; duty cycle of the tach seems unchanging.

It seems the max of the pic is 21 kHz....

So I do not what is going on here.

-Nhilar

#### kam

• Hero Member
• Posts: 1849
##### Re: [HELP] Closed loop PIC PWM circuit
« Reply #4 on: January 06, 2014, 00:25:06 AM »
Do not confuse the tach signal and the PWM signal. The 16KHz is not that important to be exactly 16KHz. The problem seems to be with the tacho signal. Lets see what's going on here.
You mention 51KHz pulses at 6000rpm. This means 51.000 pulses per 6000.rpm or 8,5 pulses per revolution. I'll take a guess and say that it is 8 pulses per revolution, which results in 48KHz at 6000 rpm. The circuit that i made is designed for PC fans with 2 revolutions per cycle, so it will always run 4 times slower thinking that it runs at 6Krpm. Normally it would run a max 1500rpm, but it seems that the 4x pulses overflow the internal counter that i use for the rpm count.

Your simplest solution is to divide by 4 the incoming pulses, either by an external 4x divider or by software.

Its a long time that i made this circuit. I run through the code and found out this:
bsf T1CON,T1CKPS1
bcf T1CON,T1CKPS0
These lines sets the Timer1 divider 1:4. I think that if you set the divider to 1:1 it will work for your fan. So change to:
bcf T1CON,T1CKPS1
bcf T1CON,T1CKPS0
OR it should be 1:8 - so change to
bsf T1CON,T1CKPS1
bsf T1CON,T1CKPS0

Try both solutions, one might work for you.

#### Nhilar

• Newbie
• Posts: 4
##### Re: [HELP] Closed loop PIC PWM circuit
« Reply #5 on: January 06, 2014, 05:20:38 AM »
So this seems to work the best, I am getting about 5% to 60% now.

bcf T1CON,T1CKPS1
bcf T1CON,T1CKPS0

Watching the tac output of these 4A 6000 rpm fans, I don't think this will ever work right. the signal as it gets faster, gets very ugly.

Did you ever write code that took analog input 0-5v and output pwm 0-100%? I think for my application it is the only thing that would work.. if you have done so for the pic12F615 posting the asm would benefit me as well as other curios minds who are having difficulty decoding asm.

-Nhilar

#### kam

• Hero Member
• Posts: 1849
##### Re: [HELP] Closed loop PIC PWM circuit
« Reply #6 on: January 06, 2014, 10:20:07 AM »

#### scarica220

• Newbie
• Posts: 2
##### Re: [HELP] Closed loop PIC PWM circuit
« Reply #7 on: March 03, 2014, 18:31:47 PM »
Hi Kam

TWO questions about file.asm " Closed Loop Pic PWM circuit"

First.
In the source.asm the register ANSEL is setting 0X00, that, Fosc/2 where Fosc it 8Mhz
ADC Clock period is outside of recommended range. 250ns "view table 9-1 page 69 Data sheet.

I don't think this will ever work right. Correct setting for ANSEL ADCS<2:0> 101 Fosc/16 or 010 Fosc/32.

Second.
The relation for compute RPM in this code is 15ex6/N(TMR1) "typical PC fans with 2 pulses per revolution" why the source works only TMR1H and ADDRESH registers?  ADC 8 bit?

sorry for my english

Scarica220