Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

problem with lm35dz and transfer data from pic to pic to activate 7 seg display

Status
Not open for further replies.

Aeddon

New Member
hi guys,
as i currently now doing my final year project, i am newbie to mirco controller using mplab programming.i hope you can help me out
my project goes like this.
i am doing temperature controller which will use lm35dz to capture the tempature and show it in the lcd with 4 switch (1. setmode,2incr,3decr and 4setpoint),after i get my temperture(e.g room temperature 27 degree)then i will compare to my set temperature range (e.g 28 degree), if temperature range were to cross buzzer will sound ,fan will start and then it's then transmit the data from 16f877 to another pic 16f628 and to activate a 7 seg display and buzzer using rf module transmission.
i am using (tws434- and rws-434 with encoder and decoder). do you have a sample code for the above mention?
hope you can advise me
1. how to write code for conversion from lm35dz binary to BCD
2. how to create a setmode temperature for a reference limit for the temperature
3. how to call in command for buzzer to appear when setmode temperature is hit
lastly.how to transfer data from pic to pic to activate another routine to control a 7 seg display

thanks.
 
This is a joke right? It's the end of November on your "final year project", you are a PIC newbie and want to do temperature sensing and control, RF comms PIC-PIC and 7 segment display all done in assembler? And you don't have any code at all?
 
This is a joke right? It's the end of November on your "final year project", you are a PIC newbie and want to do temperature sensing and control, RF comms PIC-PIC and 7 segment display all done in assembler? And you don't have any code at all?


Mr. RB , i do have code for temperature sensing conversion and show on lcd control but there are some confusion in rf transmission between pic as i google all i find is in C code, not very sure how there using, anyway, thanks for the reply
 
Aeddon here :

Some of this will probably help.


As for RF, nigel has an EXCELLENT example on his website.
 

Attachments

  • -- UART --.asm
    5.4 KB · Views: 149
  • LM35 LCD.asm
    7.1 KB · Views: 156
  • -- 16bit Bin to BCD --.asm
    2.7 KB · Views: 137
If you need any help let us know...

ya need some help here. regarding the lm35lcd, can you explain to me why


ToTemp:
CLRF VoutHi
CLRF VoutLo ; x49 = x1 + x 16 + x 32

MOVF ADCLOW,W ; x 1
ADDWF VoutLo
MOVF ADCHIGH,W
ADDWF VoutHi

RLF ADCLOW,F ; add x16 = x5
RLF ADCHIGH,F
RLF ADCLOW,F
RLF ADCHIGH,F
RLF ADCLOW,F ;
RLF ADCHIGH,F
RLF ADCLOW,F
RLF ADCHIGH,F

MOVF ADCHIGH,W
ADDWF VoutHi
MOVF ADCLOW,W
ADDWF VoutLo
BTFSC STATUS,C
INCF VoutHi

RLF ADCLOW,F ; add x32 = x49
RLF ADCHIGH,F

MOVF ADCHIGH,W
ADDWF VoutHi
MOVF ADCLOW,W
ADDWF VoutLo
BTFSC STATUS,C
INCF VoutHi
RETURN


what is the meaning of this?
anyway i connect my lm35dz directly to pic16f877a an0

and the converting part

Convert: ; Takes number in NumH:NumL
SWAPF VoutHi, w ; Returns decimal in
IORLW B'11110000' ; TenK:Thou:Hund:Tens:Ones
MOVWF Thou
ADDWF Thou,f
ADDLW 0XE2
MOVWF Hund
ADDLW 0X32
MOVWF Ones

MOVF VoutHi,w
ANDLW 0X0F
ADDWF Hund,f
ADDWF Hund,f
ADDWF Ones,f
ADDLW 0XE9
MOVWF Tens
ADDWF Tens,f
ADDWF Tens,f

SWAPF VoutLo,w
ANDLW 0X0F
ADDWF Tens,f
ADDWF Ones,f

RLF Tens,f
RLF Ones,f
COMF Ones,f
RLF Ones,f

MOVF VoutLo,w
ANDLW 0X0F
ADDWF Ones,f
RLF Thou,f

MOVLW 0X07
MOVWF TenK

MOVLW 0X0A ; Ten
Lb1: ; At this point, the original number is
ADDWF Ones,f ; equal to
DECF Tens,f ; TenK*10000+Thou*1000+Hund*100+Tens*10+Ones
BTFSS 3,0 ; if those entities are regarded as two's
GOTO Lb1 ; complement binary. To be precise, all of
Lb2: ; them are negative except TenK. Now the number
ADDWF Tens,f ; needs to be normalized, but this can all be
DECF Hund,f ; done with simple byte arithmetic.
BTFSS 3,0
GOTO Lb2
Lb3:
ADDWF Hund,f
DECF Thou,f
BTFSS 3,0
GOTO Lb3
Lb4:
ADDWF Thou,f
DECF TenK,f
BTFSS 3,0
GOTO Lb4

RETURN

sorry, can you please help me to explain ? a rough one
 
For the first one, i am using 5V so the ADC output is 5V/1023 = ~0.48 so we multiply this by ADCH:L to get the voltage.

As for the second part, I never learned how it works, just trust that it does.
 
For the first one, i am using 5V so the ADC output is 5V/1023 = ~0.48 so we multiply this by ADCH:L to get the voltage.

As for the second part, I never learned how it works, just trust that it does.


so for the first part, is getting the binary value from lm35dz right then the second part is to convert the value right?
okay as you are saying 5V reference , the rrl is use to multipy the adc value VoutLo and VoutHi?
so the whole adc conversion will display a XX.Y e.g (30.0 degree?)format?
please forgive me for asking such simple question as i just started learning and getting a hang of it as your example is good and i have read thru the datasheet .
 
Yea, multiplying on the 16F isnt exactly straight forward in ASM.

The output is in XX.Y form you are correct.

I have a video on youtube if you want to see it let me know.
 

sorry i got something that is unclear,
okay, now i am using the 10 bit adc using of the last two bit of adresh and 8 bit of adresl, after my lcd display the temperature xx.y using lm35 . my default set value will also appearred. now the question is in programming asm , how do i actually compare them to give alarm ?
because there are numl and numh i cant use subtracting method, is there any method u can recommend me ?

and also, can i just use 8 bit instead. may the whole adresh or adresl?
 
sure you can, just use 10 bit subtraction.

hi frenz,
sorry i have programme in my asm code but its fail to work, even the lcd cant display anything.
i read thru and check thru my asm code, seem okay, and my hardware i had already check my 5v and continuity, all seem fine
is there any thing wrong with my programme?
 

Attachments

  • aeddon100.asm
    23.8 KB · Views: 103
I can't see anything in your code thats obvious, are you sure you attached the LCD right? Break everything down. Get the LCD to work first, then the next thing etc. then build up your code that way!
 
i have some code, lm 35 +16f676 + lcd display + 3 sw[{1-set]{2-up}{3-dowen}] +1 relay . it 100% tesed .
 
i have some code, lm 35 +16f676 + lcd display + 3 sw[{1-set]{2-up}{3-dowen}] +1 relay . it 100% tesed .

hi sahu,
u using asm coding or c coding, because,i am using asm coding, if u are using asm coding , will you mind share it?

to mike,
i have try breaking it into only to display lcd but its still show me nothing on lcd. do you have schematics diagram for your lcdlm35 ?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top