11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a...

65
© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 1 11099 THC Implementing an I 2 C™ Thermal Controller on a PIC ® Microcontroller

Transcript of 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a...

Page 1: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 1

11099 THCImplementing an I2C™ Thermal

Controller on a PIC® Microcontroller

Page 2: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 2

Learning ObjectivesLearning Objectives

At the end of this class you should be able to:- Explain 3-wire fan control- Explain how thermal controllers work- Implement an I2C™ Thermal Controller using a

PIC16F886 MicrocontrollerPrerequisites- Analog-to-Digital Converter- Compare/Capture/PWM - Timer 1

Page 3: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 3

AgendaAgenda

Today we will discuss…Thermal Management Basics3-Wire FansThermal ControllersImplementing a Thermal Controller on a PIC16F886

Page 4: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 4

Course BackgroundCourse Background

Page 5: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 5

Thermal ManagementThermal Management

What is thermal management?- Monitoring system temperature- Monitoring fan status- Optimizing the control of temperature through

monitoring- Coordinated cooling- Proportional cooling

Page 6: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 6

Thermal ManagementThermal Management

Why the need for thermal management?- More transistors running at higher speeds = Heat- Reduces system noise- Monitor failures- Lower power consumption

Page 7: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 7

Thermal Management ControllerThermal Management Controller

Requirements:- Fan speed control

2-, 3-, 4-wire fans- Temperature Sensing- Failure Detection

Fan speed detection- Communications

Serial Communications Protocols

Page 8: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 8

3-Wire Fans

Page 9: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 9

33--Wire FansWire Fans

GND

+V

Output

Page 10: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 10

The Third WireThe Third WireTachometer (most common)- 1, 2, or 4 pulses per revolution- Open collector output

Alarm output- Signals when the fan has failed

Page 11: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 11

33--Wire Fan SchematicWire Fan Schematic

+V

Hall Sensor

TACH

GND

A look inside

Page 12: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 12

Low Frequency PWM 10Low Frequency PWM 10--100 Hz100 Hz

+V+V

Page 13: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 13

Low Frequency PWMLow Frequency PWM

Ability to extend operating range down to about 10% of max RPM

Check with manufacturer if you can PWM the 3-Wire fan

Tachometer output is no longer valid

Page 14: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 14

33--Wire SchematicWire Schematic

+V

Hall Sensor

TACH

GND

Page 15: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 15

Tachometer OutputTachometer Output

Tachometer output is invalid

PWM

Ideal

Actual

Page 16: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 16

Creating a Valid OutputCreating a Valid Output

PWM

Ideal

Actual

Pulse stretching can be used to obtain a complete period

Page 17: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 17

33--Wire FansWire Fans

Questions?

Page 18: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 18

Thermal Management Controllers

Page 19: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 19

Example Thermal Controller Example Thermal Controller FunctionsFunctions

Temperature Sensor

Analog

PWMGenerator

Fan SpeedCounter

A/DConverter

VDD

VDD

Thermal Controller

Serial Comm.

SDA

SCLPWM

TACH

VDD

VDD

Page 20: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 20

Fan Temperature Control Fan Temperature Control AlgorithmAlgorithm

Duty Cycle

Temperature

DutyMAX

DutyMIN

TMIN TMAX = TMIN + TRANGE

Page 21: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 21

Thermal Controller FlowchartThermal Controller Flowchart

Get Temperature

Set PWM Duty Cycle

Monitor Fan Speed

Page 22: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 22

Thermal Controller ConfigurationThermal Controller Configuration

Serial CommunicationsControl Registers:

- Temperatures- Duty Cycle- PWM Frequency

Status Registers:- Fan Speed- Temperature Duty Cycle Minimum

Duty Cycle Maximum

Status Register

Fan Speed Reading

Local Temperature Low

Local Temperature High

PWM Frequency

ConfigurationFan Controller Registers

Page 23: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 23

