Shop OBEX P1 Docs P2 Docs Learn Events
Any DAC examples for the propeller using SPIN? — Parallax Forums

Any DAC examples for the propeller using SPIN?

automatonautomaton Posts: 12
edited 2006-11-13 16:11 in Propeller 1
I just recently acquired a propeller chip for a project that I need to do complete (I chose it for the multiple cogs so I can do something else in the chip while I have a DAC running on another cog). Anywyas, I have to create a DAC and I am trying write in the SPIN language. I see lots of assembly examples for this, but seeing as how I am just learning the ins and outs of the chip...

I was wondering if there are any SPIN code examples for this or if someone can point me in the direction of an object to use?

Thanks.

Comments

  • T ChapT Chap Posts: 4,198
    edited 2006-11-11 23:10
    look in the propeller tool examples folder the ad8803 demo may help
  • M. K. BorriM. K. Borri Posts: 279
    edited 2006-11-11 23:43
    A cheap way to do this (I used to do that with a parallel port) is to get powers-of-two resistors (8 ohm, 16 ohm... to 2k ohm) and connect them to, say, pin 0 to pin 7, then connect them all together and amplify that a bit, mostly so the prop sees high impedance (the cheap radio shack audio amplifier will do the trick), you can drive a headphone with that. Just write bytes to outa and there you go, 8 bit audio!
  • automatonautomaton Posts: 12
    edited 2006-11-12 00:11
    MK,

    I am aware of the the old 8-bit DAC parallel port hack... but that port is being used for something else and I need more functionality than a parallel port can provide. I need to accept analog input on several of the pins and do some low frequency digital out on several of the pins.

    So I can't use too many of the pins. I was thinking of using the a single resitor, and a capacitor in the following fashion....


    PIN 0 ---/\/\/\/\
    >Analog output between 0 and 3.3 V

    Where there is a capacitor branching to the ground between the resistor and the analog terminal (tried to show it but forum code here doesn't display spaces at the front of a line)

    But I was seeing if there were SPIN code examples (not the assembly version) showing this...

    Post Edited (automaton) : 11/12/2006 12:18:04 AM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-11-12 00:39
    The reason you see the examples for sigma-delta ADC written in assembly is because the speed and deterministic nature of assembler is required to make it work. Fortunately you dont need to understand the assembly code to use it, just how to interface with it in your Spin code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • M. K. BorriM. K. Borri Posts: 279
    edited 2006-11-12 04:25
    A little basic reminder in case someone finds this thread later: in general, but especially if you go the R+C route, make sure you connect the output you generate that way to a hi-Z buffer (such as an op amp hooked up as a follower hyperphysics.phy-astr.gsu.edu/Hbase/electronic/opampvar2.html ), specifically, to something whose impedance never changes. This way you know that the rest of your circuit is always getting the right output from it.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-11-12 06:13
    Hmmm, I just noticed I misread your request. Yes DACs can be made from Spin code, here's your request:
    PUB ADC_start(pin)  dira := |< pin
      frqa := 0
      ctra := %00111 << 26 + pin
      
    PUB ADC(value)
      frqa := value
    

    ADC_start initializes the ADC to output on pin and sets the inital value to 0V, ADC changes the output voltage to 3.3x(value/2^32).
    ·
    10kOhms and .1uF are suitable values for the resistor and capacitor, though other values will work.·You must be careful about what kind of load you place on the circuit, if it's·low resistance or high capacitance, it will affect the voltage output.·For these types of loads you should run the voltage through an op-amp configured as a voltage follower as MK Borri has shown in the link he provided.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 11/12/2006 6:32:53 AM GMT
  • automatonautomaton Posts: 12
    edited 2006-11-13 16:11
    I started interpretting the assmebler code and almost had the same thing you posted above... except had the shifting different.. so I'll go back and fix it. [noparse]:)[/noparse]

    Thanks
Sign In or Register to comment.