I was looking at other post and in the help sections.
Can anyone point me to some reading on the configuration settings for an ADC?
The Vref I understand, Speed and cycles is what I want to read up on.
Bob
Config settings for ADC
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Config settings for ADC
Hello Bob,
Conversion Speed is basically the program cycle speed divided by a fixed value, e.g. on a 8-bit PIC the program cycle speed is 1/4 of the crystal speed and then say Fosc/4 is again divided by 4.
The FRC option is a oscillator independent value designed to give you a nice ADC conversion at any speed. As this is RC based it will fluctuate slightly depending on temperature and pressure.
The ADC conversion speed dictates the maximum number of samples per second as well as the accuracy of the conversion.
The Aquisition time is basically the pre-charge time where we allow the internal ADC capacitor to charge before the ADC conversion is started. If too short a delay then ADC channels will start to bleed into each other. If too long then there are no serious consequences apart from reducing the number of samples per second. If you are only sampling a single ADC channel then this can be reduced without any problems.
The PIC device datasheet details both the conversion speed and acquisition timings for various clock speeds.
Detailed component help is available from here: http://www.matrixmultimedia.com/wiki/in ... Components
Conversion Speed is basically the program cycle speed divided by a fixed value, e.g. on a 8-bit PIC the program cycle speed is 1/4 of the crystal speed and then say Fosc/4 is again divided by 4.
The FRC option is a oscillator independent value designed to give you a nice ADC conversion at any speed. As this is RC based it will fluctuate slightly depending on temperature and pressure.
The ADC conversion speed dictates the maximum number of samples per second as well as the accuracy of the conversion.
The Aquisition time is basically the pre-charge time where we allow the internal ADC capacitor to charge before the ADC conversion is started. If too short a delay then ADC channels will start to bleed into each other. If too long then there are no serious consequences apart from reducing the number of samples per second. If you are only sampling a single ADC channel then this can be reduced without any problems.
The PIC device datasheet details both the conversion speed and acquisition timings for various clock speeds.
Detailed component help is available from here: http://www.matrixmultimedia.com/wiki/in ... Components
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 157
- Joined: Sat Jan 22, 2011 10:39 pm
- Location: Michigan
- Has thanked: 6 times
- Been thanked: 27 times
- Contact:
Re: Config settings for ADC
Ben,
Just what I needed.
Kind of thought that is what the settings were for.
Suggestion for the next release, In the picture I showed above, Place a ? or help box that would link to the proper place in the WIKI page you gave me the link for.
Save other users from trying to dig around for the correct information.
I am liking version 6 but the SIM runs way slow.
Bob
Just what I needed.
Kind of thought that is what the settings were for.
Suggestion for the next release, In the picture I showed above, Place a ? or help box that would link to the proper place in the WIKI page you gave me the link for.
Save other users from trying to dig around for the correct information.
I am liking version 6 but the SIM runs way slow.
Bob
- mikn
- Posts: 209
- Joined: Mon Mar 03, 2014 10:11 pm
- Has thanked: 54 times
- Been thanked: 41 times
- Contact:
Re: Config settings for ADC
If I need to capture analog signal from the microphone at 16khz which settings should be better for the adc component?
FC 6.1.3.2 (18.02.2016)
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Config settings for ADC
What chip are you using? On some 16 bit PICs you could use interrupts or even DMA to handle ADC. You will need an amplifier of some sort for a microphone. For example code on using interrupts combined with DMA to read at 20kHz you can check http://www.matrixmultimedia.com/article.php?a=688. (Uses dsPIC33FJ128GP802)mikn wrote: If I need to capture analog signal from the microphone at 16khz which settings should be better for the adc component?
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- mikn
- Posts: 209
- Joined: Mon Mar 03, 2014 10:11 pm
- Has thanked: 54 times
- Been thanked: 41 times
- Contact:
Re: Config settings for ADC
It's easier for me as I have working hardware with another firmware. Chip is pic24fj.
Just wondering if I am on the right way. Now I set up the timer to 8khz and capture the data with adc.GetByte function then write it to sd card as raw data.
But the problem for me now is that when I set timer frequency to 16 khz or more it freezes. Seems like adc overloads and stop the whole process. Tried to play with conversion speed and aquisition times, something changes but not much. I can't capture more than 8khz. Are there any tricks?
Just wondering if I am on the right way. Now I set up the timer to 8khz and capture the data with adc.GetByte function then write it to sd card as raw data.
But the problem for me now is that when I set timer frequency to 16 khz or more it freezes. Seems like adc overloads and stop the whole process. Tried to play with conversion speed and aquisition times, something changes but not much. I can't capture more than 8khz. Are there any tricks?
FC 6.1.3.2 (18.02.2016)
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Config settings for ADC
I suspect using ADC GetByte in an interrupt will consume too many cycles. GetByte waits the acquisition time (default 40 microseconds) for every sample you take. That means at 25000 samples a second (=1/40 microseconds) the controller does nothing besides waiting the acquisition time. If there is anything else in the interrupt routine that takes significant time all cycles will be spend handling the interrupt routine. When it is done with one interrupt the next will have occurred and no other code will get any cycles.
So basically I do not think using ADC GetByte is the right way to do this. I would look into configuring the ADC to continuously sample using a timer to determine the sample rate and use the ADC interrupt to get the data byte (if available on your controller).
What is the exact chip? Do you have the source of the other firmware?
BTW, quote about acquisition time from Bens message above:
So basically I do not think using ADC GetByte is the right way to do this. I would look into configuring the ADC to continuously sample using a timer to determine the sample rate and use the ADC interrupt to get the data byte (if available on your controller).
What is the exact chip? Do you have the source of the other firmware?
BTW, quote about acquisition time from Bens message above:
So you could reduce the 40 to something like 1. (Do not use 0)Benj wrote: If you are only sampling a single ADC channel then this can be reduced without any problems.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- mikn
- Posts: 209
- Joined: Mon Mar 03, 2014 10:11 pm
- Has thanked: 54 times
- Been thanked: 41 times
- Contact:
Re: Config settings for ADC
pic24fj64ga002What is the exact chip? Do you have the source of the other firmware?
No I don't have source for other firmware.
Yes, during playing with settings I did reduce to 1 and even to 0, it worked but again I could not raise interrupt frequency more than 8khz (well, actually I've tried 2khz, 4khz, 8khz, 16khz...)So you could reduce the 40 to something like 1. (Do not use 0)
Could you tell me more on this? Some example will be helpful, as I don't understand clearly how to do continuously sampling using FCkersing wrote:I would look into configuring the ADC to continuously sample using a timer to determine the sample rate and use the ADC interrupt to get the data byte (if available on your controller).
FC 6.1.3.2 (18.02.2016)
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Config settings for ADC
I don't think continues sampling can be done in FC without using C code icons. The general sequence would be something like:
Setup ADC1 to sample your input.
Set it to start sampling upon Timer 3 compare
Set it to generate an interrupt for every sample.
Add an custom interrupt handler to get the sample value from the ADC register
Setup timer3 for the required frequency.
Parts of the code can be borrowed from the example I referred to in my previous message.
I should have some time to create example code after next weekend, not before...
Setup ADC1 to sample your input.
Set it to start sampling upon Timer 3 compare
Set it to generate an interrupt for every sample.
Add an custom interrupt handler to get the sample value from the ADC register
Setup timer3 for the required frequency.
Parts of the code can be borrowed from the example I referred to in my previous message.
I should have some time to create example code after next weekend, not before...
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis