DAC 7571 from ti

Rickg1

New Member
Guys thanks for the help on the AM2320, which thanks to you is working great now. But now this old man needs help on the next problem. I'm trying to get a 12 bit dac to work. Want to get a repeating sweep out of it. ( 0 to 5v) . Somewhere I missed the boat cause i get nothing out.




'
'


'
 

Rickg1

New Member
This may not be right way to do it but here it is..


'DAC7571 0-5v dac TI
'
' Sept11,2019
' Start , got chip solded to carrier and put on 6 pins.
' 14 sept, byte not word out, address not know..
' 16 sept still workin on it.
' 17 sept still workin on it.
'
#picaxe 08m2
#no_data
#terminal 4800


' address is $48, $4c
main:


HI2cSetup I2CMASTER, $48 , I2CSLOW, I2CBYTE
b2 = $fe
b3 = %00111111
HI2cOut (b3)
sertxd(cr,lf,"b3 ", #b3)
'pause 10

hi2cout (b2)

sertxd(cr,lf,"b2 ",#b2)
'pause 10

sertxd(cr,lf,"w1 ",w1)

'sertxd (cr,lf,"place ",#place)
pause 3000
b2 = $00
b3 = %00110000
pause 3000
goto main
 

Aries

New Member
Put [ CODE ] at the beginning of your code and [/CODE] at the end. Omit the spaces inside the brackets around CODE - I had to include them to stop the system doing this:
Put
Code:
 at the beginning of your code and
at the end
 

AllyCat

Senior Member
Hi,

What frequency or period of "Ramp" are you trying to generate? If the chip is only a "DAC" then you will need to keep updating the "dc" value as quickly as possible (in a prgram loop). At best you will only be able to do this every few milliseconds with a PICaxe, and if you only increased the value by one digit each time, it would take at least 10 seconds to step through all 4096 levels of a 12-bit value.

Also, it looks to me as if the I2C address should be $98 or $9A, depending on how you have set up A0.

Cheers, Alan.
 

hippy

Technical Support
Staff member
The datasheet appears to be here -

https://www.ti.com/lit/gpn/dac7571

From Page 16, the 8-bit slave address is shown as -

%100110x0

So that's either $98 or $9A, as AllyCat noted -

HI2cSetup I2CMASTER, $98, I2CSLOW, I2CBYTE
HI2cSetup I2CMASTER, $9A, I2CSLOW, I2CBYTE

Also from Page 16, data is sent as 16 bits, a two byte pair, MSB first -

%00ppdddddddddddd

Two zero bits, two control bits, 12 data bits

The control bits, Page 18, are -

%--00------------ Normal Operation
%--01------------ 1kΩ to AGND, PWD
%--10------------ 100kΩ to AGND, PWD
%--11------------ High Impedance, PWD

Normal operation would seem appropriate so the word sent can be thought of as a pure 12-bit number, 0 to 4095.

So to ramp the DAC up to full and back down again repeatedly, I would try -

Code:
#Picaxe 08M2

Symbol DEVICE_ID = $98 ; or $9A

HI2cSetup I2CMASTER, DEVICE_ID, I2CSLOW, I2CBYTE
Do
  For w0 = 0 To 4095 Step 1
    HI2cOut (b1,b0)
    PauseUs 100
  Next
  For w0 = 4094 to 1 Step -1
    HI2cOut (b1,b0)
    PauseUs 100
  Next
Loop
That will take over 4 seconds to ramp up and down, so reduce the PAUSEUS and/or increase the STEP values for faster ramping.
 

Rickg1

New Member
Allen,
I used the I2C scanning program from the forum and got $48 and $4c as address. Spec sheet gives $4c. A0 is at gnd. All I'm trying to do right now is to get some kind of pulse out to see it on the scope.
I was hoping that my code would made the output "step" to some voltage and then go to 0v at a 3 second time. The sweep part comes later, I hope.
Any thoughts?
 

Rickg1

New Member
Hippy,
I'll got a lot to learn!!!
Your code worked right out of the box! Thanks.
Why is the address wrong $4c vs $98 ? The scanning program gave $48 And $4c, thought i2c address is left shifted ?
At 74 yo I got so so much to "learn" and get into my head. I have put in so much time and different versions of code to try to get it to work and you do it in minutes. I hope I can get close to you leavel as i have so many projects in my head that i want to do.
 

hippy

Technical Support
Staff member
The difference between 4C/4D and 98/9A comes down to whether one considers the device address as 7-bit, without the R/W bit, or 8-bit with and set to zero -
Code:
    .---.---.---.---.---.---.---.
    | 1   0   0 | 1   1   0   x |  4C / 4D
    `---^---^---^---^---^---^---'
     /                       /
    /                       /
   /                       /
.---.---.---.---.---.---.---.---.
| 1   0   0   1 | 1   0   x   0 |  98 / 9A
`---^---^---^---^---^---^---^---'
Both standards are commonly used. The PICAXE uses 8-bit format, hence 98/9A.

Not sure why you were seeing 48 though, unless the device address is not as stated in the datasheet I found or it's some anomaly due to 'high-speed' mode.
 

Aries

New Member
Did it , how to paste "the code" into forum?
Just paste it into your message like ordinary text with the [ CODE ] and [ /CODE ] markers surrounding it. The display will interpret the markers and it will look like this:
Code:
'DAC7571  0-5v dac TI 
'
' Sept11,2019
' Start , got chip solded to carrier and put on 6 pins.
' 14 sept, byte not word out, address not know..
' 16 sept still workin on it.
' 17 sept still workin on it.
'
#picaxe 08m2
#no_data
#terminal 4800


' address is $48, $4c
main:
    
     
     HI2cSetup I2CMASTER, $48 , I2CSLOW, I2CBYTE
          b2 = $fe 
     b3 = %00111111     
     HI2cOut (b3)
     sertxd(cr,lf,"b3 ", #b3) 
     'pause 10
     
     hi2cout (b2)
     
    sertxd(cr,lf,"b2 ",#b2) 
    'pause 10
    
    sertxd(cr,lf,"w1 ",w1)
    
    'sertxd (cr,lf,"place ",#place)
    pause 3000
    b2 = $00 
     b3 = %00110000
    pause 3000
    goto main
 

Rickg1

New Member
Can someone tell me way this code does not work

HI2cSetup I2CMASTER, $98 , I2CSLOW, I2CBYTE

main:
w1= 4094
b2 = $fe
b3 = %00111111
HI2cOut (b3,b2)

pause 3

w1= $00
b2 = $00
b3 = %00110000
HI2cOut (b3,b2)

pause 3
goto main


And this does:

HI2cSetup I2CMASTER, DEVICE_ID, I2CSLOW, I2CBYTE
Do
For w0 = 0 To 4095 Step 1
HI2cOut (b1,b0)
'PauseUs 100
Next
For w0 = 4094 to 1 Step -1
HI2cOut (b1,b0)
'PauseUs 100
Next
Loop




Next question: How was it known that to get a full ramp it would take 20 seconds? it did take 20seconds.




Third: How do I go about getting a ramp ( to be used as a sweep ) of 10ms?

Please give some answers and ideas.
 

Aries

New Member
Your first code sets w1, which is (b2,b3) and then overwrites it anyway with constant values for b2 and b3 which are used in HI2COUT.
The loops in the second code set w0, which is (b0,b1) and uses the (varying) values in HI2COUT.
So, in the first case, you are simply sending the same two pairs of values every 6 or so milliseconds, in the second case you are changing the values each time. Hippy's post #7 suggests changing the step size if you want to change the timing (if you use STEP 2, it should go about twice as fast)
 

AllyCat

Senior Member
Hi,
As I indicated back in #6, you won't be able to generate a high frequency ramp. The best that can be done is a "staircase", so start with a STEP of about 100 and remove the STEP -1 section of the program. That should give a staircase of around 100 ms that you might be able to reduce to nearer 10 ms with a SETFREQ M32 (but there might be problems with the I2C bus speed).

For a "proper" ramp generator you typically need to use an analogue "integrator" such as an Op-Amp with a capacitor in its feedback loop and comparator(s) to determine the upper and lower threshold levels.

Cheers, Alan.
 

hippy

Technical Support
Staff member
IN the first case -
Code:
b2 = $fe
b3 = %00111111
HI2cOut (b3,b2)
You are sending a 16-bit value - %0011 1111 1111 1110

Map that onto what values can be sent, note the 'pp' -
Code:
%0011111111111110
%00ppdddddddddddd
'pp' = '11' turns the DAC off.

Another way of looking at is the word value of b3:b2 is greater than 4095, the maximum value you can send to the DAC.
 

hippy

Technical Support
Staff member
I did note -
Code:
w1 = 4094
HI2cOut (b3,b2)
That would have worked if you had not set 'b3' and 'b2' between the two. When you did that you no longer had 4094 in 'w1' or 'b3:b2'. It may be that your conversion of 4094 to two 8-bit values was simply incorrect.

Two useful tips are; only use word values rather than setting individual byte variable values. And, as there can be some confusion when mixing word and byte variables pairs as necessary with I2C, define those in SYMBOL statements, such as -
Code:
Symbol level     = w1  ; b3:b2
Symbol level.lsb = b2
Symbol level.msb = b3

level = 4094
HI2cOut ( level.msb, level.lsb )
 
Last edited:
Top