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

Multiple ADC - - - NEED HELP

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



Joined: 09 Sep 2003
Posts: 52

View user's profile Send private message MSN Messenger

Multiple ADC - - - NEED HELP
PostPosted: Wed Aug 06, 2003 11:31 am     Reply with quote

I am using PIC16F877 to do PID control. I have to use 2 ADC on channel 0 and channel 1. Channel 0 is for the Proportional manipulate variable, I use channel 1 as a setpoint.

How do you do ADC in multiple channel samutaneously?

Please Help!!
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516720
qm
Guest







Re: Multiple ADC - - - NEED HELP
PostPosted: Wed Aug 06, 2003 11:48 am     Reply with quote

:=I am using PIC16F877 to do PID control. I have to use 2 ADC on channel 0 and channel 1. Channel 0 is for the Proportional manipulate variable, I use channel 1 as a setpoint.
:=
:=How do you do ADC in multiple channel samutaneously?
:=
:=Please Help!!

You can use set_adc_channel(0) and set_adc_channel(1)
But remember to wait ~10us after each channel change.
(See the CCSC help on SET_ADC_CHANNEL)
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516721
Sherpa Doug
Guest







Re: Multiple ADC - - - NEED HELP
PostPosted: Wed Aug 06, 2003 12:47 pm     Reply with quote

:=I am using PIC16F877 to do PID control. I have to use 2 ADC on channel 0 and channel 1. Channel 0 is for the Proportional manipulate variable, I use channel 1 as a setpoint.
:=
:=How do you do ADC in multiple channel samutaneously?
:=
:=Please Help!!

With only one ADC you can only take one measurement at a time. The PIC16F877 only has one ADC and a multiplexer to switch the inputs. If your signal is slow enough you can interleave the two channels and treat them as if they were simultanious. Or you can interpolate one signal to see what it probably was when the other signal was converted. Or you can use a Sample & Hold circuit to store one signal untill you have time to convert it. Or you can buy two chips.

___________________________
This message was ported from CCS's old forum
Original Post ID: 144516722
Sherpa Doug
Guest







Re: Multiple ADC - - - NEED HELP
PostPosted: Wed Aug 06, 2003 12:48 pm     Reply with quote

:=I am using PIC16F877 to do PID control. I have to use 2 ADC on channel 0 and channel 1. Channel 0 is for the Proportional manipulate variable, I use channel 1 as a setpoint.
:=
:=How do you do ADC in multiple channel samutaneously?
:=
:=Please Help!!

With only one ADC you can only take one measurement at a time. The PIC16F877 only has one ADC and a multiplexer to switch the inputs. If your signal is slow enough you can interleave the two channels and treat them as if they were simultanious. Or you can interpolate one signal to see what it probably was when the other signal was converted. Or you can use a Sample & Hold circuit to store one signal untill you have time to convert it. Or you can buy two chips.

___________________________
This message was ported from CCS's old forum
Original Post ID: 144516723
cxiong



Joined: 09 Sep 2003
Posts: 52

View user's profile Send private message MSN Messenger

Re: Multiple ADC - - - NEED HELP
PostPosted: Thu Aug 07, 2003 6:14 am     Reply with quote

:=:=I am using PIC16F877 to do PID control. I have to use 2 ADC on channel 0 and channel 1. Channel 0 is for the Proportional manipulate variable, I use channel 1 as a setpoint.
:=:=
:=:=How do you do ADC in multiple channel samutaneously?
:=:=
:=:=Please Help!!
:=
:=With only one ADC you can only take one measurement at a time. The PIC16F877 only has one ADC and a multiplexer to switch the inputs. If your signal is slow enough you can interleave the two channels and treat them as if they were simultanious. Or you can interpolate one signal to see what it probably was when the other signal was converted. Or you can use a Sample & Hold circuit to store one signal untill you have time to convert it. Or you can buy two chips.
:=


When I use the code read_adc();
How do I know the result that this is result for channel0 and that is result for channel1.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516765
cxiong



Joined: 09 Sep 2003
Posts: 52

View user's profile Send private message MSN Messenger

Re: Multiple ADC - - - NEED HELP
PostPosted: Thu Aug 07, 2003 6:15 am     Reply with quote

:=:=I am using PIC16F877 to do PID control. I have to use 2 ADC on channel 0 and channel 1. Channel 0 is for the Proportional manipulate variable, I use channel 1 as a setpoint.
:=:=
:=:=How do you do ADC in multiple channel samutaneously?
:=:=
:=:=Please Help!!
:=
:=You can use set_adc_channel(0) and set_adc_channel(1)
:=But remember to wait ~10us after each channel change.
:=(See the CCSC help on SET_ADC_CHANNEL)


When I use the code read_adc();
How do I know the result that this is result for channel0 and that is result for channel1.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516769
qm
Guest







Re: Multiple ADC - - - NEED HELP
PostPosted: Thu Aug 07, 2003 11:42 am     Reply with quote

:=:=:=I am using PIC16F877 to do PID control. I have to use 2 ADC on channel 0 and channel 1. Channel 0 is for the Proportional manipulate variable, I use channel 1 as a setpoint.
:=:=:=
:=:=:=How do you do ADC in multiple channel samutaneously?
:=:=:=
:=:=:=Please Help!!
:=:=
:=:=You can use set_adc_channel(0) and set_adc_channel(1)
:=:=But remember to wait ~10us after each channel change.
:=:=(See the CCSC help on SET_ADC_CHANNEL)
:=
:=
:=When I use the code read_adc();
:=How do I know the result that this is result for channel0 and that is result for channel1.


You could use code like this:

long channelzero, channelone;
set_adc_channel(0);
delay_us(10);
channelzero = read_adc();
set_adc_channel(1);
delay_us(10);
channelone = read_adc();

You could also use a function like this:
long readchannel(int channel) {
set_adc_channel(channel);
delay_us(10);
return read_adc();
}

depending on how often you switch channels, the delay_us(10) may not be necessary.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516787
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