Shop OBEX P1 Docs P2 Docs Learn Events
Connecting ADC to Stamp — Parallax Forums

Connecting ADC to Stamp

kk Posts: 7
edited 2008-05-20 02:32 in Learn with BlocklyProp
Hi, we are trying to use the LTC1298 for analog to digital conversion. The manual says that the ADC connects to P0, 1, and 2 of the Stamp. Sorry this is probably a silly question, but just wondering if we can use other pinouts? Or are these special pins that the ADC has to connect to?

The reason I ask is because we eventually want to send the converted data to eb500 bluetooth transmitter. And according to the eb500 manual, the transmitter uses P0, 1, 5, 6 for transmitting, receiving and displaying status. I'm assuming they can't use the same pinouts?

Thanks in advance for any info.

Comments

  • MSDTechMSDTech Posts: 342
    edited 2008-05-08 11:27
    All the pins on the Basic Stamp are the same, you just need to adjust any sample code you are using to point to the right pin. The limiting factor is the eb500. Since it is pre-wired to use pins 0, 1, 2, 3, 5, and 6 in the appmod connector, you can't change its pinouts.
    A good programming practice is to assign symbolic names to all of the pins and then write the code to use the names. So for your project, if you connected the ADC to pins 4, 7 and 8 you would have a block of code like:
    BT_TX········· PIN· 0
    BT_RX········ ·PIN· 1
    BT_RTS······· PIN· 2
    BT_CTS······· PIN· 3
    ADC_CS····· · PIN· 4
    BT_Status···· PIN· 5
    BT_mode······ PIN· 6
    ADC_Data··· · PIN· 7
    ADC_CLK···· · PIN· 8
    Using this method, any future changes in the layout of the curcuit only require you to change the symbolic definitions and the rest of the code will remain unchanged.
  • kk Posts: 7
    edited 2008-05-08 15:13
    Thank you for the reply. I appreciate it. =)
  • datacpsdatacps Posts: 139
    edited 2008-05-10 05:45
    The pin info is for using different stamp boards with the eb500
    You will have to use the designated pins on the eb500 the different pins depend on what Stamp board or kit you are going to use... Board of Education, comes with the double row header so you can plug the eb500 to it. In this case you would have to use the pins specified.

    If you use the Stamp Basic Activity kit you can use the breadboard area and
    assign what ever pin you want to use as long as connect to the proper pin on the eb500. The eb500 uses pins 3,4,8,9




    Pinout
    1 3 5 7 9 11 13 15 17 19
    ? ? ? ? ? ? ? ? ? ?
    ? ? ? ? ? ? ? ? ? ?
    2 4 6 8 10 12 14 16 18 20
    1 VSS 2 VSS
    3 TX 4 RX
    5 NC 6 NC
    7 NC 8 STATUS
    9 MODE 10 NC
    11 NC 12 NC
    13 NC 14 NC
    15 NC 16 NC
    17 NC 18 NC
    19 NC 20 VCC
  • datacpsdatacps Posts: 139
    edited 2008-05-10 06:04
    You should be able to use any of the stamp boards and add the LTC1298 to it and asign any of the other pins that the eb500 is not using to comunicate with the ADC chip.

    This is the example from one of the books like MSDtech said you can use the names and the stamp will do the rest..
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    [noparse][[/noparse] Declarations ]
    adcBits VAR Byte
    v VAR Byte
    r VAR Byte
    v2 VAR Byte
    v3 VAR Byte
    '
    [noparse][[/noparse] Initialization ]
    CS PIN 0
    CLK PIN 1
    DataOutput PIN 2

    'Change the pins to what ever pin number you want to use as long as the eb500 pins are not connected to it when installed on the double row recepticles or sockets that come in the Board Of Education and the other Stamp boards with that feature.

    CS PIN 4
    CLK PIN 5
    DataOutput PIN 6

    '
    [noparse][[/noparse] Main Routine ]
    DO
    GOSUB ADC_Data
    GOSUB Calc_Volts
    GOSUB Display
    LOOP
    '
    [noparse][[/noparse] Subroutines ]
    'What ever pin you use the Stamp will execute the code using symbolic definition on that pin
    ' number. This will make it easy to change your circuit if needed without having to rewrite a lot of code
    ADC_Data:
    HIGH CS ' This will set CS high on what ever pin you designate
    LOW CS
    LOW CLK
    PULSOUT CLK, 210
    SHIFTIN DataOutput,CLK,MSBPOST,[noparse][[/noparse]adcBits\8]
    RETURN
    Calc_Volts:

    The bottom line is you can use any pin you want with the LTC1298.
    The eb500 you have to use the designated pins on the header since it is pre-wired to use pins 0, 1, 2, 3, 5, and 6 in the appmod connector, Board of Education ect.. you can't change its pinouts but you can still use the other pins that are not used on the LTC1298.. The Basic Stamp HomeWork Board does not have the double row connectors and you would have to use the breadboard area to connect both the eb500 and the LTC1298 and assign what ever pins you want to use them both...
  • FairuzFairuz Posts: 12
    edited 2008-05-20 01:49
    Hie...

    I am currently designing an optical sensor system and using LTC1298 as part of my design. When I measure the input of my ADC (output of optical sensor)·using multimeter, the measurement shows a very constant voltage until unit of milivolt. However, when I connect the output of my ADC to BS2 and debug the result on screen, the measurement shows signal that keep fluctuating about 20 to 30 steps up and down. I wonder why this happen whereas the measurement using multimeter shows other wise. I hope to receive any suggestion on why this may happen. And how to overcome it, to get a smooth signal. Is there any program line·that may help? With this email, I attached the sample measurement using stamp plot lite.

    Thanks so much in advance

    Fairuz
    620 x 479 - 63K
  • FireHopperFireHopper Posts: 180
    edited 2008-05-20 02:03
    perhaps avg the signal and just watch for trends?
  • FairuzFairuz Posts: 12
    edited 2008-05-20 02:32
    Thanks so much for the suggestion. I have tried to get the maximum value out of the first 200 AD data. But the programme does not work the way I expect it and the fluctuation is still there. Thanks so much

    'Program


    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.


    HIGH LED
    PAUSE 1000
    LOW sensor
    LOW LED
    HIGH CS ' Deactivate ADC to begin.
    HIGH DIO_n ' Set data pin for first start bit.

    again: ' Main loop.

    GOSUB convert ' Get data from ADC.
    DEBUG ? resultMax ' Display data.
    PAUSE 500 ' Wait a half second.
    GOTO again ' Endless loop.

    convert:

    resultMax = 0 ' initial maximum = zero
    FOR idx=1 TO 200

    config = config | %1011 ' Set all bits except oddSign.
    LOW CS ' Activate the ADC.
    SHIFTOUT DIO_n,CLK,LSBFIRST,[noparse][[/noparse]config\4] ' Send config bits.
    SHIFTIN DIO_n,CLK,MSBPOST,[noparse][[/noparse]AD\12] ' Get data bits.

    resultMax = AD MIN resultMax
    NEXT

    HIGH CS ' Deactivate the ADC.
    RETURN ' Return to program.
Sign In or Register to comment.