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.

HELP!! Digital Thermometer

Status
Not open for further replies.

jhunt315

Junior Member level 1
Joined
Dec 2, 2010
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,408
I have a huge project due in 2 days and i cant figure it out! I am using a PIC16F917 microcontroller and an LM34 sensor to display the thermometer readings on a seven segment display. I am using the MPLAB IDE program to program the pic, but i do not know how to write the code (I believe it is C Code) in order to get this simple temperature reading on the display. Does anyone have a C Code for my pic and sensor to make this work?
 

You need to write code for the the following functions :
Read the analogue LM34 voltage (A2D)
Convert the reading to temperature
Convert the temperature value to BCD ( 2 digits)
Convert the BCD to 7 segment code
Refresh the 7 segment displays
Re do the loop
Your school require you to write the code to demonstrate that you have the necessary skills to past your course
Which compiler does your school provide?
 

yes i know that i have to do that for the code, i am good at wiring just awful at coding. We need to use the C Compiler so C Code would be the only code i would be able to use.
 

You have CCS, hi tech and mikro compiler that use C language... and there are probably more...



(each one is unique, as in one code working for mikro will not work from hi tech without an effort to change it)
 

I am using the MPLAB C compiler, which is associated with HI TECH C compiler
 

i know its a lot to ask i am really stuck and do not understand this and would love if anyone had sample MPLAB C code for a PIC16F917 even if its for a LM35 sensor.
 

it is not alot really...

do you know how to get a lcd to work properly?
 

The first post refers to a seven segment display ; 2 digits I assume.
 

oh right forgot about it ^^

i have always been a fan of lcd over segment display ^^.

i have something around here that gets that working.


the conversion is pretty straightforward.

i never used those kind of sensors they use the usual formula to converte? ( 5*(x)/1023 )
 

no i do not know how to have an LCD work, this is my first time and i was just given a seven segment display hooked up correctly and had to find the right code using the LM34 sensor, transistors to act as switches for the seven segment, 1k resistor bank hooked up to the pic and the pic16f917. Then i was told to find the correct code using MPLAB IDE program using C to make it display on the seven segment and i have no idea what to do.
 

Here's a tutorial on using PIC to drive a seven segment display:



This PDF combined with the other three example projects in gave you in your other thread asking help for the same problem, cross posting, provides all the info you need to finish your project.
 

Multiplexed Seven Segment Display using PIC16F877A and HI-TECH C | eXtreme Electronics

follow that one for the segment display

and for the conversion just go to

C:\Program Files\HI-TECH Software\PICC\9.81\samples\A2Demo

and check out those files.

you need to know where you connect the sensor.

if you check the 16f877 datasheet you can see that it only on the PORTA you can convert Analog to digital if i am not mistaken.

in the

Code:
void
adc_read(unsigned char channel)
{

	ADCON0 = (channel << 3) + 0xC1;		// enable ADC, RC osc.
	ADGO = 1;
	while(ADGO)
		continue;	// wait for conversion complete
}


ADCON0 = (channel << 3) + 0xC1; <--- this is where you tell the pic where to convert the signal.

as i said before check the datasheet and in there there will be 1 or 2 pages about ADCON0 and ADCON1 read them, understand them, get the correct config on your code.

and i believe... it is pretty much at the end your project ;)


have fun.
 

thanks zwilorg!!

---------- Post added at 18:30 ---------- Previous post was at 18:27 ----------

One quick questions. In the code it has #include <htc.h>. Would i have to download that library because in the MPLAB IDE for the PIC16F917 it doesn't have that library it says.
 

thanks zwilorg!!

---------- Post added at 18:30 ---------- Previous post was at 18:27 ----------

One quick questions. In the code it has #include <htc.h>. Would i have to download that library because in the MPLAB IDE for the PIC16F917 it doesn't have that library it says.



No problem m8.

You maybe doing something wrong then :S

htc.h aswell as some others are the "default" libraries of hitech compiler :S you don´t need to add them to your project. just include them...

i can´t help you with that error :S sorry
 

Ok I got that problem fixed. One quick question though, looking at the code it looks like the seven segment display is connected to port D. Is that correct?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top