can someone help me with my uc project (PIC & temperature sensor & LCD)?

Discussion in 'Embedded Systems and Microcontrollers' started by voyage, May 24, 2011.

  1. voyage

    Thread Starter New Member

    May 24, 2011
    3
    0
    Hi everyone. I'm doing this hobby PIC project, basically it's a thermometer with LCD. I found both a schematics and code (hex file) in some well-known electronics related magazine and i decided to give it a shot. I should add I've never had any experience with uc, especially not PICs. The project didn't seem too difficult and it consists of only 3 IC (a pic, a sensor and DC-DC voltage regulator) , LCD display and a few other usual components. The schematic is attached below.

    So i bought all the electronic components, PIC 16f786a and PIC Kit 3 (for programming my PIC). What i've done so far: I programmed my PIC (downloaded the 'hex' file and wrote it into the chip with pickit3) and set the project on a breadboard (protoboard) so that i could test it first. The problem is that it doesn't work. The LCD display doesn't seem to be turned on at all. Now, if i assume that all components are connected correctly (on the breadboard), then I guess the problem might only be in one (or more) of those three parts: PIC (and the code), LCD or the sensor. Like i said, i didn't write the code, but i believe it's written correctly (as i got it from the original author of that project (it was written in MikroBasic)). So checking the code would be the last thing for me to do. I want to check "hardware" parts first. So i decided to test those parts of the circuit, starting with LCD display.

    My questions are:

    1.) LCD: Any idea where to get a code or hex file for testing my LCD? I basically just want to see if it's working and i need some easy and quick test. Like "hello world" written on display or something. My LCD is 20 x 4 using standard 4-bit interface interface (HD44780 or KS066). Power supply (Vdd) is 5V.

    2.) PIC & sensor: The temperature sensor I'm using is a very good one. It has internal ADC, RAM, DSP and it can work in two possible modes. The output temperature is already in digital form (15 bit word). Communicating between PIC and my sensor is via SMBus (very similar to I2C). As you can see on the schematic, the temperature sensor is connected to PIC via 2 pins: SCL (RC3) and SDA (RC4). If i understand correctly, PIC is Master (who provides clock signal) and the sensor is Slave. Right? I checked SCL pin, which is supposed to be 'clock' signal, but on the oscilloscope it DOESN'T look like it at all. It's rather a DC signal (around 4,5V; power supply for the sensor, PIC and LCD is 5V) with some noise. Without scl as a 'clock' signal, the sensor can't perform or send any usefull data (temperature values) to PIC, so this is surely one of the problems. Any ideas what should I do next?

    Any other advices or any kind of help would really be appreciated!
     
  2. JDT

    Well-Known Member

    Feb 12, 2009
    658
    85
    If all you have got is the HEX file then it is very difficult to see what's going on and debug. Can you get the original source - either assembler (.asm) or C?

    If not, now that you have constructed this, it might be time to learn PIC programming and write your own code. There are plenty of examples about on writing to the display and you need to get a full datasheet for the sensor so that you can find out exactly how that works.

    Copying other people's code, even if you can get well commented source code, does not really teach you how it's done!
     
  3. voyage

    Thread Starter New Member

    May 24, 2011
    3
    0
    I actually have 3 files - a 'hex' and 'mbas' files and fuses.txt. The code was written in Mikrobasic. This mbas file can be open by notepad for a quick look and is kinda readable. And it has comments too. I attached it below.

    I know, you're totally right here. But you see, i didn't start this project to learn programming PICs (although i know it'd be useful), i just wanted to make this IR thermometer, since the code was already written. So that's big difference. Besides, writing my own code would probably be a bit too difficult for such a beginner. This project is too complex (with all this I2C Master-Slave protocol and reconstructing digital words from sensor to real temperatures)... Not to mention the sensor, which is quite complex too (btw, i have all the datasheets). So i hope i can fix this problem without having to read or even write my own code, because I still believe the problem is not the code (hex file), but something else. And I'm trying to find what. Thanks for your answer anyway. ;)
     
  4. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    You're in the unfortunate position of having hardware and software that you don't understand, and no diagnostic tools. If you've made a mistake wiring the LCD, how will you ever trace it? And if the code has a bug, how can you find it? You've got to get everything exactly right, or it just won't work (and that's what seems to be happening).

    Operating the typical LCD display is a rather intricate process of timing and sequential inputs on various digital lines. If you had a scope I'd say try a few tests to check that the wires are in the right places. Is there any way you can do something like that?
     
  5. JDT

    Well-Known Member

    Feb 12, 2009
    658
    85
  6. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    One thing to check is that the configuration bits are set up as per the fuses.txt file. Wrong fuses settings could prevent the PIC from working!
    Look in MPLAB menu "Configure\Configuration Bits..." to see or alter the fuses settings.
     
  7. voyage

    Thread Starter New Member

    May 24, 2011
    3
    0
    I never said I have no diagnostic tools. I have devices like an oscilloscope, a multimeter and signal & func generator. I just need some advice what and how to test. ;)

    I soldered 16 pins header to my LCD so that i can use it on breadboard. Therefore i can easily check possible wiring mistakes on LCD-Pic relation. I also believe the code has no bugs, because it was written for the very same project (using the very same ICs (pic, sensor and lcd)). Ofc you can't be totally sure about it, but I believe the problem is somewhere else... maybe an oscillator? I have 20Mhz quarz. I heard some crystals can act weird on breadboards (because of additional parasite capacitance). Any idea how to test it? I can check OSC1 and OSC2 pins with scope, but i'm not sure what to except - a sine or squad signal?

    Also, any idea how to quickly test if my LCD works at all?

    JDT, thanks for your link, but like i said... i'd rather check my hardware parts first before looking at the code.
     
Loading...