Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC A/D Converter

Status
Not open for further replies.
Mike,

Can you provide a drawing of the waveform (e.g. from a DSO/CRO) you are monitoring? Is it anything like the waveforms here https://www.bem.fi/book/19/19.htm ?

The spike is quite narrow; is it possible that you will miss the part of the signal that you wish to capture by sampling at such a low rate? If you are missing the peaks, then you can just increase the sample rate of your ADC and perform the hysteresis or blanking in software.
 
That is exactly the shape of the peaks i am receiving at the input of the A/D converter, i think the best bet will be to 'over-sample' ( use a higher than necessary conversion rate) then use the software to scale down (blank) the answer by whatever factor is necessary, ive just calculated that with a fosc of 2MHz and, a A/D clock conversion of fosc/2 i should be converting at a rate of 1us. the duration of the peak is said to be around 0.08, which makes my rate of sampling still very fast. ill probably use a nested loop and the GO/DONE pin to slow it down more so that i am not adjusting from such a large value that i need to consider a large value stored across anything larger than an 8bit register
 
Why don't you sample at a constant rate set by one of the hardware timers? The ECCP2 special trigger can be used to trigger conversions in the background without wasting CPU cycles; you just need to check the GO/DONE flag for conversion completion (see section 20.6 of the family datasheet (above)). You can then use a state machine (incl. hys./blanking/noise-removal/etc.) or filter etc. as required to get the appropriate information from the sample stream.
 
However i am having trouble setting up the register. i want the A/D converter to sample every 0.12 seconds (Max), and my micro has a clock frequency of 8MHz. How does that relate to the

"TAD"
and
"ADCS" bits shown in the attached file (data sheet screen shot).

I'm a bit late to this party but I think there has been some confusing (if interesting) discussion in this thread.

Put simply the acquisition time is probably not what you are looking for. As suggested in this thread you should simply setup a timer to interrupt you N times a second which can start the acquisition using the GO/DONE bit. At a rate of less than ten samples per second (0.12s max) with your slow moving signal this should be adequate.

If you are short on processor cycles you can use some of the advanced CCP module features to do this automatically in the background, but this does not seem necessary given your current requirements.

If you still have problems with hysteresis, the impedance of your input signal or you want to switch ADC channels then you can start adjusting TAD and ADCS as required. But again this is most likely not what you need right now.
 
I'm a bit late to this party but I think there has been some confusing (if interesting) discussion in this thread.
Yes, all the pretty girls are taken and someone's peed in the punch bowl.
At a rate of less than ten samples per second (0.12s max) with your slow moving signal this should be adequate.
Except that the QRS part of the wave is generally less than 100ms, meaning that it's very likely that pulses will be missed with such a low sample rate.
ref : normal+ecg.jpge_parts.gif
https://www.cvphysiology.com/Arrhythmias/ECG trace with grid.gif
If you are short on processor cycles you can use some of the advanced CCP module features to do this automatically in the background, but this does not seem necessary given your current requirements.
It is probably the most logical method of triggering acquisition though. It's very simple, runs in the background and doesn't affect program flow.
 
If it was me, I would first amplify the signal with an instrumentation amp, and perhaps filter the signal with a high pass filter (perhaps followed by more amplification). I would then use an external comparator (or find a PIC with one inbuilt) and add some hystersis, this should be easily done if your signal is now in order of hundreds of millivolts or more.

Use a DAC or potentiometer to set the threshold (DAC would be nicer, you could make an algorithm that hunts for a typically valid range of count values), others in this thread have discussed internal PIC comparators.

Feed the output of the comparator into a Timer clock. On another timer, set it to generate interrupts every second (or time period of interest). On every interrupt, read the value of the externally clocked timer, reset it 0, and update the count value as displayed on the LCD, or output a new value over serial or whatever.

If you are trying to discriminate or sample a signal in the order of 1 millivolt, your gonna have a bad time! Google ECG instrumentation amplifier, it should start you down a proven path that others have taken.
 
Sorry for my absence guys guess the party is all warmed up..

i actually already have (in a matter of speaking) done exactly what Rich said, the electrodes reading the heart beat were connected to the chest at one end and instrumentation amplifier at the other, the output of which was input to a bandpass filter, this was subsequently input to the microcontroller through the pics onboard comparator

the comparator exhibited multiple transitions for each input of the above threshold (the R portion of the cardiac waveform) so hysteresis was introduced.
Hysteresis failed to lower the output fluctuations to a level that was consistant (such that it could be eliminated through code) though the bounce was reduced.

i am positive the hysteresis values were correct because i simulated them in LT spice transient analysis and it shows the two distinct thresholds
Untitled.png

so yes, i can get the cardiac waveform but cant get the input to the pic such that i can receive a meaningful digital pulse in order to continue calculations.

Timers are a good way to go initially i was going to use the ECCP module but it turns out it is not supported MPSim for this family of devices.

:)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top