Shop OBEX P1 Docs P2 Docs Learn Events
Ltc1298 analog to digital reading problems — Parallax Forums

Ltc1298 analog to digital reading problems

pimp200277pimp200277 Posts: 22
edited 2007-04-25 14:27 in BASIC Stamp
Hi,
·· I have been trying for the past month to get this analog to digital converter (ltc1298 by www.linear) to read the voltage from my Vernier PH analog sensor but I have had no sucess.

1.) What I am trying to do is get the analog to digital converter on 1 channel·to read from my·ph sensor ( which outsputs voltage) then take that·value and converter it in to ph units.

2.) ·Then on the 2nd channel read my temperature sensor which I am using an LM35DZ temperature sensor.

The formula for ph is pH = voltage / 0.25··ph units

Here's the code I am using:


CS· CON· 12··· ' Chip select (low true)
CLK· CON· 15··· ' ADC Clock
Din· CON· 13··· ' ADC Data input
Dout· CON· 14··· ' ADC Data output
config· VAR· Nib··· ' Configuration bits for ADC
ADres· VAR· Word··· ' Variable to hold 12-bit AD result
startB· VAR· config.BIT0· ' Start bit for comm with ADC
sglDif· VAR· config.BIT1· ' Single-ended or differential mode
oddSign· VAR· config.BIT2· ' Channel selection
msbf· VAR· config.BIT3· ' Output 0s after data xfer complete
v···· VAR· Byte
ph··· VAR Byte
INIT:······· ' Initialization code
· HIGH CS····· ' Deactivate ADC to begin
· HIGH Din··· ' Set up data lines
· HIGH Dout
START:······· ' Main loop
· FOR oddSign = 0 TO 1· ' Toggle between input channels
· GOSUB convert··· ' Get data from ADC and display it
· GOSUB calc
· DEBUG "Ch:",DEC oddSign, " ", DEC3 ADres,CR
· PAUSE 500··· ' Wait a half second
NEXT······· ' Change channels
· GOTO START··· ' Repeat forever
convert:······· ' Convert subroutine start here
· config = config | %1011· ' Set all bits except oddSign
· LOW CS····· ' Activate the ADC
· SHIFTOUT Din,CLK,LSBFIRST,[noparse][[/noparse]config\4]· ' Send config bits to ADC
· SHIFTIN Dout,CLK,MSBPOST,[noparse][[/noparse]ADres\12]· ' Get data bits from ADC
· HIGH CS····· ' Deactivate the ADC.
RETURN······· ' Return to main program
· calc:
· v = 5 * ADres / 4095
· ph = v /(1/4)
· RETURN



I got this code of the·CD I got with my basic stamp 2 - Under basic stamp activiy board File: LTC1298.bS2.
I tried adding in a calulation section as you could see at the end of this code but that didn't help.·
Any suggestions on what I can do?

Comments

  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-04-25 04:52
    The calculation for ph will not work on the STAMP, because (1/4) in stampese integer math equals zero. You simply need ph = v * 4. But I suspect that is not your main problem, and there may be something wrong with the way the ADC or sensors are hooked up.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • pimp200277pimp200277 Posts: 22
    edited 2007-04-25 13:47
    I am using this schematic on page 1 of this pdf file:

    under Hardware Interface:

    http://www.parallaxinc.com/dl/docs/prod/appkit/ltc1298.pdf

    Then I am using this adapter to analog connecter between my sensor and

    basic stamp 2:

    http://www.vernier.com/probes/probes.html?bta-elv&template=standard.html

    I just apply 5v to the connector, ground it and I use eithier signal 1 or signal 2 pin from the connector and I connected it to eitheir channel·0 ·or channel 1 on the ltc1298·adc.
  • DaveGDaveG Posts: 84
    edited 2007-04-25 14:27
    I think your DEBUG statement is chopping of the 4th digit of the output display. The ADC puts out 0 to 4095,
    but "DEC3 ADres" only displays 3 digits. Just change it from "DEC3 ADres" to "DEC4 ADres" or "DEC ADres".

    You might try connecting a simple 1.5v battery to channel 2 and see if the output is correct.
    It should read about 1228. (1.5/5.0 * 4096 = 1228)

    Dave G
Sign In or Register to comment.