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.

temperature sensor -PIC 16f877

Status
Not open for further replies.
Hi...
i just met my supervisor today.. it seems she prefer for AC motor...huhu.. i wonder how to do it..?...

any suggestion....
 

hi tahmid, when i compiled the code that you wrote , i got an error. (PWM_Init(5000) is undeclared identifier) and also my mikroC doesnt compile PWM_Change_Duty(medium);
when i replaced it with PWM1_Set_Duty(medium); it says ok. Is there any problem at my mikroC. I downloaded the new version but actually i am not good at mikroC. Pls help me
 

hi tahmid i want this program with mikrobasic i need it so pls help me
 

Hi wdepot61,
Usually I use mikroBASIC, seldom mikroC, so when I code with mikroC, I use what I have: the old version 8.2
The code given will show errors in the new versions, there need to be a few modifications. If you download v8.2, then the code is fine.
Try this instead:
Code:
#define slow 32 //Duty cycle set for slow
#define medium 96 //Duty cycle set for medium
#define fast 230 //Duty cycle for fast
#define cel20 41 //20'C
#define cel50 102 //50'C

//I set range as:
//Less than 20'C : speed is slow
//From 20'C to 50'C : speed is medium
//Greater than 50'C : speed is fast

int ADVal; //Variable to store ADC result
unsigned char duty;

void main(void){
     TRISC = 0;
     PORTC = 0;
     PWM1_Init(5000); //5khz pwm
     PWM1_Set_Duty(medium); //50% duty cycle
     PWM1_Start(); //Start PWM
     while (1){
           ADVal = ADC_Read(0);
           if (ADVal < cel20){
              duty = slow;
           }
           if ( (ADVal > cel20) & (ADVal < cel50) ){
              duty = medium;
           }
           if (ADVal > cel50){
              duty = fast;
           }
           PWM1_Set_Duty(duty); //Change duty cycle and adjust
           delay_ms(100); //Wait for adjusting (Optional and may be left out)
     }
}

Hope this helps.
Tahmid.

Added after 5 minutes:

Hi som3aabero,

Try this:
Code:
program TempFanControl

'I set range as:
'Less than 20'C : speed is slow
'From 20'C to 50'C : speed is medium
'Greater than 50'C : speed is fast

dim ADVal as word 'Variable to store ADC result
dim duty as byte

const slow = 32 'Duty cycle set for slow
const medium = 96 'Duty cycle set for medium
const fast = 230 'Duty cycle for fast
const cel20 = 41 '20'C
const cel50 = 102 '50'C

main:
     TRISC = 0
     PORTC = 0
     PWM1_Init(5000) '5khz pwm
     PWM1_Set_Duty(medium) '50% duty cycle
     PWM1_Start() 'Start PWM
     while true
           ADVal = ADC_Read(0)
           if ADVal < cel20 then
              duty = slow
           end if
           if (ADVal > cel20) and (ADVal < cel50) then
              duty = medium
           end if
           if ADVal > cel50 then
              duty = fast
           end if
           PWM1_Set_Duty(duty) 'Change duty cycle and adjust
           delay_ms(100) 'Wait for adjusting (Optional and may be left out)
     wend
end.

Hope this helps.
Tahmid.
 

    V

    Points: 2
    Helpful Answer Positive Rating
Thank you Tahmid. Actually there is no error but when i simulate it in PROTEUS, the i cant see PWM output at RC2. Could u see it?
 

thank u very much tahmid

Added after 1 hours 18 minutes:

hi tahmid i try it in the Proteus and it dosnt work i connect every thing pic with lcd and lm35 but it dosnt work so pls can u help me
 

hey isn d code easier with assembly language??m doin similar kind of project! m makin d code in mplab software..cn u help wid assembly language??
 

hi tahmid ..
I appreciate your knowledge
Can you please help me to drive a stepper motor in simulator
Since my board is under designing process

Thanks in advance.
 

i tried many times to build a temperature control but i always fail and i have to finish my work within 3 days pzl any body help me be schematic and source code
 

Hi,
Tahmid did a good job. I have compiled it and simulated it in proteus.
check it out.

Thanks Tahmid.
 

HI tahmid i am using LM35 temp sensor for temp reading ..

LM35 conversion 10mv/ degree C
PIC16f877a 4.88mv per count..

i am not getting how to count the values..

and one more thing.. is PIC is 10bit resolution how to take it as 8bit value..

plz reply me

Added after 2 minutes:

smita which controller ur using send schematic for stepper motor control so that i can help u
 

salam mr TAhmid,
bro i just wanted to thank u whole heartedly about the effort u ve made to make people like me and others understand the each and every bit of programming and pwm calculation.it was worth reading and i grasped much more than i gain me electronics lecturer class.plus no offences i ve realized my lecturer is shit.thanks mate again.*** bless u.
regards,
zuni
 

if the input range of analog sensor is 0 to 5v in microC we do adc_read(0). can u please tell me if the input voltage range is 0 to 1v what we will do???
 

0-5V means adc value for 5V will be 1023 for 10-bit adc.
0-1V means adc value for 1V will be 1023 if Vref is 1V. If no Vref is used adc value will be 204.6 for 1V.

adc resolution without Vref will be 0.0048875855327468
with 1v Vref will be 0.0009775171065493646e
 

what to do in the code to set vref to 1v.?

- - - Updated - - -

please tell me about a good book to learn pic16877a programming, i am good in programming of 8051 but dont know about pic16f877a
 

what to do in the code to set vref to 1v.?

- - - Updated - - -

please tell me about a good book to learn pic16877a programming, i am good in programming of 8051 but dont know about pic16f877a

You need to use an external VREF.

This means you connect a +1V circuit to the RA3/AN3/VREF pin of the PIC16F877a and enable this pin in your code as VREF+ instead of digital I/O or analog input.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top