Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution.

Reply
 
LinkBack Thread Tools Display Modes
Old 1st February 2004, 05:15 AM   (permalink)
Default Circuit not working...

Hello. I have been working on a car part that I was using a PIC 16F628 on, and Pic Basic Pro. I ended up needing an ADC so I switched to the 16F819. Now I cannot get my LCD or any serial communication to work. I think it is because of the timing. I tried to use the internal rc, but I could not get it to work. Now I am using a 20mhrz crystal and two 18pf capacitors. Here is how I have it set up:

pin 4 -> 2.2K -> 5v
pin 5 -> GND
pin 6 -> Serial port
pin 14 -> 5v
pin 15 -> 20mhrz -> 18pf -> GND
pin 16 -> 20mhrz -> 18pf -> GND

Here's my code:

DEFINE OSC 20

TRISA = %00000000
TRISB = %00000000

loop:

SerOut2 PORTB.0,9600,["Hello",10,13]

GoTo loop

I programmed it with a JDM programmer and ICPROG. I have tried pretty much every setting on the rc and haven't had any luck with any of them. Which one should you use? I am thinking HS, but I am not sure.


Also, this is a little off the subject, but how hard is it to get a 16f876 to work correctly. I have messed with the 819 for about two weeks and I am getting ready to give up on it. Is it easier to deal with?

One last question, does anyone have any advice on calibrating a pressure sensor and getting an actual reading out of it? Any advice on any of these would be greatly appreciated.

Thanks!
Brent
brentonw2004 is offline  
Old 1st February 2004, 08:43 AM   (permalink)
Default Re: Circuit not working...

Quote:
Originally Posted by brentonw2004
Which one should you use? I am thinking HS, but I am not sure.
For a 20MHz crystal you should use HS.

Quote:
Also, this is a little off the subject, but how hard is it to get a 16f876 to work correctly. I have messed with the 819 for about two weeks and I am getting ready to give up on it. Is it easier to deal with?
It's easy to get a 16F876 to work, but it 'should' be easy to get an 819 to work as well. I'm presuming your PicBasic Pro supports the 819?.
Nigel Goodwin is offline  
Old 1st February 2004, 04:01 PM   (permalink)
Default

On there website it said that my version of pic basic pro supports it. It has all of the includes. I think that it is only my timing slightly off, because the only thing that I notice is corrupt is serial communication. I have also read that serial communiction will not work unless it is almost exactly perfect. Are my crystals right? Does the internal rc have anything to do with why it's not working? Is 18pf correct? I have read some places that you use 15pf and other places say that you use 18pf? How big of a difference would this make?

Thanks!!
Brent
brentonw2004 is offline  
Old 1st February 2004, 05:45 PM   (permalink)
Default

How is the pic connected to the serial port of the pc? You need an inverter between pic and pc. Or a RS232 driver like a MAX232
Exo is offline  
Old 1st February 2004, 06:11 PM   (permalink)
Default

I am just connecting pin 2 of a serial cable to my pic and pin 5 to ground. Then I just plug it into my com1 port on the back or my computer and watch for the signal in HyperTerminal. I have did it like this before and everything worked fine on the 16f628. Does anyone have any advice?

Thanks!
Brent
brentonw2004 is offline  
Old 1st February 2004, 06:13 PM   (permalink)
Default

Quote:
Originally Posted by brentonw2004
On there website it said that my version of pic basic pro supports it. It has all of the includes. I think that it is only my timing slightly off, because the only thing that I notice is corrupt is serial communication. I have also read that serial communiction will not work unless it is almost exactly perfect. Are my crystals right? Does the internal rc have anything to do with why it's not working? Is 18pf correct? I have read some places that you use 15pf and other places say that you use 18pf? How big of a difference would this make?

Thanks!!
Brent
The value of the caps seems to make very little difference - I use whatever I happen to have to hand, anywhere from 10pF to 27pF, as long as they are both the same.

Are you sure the configuration fuses are set correctly?, read the chip back and check what they are set to - if you have a 20MHz crystal, but the chip is set to use the internal oscillator - it will only be running at 4MHz.

Using the in-built RC oscillator at 4MHz on a 16F628 works fine for serial comms, using either software or the hardware USART - I've no reason to suspect an 819 would be any different, and running it from a crystal it's going to be more than accurate enough.
Nigel Goodwin is offline  
Old 1st February 2004, 06:17 PM   (permalink)
Default

Quote:
Originally Posted by brentonw2004
I am just connecting pin 2 of a serial cable to my pic and pin 5 to ground. Then I just plug it into my com1 port on the back or my computer and watch for the signal in HyperTerminal. I have did it like this before and everything worked fine on the 16f628. Does anyone have any advice?
RS232 on a PIC is 'usually' intended for use with a MAX232, which inverts the signal - using the hardware USART, you have to do so to get the polarity correct. If using software simulation for RS232, you can invert it in software if you like - but you need to have it set correctly for what you are wanting to do - presumably your compiler will explain what you need to do, and how you do it.
Nigel Goodwin is offline  
Old 2nd February 2004, 01:00 AM   (permalink)
Default

I finally got it sort of working. I finally got it to send some data to the computer, but it is wrong. Instead of the computer reading 'Hello', I am getting " !ëåo5'' " I have tried to use SerOut and SerOut2, but they are both messing up. Any advice on this?
brentonw2004 is offline  
Old 2nd February 2004, 03:55 PM   (permalink)
Default

Baudrate could be wrong at pc or pic side, data might be inverted...
Exo is offline  
Old 2nd February 2004, 05:46 PM   (permalink)
Default

Your serout2 Code is incorrect.
Code:
DEFINE OSC 20 

TRISA = %00000000 
TRISB = %00000000 

loop: 

SerOut2 PORTB.0,9600,["Hello",10,13] 

GoTo loop
The part where it says 9600 for the baudrate is actually giving you a baudrate of 103.95. And that explains the error.
Since you have your PIC connected straight to the serial port then you are going to need to send the data inverted, and if you want to use a 9600 baud rate then you will need to change your Serout2 command to:

Code:
SerOut2 PORTB.0,16468,["Hello",10,13]

Ivancho
ivancho is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 09:10 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

eXTReMe Tracker