ad5204 digital pot chip help with code please
staffshome
Posts: 28
hi all
i am trying to use a ad5204 digi pot chip with spi·to bs2p & im not getting very far with code,can anyone help with some code to start me off.
have attached datasheets, interfacing info on page 15
regards adrian
i am trying to use a ad5204 digi pot chip with spi·to bs2p & im not getting very far with code,can anyone help with some code to start me off.
have attached datasheets, interfacing info on page 15
regards adrian
pdf
399K
Comments
Basically, you use the SHIFTOUT statement to transfer the data to the AD5204. Again, look at the examples for other devices and the description of SHIFTOUT in the Stamp Manual or Stamp Editor Help Files.
LOW potCS
SHIFTOUT potData, potClk, MSBFIRST, [noparse][[/noparse]potNumber\3, potValue]
HIGH potCS
potCS is the chip select pin
potData is the data in pin of the chip
potClk is the clock pin which should be initialized HIGH
potNumber is the number of the pot (0 - 3 or 0 - 5 depending on the chip used)
potValue is the 8-bit setting of the pot
thanks for sample code,that's how i thought it should be,similar to max7219 im using already.
as you may have guessed i'm not very good at this programming stuff,1st attempt & probably my·only attempt.
only trying my hand after being let down by two so called professional programmers,but thats another story.
im just a bit confused as to data format for the 11bits.
as far a i can tell from datasheet,i send 1st 3 bits to sellect pot to address & them send 8data bits,does this mean i send· 000 (pot1) / 64 (1/4 pot position or do i need to send 8bits for (64)?
sorry for such basic questions but clueless really.
I have read thestamp app no18 august 96 "need analog output from stamp" app uses· ds1267 digi pot & i think i just confused myself even more !!
regards Adrian
·I cannot thank you enough,for some reason the penny has now dropped re spi interfacing,must have been your example & explanation.
put pot device code in my app & all works fine,except i forgot that i need 2·pots ramping·simultaneously for 3rd gear, oop's. . i may be able to get away with 1 @ 100% & the other ramping up, will have to see if it will work on the·test rig !!!
Thanks again for your superb help.