Shop OBEX P1 Docs P2 Docs Learn Events
Analog to digital conversion — Parallax Forums

Analog to digital conversion

AppCogSysAppCogSys Posts: 9
edited 2006-08-09 15:52 in Propeller 1
It looks like it is possible to do analog to digital conversion, and D to A, with some coding on the Propeller chip. My question is... Is there any benefit to allowing the chip to do the conversion or would it be better to include dedicated A to D hardware in my design. In this particular instance I have several (call it 7) analog sensors (IR proximity, etc.) that I need to keep tabs on. Any insight, opionions or WAGs appreciated.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-06-19 15:58
    It depends on what else you're trying to do and where you're trying to save on hardware. Clearly, the Propellor is capable of doing A-D conversion on a one-per-cog basis. If you've only got 3 to 4 sensors and maybe a couple of servos that can be driven off one cog and need only one full-duplex serial channel and nothing else, that fits into the 8 cogs with some to spare and why not save hardware! If, on the other hand, you want keyboard and mouse input and vga display output and a serial channel and a bunch of servos, some external memory needs, and then have 7 analog input channels as well, you'd be better off with a nice external I2C based 8 channel A-D converter that you can hook up to the same pins that are used for the program EEPROM and your own external EEPROM or Ramtron data serial memory.
  • AppCogSysAppCogSys Posts: 9
    edited 2006-06-19 16:11
    Thanks for the quick reply. I was leaning toward hardware and I think you helped sway me in that direction. I'm not sure what my final demands on the processor will be but it shaping up to be the latter of your reply so it makes sense to offload the A-D onto dedicated hardware. It adds a bit o' hardware but keeps things free to do other things and we all need to keep our things free!

    Thanks again...

    D'
  • cgraceycgracey Posts: 14,206
    edited 2006-06-19 16:43
    Each COG has two CTRs which can each perform continous A/D conversion. If you only needed sporadic sampling, you could time-multiplex even a single counter and get lots of A/D channels. Each channel requires two pins - one for input and one for feedback.·One nice·thing about an external ADC is that you have less noise in your conversions because you can use a filtered Vref. Using the CTRs for ADC you have some system noise seeping in. I've found that having dual integrator caps, to both to VSS and VDD helps reduce·sample noise down quite a bit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • pjvpjv Posts: 1,903
    edited 2006-06-19 17:29
    Hi All;

    I agree with Chip, but I'd like to suggest further that by not using the internal CTRs, and having the virtual A/Ds timed under software control (very simple with the Propeller), a single Cog could run as many as 16 A/Ds; limited by port bit availability..... 2 per A/D.

    And if you're willing to give up a bit of speed performance, one could reconfigure the software driven A/Ds to use only a single port bit, so the limit would then be 32 channels.

    And the software to implement the virtual A/D is simpler than the software one would need to communicate serially to an external A/D.

    Furthermore, the cost of a virtual A/D is two resistors, one capacitor and severl lines of code. A whopping total of 5 cents per A/D.

    Cheers,

    Peter (pjv)
  • cgraceycgracey Posts: 14,206
    edited 2006-06-19 18:57
    Right on, Peter!!! BTW, we are going to change the microphone A/D on the next Demo Board by adding a secondary 1nF cap to VDD (to balance the one to VSS). This cause power-supply noise to get canceled, as it couples to the input from both sides, keeping the sense pin at its threshold.
    pjv said...
    Hi All;

    I agree with Chip, but I'd like to suggest further that by not using the internal CTRs, and having the virtual A/Ds timed under software control (very simple with the Propeller), a single Cog could run as many as 16 A/Ds; limited by port bit availability..... 2 per A/D.

    And if you're willing to give up a bit of speed performance, one could reconfigure the software driven A/Ds to use only a single port bit, so the limit would then be 32 channels.

    And the software to implement the virtual A/D is simpler than the software one would need to communicate serially to an external A/D.

    Furthermore, the cost of a virtual A/D is two resistors, one capacitor and severl lines of code. A whopping total of 5 cents per A/D.

    Cheers,

    Peter (pjv)
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • SawmillerSawmiller Posts: 276
    edited 2006-06-20 00:52
    hmmm this would be nicer than buying a external a/d for my project, however im using a linear transducer that puts out 0-10vdc.. isnt that way too much to get close to the prop ????

    dan
  • cgraceycgracey Posts: 14,206
    edited 2006-06-20 00:56
    No problem, just ratio your two resistors to bring it into the 3.3V range.
    Sawmiller said...

    hmmm this would be nicer than buying a external a/d for my project, however im using a linear transducer that puts out 0-10vdc.. isnt that way too much to get close to the prop ????

    dan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • SawmillerSawmiller Posts: 276
    edited 2006-06-20 01:31
    3.3 v divided by 4096 to get 12 bit a/d ...awfull small voltages...will go look up some examples of a/d circuts...
    thanks
    dan
  • pjvpjv Posts: 1,903
    edited 2006-06-20 04:13
    Hi Sawmiller;

    I have use the virtual A/D to measure the positive phase of 110 VAC line with no problem at all!

    Just go to the examples and app note on the Parallax site, and study how it works. It's quite simple really.

    Although if you really need 12 bits you do need to be quite careful in your layout and software approach. I have managed 14 bits, but it was somewhat of a stretch!

    Cheers,

    Peter (pjv)
  • AppCogSysAppCogSys Posts: 9
    edited 2006-06-20 15:59
    Peter,

    Thanks for the tip on virtual A-D. However, pretend like you're talking to a complete simpleton (me) and flesh out the concept a wee bit more so that I have a little to ruminate on. I hate to be cliche' but "I'm new to Propeller" and need a little more in the way of basic theory and implementation. You don't need to spell it all out. That would deprive me of all of the joy of discovery. Just the general outline. My specific instance would be a Sharp IR proximity sensor. Typical analog with power ground and signal.

    D'
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-06-20 16:16
    Regarding noise, do all the connections have to be soldered? I am thinking of breadboarding a prototype but fear that it would be unreliable.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-20 16:30
    Somebody (Sawmiller?)·looking for a voltage divider?
    256 x 219 - 5K
  • cgraceycgracey Posts: 14,206
    edited 2006-06-20 16:51
    Here is what the ADC circuit would look like for a two-pin converter that could·use the CTR modules:

    ·attachment.php?attachmentid=42150

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
    697 x 156 - 12K
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-06-20 18:11
    Kramer, the capacitors and 10k resistor should be located as close to the propeller as possible with minimized leads. Chip soldered parts directly to the pins when he developed the object, you dont have to goto this length, but breadboarding will affect the amount of precision possible.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is one giant teacup ride.
  • SawmillerSawmiller Posts: 276
    edited 2006-06-21 14:27
    chip, your picture for the a/d shows putting 10 volts to a prop pin.....

    i've set up my system using the voltage divider that pj had, then into your diagram.. correct ? dont want to let the smoke out...

    dont see any app notes for the prop, but am studying example 20, even thou that appears to be a measure of resistance...

    dan



    ps thanks for the patience


    Post Edited (Sawmiller) : 6/21/2006 3:04:00 PM GMT
  • bambinobambino Posts: 789
    edited 2006-06-21 16:51
    While you guys are dishing it out, Any tricks on how to measure a 0 to -5V signal without external hardware?

    Currently using the MAX1270 for the StampPLC!
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-21 18:14
    FFT... Fast Fiourier Transforms?
    Isn't that what's used to dertermin what frequencies are in a digitized sample of audio?
    ...I'm nearly bald as it is, and here I am scratchin my head tryin to figure this out.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-21 19:46
    bambino said...
    Any tricks on how to measure a 0 to -5V signal without external hardware?
    Kind of depends.· You could bring it straight over if the device generating the 0 to·-5V and the measuring circuit use separate/isolated power.· (Couldn't you?)
    Like reversing the leads on a DMM (one way it's NEG, the other it's POS.)
    391 x 208 - 7K
  • bambinobambino Posts: 789
    edited 2006-06-21 20:50
    Thanks, It will be awhile before I can try it, but shifting·GND opens up some options.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-21 21:15
    Just want to emphasize, bambino, that the supplies for the two circuits must be isolated from each other (like separate batteries.)
  • johnsroboticsjohnsrobotics Posts: 26
    edited 2006-06-22 00:57
    Sawmiller,

    Chip's schematic shows a voltage divider included before the propeller pins.
    The -8V to 10V analog signal gets divided up so 10V will never reach a pin.
    PJ's voltage divider can be left out.
  • SawmillerSawmiller Posts: 276
    edited 2006-06-22 01:22
    ok, i see that now, the doulbe caps thru me off..
    thanks
    dan
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-06-22 15:00
    Its actually a little more complicated than that, if the ADC's feedback pin were left high and the input were +10V, the voltage at the input would tend to float to around 4.4V, but there is a diode in the input pin which clamps the voltage to somewhere just shy of 4V, this leaves 0.4V of potential that drains through the diode, but the resistances are so large, not much current can flow through that diode, so it doesn't burn out. Its actually even more complicated than this because the voltage drop across the diode is dictated by the current (creating a quiescent point) but it isn't nessesary to understand all the intricasies of how it works in order to use it. I won't bother you with·trying to explain how switching the feedback pin and the two capacitors will effect the circuit's nodal voltage.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is one giant teacup ride.

    Post Edited (Paul Baker) : 6/22/2006 3:03:37 PM GMT
  • bambinobambino Posts: 789
    edited 2006-06-22 15:26
    Pj Allen

    Thanks again,
    It will be awhile More because they are isolated!
    The signal comes from a 27volt circuit with a virtual GND at 11Volts. Without the virtual gnd I doubt an A2D will read anything, and with it I'm just not brave enough yet. The max1270 does a great job, I'm just looking to make the device smaller in the future and taking it out would help if I didn't lose performance.
    When I do·have a disposable model I think I'll try moveing GND though. Thanks again.
  • IanMIanM Posts: 40
    edited 2006-07-26 10:37
    Hi, could someone kindly show me where the code is for the A/D converter?

    Many thanks smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ian Mitchell
    www.research.utas.edu.au
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-07-26 15:46
    It is located here: http://forums.parallax.com/showthread.php?p=576575

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ...
  • RinksCustomsRinksCustoms Posts: 531
    edited 2006-08-08 00:47
    Sawmiller said...

    chip, your picture for the a/d shows putting 10 volts to a prop pin.....

    i've set up my system using the voltage divider that pj had, then into your diagram.. correct ? dont want to let the smoke out...

    dont see any app notes for the prop, but am studying example 20, even thou that appears to be a measure of resistance...

    dan



    ps thanks for the patience


    I've seen this saying before, somewhere in· the WWW, "dont want to let the smoke out...".· Just a note on that, there is no magical smoke, when a component (resistor,cap,diode,semi) reaches critical mass (ie. 30V to a 16Vcap or dimming a 100W light with a 1/4W resistor), it will have a thermal runaway effect until it vaporizes or the power is removed.jumpin.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Definetly a E3 (Electronics Engineer Extrodinare!)
    "I laugh in the face of imposible,... not because i know it all, ... but because I don't know well enough!"
  • M. K. BorriM. K. Borri Posts: 279
    edited 2006-08-08 10:17
    On my current project (automated sailboat) I personally use Picaxe-08s, which are nicely cheap, as slaves to the Propeller. Their only job is to read analog voltages and convert them to either pulse length or a NMEA-like serial string.
  • rprp Posts: 2
    edited 2006-08-09 15:52
    Sorry for the cross post, I realized that my original post was to the A/D EXAMPLE - figured this was a more appropriate discussion.

    Ok, maybe I'm thinking about pushing this thing a little too hard. I saw the Propeller for the first time this past weekend (cool! [noparse]:D[/noparse]). I'm curious if you think it might be possible to build a software defined radio at around 13.5Mhz without using an external A to D converter. I'm thinking two options. The first is everything but the antenna and matching would be done in software - all downconverting and demodulation. Second option would be to build the first IF in analog to downcovert to around 1Mhz, then do the rest in the Propeller.

    It appears that all of the A/D you have discussed in you software implementations have been in the sub-megahertz range (most appears to be in the single digit kilohertz or sub-kilohertz range). So, how far up do you think it could be pushed?

    Thanks,
    Robert (rp)
Sign In or Register to comment.