SIgmaDelta ADC
John Board
Posts: 371
G'day,
I've been playing around with SigmaDeltas lately to read the voltages coming in from a sharp IR sensor. As I do not possess an ADC chip, nor have the time to buy one/figure out how it works, I'm sticking with SD's for now.
My problem is I have the code to read one sigma delta, but cores are precious, and this one takes up an entire core, for reading just 1 SigmaDelta. I need to have it reading 2 at the very least. Since I'm not brilliant at PASM and can't modify the library I'm using, I'm wondering if anyone knows of a SigmaDelta library that supports at least reading 4 SDs on 1 cog.
At the moment I'm using the builtin "ADC" library as provided with Propeller Tool.
Thanks for your help!
-John
I've been playing around with SigmaDeltas lately to read the voltages coming in from a sharp IR sensor. As I do not possess an ADC chip, nor have the time to buy one/figure out how it works, I'm sticking with SD's for now.
My problem is I have the code to read one sigma delta, but cores are precious, and this one takes up an entire core, for reading just 1 SigmaDelta. I need to have it reading 2 at the very least. Since I'm not brilliant at PASM and can't modify the library I'm using, I'm wondering if anyone knows of a SigmaDelta library that supports at least reading 4 SDs on 1 cog.
At the moment I'm using the builtin "ADC" library as provided with Propeller Tool.
Thanks for your help!
-John
Comments
I'm too busy to take this on myself but any one doing so should be aware these lines of code:
Will only work pins 0 through 9 because of the 9-bit limit of the source field. The pins for higher pin numbers will need to be stored as variable and referenced indirectly.
Thank you. I should have thought of that.
I'll have to rethink about why I had problems with the object using higher pin numbers.
Edit:
This is the culprit.
I've been poking around some ASM tutorials, such as Potatohead's, and looking at the CTRA (and other register) tutorials, and it seems to be that I can only do 2 SigmaDeltas / core (using APIN and BPIN of CTRA and CTRB) in assembly. Is the way to boost this number to code your own POS w/ feedback code in assembly, while utilizing both CTRA and CTRB? Or is it by recalibrating CTRA and CTRB on the fly, for different pins, aka, take a reading using the first 2 pins, and then recalibrate the CTRx to use the second pin, take a reading, then repeat...?
This is my guess of how it could be done.
While it seems like a good idea to have a DS object with four channels, I'm betting you're project would be completed sooner if you used an ADC chip.
I finished it, seems to work fairly well, it basically keeps reconfiguring the registers. It currently reads 2 channels,but ultimatly can be configured to read X number of channels, although each channel added will of course slow down the entire loop. Fast enough for what I need though, so I'm happy. I'll chuck a profiler on it later today, and see how fast it's sampling at with ~4 channels.
I'll polish it up, and perhaps put it on the OBEX!
-John
If you do, it would be nice if the Start method accepted the pin numbers as parameters. It would be also nice if the object could use pins above P9.
If you use the second counter you should be able to read the two channels at once and not reduce the update rate (at least I think this would work).
I think you could make the loop a little faster by eliminating one instruction in the self-modifying code.......... if you combine the movd and movs for counterA into a single register and then use "mov ctra,dscombo",
You are already overwriting the left end of the instruction with the movi that you have.
Cheers,
Peter (pjv)
the software together with the hardware tries to hold the voltage at the C at 3.3V/2. But just at/after the switch to the new channel the voltage will not be nearby this level. So each switching will bring some inaccuracy to the system. This is a difference to the single channel version. The counting should start only AFTER the first change of level of the output pin, I think.
Christof