Implementing a ThermalImplementing a ThermalController on a PIC16F886Controller on a PIC16F886

Page 24: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 24

Thermal Controller Thermal Controller ImplementationImplementation

Temperature Sensor

Analog

PWM

TACH

VDD

VDD VDD

VDD

SDA

SCLPWM

Generator

Fan SpeedCounter

A/DConverter

Thermal Controller

Serial Comm.

Page 25: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 25

Thermal Controller Thermal Controller ImplementationImplementation

Temperature Sensor

Analog

VDD

VDD

SDA

SCLCCP

Module

ComparatorModule

A/DConverterModule

PIC16F886

MSSPModule

MCP9700

I/O

TACH

VDD

VDD

Page 26: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 26

PICPIC®® MCU Thermal Controller MCU Thermal Controller FlowchartFlowchart

Get Temperature

Calculate andSet PWM Duty Cycle

Monitor Fan Speed

Page 27: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 27

Temperature MeasurementTemperature Measurement

MCP9700 Temperature SensorAnalog Temperature Sensor

VOUT = TC * TA + V0degC

Where: TA = Ambient TemperatureVOUT = Sensor Output VoltageV0degC = Sensor Output Voltage at 0 degC = 500 mVTC = Temperature Coefficient = 10 mV/degC

MCP9700 Output

0

0.5

1

1.5

2

-50 0 50 100 150

Ambient Temperature (C)

Out

put (

V)

Page 28: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 28

Configuring AnalogConfiguring Analog--toto--Digital Digital ConverterConverter

0000MCP9700Output

ADC

CHS<3:0>

2.5 Volt Reference

GO/DONE

ADONADRESH ADRESL

10

Page 29: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 29

Temperature MeasurementTemperature Measurement

10-Bit Analog-to-Digital ConversionStore to 2 Byte Temperature Register

Get Temperature

Configure ADC

Initiate Conversion

Store Values

Return

Get Temperature

Configure ADC

Initiate Conversion

Store Values

Return

Page 30: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 30

Thermal Controller Thermal Controller ImplementationImplementation

Temperature Sensor

Analog

VDD

VDD

SDA

SCL

ComparatorModule

A/DConverterModule

PIC16F886

MSSPModule

MCP9700

I/O

TACH

VDD

VDD

CCPModule

Page 31: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 31

PICPIC®® MCU Thermal Controller MCU Thermal Controller FlowchartFlowchart

Get Temperature

Calculate and setPWM Duty Cycle

Monitor Fan Speed

Page 32: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 32

Generating a PWM SignalGenerating a PWM Signal

Requirement: Low-speed 10-100 Hz signal to control fan speedProblem: PWM module cannot generate a 10 Hz signalSolution: Software PWM

Page 33: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 33

Generating a Software PWMGenerating a Software PWM

V

Time

Set I/O Line High Set I/O Line Low

Wait a high time Wait a low time

PWM Waveform

Page 34: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 34

Generating a Software PWM with Generating a Software PWM with CCP Compare ModeCCP Compare Mode

COMPARE Mode to time when the I/O Line needs to be toggledInterrupt is generated when TMR1 equals CCPR1

CCPR1H CCPR1L

TMR1H TMR1L

Comparator Set CCP1IF FlagMatch

32.768 kHz

Page 35: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 35

Generating a Software PWM using theGenerating a Software PWM using theCCP Compare ModeCCP Compare Mode

V

1 2 1

Time

THIGH

Timer1 Timer1 + THIGH

Page 36: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 36

Software PWM FlowchartSoftware PWM Flowchart

1

Set PWM I/O High

Add THIGH to TMR1H:TMR1L

(store result in W)

Move result to CCPR1H:CCPR1L

Return

CCP (Compare) Interrupt

Page 37: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 37

Setting PWM Duty CycleSetting PWM Duty Cycle

V

1 2 1Time

TLOW

Timer1 Timer1 + TLOW

Page 38: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 38

