Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Bolier control application. PWM output with a PIC16F876 to control valve.

Status
Not open for further replies.

Mitchy190

Newbie level 4
Joined
Apr 19, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,333
Hello everyone, bellow shows a question with regards to micro-controllers which I am currently interested in, but stuck on, and need some (a lot) of help!

A boiler has an analogue inlet and outlet temperature sensor and the output controls
a valve in the gas supply to determine the heat input. This valve must be activated
within 1ms from a change in demand. Pulse width modulation with a fundamental
period of 10ms is used to perform the activation and the temperature difference
between the two sensors is used to represent the on period of the valve.

I need to use the PIC16F8761 data sheet to study the subsystems that will be required and
develop a procedure to determine if the time response would be adequate for the application.

data sheet found at "http://ww1.microchip.com/downloads/en/DeviceDoc/30292c.pdf"

It can be assumed that:
i) 8-bit resolution is adequate for the analogue inputs
ii) A 20MHz crystal is used for the PIC

Basically I want to use the assembler language to create the appropriate code needed to perform the control of the valve within the time specifications shown above, and what I understand from the above so far is that:

duty cycle = outlet sensor - inlet sensor

and that the PIC I am using has a PWM module in which I have no clue on how to set it up. I would much appropriate some help in how to go about this question, and where to start first!

Many thanks Mitch! :)
 

Greetings,

If your pic has a pwm module then this is fairly easy to set up. You will have to configure the timer, then set up the PWM module, and then maybe write a function or two to output specific duty cycles.

I have included the link to the user guide for the capture/compare/pwm module. This is a fairly useful guide that will show you the steps that need to be taken in order to create a PWM pulse...
https://ww1.microchip.com/downloads/en/DeviceDoc/31014a.pdf
The instructions are in assembly, but it should still give you a pretty general idea of what needs to happen.

Regards,
Willis
 

using Microchp's PICDEM mechatronics kit
**broken link removed**

the following code is used to control motor speed using PWM
Code:
// initialise PWM using Capture Compare PWM Module 2
void PWMinitialise(void)
{
        // assume Fosc uses oscillator 8MHz - call systemInitialise() first
        TRISD2=0;                // set RD2/CCP2 is output
        TRISD7=0;                // set RD7 is output
        PR2=0x3f;                // set PR2 to 31.2 kHz PWM (PWM value will be 8 bits)
        // Configure Capture Compare PWM Module 2
        CCPR2L=0;                // set PWM duty cycle to 0
        CCP2CON=0xC;             // set PWM mode
        TMR2ON=1;                // Turn on Timer 2 PWM
}

// set PWM duty cycle - value between 0 and 100
void PWMcontrol(int dutyCycle)
{
        // get 8 bit value for PWM control at 31.2 kHz PWM
        dutyCycle = (int) (dutyCycle * 255L / 100L);             // get 8 bit value
        RD7=1;                                                   // switch on motor
        // load most significant 6 bits in CCPR2l and least significant two bits in CCP2CON
        CCPR2L=dutyCycle >> 2;                          
        CCP2CON = (CCP2CON & 0xF) + ((dutyCycle << 4) & 0x30);   // set bits 4 and 5
}
 
  • Like
Reactions: Teja.p

    Teja.p

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top