Shop OBEX P1 Docs P2 Docs Learn Events
MAX 536 DAC to BS2 — Parallax Forums

MAX 536 DAC to BS2

illuzionilluzion Posts: 9
edited 2006-03-01 22:08 in BASIC Stamp
Does anyone have any code handy that will allow me to interface a MAX536 DAC to a BS2?· I would like to use this IC as I am trying to program it in an existing application.· I have enclosed the datasheet for it.· This comminicates via SPI.
Thanks in Advance

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-22 15:46
    I don't have any code "handy" but after a quick (emphasis on quick) look at the data sheet I think this subroutine will work:

    Update_DAC:
    · outVal = adcVal & $0FFF······················ ' copy output value
    · outVal.NIB3 = (channel << 2) | %0001········· ' setup channel and control bits
    · LOW CS······································· ' activate DAC
    · SHIFTOUT SO, SK, MSBFIRST, [noparse][[/noparse]outVal\16]······· ' shift the control + dac bits
    · HIGH CS
    · RETURN

    This routine assumes the LDAC line is tied low (see Table 1 in the docs you reference)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-02-22 16:58
    There is Stamp code for the MAX5722 (another MAXIM 12 bit DAC with SPI interface, dual channel) at this URL:
    http://forums.parallax.com/showthread.php?p=553090

    That tread also has code for the TI TLV5618A and a long discussion about how to decipher DAC data sheets.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • illuzionilluzion Posts: 9
    edited 2006-03-01 22:08
    I would really like to understand if and how this works, since you didnt send me a complete program, I tried to fill in the blanks the best I could.· First let me know if this is all correct, I have not tested it yet.· First off channel is a Nibble which occupies the first two bits of the 16 bit datastream setting the address???? Second two bits are control which are %X1 to program the output.· Tieing LDAC low makes the adc change state as soon as data is loaded into it correct?· Next 12 bits as we know are the data being loaded into the dac.· Now as far as the program goes, outVal = adcVal & $0FFF·I dont understand this and statement, next outVal.NIB3 = (channel << 2) | %0001, I would assume this makes sure that Control Bit C0 is a 1 always, and Takes the nibble channel and loads it into A1 and A0.·

    Thanks
    Brian







    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    'DAC TESTER

    'Hardware Notes
    'LDAC Must be tied low to make adc outputs update on rising edge of cs
    '16 bit serial input
    'first 2 bits Address, next 2 control, next 12 data
    'TP Must be tied to Vdd

    'Variable Declarations
    adcVal VAR Word
    outval VAR Word
    channel VAR Nib

    'Constant Declarations
    adcval=4000
    channel = %0001 'should load channel 1?

    'IO Declarations
    CS PIN 13 'Chip Select
    SO PIN 14 'Serial Data
    SK PIN 15 'Serial Clock


    · Update_DAC:
    · outVal = adcVal & $0FFF······················ ' copy output value
    · outVal.NIB3 = (channel << 2) | %0001········· ' setup channel and control bits
    · LOW CS······································· ' activate DAC
    · SHIFTOUT SO, SK, MSBFIRST, [noparse][[/noparse]outVal\16]······· ' shift the control + dac bits
    · HIGH CS
    · RETURN
Sign In or Register to comment.