CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

strange results when put on PCB

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Chubbs



Joined: 02 May 2005
Posts: 14

View user's profile Send private message

strange results when put on PCB
PostPosted: Wed Jun 08, 2005 10:16 pm     Reply with quote

Hi all,
I've been using the PIC16F876A on a modified smoke/CO detector. The system worked fine when I connected everything to the PIC on a bread-board. I have now transferred the system to a PCB, changing none of the connections or the code. The problem I now have is that the ADC conversion of the sensor inputs is a little off. For instance the output of the CO sensor is around a constant 0.9v the output from the PIC shown on an LCD jumps around the actual value, you can get 0.94, 0.84, 0.73, 0.97. Even the input from a pot does not give the correct output. The voltages at the pins of the PIC are constant, correct and do not change, however each time a sample is taken a slightly different result is obtained.
If the input from the pot is 2.5v the output may vary from 2.3 to 2.7v. Everything else seems to work ok the program runs as intented except for the conversions. When done on the bread-board the results were perfect, is there any reason anyone may know as to why this is happening?
Any help will be appreciated.
Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 08, 2005 10:34 pm     Reply with quote

Quote:
Even the input from a pot does not give the correct output.

What is different between the two boards ?

1. The crystal frequency: Is it different ?

2. Circuit wiring: Do you have a ground connection to your sensor ?
jbmiller
Guest







'off' adc readings
PostPosted: Thu Jun 09, 2005 4:49 am     Reply with quote

Any chance you've changed the power supply feeding the PIC? How about some induced AC voltage ( hummmm ?)? Bad ground wiring or faulty bypass caps?
hope this helps
jay
Chubbs



Joined: 02 May 2005
Posts: 14

View user's profile Send private message

PostPosted: Thu Jun 09, 2005 7:23 pm     Reply with quote

Since the system was working fine before the PCB, I've kept everything the same. It has the same crytals, same caps, same everything. I've checked over all the wiring and it seems fine.
Measuring all the voltages at the ADC input pins shows constant correct values , shouldn't this be enough to ensure a correct relult??
What could effect the result after this point?
All the known voltages on the PIC's pins look ok the reference voltages are ok ( 0.01v and 5.02v ).
What should the levesl be for the crystal???
jbmiller
Guest







off adc readings
PostPosted: Thu Jun 09, 2005 7:35 pm     Reply with quote

Hmm..don't get fooled by a digital voltmeter.they only take 3 or 4 readings per second so your voltage my 'look' stable but is actually dynamic. If you have an oscilloscope try looking with it. Is the PCB layout the same as your prototype? Could you have a 'noisey' line close by the adc pins ? Do you have a really good ground bus ? I know, you've probably already thought of these, just trying to help. heck I've got 20 year old wirewrapped boards still running and even a couple of 877s in those white 'experimentor's boards' that run fine. I suspect some kind of induce AC is leaking onto the adc pins. have you gronded the adc pins and read them ? they 'should' be all zeros..... How about the adc reference ? just more ideas....please let us know what you find out, these 'little problems' can be real head scratchers !!

jay
jbmiller
Guest







off adc readings
PostPosted: Thu Jun 09, 2005 7:36 pm     Reply with quote

Hmm..don't get fooled by a digital voltmeter.they only take 3 or 4 readings per second so your voltage my 'look' stable but is actually dynamic. If you have an oscilloscope try looking with it. Is the PCB layout the same as your prototype? Could you have a 'noisey' line close by the adc pins ? Do you have a really good ground bus ? I know, you've probably already thought of these, just trying to help. heck I've got 20 year old wirewrapped boards still running and even a couple of 877s in those white 'experimentor's boards' that run fine. I suspect some kind of induce AC is leaking onto the adc pins. have you gronded the adc pins and read them ? they 'should' be all zeros..... How about the adc reference ? just more ideas....please let us know what you find out, these 'little problems' can be real head scratchers !!

jay
A.Agiannidis



Joined: 04 Jun 2005
Posts: 2

View user's profile Send private message

PostPosted: Fri Jun 10, 2005 5:37 am     Reply with quote

Had a similar situation in the past. Check for some noise to your analog input pin. You will find that on a fast oscilloscope the level on the signal is not steady but in the form of a waveform. Find the period of that waveform and then instead of sampling one value , sample many times for that period. then average the values and you should see a steady, more realistic output. It is however, that you sample as long as the period. Otherwise, the non deterministic start of sampling would incur different results again.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Jun 10, 2005 6:10 am     Reply with quote

Are you reading just one channel or multiple one?
Did you verify that all Vdd's and Vss's are connected?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 10, 2005 1:08 pm     Reply with quote

Try the program shown below. This is a minimalist test program
which should work on your board. I tested it with a 16F877A on
my board, with a 1K trimpot connected to pin RA0, so I could vary
the voltage on RA0 between 0 and +5v. It worked fine.
Here is a typical output, with the trimpot left sitting in one position.
Quote:
0218
0218
0218
0219
0218
0218
0218
0218
0218
0217
0218
0218


Your version of the compiler does a have a bug. The startup code
sets the TRISA register to 0x00, so all Port A pins are outputs.
I had to put in a set_tris_a(0xFF) statement to fix this. Then I
was able to read the A/D without problems. But I think you are
already doing this.

Anyway, if the following program doesn't run OK on your board,
then I think you have a hardware problem. I tested it with your
version, PCM 3.213.

Code:
#include <16F876A.H>
#device adc=10
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

void main()
{
int16 result;

set_tris_a(0xFF);

setup_adc_ports(AN0);

setup_adc(ADC_CLOCK_DIV_8);

set_adc_channel(0);

while(1)
  {
   result = read_adc();
   printf("%lx\n\r", result);
   delay_ms(500);
  }

}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group