Help communicating a BS2 to a BK precision multimeter 5491B via RS232
Pantro040475
Posts: 8
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
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
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.
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.
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.
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.
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.)
*** Idle_HI instead of "True", Idle_LO instead of "Inverted"
thank you PJ and MG.