Shop OBEX P1 Docs P2 Docs Learn Events
How to use AD7730 in BS2 — Parallax Forums

How to use AD7730 in BS2

AgouaAgoua Posts: 2
edited 2006-02-12 13:43 in BASIC Stamp
I would like to build a small weigh scale indicator using AD7730 and BS2.
Can you give me some indications ?
Thank you and best regards

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-02-12 13:43
    Agoua -

    Here is some sample coding, thanks to Mohamed Refky:

    /code

    'Use of·an AD7730 in a weigh scale applications.·Example codes of writing and reading of registers

    ADdata········var·····WORD····'variable to hold 16 bit result.
    DATAin········con·····2·······'AD data input pin.
    DATAout······con·····3·······'AD data output pin.
    SCKL···········con·····4·······'clock to AD.
    RDY·············con·····5·······'RDY input .

    ···· INPUT·5

    Initial:

    ···· SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$FFFF\16,$FFFF\16]·······'write 32 ones will reset the AD7730 to the default state

    ···· SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$02]·············'write to communication register setting next operation as write to mode register.

    ···· SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$3080\16]·····'write to mode register starting continuous conversion for 10mV input range,unipolar,16 bit data word and 5V reference.

    ···· SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$21]·············'write to communication register setting next operation as continuous read from data· register.

    ···· LOW 2···········' set DIN line low to insure part is not reset while in continuous read mode.

    ReadData:

    waitRDY:
    ··· IF RDY = 1 THEN waitRDY·····················'wait for RDY to go low to indicate output update.

    ··· SHIFTIN DATAout, SCLK, MSBPOST, [noparse][[/noparse]ADdata\16]····'read conversion result from data register.

    ···· DEBUG DEC ADdata, CR·····························'display data in decimal.

    ···· PAUSE·500·······································'wait 0.5 second between reading.

    ···· GOTO ReadData
    ···· END
    code/


    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
Sign In or Register to comment.