Shop OBEX P1 Docs P2 Docs Learn Events
BS2SX with MCP3301 analog-to-digital — Parallax Forums

BS2SX with MCP3301 analog-to-digital

hatallicahatallica Posts: 175
edited 2007-11-13 23:42 in BASIC Stamp
I am experimenting with the BS2SX and Microchip MCP3301 without much success.· From what I can gather from the datasheets, the programming should be very similar to the LTC1298.· There are three differences that I see: 1) The MCP3301 is differential-mode only; the '3301 returns 13-bit 2's compliment data; and 3) the '3301, therefore, does not require any configuation (data input).

My output data is consistently zero, regardless of the input.· While testing, I tied one input to Vref = 2.5V and the other to VSS = GND.· The power and reference voltages measure as expected.

With my cheap-o'scope, I confirmed that the clock is cranking out a nice pulse train (40-42KHz and ~50% duty).· Also with the scope, I observed the data line going high briefly (couple of microseconds) and then staying low for the remainder of the communication.·

Below is the exact code that I was using.· I get the feeling that I am missing something obvious ... ideas?

code below this line, comments and all

'{$STAMP BS2sx}
'{$PBASIC 2.5}

' Program: ADC_Routine
' Adapted for MicroChip MCP3301 (that's the idea, anyway)
' MCP3301 has one diff channel instead of two single-end channels
' MCP3301 does not accept configuration data input
' This program, therefore, only uses SHIFTIN communication
' Shiftin to capture the results of the conversion.

' ==========================================================
'···················· Constant/Variable
' ==========================================================

CS1······ CON· 3· ' Chip Select 1 assigned to MCP3301; pin3; active low
SERCLK··· CON· 1· ' Serial bus clock; pin1; out on rising, in on falling edge.
SERDAT··· CON· 2· ' Serial data bus; pin2
ADResult· VAR· Word· ' Variable to hold 13-bit, 2's compliment result)

' ==========================================================
'···················· Demo Program
' ==========================================================

HIGH CS1···· ' ADC must be deselected for finite time before a conversion
PAUSE 1····· ' very brief wait to reset chip

convert_again:······ ' Main loop.

· LOW CS1···· ' Activate the ADC.
· SHIFTIN SERDAT,SERCLK,MSBPOST,[noparse][[/noparse]ADResult\13] ' Get ADC output bits
· HIGH CS1·· ' Deactivate the ADC

· DEBUG "Differential Output = "·· ' Begin output text
· DEBUG ? ADResult················ ' Display data
'· PAUSE 1000··· ' Wait before looping

GOTO convert_again··· ' Endless loop.

Comments

  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-11-13 06:51
    I see the chip needs more than 13 clocks in order to acquire the data, including two clock cycles to sample the input. But that doesn't explain the zero result. Note that negative full scale is $1000, so that could explain the single pulse if the (-) input is connected to 2.5 and the (+) input to ground.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • hatallicahatallica Posts: 175
    edited 2007-11-13 17:07
    Thanks for the response, Tracy.
    Good point regarding negative full-scale. The +V(ref) pin is right next to the IN(+) pin and the Ground pin is right next to the IN(-) pin. Since I am inherently lazy, it was easier to wire the circuit to go to the positive full-scale ($0FFF).

    The '3301 seems to be very much like the LTC1286 (sibling of the LTC1298). Both only differ from the LTC1298 in that they do not require the configuration input. As soon as the CS line drops, the conversion begins. The output is held at high impedance for a couple of cycles, drops to a null bit, and then vomits out the sequence of data. For the '1298, the high impedance output portion is the data input portion, and then the rest is essentially the same.

    There are some minor tweeks that I'll have to make to capture the correct 13-bits. There still seems to be something catostrophically wrong. Hmm ... back to the datasheet I go.
  • hatallicahatallica Posts: 175
    edited 2007-11-13 23:42
    It was, in fact, something obvious. It helps greatly when the software refers to the correct pin. I have no shame. I'll admit that the serial data bus was actually connected to pin0 and not pin2.

    Works quite nicely now [noparse]:)[/noparse]

    Excerpt from A Checklist of Behavioral and Personality Attributes of the Creative Engineer:

    "When he gets stuck in his work on a problem he knows that this is frequently due to the fact that he is asking the wrong questions."
Sign In or Register to comment.