Shop OBEX P1 Docs P2 Docs Learn Events
Need help integrating a BS2e with two sensors — Parallax Forums

Need help integrating a BS2e with two sensors

'O Flyer'O Flyer Posts: 9
edited 2005-04-27 17:48 in BASIC Stamp
Hi people,

I'm attempting to integrate a BS2e with two sensors - barometric pressure and fluid level - sending their output of approx. 0.25 to 4.75v ea. to an A to D converter , on to the Stamp and then on to a Decade Engineering BOB3 video overlay module. Because I may later·add a couple more sensors, I chose a Texas Instuments TLV2544· 4-ch A to D converter. Compared to the Linear Technology LTC1298 (for which there's probably adequate example programming documentation·in "Stamp Applications no.4", the '2544 is "high speed" with a sampling·rate of 200 KSPS vs 11.1 KSPS for the '1298. The '2544 data sheet gives a recommended 10 microsec. max. for the "sample clock" cycle time.·Would this indicate that the TLV2544 is too high·speed a device to be compatable with the BS2e?

Assuming they can work together, the '2544 needs to be "configured" with a 16 bit setup word.·I want to "feed" this word ("Setuptotal") to the '2544s serial data in pin MSBF. I was trying out this particular code:

Setuptotal····· VAR······· W0
n·················· VAR······· Nib
Bitn··············· VAR······· Bit
Setuptotal = %1010101111101010

FOR n = 15 TO 0
·· DEBUG BIN Bitn
·· PAUSE 250
NEXT


At this stage my goal is simply to reproduce the above constant "Setuptotal" in the DEBUG window with this code. What am·I doing wrong here?·Aren't the bits making up the number "Setuptotal" in RAM register W0 known to the·Stamp as Bit15 through Bit0?

'O Flyer



Post Edited By Moderator (Chris Savage (Parallax)) : 4/27/2005 12:47:58 AM GMT

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-27 01:15
    The first and most serious problem is that you're using internal variable names mixed with variable types -- big no no.· Don't do it ... ever.· When you catch yourself considering it,·stop.· The compiler lets you lay in manual variables (like W0 in your example) but doesn't consider them when doing its own assignments.· So, 'n' is actually the low nibble of 'Setuptotal' and 'Bitn' is actually BIT4 of 'Setuptotal'.

    I think this is what you want:

    setupTotal··· VAR··· Word
    idx·········· VAR·· ·Nib
    theBit······· VAR·· ·Bit

    Main:
    · setupTotal = %1010101111101010
    · FOR idx = 15 TO 0
    ··· theBit = setupTotal.LOWBIT(idx)
    ··· DEBUG BIN theBit
    ··· PAUSE 250
    · NEXT

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • 'O Flyer'O Flyer Posts: 9
    edited 2005-04-27 17:48
    Hi Jon,

    Thank you for that quick reply. I'll experiment a bit in order to better understand what you're saying. And I'll eventually have more questions!

    Vern Roach (O'Flyer)
Sign In or Register to comment.