Software PWM FlowchartSoftware PWM Flowchart

2

Set PWM I/O Low

Add TLOW to TMR1H:TMR1L(store in WREG)

Move result to CCPR1H:CCPR1L

Return

CCP (Compare) Interrupt

Page 39: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 39

Calculating PWM Duty CycleCalculating PWM Duty Cycle

Duty Cycle

Temperature

THIGH = TA * [(DCMAX – DCMIN) / (TempMAX-TempMIN)]TLOW = TPERIOD – THIGH

DCMAX

DCMIN

TempMIN TempMAX

Page 40: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 40

Recall: Pulse StretchingRecall: Pulse Stretching

PWM

Ideal

Actual

Must leave the PWM line high if a measurement in progressSolution: Create a flag called Measurement Flag to indicate when a measurement is in progress

Page 41: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 41

Setting PWM Duty CycleSetting PWM Duty Cycle

V

1 2 1Time

TLOW

Timer1 Timer1 + TLOW

Page 42: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 42

Software PWM FlowchartSoftware PWM Flowchart

2

Set PWM I/O Low

Add TLOW to TMR1H:TMR1L

Move result to CCPR1H:CCPR1L

Return

CCP (Compare) Interrupt

MeasurementFlag?

No

Yes

Page 43: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 43

PWM GenerationPWM Generation

Questions?

Page 44: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 44

Thermal Controller Thermal Controller ImplementationImplementation

Temperature Sensor

Analog

VDD

VDD

SDA

SCL

ComparatorModule

CCPModule

A/DConverterModule

PIC16F886

MSSPModule

MCP9700

I/O

TACH

VDD

VDD

Page 45: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 45

PICPIC®® MCU Thermal Controller MCU Thermal Controller FlowchartFlowchart

Get Temperature

Calculate andSet PWM Duty Cycle

Monitor Fan Speed

Page 46: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 46

Measuring Fan SpeedMeasuring Fan Speed

Comparator and timer 1 peripheral

4 transitions per revolution on TACH line- Fan datasheet specifies TACH line

output

Page 47: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 47

Tachometer OutputTachometer Output

V

Time (seconds)T1 T2 T3 T4

T = 1 RotationT = T1 + T2 + T3 + T4 T1 = T2 = T3 = T4 = 60 / (4 x RPM)

RPM = 60 / (4 x T1)

VIN-

VIN+

Page 48: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 48

Comparator InterruptsComparator Interrupts

V

1 2Time (seconds)

3

VIN-

VIN+

Page 49: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 49

Measuring Fan SpeedMeasuring Fan Speed

1

Increment state variable

Comparator InterruptIncrement the state variableIgnore first edge (allows Hall sensor to stabilize)

Return

Page 50: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 50

Comparator Interrupt 2Comparator Interrupt 2

V

1 2Time (seconds)

3

VIN-

VIN+

Page 51: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 51

Measuring Fan SpeedMeasuring Fan Speed

2

Increment state variable

Comparator InterruptSecond interrupt stores Timer 1 valueBegin Measurement

Return

Store TMR1H:TMR1L

Page 52: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 52

Comparator Interrupt 3Comparator Interrupt 3

V

1 2Time (seconds)

3

VIN-

VIN+

Page 53: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 53

Measuring Fan SpeedMeasuring Fan Speed

3

Reset state variable

Comparator InterruptThird determines the change in time

Return

Subtract stored Timer1from current Timer 1

Turn off Comparator

Clear Measurement Flag

Page 54: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 54

Problem: Measuring Too OftenProblem: Measuring Too Often

PWM

Ideal

Actual

Fan will be full on during measurementsMeasuring too often can change the speed of a fanNot measuring enough may yield inaccurate speed measurementsSolution: Measure every half second

Page 55: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 55

SolutionSolution

Get Temperature

Set PWM Duty Cycle

Monitor Fan Speed

1/2 Second Elapsed?

Set Measurement Flag

