Hello,everybody.Would you please answer to the following questions;
1.What is the difference between these two instructions;
[unsigned ADC_Get_Sample(unsigned short channel);] & [unsigned ADC_Read(unsigned short channel);] ?
2.Is there the instruction;[unsigned ADC_Get_Sample(unsigned short channel);] having to do
with [and related to] oversampling technique ?
Thanks,
ADC library of mikroC PRO for PIC v.5.30 questions???
Re: ADC library of mikroC PRO for PIC v.5.30 questions???
@bobx
You are using V5.3 which is the very lates verion is there a specific reason why you are posting in the mikroC compiler section and not in the mikroC Pro section
this forum is for the old non Pro verions
You are using V5.3 which is the very lates verion is there a specific reason why you are posting in the mikroC compiler section and not in the mikroC Pro section
this forum is for the old non Pro verions
P.Erasmus
Saratov,Russia
--------------------------------------------------------------
Saratov,Russia
--------------------------------------------------------------
Re: ADC library of mikroC PRO for PIC v.5.30 questions???
Hello,p.erasmus.
My reasons are;1. I want to write a program and 2. to higher my ADC reading
accuracy from 10-bit[18f8722] into 12-bit or 16-bit?
Thanks,
My reasons are;1. I want to write a program and 2. to higher my ADC reading
accuracy from 10-bit[18f8722] into 12-bit or 16-bit?
Thanks,
Re: ADC library of mikroC PRO for PIC v.5.30 questions???
Well being sarcastic wount bring you any help and secondly it does not change the fact that you post in the in correct forum!bobx wrote:My reasons are;1. I want to write a program and 2. to higher my ADC reading
P.Erasmus
Saratov,Russia
--------------------------------------------------------------
Saratov,Russia
--------------------------------------------------------------
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: ADC library of mikroC PRO for PIC v.5.30 questions???
Hello,
Please check the help file for more details.
ADC_Read() function will initialize ADC module and read single value from selected channel.
ADC_Get_Sample() will only read selected channel, and you will need to initialize module prior calling this routine.
Best regards.
Please check the help file for more details.
ADC_Read() function will initialize ADC module and read single value from selected channel.
ADC_Get_Sample() will only read selected channel, and you will need to initialize module prior calling this routine.
Best regards.
-
- Posts: 111
- Joined: 25 Nov 2011 09:52
Re: ADC library of mikroC PRO for PIC v.5.30 questions???
I've been trying to get one question answered, that doesn't seem to be covered anywhere else:janko.kaljevic wrote:Hello,
Please check the help file for more details.
ADC_Read() function will initialize ADC module and read single value from selected channel.
ADC_Get_Sample() will only read selected channel, and you will need to initialize module prior calling this routine.
Does the ADC_Init() have to be called prior to each ADC_Get_Sample()? Or is one ADC_Init() sufficient, and calls to ADC_Get_Sample can occur anytime?
I've seen a description of starting a read in the interrupt routine, then reading the result in a future interrupt. But I haven't seen this well described anywhere. Is that using an ADC_Init(), then using an ADC_Get_Sample later? Is the ADC_Get_Sample fast enough to use in an interrupt routine?
I don't really want to try to learn this by trial and error, as I may not get a definitive answer.
Thanks.
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: ADC library of mikroC PRO for PIC v.5.30 questions???
Hello,
If you want to use ADC_Get_Sample function, you only need to call ADC_Init once before you begin to read ADC.
Yes, you can use ADC_Get_Sample in interrupt routine.
Best regards.
If you want to use ADC_Get_Sample function, you only need to call ADC_Init once before you begin to read ADC.
Yes, you can use ADC_Get_Sample in interrupt routine.
Best regards.
-
- Posts: 111
- Joined: 25 Nov 2011 09:52
Re: ADC library of mikroC PRO for PIC v.5.30 questions???
Thank you. But just a reality check: It seems like I'm missing something that everyone else sees but me.
Why do all the sample code listings I see use ADC_Read() in their loops? Doesn't that take a lot more time? Why don't they just use ADC_Init() once, then just get samples from then on? Is there something wrong with this approach that I'm missing? It seems to me like ADC_get_sample() is the only correct way to read the ADC. I would think that the only use of ADC_Read(), is if you didn't want to write a 2nd line of code and didn't care that the procedure was going to wait for 12 TAD and hold up your program until the ADC returned your value.
Also, the code I'm working with (which I inherited from someone else) goes like this:
My processor has 10 bit ADC precision. Is there some case where ADC_Read() can give a value larger than 10 bits? It seems like the check is completely unneeded. But the guy that wrote the program wasn't a dummy or anything, so I'm wondering if there's some way that the ADC_Read instruction can give a larger number, perhaps as an error condition or something. I don't see anything in the manual or help about it.
Why do all the sample code listings I see use ADC_Read() in their loops? Doesn't that take a lot more time? Why don't they just use ADC_Init() once, then just get samples from then on? Is there something wrong with this approach that I'm missing? It seems to me like ADC_get_sample() is the only correct way to read the ADC. I would think that the only use of ADC_Read(), is if you didn't want to write a 2nd line of code and didn't care that the procedure was going to wait for 12 TAD and hold up your program until the ADC returned your value.
Also, the code I'm working with (which I inherited from someone else) goes like this:
Code: Select all
adc_rd = ADC_Read(0)
if (adc_rd > 1024) then
adc_rd = 0
end if
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: ADC library of mikroC PRO for PIC v.5.30 questions???
Hello,
ADC_Read() is function that you can use at any time to obtain result from AD converter.
But if you want to use it constantly use ADC_Get_Sample.
There is no need for this if check. Result will never be larger than 1024.
Best regards.
ADC_Read() is function that you can use at any time to obtain result from AD converter.
But if you want to use it constantly use ADC_Get_Sample.
There is no need for this if check. Result will never be larger than 1024.
Best regards.
-
- Posts: 111
- Joined: 25 Nov 2011 09:52
Re: ADC library of mikroC PRO for PIC v.5.30 questions???
Ok, thanks a lot. I was having trouble finding answers to those questions. I appreciate it.