Shop OBEX P1 Docs P2 Docs Learn Events
Sending data via I2C — Parallax Forums

Sending data via I2C

londlond Posts: 9
edited 2006-09-30 18:52 in BASIC Stamp
Hi!

I want to send this data string via I2C instead of a serial interface.

[noparse][[/noparse](Xmg.BIT15 * 2 + "+"), DEC (ABS Xmg/ 1000), ".", DEC3 (ABS Xmg), ",", (Ymg.BIT15 * 2 + "+"), DEC (ABS Ymg/ 1000), ".", DEC3 (ABS Ymg), ",", (Zmg.BIT15 * 2 + "+"), DEC (ABS Zmg/ 1000), ".", DEC3 (ABS Zmg), CR, LF]


The readout is something like this: "+0.054,-0.009,+1.056"


// Marcus L

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2006-09-29 18:06
    From where, to what, using what hardware? Are you using a BS2, BS2sx, BS2p? What device will recieve it?
  • londlond Posts: 9
    edited 2006-09-29 18:21
    from a bs2p to a µALFAT-SD

    // Marcus Löfstrand
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-09-29 19:53
    Marcus -

    This is _UNTESTED_, but I suspect it's probably going to have to be more like this:

    [noparse][[/noparse]SDEC (Xmg.BIT15 * 2), DEC (ABS Xmg/ 1000), ".", DEC3 (ABS Xmg), ",", SDEC (Ymg.BIT15 * 2), DEC (ABS Ymg/ 1000), ".", DEC3 (ABS Ymg), ",", (SDEC Zmg.BIT15 * 2), DEC (ABS Zmg/ 1000), ".", DEC3 (ABS Zmg), CR, LF]

    I imagine you were intending to use the "+" as a catenation operator, but unfortunately there is no such operator in PBASIC.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • londlond Posts: 9
    edited 2006-09-29 20:02
    (Xmg.BIT15 * 2 + "+") this piece generate a + or a -. So the + is very important.

    // Marcus L
  • londlond Posts: 9
    edited 2006-09-29 21:46
    I think I can use this (Xmg.BIT15 * 2 + $2B) were the $2B is the hexcode for +.

    // Marcus L
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-09-29 22:01
    Marcus -

    If you've found a catenation operator, I'm sure that Jeff Martin would love to hear about it, as he WROTE PBASIC. Hoping that "+" will catenate a "+" sign is just that - hope. SDEC will PERMIT and GENERATE a + or - based on the content of the data.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • londlond Posts: 9
    edited 2006-09-30 18:52
    The problem is that to be able to send data to the µALFAT-SD you have to set up how many characters you going to send to the µALFAT before you send the characters. With SDEC4 you will have 4 characters if it's a positive value or 5 characters if it's a negative value. With the data-string I use I will always have the same numbers of characters.

    // Marcus Löfstrand

    Post Edited (lond) : 9/30/2006 6:55:56 PM GMT
Sign In or Register to comment.