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 with writing Assembly to Display Temperature and converting Binary to Decimal

Status
Not open for further replies.

BmanS

Newbie level 6
Joined
Apr 18, 2013
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,364
Here is my board :

https://i.imgur.com/eXySomM.jpg

Im programming for a PIC16F676 , Im writing in Assembly and the instructor only gave us a Crash Course in the language.

the LCD Display will display the temperature in Farenheit , I already have a simply count assembly program burned on the PIC , which just outputs on the LCD numbers counting from 1-99 .

How should I start? Where should I start ?

Thanks a lot everyone.
 

if you can program in C, i can help you a lot, or you can go to microe compilers, they have easy solutions for functions like this, again microe uses C.

in assembly show me your current code...
 

Well dont know C and Im trying to implement it in Assembly.. I only have the count code which is in hex for now...

which I have uploaded : **broken link removed**
 

i do not have PIC16F676 with me now so i cant test your hex..

search for instruction set of your pic device..
and if you are using mplab ... go to mpasm help..
 

Im using the PIC16 IDE by Oshonsoft currently and then QLPROG2006 to burn the program onto the chip. Will look at the instruction set and check back.
Thanks
 

to convert data into decimal do this thing..

say for example data2;
digit20xff;
in decimal it is 255;

so to isolate each digit you can
Code:
digit1=data /100;
data=data%100;

digit2=data/10;
data=data%10;

digit3=data/1;  //not necessary apperantly

your output will be
Code:
digit1=2;
digit2=5;
digit3=5;

i assume that you know how to divide in assembly..
 
  • Like
Reactions: BmanS

    BmanS

    Points: 2
    Helpful Answer Positive Rating
Yes you shift left in order to divide , thanks for providing so far.. will work on the code given.
 

Im trying to figure out this process but how would I exactly read the display ?

P.S and the code you posted how would I then go to Binary ? Since the Display will be talking back and forth with the Temperture Sensor(not yet added to the board instructor has not given that to us) .
 

which kind of lcd display & temp. sensor do you have?

- - - Updated - - -

which kind of lcd display & temp. sensor do you have?
 

It's a HP 7 segment display here:**broken link removed**
I don't have the sensor most likely today the professor will give it to us.
 

the temp. sensor that u'll be using should have analog output....
so turn on adc module in pic, than translate adc result (ranging from 0 to 255) in to decimal form, and send it to your display.. thats it..
 
  • Like
Reactions: BmanS

    BmanS

    Points: 2
    Helpful Answer Positive Rating
If the sensor is analog, use the ADC then conversion routines here: to convert to decimal.
If it's a digital sensor like the DS18B20 series, look carefully at the result format, it's easy to split the whole and fractional part of the result and deal with them individually.

Note that LCD displays have to be initialized before using them. This is done by sending a series of numbers to them with the correct delays between them. They also accept characters in ASCII format so you may need to do some simple conversion before the data can be displayed as normal digits.

Brian.
 
  • Like
Reactions: BmanS

    BmanS

    Points: 2
    Helpful Answer Positive Rating
Ok thanks guys for your help ..will continue working on it.
 

I have a question do you know by any chance where i can find a sample asm code that simply counts random numbers ? like 1-99 ?

preferably something that will convert to BCD and push it to the display I only have some count code in hex ..

also im using oshon soft pic IDE and Im getting compile errors because I dont have the pic16f676 header file anyway that I can include that so the errors I have can go away? Im unable to even use the 'movf' command even.

thanks
 
Last edited:

Oshonsoft produce a BASIC compiler and IDE yet you are talking about asm code. I know you can load binary files into the IDE and simulate them but is that what you are doing? It isn't the smartest way to do it when Microchip have their own excellent and completely free assembler and debugger.

For random number generation, take a look at the PICList web site which has lots of source examples.

Brian.
 

Sorry if Im confusing you, I have a QLProgrammer Device, with it the QLPROG PIC16 software which will ultimately burn the code onto the chip

Issues I have:

  • I have C code
  • I need that C code to go eventually to 'hex' format so I can burn it Im at the finishing stages now


Im using MikroC Pro since I have C code and figuring out how to bring that to hex so I can test if it works on my board.

Thanks so far for all the help
 

Hex files are produced as the output of the compiler. As long as the compilation is sucessful (no errors!) it should produce the file for you. There isn't a separate process to create the hex file.

Brian.
 

Ok so the BASIC compiler will do the job? Now the issue of the "include header file" for the pic16 where will I get that so the compile errors go away?
 

I'm guessing the header files is supposed to come from MPLAB. 'Normal' assembly files use the header to save having to name all the registers and bit names.
If you have MPLAB and it's installed in the default location, it's at "C:\Program Files\Microchip\MPASM Suite\P16F676.INC". Your files are somewhat non-standard though so it might be a different file altogether your compiler is asking for.

Brian.
 

thanks I figured the issue, my final issue I would think thats really making me hit my head on the wall is that I cant find any sample code for the PIC16F676 that simply writes to a 7segment display which includes a 8-bit shift register...I just need to read some code like that so I know what is being serialized and what bits are sent out. Every example Im reading has a multiplexer but the PIC is directly being connected to the 7segment display without a Shift Register.

Really stuck on this one any help would be great.

Thanks for everything so far
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top