Shop OBEX P1 Docs P2 Docs Learn Events
Help communicating a BS2 to a BK precision multimeter 5491B via RS232 — Parallax Forums

Help communicating a BS2 to a BK precision multimeter 5491B via RS232

Pantro040475Pantro040475 Posts: 8
edited 2011-11-14 09:11 in BASIC Stamp
Hello, dear parallax:
My name is Miguel Zepeda Electronics engineer, need help, we are making a project and we need to communicate a basic stamp 2 with a BK precision multimeter 5491B via RS232. What we do so far, is that we connect the multimeter with the computer and we use the parallax software and we send the command FETCH? to the multimeter and it responds with the reading that is in the display.
Now we are programming the BS2 to communicate with the multimeter and it only display BUS: BAD COMMAND.
This is the program we are using for the BS2:

'{$STAMP BS2}

Button VAR IN15
VOLTAGE VAR Byte(16) 'VOLTAGE ON DISPLAY

TOP: SEROUT 16, 16468,[" :FETCH? ", CR] '9600 BAUD
SERIN 15, 16468,[STR " ", CR] '9600 BAUD
DEBUG ":FETCH", CR
PAUSE 100
GOTO TOP
END


If you need anything else just let me know.
Thank you for your help.


Miguel Zepeda.
Electronics engineer
Standex Electronics

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-07 10:33
    How do you have things connected?

    Remember that DEBUG and SEROUT 16 are essentially the same. They both transmit via the link to the PC. Although this uses a DB-9 connection and connects to a PC's serial port, the signal levels are not exactly RS-232 and may not work with some serial ports. You may need to use a MAX232 RS-232 interface chip. It depends on the requirements of the multimeter.

    I don't understand what you're doing with the SERIN. What you wrote is an illegal statement (because of the STR " "). It shouldn't compile.
  • Pantro040475Pantro040475 Posts: 8
    edited 2011-11-07 10:49
    I have a DB9 connection to the BS2 and I'm programming the BS2 and after that I use that to connect the multimeter.
    Now I'm going to use a MAX 232 chip. What I need is the programming for the BS2 to communicate with the multimeter using SERIN and SEROUT.


    Thank you.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-07 11:17
    There is nothing special about using a MAX232. You would still use inverted mode, so you would continue to use the same Baud constant (16468) for 9600 Baud. You would use any two I/O pins, one for input (SERIN) and one for output (SEROUT). The details of how to communicate with the multimeter depends on the multimeter. Do you have documentation that shows what the multimeter requires?
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-07 12:56
    From the meter's manual, it looks like you're going to have to simplify the handling of the protocol.

    1) The meter echoes the received commands, one character at a time. The controller (the Stamp) is supposed to check to make sure that the character was received properly and not send the next character until the echoed character is received and checked against what was sent. The Stamp can't do that. It can send characters, but not receive at the same time. The echoed characters will be ignored by the Stamp. That may be ok (unless the meter is busy ... the Stamp can't check for that).

    2) The meter replies with what looks like a 15 character floating point number. You'll need to use a SERIN that stores the value in a byte array that's large enough for the number. Remember that there are only 26 bytes of variable space available on a BS2. You'll need to declare the buffer as:

    buffer VAR BYTE(15)

    and your SERIN statement would look something like:

    SERIN <pin>, 16468, [STR buffer\15\10]

    This receives up to 15 characters (including the terminating new line character).

    Transmitting commands to the meter would require something like:

    SEROUT <pin>, 16468, [":FETCH?",10]

    Note that the meter looks like it expects the delimiter to be a line feed / new line character whose value is 10. It can be configured to use a carriage return whose value is 13. See the meter's manual for details.
  • Pantro040475Pantro040475 Posts: 8
    edited 2011-11-09 14:42
    This are the meter settings from the manual:
    9600 baud 8 bit, 1 stop bit and no parity. Each program message that is transmitted to the controller is terminated with LF or CR


    This is the programming we did but still having BUS:BAD COMMAND

    buffer VAR Byte (15)

    SEND: SEROUT 16, 16468,["FETCH?",10]
    SERIN 17, 16468,[STR buffer\15\10]
    PAUSE 1000
    DEBUG " THE VOLTAGE IS", STR buffer\15, CR
    PAUSE 1000
    GOTO SEND
    END
    We need to know if we use the pin 16 for sendind data what would be the pin to use for receiving data?

    thank you.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-11-09 15:25
    "Now I'm going to use a MAX 232 chip. What I need is the programming for the BS2 to communicate with the multimeter using SERIN and SEROUT."
    "There is nothing special about using a MAX232. You would still use inverted mode, so you would continue to use the same Baud constant (16468) for 9600 Baud. You would use any two I/O pins, one for input (SERIN) and one for output (SEROUT)."

    If a MAX232 is used, then True baudmodes must be used.
    If connecting the meter comm pins directly to the Stamp pins then Inverted baudmodes are needed, and there must be a 22K resistor between the meter and the Stamp SERIN pin.

    *** If you're still using the DB9 (programming connector) then your SERIN should be on 15, SERIN 15,... (but you're going to have that Echo thing because of that 4k7 resistor.)
    I think you ought to go with a MAX232 and use P0-P14 (your choice.)

    About Levels.JPG
    577 x 805 - 40K
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-09 15:28
    Thanks PJ. I got that backwards again.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-11-09 15:39
    I would have chosen different nomenclature***.


    *** Idle_HI instead of "True", Idle_LO instead of "Inverted"
  • Pantro040475Pantro040475 Posts: 8
    edited 2011-11-14 09:11
    Ok, your info was very helpful to resolve the problem, we just put the 22k resistor to the serin pin and the meter start to communicate with the BS2.
    thank you PJ and MG.
Sign In or Register to comment.