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.

can you help me with my project (PIC & temperature sensor)?

Status
Not open for further replies.

voyage

New Member
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. I checked SCL pin, which is supposed to be 'clock', but on 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. So this is surely one of the problems. Any ideas what should I do next? :(

Any other advices or help would really be appreciated!
 

Attachments

  • sch1.jpg
    sch1.jpg
    89.7 KB · Views: 251
Have you tried to set the contrast on the lcd. If it is not correct voltage then the screen will appear to be blank (not working).
 
Hold the PIC in reset and turn on your circuit.

If the top line of the LCD isn't filled with blocks, then there is an LCD problem (either contrast or power). Try adjusting your contrast. Some HD44780 compatible LCD's have the VDD and VSS switched around. The back of your LCD (the chips on board) will get very warm if that is the case but it may still work.

If you are indeed seeing nothing on the SCL line for the temperature sensor, then it is a PIC problem, provided the program is made for your sensor and the outputs/inputs you're using.

Perhaps an oscillator problem?

Just out of curiosity, if you pull the SCL line low when the circuit is operating, does it actually go low? If it does then RC3 is still set at the default input, meaning your PIC (or the program) hasn't started up.
 
Hold the PIC in reset and turn on your circuit.

If the top line of the LCD isn't filled with blocks, then there is an LCD problem (either contrast or power). Try adjusting your contrast.
I tried this before, but the LCD doesn't show anything. I'll check the LCD-to-PIC connections and try it again, though. BTW, what should be the right contrast (voltage of V0) to see anything? (Vdd is 5V).

Perhaps an oscillator problem?
That's a good idea. What could go wrong here? I have a 20 Mhz crystal and two 22p capacitors, just like it's required. How can i check if my 20 Mhz crystal is ok? I can check it on oscilloscope (should i remove it from the circuit and test it on another breadboard?). Should it be sine or square signal?

Just out of curiosity, if you pull the SCL line low when the circuit is operating, does it actually go low? If it does then RC3 is still set at the default input, meaning your PIC (or the program) hasn't started up.
Hmmm how can I "pull" SCL line low? You mean by connecting it to Vss (GND)?
And another question: are SCL(RC3) and SDA(RC4) pins inputs or outputs (in Pic as Master mode)?

Thanks in advance.
 
I tried this before, but the LCD doesn't show anything. I'll check the LCD-to-PIC connections and try it again, though. BTW, what should be the right contrast (voltage of V0) to see anything? (Vdd is 5V).

I don't remember to be honest. Perhaps somebody with one connected can measure it and let us know?


That's a good idea. What could go wrong here? I have a 20 Mhz crystal and two 22p capacitors, just like it's required. How can i check if my 20 Mhz crystal is ok? I can check it on oscilloscope (should i remove it from the circuit and test it on another breadboard?). Should it be sine or square signal?

The most common reason for a crystal not starting is too high of a capacitance. This can be caused by using a breadboard with capacitors (crystal capacitors are usually not required for a breadboard) or the trace length being too long. The crystal should be as close to the PIC as physically possible with short traces.

I'm not sure how to test a crystal. I usually write a tiny blink LED program or similar.


Hmmm how can I "pull" SCL line low? You mean by connecting it to Vss (GND)?
And another question: are SCL(RC3) and SDA(RC4) pins inputs or outputs (in Pic as Master mode)?

Thanks in advance.

Yeh remove the pull-up from the SCL line and pull it low instead. I'm just wondering whether the PIC is holding it high or it's the pullup the pull-up.

The SCL line should be an output (for the PIC to clock the data out of the temperature IC) and the SDA line should be an input (to read the data).
 
Hey, just want to say I managed to fix the problem today. Not sure what exactly was the real reason, but after I moved my crystal oscilator as close as possible to pic's Osc1 and Osc2 pins and played a bit with the contrast (V0), the LCD suddently stared to display the temperature! So thanks again for your help!
 
Sounds like the internal capacitance of the breadboard busses caused the crystal to stall. Shortening the busses lowered the capacitance and got it going. Might be a bit intermittent though.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top