Shop OBEX P1 Docs P2 Docs Learn Events
Help with LTC1257 DAC — Parallax Forums

Help with LTC1257 DAC

Alex41Alex41 Posts: 112
edited 2008-03-02 03:07 in General Discussion
Hello again,

I have written the following program to use the LTC1257 12bit DAC. I gathered all the info I could and wrote the code. The N&V column·#4 and #43 were very helpful. Of course I read the LTC1257 datasheet too. It seems these articles were written before the SHIFTIN and SHIFTOUT commands were available, so I'm kinda shooting in the dark with setting those up.

The program is basically working, but not 100%.

I'm using a pot with RCTIME to input a number between 0 and 4095. The code seems to be working somewhat, but the output is from 0v to about 3.6 volts. I'm looking for a range of 0 to 5v. The output of the LTC1257 goes through a LM356 op amp and I've read the voltage out of the chip and the op-amp and they are the same, so·it appears to be hooked up correctly.

I would guess the code with the SHIFTIN may not be correct, but really don't know where to go from here.·Any input?

Thanks,
Alex

Code is below





' =========================================================
'
'·· File...... LTC1257R1.SXB
'·· Purpose... Simple program to use LTC1257 DAC
'·· Author.... Alex41
'·· E-mail....·
'·· Started... Feb 18 2008
'·· Updated... Feb 19 2008
'
' =========================================================
' Revision 1,
'
'
' Program Description
'
'
' This is a simple program to test programming of the LTC1298 DAC chip
' A pot is used to provide a value for the DAC to use
'
' Chip connections,
'
' 1· CLK - RC.0··8· Vcc to 9v pos
' 2· Din - RC.1··7· Vout - output amplified by LM358
' 3· LOAD- RC.2··6· Vref - 5v pos
' 4· Dout - not used·5· Gnd· - Ground
'
' Note - pin 8 on chip is provided with 9v to allow a 0-5v output range
'
' Device Settings
'
DEVICE········· SX28, OSCXT2, TURBO, STACKX, OPTIONX, BOR42
FREQ··········· 4_000_000
ID············· "LTC1257"
'
' IO Pins
'

Clk··PIN·RC.0·OUTPUT
Din··PIN·RC.1·OUTPUT
PinLoad··PIN·RC.2·OUTPUT
Potpin··PIN·RC.7·OUTPUT

'
' Constants
'

'
' Variables
'

TmpW1··VAR·Word
Pottime··VAR·Word

' =========================================================
· PROGRAM Start
' =========================================================
·
'
' Subroutine Declarations
'
DELAY_MS·SUB·1, 2
'
' Program Code
'
Start:
· ' initialization code here
Main:······' main code here
DO·
· ' RCtime - read pot to get value
· HIGH potpin···' charge the capacitor
· PAUSEUS 300···' Pause for 50 us
· RCTIME Potpin, 1, Pottime·' measure in 2 us units
· IF Pottime > 4095 THEN·' max input of 4095 for DAC chip
··· Pottime = 4095
· ENDIF
· PinLoad = 0·············· ··' activate chip to receive data
· SHIFTOUT Din,Clk,MSBFIRST,Pottime_MSB·' send high nib
· SHIFTOUT Din,Clk,MSBFIRST,Pottime_LSB·' send low byte
· PinLoad = 1··········· ··' de-active chip to output voltage
· DELAY_MS 500
LOOP

'
' Subroutine / Function Code
'
' Use: DELAY_MS duration
SUB DELAY_MS
· IF __PARAMCNT = 1 THEN
··· tmpW1 = __PARAM1··························· ' save byte value
· ELSE
··· tmpW1 = __WPARAM12························· ' save word value
· ENDIF
· PAUSE tmpW1
· ENDSUB

' =========================================================
' User Data
' =========================================================

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If at first you don't succeed, then skydiving is not for you.

Comments

  • Alex41Alex41 Posts: 112
    edited 2008-03-02 03:07
    OK, got it figured out.

    1. For some reason the RC combo for the RCTIME measurement was returning less than the max value of 4095, even though I checked it when I set it up. Fixed that.

    2. Also found that the supply voltage to the op amp needed to be more than 5v!

    Solved easily enough!

    Thanks for the help,
    Alex
Sign In or Register to comment.