|
|
View previous topic :: View next topic |
Author |
Message |
Gerrit
Joined: 15 Sep 2003 Posts: 58
|
|
Posted: Mon Feb 23, 2004 5:01 pm |
|
|
PCM programmer,
that was my point of asking what the tru-put was without coverting and
sampling.
If AD is used and 10 bits are requiered than you could use a 3 byte
format for 2 channels with a STX character where the hig bit is set
and let the computer or other device do the conversion to what ever.
This could increse preformance by 100 - 200 %
Regards,
Gerrit |
|
|
pfo
Joined: 22 Feb 2004 Posts: 16 Location: vienna, austria.
|
|
Posted: Tue Feb 24, 2004 12:18 am |
|
|
i'm trying to sample a MMA series accelerometer, it has a refresh freq @ ~ 1KHz, and i want to oversample it, cause its quite noisy.
but i'm hardly ablue to got even to nyquist! |
|
|
Gerrit
Joined: 15 Sep 2003 Posts: 58
|
|
Posted: Tue Feb 24, 2004 2:36 am |
|
|
pfo,
Max speed rs232 at 115.2k =>
115200/10 = 11520 characters if you devide over two channels
5760 characters / channel if you use 2 bytes per sample
2880 samples/ channel are posible.
if you take 3 byte for two samples 2 x 10 bit + 3 bit for start recognition
11520 / 3 = 3840 sapmles per channel are posible.
If I look at last calculation you are way past you nyquist frequency
It will take good programming skills to pack and unpack the data on an
other device (PC or what ever)
Do you realy need this reaction speed of can you do analog filtering ?
what resolution do you need for AD?
Regards,
Gerrit |
|
|
Ttelmah Guest
|
|
Posted: Tue Feb 24, 2004 6:20 am |
|
|
pfo wrote: | i'm trying to sample a MMA series accelerometer, it has a refresh freq @ ~ 1KHz, and i want to oversample it, cause its quite noisy.
but i'm hardly ablue to got even to nyquist! |
You may be better to oversample in the PIC, and then send the average, rather than each sample in turn.
If you use something like:
Code: |
int16 valsum;
int16 val;
int8 ctr=0;
while (ctr++<16) {
delay_us(20);
valsum+=read_adc()
val=valsum>>4;
valsum-=val;
}
printf(bputc,"\r\n%lu",val;
|
You would have to modify this to do the two channels, but basically, it will take 16 readings at just over 20uSec intervals, and then print the average to the serial using the buffered output. This way your data rate required on the serial becomes acceptable, and the sampling interval is short.
Best Wishes |
|
|
pfo
Joined: 22 Feb 2004 Posts: 16 Location: vienna, austria.
|
|
Posted: Tue Feb 24, 2004 6:41 am |
|
|
Gerrit wrote: | pfo,
Max speed rs232 at 115.2k =>
115200/10 = 11520 characters if you devide over two channels
5760 characters / channel if you use 2 bytes per sample
2880 samples/ channel are posible.
if you take 3 byte for two samples 2 x 10 bit + 3 bit for start recognition
11520 / 3 = 3840 sapmles per channel are posible.
If I look at last calculation you are way past you nyquist frequency
It will take good programming skills to pack and unpack the data on an
other device (PC or what ever)
Do you realy need this reaction speed of can you do analog filtering ?
what resolution do you need for AD?
Regards,
Gerrit |
I need 10 bit mimimum resolution, i can't do analog filtering, because my pcb space is limitid and the application is overall very space constrained.
do you have any other hints? source code for linux rs232 communication and for the packing? wouldn't a compression yield better performance? |
|
|
pfo
Joined: 22 Feb 2004 Posts: 16 Location: vienna, austria.
|
|
Posted: Tue Feb 24, 2004 6:43 am |
|
|
Ttelmah wrote: | pfo wrote: | i'm trying to sample a MMA series accelerometer, it has a refresh freq @ ~ 1KHz, and i want to oversample it, cause its quite noisy.
but i'm hardly ablue to got even to nyquist! |
You may be better to oversample in the PIC, and then send the average, rather than each sample in turn.
If you use something like:
Code: |
int16 valsum;
int16 val;
int8 ctr=0;
while (ctr++<16) {
delay_us(20);
valsum+=read_adc()
val=valsum>>4;
valsum-=val;
}
printf(bputc,"\r\n%lu",val;
|
You would have to modify this to do the two channels, but basically, it will take 16 readings at just over 20uSec intervals, and then print the average to the serial using the buffered output. This way your data rate required on the serial becomes acceptable, and the sampling interval is short.
Best Wishes |
afaik that's not oversampling, because i throw away samples ... (_afaik_) |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Tue Feb 24, 2004 8:26 am |
|
|
You can do something like this and achieve resultes simular to an RC filter.
Code: |
set_adc_channel(0);
GO_DONE=1;
Analog_0_Work+=Analog_0_RAW;
Analog_0_Filtered=(Analog_0_Work>>2);
Analog_0_Work-=Analog_0_Filtered;
While(GO_DONE);
Analog_0_RAW=read_adc();
set_adc_channel(1);
GO_DONE=1;
Analog_1_Work+=Analog_1_RAW;
Analog_1_Filtered=(Analog_1_Work>>2);
Analog_1_Work-=Analog_1_Filtered;
While(GO_DONE);
Analog_1_RAW=read_adc();
|
If you call a function like this to sample the inputs many times faster than you report results you have over sampled and filtered. This will remove high frequency noise from most signals that should have a stable value. It also runs very fast. |
|
|
Ttelmah Guest
|
|
Posted: Tue Feb 24, 2004 10:34 am |
|
|
pfo wrote: | Ttelmah wrote: | pfo wrote: | i'm trying to sample a MMA series accelerometer, it has a refresh freq @ ~ 1KHz, and i want to oversample it, cause its quite noisy.
but i'm hardly ablue to got even to nyquist! |
You may be better to oversample in the PIC, and then send the average, rather than each sample in turn.
If you use something like:
Code: |
int16 valsum;
int16 val;
int8 ctr=0;
while (ctr++<16) {
delay_us(20);
valsum+=read_adc()
val=valsum>>4;
valsum-=val;
}
printf(bputc,"\r\n%lu",val;
|
You would have to modify this to do the two channels, but basically, it will take 16 readings at just over 20uSec intervals, and then print the average to the serial using the buffered output. This way your data rate required on the serial becomes acceptable, and the sampling interval is short.
Best Wishes |
afaik that's not oversampling, because i throw away samples ... (_afaik_) |
This is doing the basic 'throwing away' for you. Just taking more samples than needed, and throwing away some of them, is _not_ inherently oversampling. To oversample, you need to throw away parts of the sample, so that the significant data builds, while the noise gets rejected.
Best Wishes |
|
|
P_FO Guest
|
|
Posted: Tue Feb 24, 2004 10:43 am |
|
|
Ttelmah wrote: | pfo wrote: | Ttelmah wrote: | pfo wrote: | i'm trying to sample a MMA series accelerometer, it has a refresh freq @ ~ 1KHz, and i want to oversample it, cause its quite noisy.
but i'm hardly ablue to got even to nyquist! |
You may be better to oversample in the PIC, and then send the average, rather than each sample in turn.
If you use something like:
Code: |
int16 valsum;
int16 val;
int8 ctr=0;
while (ctr++<16) {
delay_us(20);
valsum+=read_adc()
val=valsum>>4;
valsum-=val;
}
printf(bputc,"\r\n%lu",val;
|
You would have to modify this to do the two channels, but basically, it will take 16 readings at just over 20uSec intervals, and then print the average to the serial using the buffered output. This way your data rate required on the serial becomes acceptable, and the sampling interval is short.
Best Wishes |
afaik that's not oversampling, because i throw away samples ... (_afaik_) |
This is doing the basic 'throwing away' for you. Just taking more samples than needed, and throwing away some of them, is _not_ inherently oversampling. To oversample, you need to throw away parts of the sample, so that the significant data builds, while the noise gets rejected.
Best Wishes |
how would the code for that look like? |
|
|
Ttelmah Guest
|
|
Posted: Tue Feb 24, 2004 11:12 am |
|
|
Er. That is what has allready been posted. The same algorithm, has also been posted again by another user.
The function behaves rather like a capacitive integrator.
Best Wishes |
|
|
pfo
Joined: 22 Feb 2004 Posts: 16 Location: vienna, austria.
|
|
Posted: Wed Feb 25, 2004 3:56 am |
|
|
Neutone wrote: | You can do something like this and achieve resultes simular to an RC filter.
Code: |
set_adc_channel(0);
GO_DONE=1;
Analog_0_Work+=Analog_0_RAW;
Analog_0_Filtered=(Analog_0_Work>>2);
Analog_0_Work-=Analog_0_Filtered;
While(GO_DONE);
Analog_0_RAW=read_adc();
set_adc_channel(1);
GO_DONE=1;
Analog_1_Work+=Analog_1_RAW;
Analog_1_Filtered=(Analog_1_Work>>2);
Analog_1_Work-=Analog_1_Filtered;
While(GO_DONE);
Analog_1_RAW=read_adc();
|
If you call a function like this to sample the inputs many times faster than you report results you have over sampled and filtered. This will remove high frequency noise from most signals that should have a stable value. It also runs very fast. |
what is the variable GO_DONE ? |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Wed Feb 25, 2004 9:18 am |
|
|
pfo wrote: | Neutone wrote: | You can do something like this and achieve resultes simular to an RC filter.
Code: |
set_adc_channel(0);
GO_DONE=1;
Analog_0_Work+=Analog_0_RAW;
Analog_0_Filtered=(Analog_0_Work>>2);
Analog_0_Work-=Analog_0_Filtered;
While(GO_DONE);
Analog_0_RAW=read_adc();
set_adc_channel(1);
GO_DONE=1;
Analog_1_Work+=Analog_1_RAW;
Analog_1_Filtered=(Analog_1_Work>>2);
Analog_1_Work-=Analog_1_Filtered;
While(GO_DONE);
Analog_1_RAW=read_adc();
|
If you call a function like this to sample the inputs many times faster than you report results you have over sampled and filtered. This will remove high frequency noise from most signals that should have a stable value. It also runs very fast. |
what is the variable GO_DONE ? |
I should have included a definition.
For the PIC18
Code: |
#define ADCON0 0xFC2
#bit GO_DONE = ADCON0.1
|
Setting this bit causes an analog conversion to occure. The bit is cleared when the reading is finished, 12 Tad later. This is a simple way to delay while the channel is being switched. Also during the delay work is being done. You can even service an interupt while waiting without adding time to the delay period. |
|
|
|
|
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
|