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 CCS Technical Support

Problem Migrating to 18F4620 from 18F458

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



Joined: 05 Sep 2007
Posts: 46
Location: Londrina - Brazil

View user's profile Send private message

Problem Migrating to 18F4620 from 18F458
PostPosted: Fri Jul 04, 2008 11:25 am     Reply with quote

Hi.

I have a big program (greater than 3000 lines of code) which was first created for 18F458 and works perfectly. It's a code for a weighting scale.

Now, I'm trying to migrate a 18F4620 with exactly the same code but the system doesn't work as expected.

When using the 18F458, the ADC results vary from 6000 to 50000 (correct and expected values). With 18F4620 the ADC results goes from 50 to 350 and sometimes the program freezes.
The PIC is interfaced to a TC520 from Microchip using 7 digital I/O pins.

I'v tried to disable almost everything in code and keep only the ADC initialization routine and ADC read routine, but didn't work.

My fuses config are:

Code:

#fuses HS, NOWDT, NOPROTECT, NOLVP, NOPUT, NOBROWNOUT


Using a 8MHz crystal (without PLL).

What can be the problem? Is there any kind of fuse that I have to set or unset?

Any help will be gratefull.
Thanks!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 04, 2008 11:27 am     Reply with quote

Post the compiler versions used for the first PIC, and for the 2nd PIC.
rhaguiuda



Joined: 05 Sep 2007
Posts: 46
Location: Londrina - Brazil

View user's profile Send private message

PostPosted: Fri Jul 04, 2008 11:37 am     Reply with quote

Sorry!!!

Compiler for both PICs: 4.017 PCH
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 04, 2008 11:53 am     Reply with quote

Use the following test program for the 18F548:
Code:

#include <18F458.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=8000000) 
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//=================================
void main()
{
int16 result;

setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_DIV_16);   // For 8 MHz osc
set_adc_channel(0);
delay_us(15);

while(1)
  { 
   result = read_adc();
   printf("%LX ", result);
   delay_ms(500);
  }

}


For the 18F4620, use the same program except change the ADC divisor
to this:
Code:
setup_adc(ADC_CLOCK_DIV_8);   // For 8 MHz osc


Post the results of the tests. (This assumes you're using ADC channel 0).
rhaguiuda



Joined: 05 Sep 2007
Posts: 46
Location: Londrina - Brazil

View user's profile Send private message

PostPosted: Fri Jul 04, 2008 12:00 pm     Reply with quote

Thanks for all help PCM Programmer

Sorry, I didn't explained well. I'm not using the PIC internal ADC, I'm using an external ADC (TC520 with TC500 both from Microchip).

Anything else that can be done?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 04, 2008 12:21 pm     Reply with quote

OK, I skipped over checking out the TC500 that you mentioned.
This is a 17-bit A/D. You didn't say what your input range is, but
with a 0 to 5v input, that's 38 uV per step. That's an incredibly low
level for a PIC circuit. It would require very, very careful PCB layout.

Did you build the board, or did you buy it ? If you bought it, post the
manufacturer and part number of the board.

Are you using the same board for these tests ? i.e., did you pull out
the 18F458 from a socket and substitute the 18F4620 ?
rhaguiuda



Joined: 05 Sep 2007
Posts: 46
Location: Londrina - Brazil

View user's profile Send private message

PostPosted: Fri Jul 04, 2008 12:40 pm     Reply with quote

PCM,

I'm using a 1V input range from a Load Cell Sensor. (7.62uV per step).

I've built the PCB. It's layout has been designed with lots of caution (including By-pass capacitors on all ICs, analod and digital grould planes and high speed circuitry away from low speed analog circuitry).

The basic schematic is: load cell sends signal to a instrumentation amplifier (AD620 from Analog Devices). It's gain is set to 120. Then this amplified signal is injected into the TC500 (17bit AD from Microchip). The TC520 is a serial adapter interface for TC500AD since TC500 does not have a serial interface for interfacing microcontrollers.

Anyway, I'm using the same board with both PICs. I did pull out the 18F458 from a socket and subtituite the 18F4620.
I have no idea or explannation on why the ADC changes its values so raddicaly....

P.S. Sorry about my english if anything is wrong or make no sense.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 04, 2008 12:52 pm     Reply with quote

At the end of this thread on the Microchip forum, they suggest that using the proper type of capacitor for Cint is very important:
http://forum.microchip.com/tm.aspx?m=30793&mpage=1
rhaguiuda



Joined: 05 Sep 2007
Posts: 46
Location: Londrina - Brazil

View user's profile Send private message

PostPosted: Sat Jul 05, 2008 2:10 pm     Reply with quote

Thanks PCM for your help.

I've adjusted the LOAD VALUE of TC520 and for now it's working, but a little different when the 18F458 was in place.
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