libftdi Archives

Subject: FT4232H, TI ADS7871 A/D Converter

From: averwind <tumert@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 18 Apr 2011 18:00:40 -0700 (PDT)
This topic doesn't really belong here but I am hopping someone can share
their experience as I do really need it. I am trying to read from the Texas
Instrument's ADS7871 A/D converter. Here is a link to its specs: 

http://focus.ti.com/lit/ds/symlink/ads7871.pdf

I am programming under windows so I am stuck with D2xx library provided by
FTDI. Unfortunately I wasn't able to accomplish much. I tried to convert a
code written under linux and use D2xx's functions. The read functions
somehow always return the same value and the last 16 bit read is simply
locking up the software. I have also posted the code I have written (uses
D2xx library) 

If there is anyone that has some experience can you please direct me to some
examples? I have already connected FTDI support but all they said was I have
to use FT2232D or the FT2232H as they have an MPSSE block. 

Thanks...



function TFtdi4232.ReadVoltage(channelNo: Byte): Double;
var
        ret, i: Integer;
  val: UInt16;
        mux_cnv: Byte;
  Instruction: Array[0..1] of Byte;
  BytesWritten: DWORD;
  FtStatus: FT_Result;
begin
  ret := 0;
  val := 0;
  i   := 0;

        // MUX_M3_bm forces single ended*/
        // This is also where the gain of the PGA would be set*/
  Instruction[0] := REG_GAIN_MUX;
  Instruction[1] := (MUX_CNV_bm or MUX_M3_bm or channelNo);
  FtStatus := FT_Write(FTHandle, @Instruction, sizeof(Instruction),
@BytesWritten);

        ret := ReadReg8(REG_GAIN_MUX);
        mux_cnv := ((ret and MUX_CNV_bm) shr MUX_CNV_bv);
        // on 400MHz arm9 platform the conversion
  // is already done when we do this test
        while ((i < 2) and (mux_cnv <> 0)) do
  begin
                i := i + 1;
                ret := ReadReg8(REG_GAIN_MUX);
          mux_cnv := ((ret and MUX_CNV_bm) shr MUX_CNV_bv);
                Sleep(1);
        end;

        if (mux_cnv = 0) then
  begin
                val := ReadReg16(REG_LS_BYTE);
                // result in volts*10000 = (val/8192)*2.5*10000
                result := ((val shr 2) * 25000) / 8192;
        end
  else
                result := -1;
end;

function TFtdi4232.ReadReg8(Reg: Byte): UInt8;
var
  BytesWritten: DWORD;
begin
        Reg := Reg or INST_READ_bm;

  FT_Write(FTHandle, @Reg, sizeof(Byte), @BytesWritten);
  FT_Read(FTHandle, @Result, sizeof(Byte), @BytesWritten);
end;

function TFtdi4232.ReadReg16(Reg: Byte): UInt16  ;
var
  BytesWritten: DWORD;
  temp: Array[0..1] of Byte;
begin
        Reg := Reg or INST_READ_bm or INST_16BIT_bm;

  FT_Write(FTHandle, @Reg, sizeof(Byte), @BytesWritten);
  FT_Read(FTHandle, @temp, 1, @BytesWritten);
  Result := (temp[1] shl 8) or temp[0];

end;

--
View this message in context: 
http://libftdi.141977.n3.nabble.com/FT4232H-TI-ADS7871-A-D-Converter-tp2837020p2837020.html
Sent from the libFTDI mailing list archive at Nabble.com.

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread