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

data acquisition with CCS,first topic help please

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



Joined: 10 Apr 2007
Posts: 18

View user's profile Send private message

data acquisition with CCS,first topic help please
PostPosted: Tue Apr 10, 2007 8:11 am     Reply with quote

hi everyone,as u can see i'm a new member and a beginner in pic C programming,so i hope that you can help me and be patient with me!!! Embarassed
i want to realize the circuit shown in the picture below,using the pic18f8722
and the DAC08( digital to analog converter),the tranmitted signal must vary from 0x00 to 0xff.
1-my first question is how can i introduce the pic18f8722 in my CCS cause i it doesn't exist even in the last version (i have 3.43 ide version pcwh)??
2-can i get the 04 analog signal from my circuit at the same time??and how?
i'm trying to do something like tath

#include<pic18f8722.h>
#include<stdio.h>
#use delay (clock=20000000)
void main ()
{
setup_adc_port_A(allanalog);
setup_adc(ADC_CLOCK_INTERNAL );
set_adc_channel(0)
unsigned char dsignal=0;
float rcv0[256],rcv1[256],rcv2[256],rcv4[256]
SET_TRIS_F(0x00); //put the prot F as digital output
while (1)
{
PORTF=dsignal++; // output digital signal

if(dsignal==0xff);
{
dsignal=0;
}

delay ms(100);
rcv0=read_adc(A0) // here i don't know if 'im right but i wanna do something
rcv1=read_adc(A1) // like that and after to store all the values taht i get
rcv2=read_adc(A2) //
rcv4=read_adc(A4) //
}



thanks a lot[/img]


Last edited by TheBeginner on Tue Apr 10, 2007 8:26 am; edited 1 time in total
TheBeginner



Joined: 10 Apr 2007
Posts: 18

View user's profile Send private message

PostPosted: Tue Apr 10, 2007 8:23 am     Reply with quote

sorry here it is the circuit
TheBeginner



Joined: 10 Apr 2007
Posts: 18

View user's profile Send private message

PostPosted: Tue Apr 10, 2007 10:45 am     Reply with quote

please i need your help
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 10, 2007 12:10 pm     Reply with quote

Quote:

1-my first question is how can i introduce the pic18f8722 in my
CCS cause i it doesn't exist even in the last version (i have 3.43 ide version pcwh)??

What is the compiler version ? The IDE version is not the compiler
version. See this post for ways to find the version.
http://www.ccsinfo.com/forum/viewtopic.php?t=25939&start=2
TheBeginner



Joined: 10 Apr 2007
Posts: 18

View user's profile Send private message

PostPosted: Tue Apr 10, 2007 2:46 pm     Reply with quote

okey i've resolved my first question to buy the last version 4.013 which contains the pic18f8722
what about the second ????
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 10, 2007 4:08 pm     Reply with quote

After you setup the A/D port(s) and setup the A/D, then you can
sequentially read each A/D channel. You select the channel, wait
for a short delay time and then read the channel.

Also, the output of the A/D is either an 8-bit or a 10-bit unsigned integer.
It's not a float. If you want the 10-bit result, you have to tell the compiler
to do this with a "#device adc=10" statement. You also have to store the
10-bit result in a 16-bit variable.

Code:
int16 result0, result1;


Code:
set_adc_channel(0);
delay_us(20);
result0 = read_adc();

set_adc_channel(1);
delay_us(20);
result1 = read_adc();

Etc.
TheBeginner



Joined: 10 Apr 2007
Posts: 18

View user's profile Send private message

PostPosted: Tue Apr 10, 2007 4:17 pm     Reply with quote

thanks a lot for your help man,but here if i do" int8 result0,result1 " i will have only one value for the" result0 and result1" ,i need to get 256 times the data from channel0 (for exemple)
can i do something like that

int8 result0[256],result1[256]
.
.
.
.result0=read_adc
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 10, 2007 4:33 pm     Reply with quote

Use a for(;;) loop to cycle through indexes of 0 to 255 in your arrays.
TheBeginner



Joined: 10 Apr 2007
Posts: 18

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 1:40 pm     Reply with quote

PCM programmer wrote:
Use a for(;;) loop to cycle through indexes of 0 to 255 in your arrays.

and after how can i refind my 256 values in the arrays
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 1:58 pm     Reply with quote

Why do you want to store 256 A/D values in an array? That will chew up a lot of RAM space. Your PIC has enough space though most PICs don't. If you are simply taking an average you can just keep a sum as readings are taken. You have time to do some math while waiting for the A/D to take its readings.
_________________
The search for better is endless. Instead simply find very good and get the job done.
TheBeginner



Joined: 10 Apr 2007
Posts: 18

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 3:03 pm     Reply with quote

i'm not taking a average,i need the 256 a/d values from four chaneels to post them in a graphe (such as I=f(V) ),so i gotta to store them and after to post them by using an LCd
thanks very much for your help
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 3:20 pm     Reply with quote

If you want to loop through all 256 elements of the arrays and display
the contents, here is one way to do it:
Code:
#include <18F452.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//==================================
void main()
{
int8 result0[256];
int8 result1[256];
int8 i;

i = 0;
do{
   printf("address:%u result0:%u, result1:%u \n\r",
           i, result0[i], result1[i]);
  }while(i++ != 255);

while(1);
}
TheBeginner



Joined: 10 Apr 2007
Posts: 18

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 4:46 pm     Reply with quote

sorry but what do you mean by adress
thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 4:51 pm     Reply with quote

'address' was just another name for the array index, or the position
within the array.
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