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

1us ADC samples

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



Joined: 06 Dec 2015
Posts: 42

View user's profile Send private message

1us ADC samples
PostPosted: Tue Jan 26, 2016 3:58 am     Reply with quote

Hi,
I am not a good programmer and new in C but I have a question. I want to take 80 samples for every 1us at AN0 after pin C1 goes HIGH. Therefore the values will be in array of 80 elements. Then I need to get the time value which the maximum values occurs at AN0 during the period and store the value. Using the stored timing value I need to retrieve the value and use it as delay to trigger pin C4 to HIGH when start button is pressed at pin C2. I am using dspic30f6014a with 20MHz oscillator. Is it possible to get values in ADC for every 1us? Any links which I can use as reference? Really need advice from the experts.
Ttelmah



Joined: 11 Mar 2010
Posts: 19516

View user's profile Send private message

PostPosted: Tue Jan 26, 2016 4:06 am     Reply with quote

No.

Beyond the speed capability of the chip or the ADC.

The fastest this chip can sample is 200ksps (5uSec per sample), and this has specific requirements (must be using external Vref).
Data sheet specifies how this can be done.
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jan 26, 2016 6:35 am     Reply with quote

If I'm reading your post correctly you want to take 80 ADC samples and then use the maximum ADC reading as a 'delay' to trigger C4.
If this is true thers' no need to store an array of data, simply test the ADC reading. If reading > last one, save as 'ADC_max'. Once all 80 have been read, 'ADC_max' contains biggest ADC value.

I have to ask what are you trying to measure? 80 samples within a 1us time frame is really fast (80MHz ??)! No PIC I know can do it. Or...do you mean 1 sample per 1us (1 MHz)?, which is 80 x slower, though not sure a PIC can do that either.

Perhaps telling us more what you want, we can help you better. I know English is a hard language to master, even after 60+ years I don't say things right !

Jay
arelone



Joined: 06 Dec 2015
Posts: 42

View user's profile Send private message

PostPosted: Wed Jan 27, 2016 1:34 am     Reply with quote

Hi,

Sorry for the bad english I have. Thank you Ttelmah for the answer. Actually I want to make a calibration program for ultrasonic transducers. Currently I perform the calibration in manual way by means I obtained the observation time (ts) using the oscilloscope. There are 144 observation times and I have to do it manually. That's really a tedious job. What I am thinking is to create a program and using the dspic30F to perform the calibration tasks. The calibration will execute in sequential fashion. For example the theoretical values of ts for receiver at sensor#1 is 45us, sensor #2 is 76us. The ts is measured at the time transmitter signal starts send a pulse signal to the receiver. Receiver circuit is connected with the sensor#1 and the output is connected to AN0. Sensor#2 is connected to AN1. The ADC at AN0 will read the maximum values in period of 0-50us then stop. Then the transmitter send a signal again and AN1 will read maximum values in the period of 0-80us. This process is repeated till sensor#16. The time when the max value occurs is stored in a memory which can be obtained when I want to perform measurements. Let the recorded ts#1 for sensor#1 is 47us and ts#2 is 79us for sensor#2. These timing values will be used as delay when performing measurements. For the time being that is what I am thinking to do. If anyone have better ideas then mine please share.

Thank you
newguy



Joined: 24 Jun 2004
Posts: 1908

View user's profile Send private message

PostPosted: Wed Jan 27, 2016 7:46 am     Reply with quote

If all you're trying to do is measure the time delays, then using the A/D is a bad approach to the problem. A PIC can measure analog voltages but it isn't good at measuring analog voltages quickly.

You should instead route the received signal to a comparator (either external to the PIC or built-in), and then you can measure/trigger off of the time when the signal goes high (assuming the output level is sufficient to saturate the comparator). You can very accurately measure times with a PIC....play to its strengths.
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jan 27, 2016 9:14 am     Reply with quote

I'm with newguy here ! You'll get better reading but....
be sure your analog wiring is done right! Proper grounds,quiet power feeds,filtering for HF, etc. are all important in getting a good reliable results.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19516

View user's profile Send private message

PostPosted: Wed Jan 27, 2016 11:26 am     Reply with quote

He posted before in another thread, and appears to be trying to find the peak return pulse by doing successive ADC readings. I pointed out then that he really needs hardware to return the 'envelope' of the signal being returned, rather that trying to do this on the data directly.
arelone



Joined: 06 Dec 2015
Posts: 42

View user's profile Send private message

PostPosted: Sat Jan 30, 2016 2:56 am     Reply with quote

Hi,

Thanks for all the suggestions. From the answers clearly I need to make some modifications in my circuits i.e the peak detector, threshold and S&H etc. I am working with it now. Will update with you guys when I completed.

Thank you
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