No

Yes

Page 56: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 56

Measuring Fan SpeedMeasuring Fan Speed

Questions?

Page 57: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 57

Thermal Controller Thermal Controller ImplementationImplementation

Temperature Sensor

Analog

VDD

VDD

SDA

SCL

ComparatorModule

CCPModule

A/DConverterModule

PIC16F886

MSSPModule

MCP9700

I/O

TACH

VDD

VDD

Page 58: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 58

MSSP BasicsMSSP Basics

MSSP I2C™ Mode Supports:- Master/Multi-Master Mode- Slave Mode- 7 or 10-bit Addressing

Configurations:- I2C Master Mode- I2C Slave Mode- I2C Slave Mode with Start and Stop bit

interrupts enabled- I2C firmware controlled master, slave is idle

Page 59: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 59

II2CC™™ BasicsBasics

NXP(Philips) Inter-Integrated Circuit (I2C)- Specification:

www.standardics.nxp.com/literature/books/i2c/pdf/i2c.bus.specification.pdf

Synchronous (not like RS232)Master-Slave ProtocolBidirectionalHalf Duplex Serial Interface

Master EEPROM Real-Time Clock

A/DConverter

SDA

SCL

Page 60: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 60

II22CC™™ Message FormattingMessage Formatting

Master Write to Slave

A PDataAWord AddressAS Slave Address [W]

From master to slave

From slave to master

A = Acknowledge

S = Start Condition

P = Stop Condition

Page 61: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 61

II22CC™™ Message FormattingMessage Formatting

Master Combination Read from Slave

Slave Address [R]Sr AADataASlave Address [W]S PAData

From master to slave

From slave to master

A = Acknowledge

A = No Acknowledge

S = Start

Sr= Repeated Start

P = Stop

Page 62: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 62

II22CC™™ Slave Mode Firmware Slave Mode Firmware OverviewOverview

Slave Address [R]Sr AADataASlave Address [W]S Data A PAData

SSP Interrupt

Page 63: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 63

Thermal Management Controller Thermal Management Controller RegistersRegisters

Fan Controller writes data to GPRFan Controller data is made read/writable through the I2C™Slave Mode Firmware

Fan Status

Temperature Max_L

Fan Speed_LFan Speed_H

Temperature Min_LTemperature Min_H

Temperature Max_H

General Purpose Registers

PWM Period_HPWM High Time Min_L

PWM High Time Max_LPWM High Time Min_H

Temperature_H

PWM Period_L

PWM High Time Max_HPWM High Time_LPWM High Time_H

Temperature_L

Offset Register 0x000x010x020x030x040x050x060x070x080x09

0x0B0x0C0x0D0x0E0x0F0x10

0x0A

0x11

Page 64: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 64

SummarySummary

Thermal Management Basics3-Wire FansThermal ControllersImplementing a Thermal Controller on a PIC16F886

Page 65: 11099 THC - amoBBSd1.amobbs.com/bbs_upload782111/files_10/ourdev_287708.pdf · Controller on a PIC® Microcontroller ... 11099 THC Slide 2 ... Generating a Software PWM using the

© 2007 Microchip Technology Incorporated. All Rights Reserved. 11099 THC Slide 65

TrademarksTrademarksThe Microchip name and logo, the Microchip logo, Accuron, dsPIC, KeeLoq, KeeLoq logo, microID, MPLAB, PIC, PICmicro, PICSTART, PRO MATE, rfPIC and SmartShunt are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.AmpLab, FilterLab, Linear Active Thermistor, Migratable Memory, MXDEV, MXLAB, SEEVAL, SmartSensor and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A.Analog-for-the-Digital Age, Application Maestro, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP, ICEPIC, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK, PICkit, PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo, PowerMate, PowerTool, REAL ICE, rfLAB, Select Mode, Smart Serial, SmartTel, Total Endurance, UNI/O, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.All other trademarks mentioned herein are property of their respective companies.