ADC For A Sine Wave. - S08QE128

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC For A Sine Wave. - S08QE128

3,467 Views
FWFan
Contributor III
Hi All,
 
I am new to firmware.  I'm trying to capture a sine wave from my filter using the ADC on my
QE128 demo board.  It has an 8 bit processor (S08QE128).  Do you guys have any suggestions or codes (C or assembly) ?  Something that I can try to immitate?  This board also has the capability of switching to the V1 ColdFire.
 
Thank you in advance.
FWFan
 
 
 
Added p/n to subject.


Message Edited by NLFSJ on 2008-09-04 02:16 PM
Labels (1)
0 Kudos
8 Replies

597 Views
Ake
Contributor II
Hi,
What do you want to measure? Is it the amplitude of the sine wave or is is the frequency? Or both?
What frequency has the input signal? If it is slow enough, the ADC can measure it.
Does the AC signal have a DC component, or is the AC signal symmetric round ground.
If it doesn't, a high-pass AC filter must be installed. The high-pass frequency must be low enough  not to affect the AC signal.
An alternative is to use an active "diod" which will remove the negative pulses.
 
If the AC signal is too high for direct measurement, an active low pass- or peak filter must be used.
The low pass/peak filter could have a bleeder resistor, so that if the signal drops, the filter output will drop.
The other way is to include a "reset" input to the filter, so after each measurement, the filter is reset, and can then measure the maximum input voltage.
If a reset function is used, the filter must run for at least 1/f seconds before the ADC is started.
 
Regards,
Ake
0 Kudos

597 Views
FWFan
Contributor III
Hi Ake,
 
I'm trying to measure the amplitude only.  The center frequency of this analog bp filter is 360 Hz only.  I like to sweep it from 50 to 500 Hz.  I figure I can capture the adc samples and compare it to the center amplitude and light up an LED or write something to the 7-seg. LED.  It does have a DC offset.  Actually, I think my offset is too high right now.  I have to redesign this filter.  My demo board (DEMOQE128) has a fixed VREFH of 3.1 V I think.  I'll get back with you later when I got things corrected. 
 
Basically, I am trying to write some ADC C code to capture the amplitude of this filter.
 
Thanks,
FWFan
0 Kudos

597 Views
Ake
Contributor II
Hi,
If you want to measure the ampliture of an AC signal, you can do it it in two ways:
 
1) You can measure the AC signal several time, and set the maximum value as the Vpeak voltage.
 
2) You can add external components to get the Vpeak value. The simplest is a diod and a capacitor, but then you will get a Vpeak = 0, signal for any input voltage under 0.7 V.
So I would recommend an opamp connected as a ideal diod.
 
Note that this is for measuring the amplitude (V) of the signal.
 
But if you want to measure the frequency (Hz), use the TPM instead.
It sounds like that is more what you are interested in.
 
If the signal is a sine wave and you want to measure the frequency, just make it a square wave, by amplifying it and cut the Vpeak voltage to Vdd.
 
If you feed the sinus wave into the TPM pin, you might get false triggering when the signal passes from 0 to 1 and the other way.
 
Regards,
Ake
0 Kudos

597 Views
FWFan
Contributor III
Thanks Ake.
 
I was thinking about using the diode to rectify the signal.  But I want to practice capturing the sine wave, because later I may do direct DSP on the ac wave.  But for now I may rectify the signal as you suggest.
 
If I decide to do the ac input, can I just input the signal directly onto one of the adc inputs?  I tried that over the weekend and I didn't see any reaction.  My peak is only 1.33 V and the Vpp is about 0.200 V.  This is a sine wave.  The demoboard has 3.00 V as the VREFH.
 
Also, can I save these samples into the RAM area?  Or should I?  Sorry, I'm new to the micro world.
 
Thanks,
FWFan 
0 Kudos

597 Views
bigmac
Specialist III
Hello,
 
To directly derive the peak-to-peak voltage, you would need to apply DC offset to the input waveform, usually one half the Vdd supply.  This might require the use of an op amplifier buffer, to easily provide the offset.  You might also need to AC couple the signal, prior to the application of the offset.
 
With a maximum input frequency of 500 Hz your sampling rate would need to be quite high to measure the positive and negative peaks (maxima an minima) to within 1 LSB of whatever ADC resolution you have chosen.  To achive this accuracy within one cycle, for 10-bit accuracy you are likely to need 100 samples per cycle, or the processing of a reading every 20 microseconds.
 
If your input waveform is always sinusoidal, an alternative approach might be to measure the half-period of the signal (between "zero crossings" ), from which you could derive the time when the signal should be at its maximum and minimum, requiring only two samples per cycle.  For the half-period measurement, you might make use of one of the comparator modules, with the output of the comparator then fed to one of the TPM channel pins, for input capture operation.
 
Regards,
Mac
 


Message Edited by bigmac on 2008-09-09 02:26 AM
0 Kudos

597 Views
FWFan
Contributor III
Hi bigmac,
 
I do have a dc offset of 1.1V and the Vpp is 0.2V.  My VREFH is 3.00V.  Do you think I should change it to 2.00V?  I'm limited to these two options with the DEMOQE128 board.
 
I may also try the TPM method as you suggested.
 
Thanks,
FWFan
0 Kudos

597 Views
bigmac
Specialist III
Hello,
 
Your bias voltage should be OK, and you would slightly increase the sensitivity of the measurement with the lower reference voltage.  However, the applied peak-peak voltage swing is a little low for good accuracy and resolution.  Assuming this is close to the maximum level that you require to measure, you would benefit from the use of an external amplifier with a gain of about 8, to produce a peak swing of +/- 0.8 volt, relative to the 1.1 volt bias level.  Using the 3.0 volt reference, the amplifier gain could be increased to 10.
 
Regards,
Mac
 
0 Kudos

597 Views
FWFan
Contributor III
Hi Bigmac,
 
I've got the offset at around 1.1 V and the swing to be 0.8 Vpp.  I've managed to get an array of 128 bytes
of 8bit ADC readings.  I've used the RAM address 0x0080 to store the values.  But for some reason, I cannot save 256 bytes.  I'm trying to save 2^N bytes of ADC values.  Do you have any suggestion?
Also, can I store my values at any address in the PPAGE (Paging Window) flash memory?
 
Thank you,
FWFan
0 Kudos