Shop OBEX P1 Docs P2 Docs Learn Events
converting variables in a BSII — Parallax Forums

converting variables in a BSII

ArchiverArchiver Posts: 46,084
edited 2000-06-08 20:22 in General Discussion
I am in a project where I am basically (SIC) reading a couple of
DIP switches, concatonating them together, and sending them out as
a single RS232 string. My problem is that I dont know the BSII
converts this information internally (i.e. numbers to strings).

I read a couple of nibbles (0 to 9) from a multiplexed bus. Lets say
i have 4 DIP switches, and they are multiplexed. My program
correctly
reads them, lets say they are set for 2,3,4, and 5. I can implement
a
'debug' command, and sure enough, they are read in correctly.

However, my final RS232 string really needs to be somethinge like the
following:

"F10.2345 GA"

So, I need to put an F in front, followed by the number 10, then a
period, then the data I read from the DIP switches, then a space,
then
the letters GA.

I thought about using an array, such as DIGITS(11) to hold 11
elements. To assign the elements I would say something like:
DIGITS(1) = "F", and so on.

However, when I try to send the whole thing out, it does not work.

I am having a heck of time with this. If anybody can help, it would
be apprecited.

Cheers,
Tracy

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-06-08 19:30
    In a message dated 6/8/00 12:17:17 PM Central Daylight Time,
    thooker@p... writes:

    > However, my final RS232 string really needs to be somethinge like the
    > following:
    >
    > "F10.2345 GA"
    >
    > So, I need to put an F in front, followed by the number 10, then a
    > period, then the data I read from the DIP switches, then a space,
    > then the letters GA.

    Give this a try:

    dips VAR WORD
    dip0 VAR dips.NIB0
    dip1 VAR dips.NIB1
    dip2 VAR dips.NIB2
    dip3 VAR dips.NIB3

    ' read the dip switches

    SEROUT sPin, baud, [noparse][[/noparse]"F10.", HEX4 dips, " GA"]


    I tested this by manually stuffing the dipX variables and using DEBUG. It
    gives the string you're looking for.
  • ArchiverArchiver Posts: 46,084
    edited 2000-06-08 20:22
    Tracy,

    I think your on the right track by using an array I do this using other
    microcontrollers all the time but you can't send the whole array at
    once you need to "parse it" or send one element of the array at a
    time with the command to send it out the port (i have'nt used my
    stamp in a long while). here's a crude example this is general not
    to basic stamp code spek

    An array with 10 elements

    array(10)

    for counter = 1 to 10
    ComPortOutput = array(counter)
    next counter

    Good luck
    I'm also here in Sunny & Hot New Mexico (Rio Rancho) Also I see
    your at NMSU Great EE School.
    Mike Fowler
    C Programmer
Sign In or Register to comment.