Troubles with Sigma-Delta ADC
slosjo
Posts: 25
Hello all-
I am trying to implement a Sigma-Delta ADC object into my code.· After I call the ADC object, I am using PropTerminal to monitor·a variable being set by the ADC.· The results are not what they should be and·I'm not sure what I am doing wrong or weather it is a software or hardware issue.· If anyone is interested in offering up some advice, let me know and I will send you my code and/or elaborate more on my problem.·
Thanks
·
I am trying to implement a Sigma-Delta ADC object into my code.· After I call the ADC object, I am using PropTerminal to monitor·a variable being set by the ADC.· The results are not what they should be and·I'm not sure what I am doing wrong or weather it is a software or hardware issue.· If anyone is interested in offering up some advice, let me know and I will send you my code and/or elaborate more on my problem.·
Thanks
·
Comments
Thanks
Thanks
Post Edited (slosjo) : 9/21/2007 6:36:38 PM GMT
Try slowing everything down. Instead of using an 80MHz clock, try a 40MHz clock, then a 20MHz clock, etc. by changing _clkmode to pll8 or pll4, etc. If the problem is noise or reflections, etc., slowing down the clock should help. The serial debug routines should adjust their timing since the clkfreq function is normally used to calculate timing for drivers that are speed dependent.
What is the resistance of your pot?· It need to be much smaller that 150k...
Post Edited (Rayman) : 9/21/2007 7:27:15 PM GMT
You're not going to get a range from 0 to 3.3V. Actually, 0.4 to 2.9 sounds pretty good. Don't forget that the output (feedback) pin doesn't really switch from 0 to 3.3V. There are some voltage drops in the output switching transistors. If it's important to get a wider range, you could use an op-amp on the input to the ADC with an offset of about 0.4V and less than unity gain. That would transform a range of 0-3.3V to something more like the 0.4-2.9V that the ADC can handle.
The ">> 8" I suggested before was based on your using 14 bit resolution and was just a way to focus on the significant bits (given the noise involved). You could leave out the shift entirely if you think the numbers you're seeing are valid.
I'd posted a circuit analysis for Prop Sigma-Delta at
this link.
It might help with the choice of resistors for the range.
With 100k for feedback and 150k for input, and a prop threshold of 1.65 volts nominal, the range calculated range should be a count of 68 at 2.8 volts input up to a count of 191 at 0.4 volts input.
count = (2^bits) * (1.65*(R1+R2) - (R2 * Vin)) / (3.3 * R1)
R1=input ohms
Vin=input voltage
1.65=threshold voltage
3.3=Vdd-Vss
bits=bits in result, eg WAITCNT N=256 cycles for 8 bit result
count= change in phsx register in N cycles, result.
I don't know why you're only seeing 20 to 70. You asked if you should be "doing x := getvalues.read1 >>2 ?". I don't think so. Why?
P.S. Edited it to use the names stated. I had first posted it with cell references from an Excel spreadsheet. As Mike points out, the result depends too on the drive capabilities of the totem pole output transistors and on the exact threshold level of the input transistors.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 9/21/2007 11:50:30 PM GMT
-Phil
Initial efforts, bad results halfway down the thread, Chip is puzzled too.
Chip got it working!
The ADC circuit on the new demo board reflect those insights.
Remember too that the sigma-delta technique causes the input pin to hover exactly at its input threshold. Both input transistors are partly turned on. According to Chip, the input transistors have a relatively small geometry, and by my measurement the totem pole current due to them hovering at threshold is around 1 or 1.5 milliamps. That fluctuates wildly as the sigma-delta action is taking place, alternately driving the pin just below and just above threshold. That is another reason to to pay close attention to the layout, and that is especially true when the clock frequency is high.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I just read Chip Gracey's example about Sigma Delta ADC conversion and he said that he used surface mount components extremely close to the pins. Has anyone done a successful sigma delta using the holes surrounding the·propeller·on the prototype board to connect their inputs and capacitors? If so, please elaborate on the specifics of your connections because I am having troubles with mine and still getting very unstable results.
Thanks
Post Edited (slosjo) : 9/24/2007 1:32:40 PM GMT
Maybe using a "real" comparator rather than a Prop pin will improve things much (reasons for this given by Tracy)
Absolutely stable power supply is a "must": Do you have at least 200nF close at the Prop power pins?
deSilva => "Absolutely stable power supply is a "must": Do you have at least 200nF close at the Prop power pins?"
Are you referring to the caps I described above, connected to the analog input pin?
Output/direction signals for pins 0-15 run right-to-left on the die, going through OR gates beginning with Cog7 and ending at Cog0. So Cog0 has the shortest drive path to pins 0-15. Furthermore, the last series OR coming from Cog0 has very short wires to pins·7 and 8. So, having a low-numbered cog drive pins physically close to Cog0 is very low-latency, which matters greatly at 80MHz, but not at 40MHz.
Conversely, output/direction signals·for·pins 16-31 run left-to-right on the die, going through OR gates beginning with Cog0 and ending with Cog7. So, Cog7 has the shortest drive path to pins 16-31. And from Cog7, the wires connecting to pins 23 and 24 are quite short, keeping latency minimal.
This right-to-left·and left-to-right arrangement was to keep worst-case wiring lengths at half of what they would have been, had all pin-control signals·begun at Cog0 and ended at Cog7, or vice-versa. even so, the worst-case output/direction signal delay through 7 cogs is only about 1.5ns.
For inputs, all cogs see the same signals at the nearly the same time, as there are no series-gate delays. There is a slightly increasing wire delay from pin 7 down to 0, pin 8 up to 15, pin 23 down to 16, and pin 24 up to 31. The·worst-case input signal wiring delay·is about 500ps. These wiring delays affect both inputs and output signals.
So, the best sigma-delta cog/pin combinations would be Cog0 using pins 7 and 8, and Cog7 using pins 23 and 24.
There is one more source of delay, and that is the I/O pad, itself. It takes about 500ps to translate an input to a driven internal signal which goes to all the cogs. It takes about 700ps to translate an output signal to a pad voltage. This means that the best case output-to-input loop delay is ~1.2ns (700ps + 500ps). The worst case is that value plus max wiring delays both directions and 1.5ns for 7 series-ORs. This would sum to 4ns. That's a big chunk of a 12.5ns (80MHz) cycle and it eats greatly·into the feedback time.
What can really mess things up are parasitic capacitances and inductances due to PCB/breadboard wiring. They make the on-chip delays seem like nothing. If you look at the microphone·layout on the Propeller Demo Board, you'll see that wires were kept to just a few millimeters and small SMT parts were used. Also, pins 8 and 9 were chosen to keep on-chip wire delays to a minimum, especially when driven with a low-numbered cog.
And as was said earlier, having identical sigma-delta filter caps to both VSS and VDD keep power supply noise balanced at the input. This makes a big difference·over having·just·one to VSS or one to VDD.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
Post Edited (Chip Gracey (Parallax)) : 9/25/2007 5:36:31 AM GMT
Anybody up on Sigma-Delta ADC theory?
The basic idea is - looking at the Demo Board circuit - to keep the cap(s) at some voltage level (Vdd/2 to be precise) by feeding it exactly enough current from the Prop (or drawing from it) as is drawn from/fed to the external source. This is accomplished by some sort of PWM (>50%: feeding, <50% drawing). The program logic is another thing but the "electrical" idea is quite simple. So to be able to fast react to a change of voltage the cap must not be too large, as you might not be able to provide the needed charge by your pulses. On the other hand a tiny cap will not allow you to use the full pulse width of your signal, thus reducing the possible dynamic range.
Allowing a full voltage swing each T will require a C around T/2R; a smaller cap will reduce the dynamic, a larger will generate distortion at higher frequencies (low pass characteristic)
The R at the Prop feedback pin depends on the situation at the signal source - you have to adapt to its output impedance.. See Tracy's computations...
Post Edited (deSilva) : 10/16/2007 11:35:02 PM GMT
But, what I don't know is how to pick the best value for the capacitors [noparse]:)[/noparse]
And he says he is unsure how to chose the capacity. Sigh....
You shouldn't get upset when people don't seem to read or understand your posts, it's not always their fault, sometimes your posts are hard to understand for a variety of reasons (readers technical background, English, formatting, "comedy").
Having said that it's important to spend at least as much time reading replies as the person spent typing them.
Graham