communicating with Visual Basic
Archiver
Posts: 46,084
Hi. I'm having a lot of problems communicating with VB 6.0 from my
BS2SX.
I have four different instruments which will be connected to the 2SX
and these instruments will all give out readings which I need to send
to VB, to be displayed in a GUI. However I only know how to send one
of these readings, and can't figure out how to send readings from the
other instruments. How can I differentiate between the different
instruments and how can I direct different readings to the
appropriate places in VB? Please help, I've been working on this for
ages and it is driving me mad. Thanks!
BS2SX.
I have four different instruments which will be connected to the 2SX
and these instruments will all give out readings which I need to send
to VB, to be displayed in a GUI. However I only know how to send one
of these readings, and can't figure out how to send readings from the
other instruments. How can I differentiate between the different
instruments and how can I direct different readings to the
appropriate places in VB? Please help, I've been working on this for
ages and it is driving me mad. Thanks!
Comments
Subject: [noparse][[/noparse]basicstamps] communicating with Visual Basic
> Hi. I'm having a lot of problems communicating with VB 6.0 from my
> BS2SX.
> I have four different instruments which will be connected to the 2SX
> and these instruments will all give out readings which I need to send
> to VB, to be displayed in a GUI. However I only know how to send one
> of these readings, and can't figure out how to send readings from the
> other instruments. How can I differentiate between the different
> instruments and how can I direct different readings to the
> appropriate places in VB? Please help, I've been working on this for
> ages and it is driving me mad. Thanks!
I have an article http://www.rentron.com/PicBasic/VB_PIC_TEMP.htm
showing how to separate incoming serial data with VB6.
Regards,
-Bruce
tech@r...
http://www.rentron.com
<e99bf0e8@s...> wrote:
> Hi. I'm having a lot of problems communicating with VB 6.0 from my
> BS2SX.
> I have four different instruments which will be connected to the
2SX
> and these instruments will all give out readings which I need to
send
> to VB, to be displayed in a GUI. However I only know how to send
one
> of these readings, and can't figure out how to send readings from
the
> other instruments. How can I differentiate between the different
> instruments and how can I direct different readings to the
> appropriate places in VB? Please help, I've been working on this
for
> ages and it is driving me mad. Thanks!
If I am understanding what you have said, you can make the Stamp
transmit data to Visual BASIC okay. The problem is how to create a
way to identify the data as coming from a specific device.
I would sugggest that you program the Stamp to send a fixed length
data string for all devices (if a device sends less data than the
rest of the devices, pad the string out with some suitable value like
00H) but make the first character of the string act as an
identifier.
For example, a five byte data block (in hexadecimal) for a
thermometer might be:
"010A550000"
where "01" is the identifier, "0A" and "55" is the temperature data
and "0000" are pad values to make a five-byte block.
A data block for a strain gage might be:
"0222D345C0"
where "02" is the identifier and "22D345C0" is four bytes of strain
gage data.
You could add a checksum byte if you wanted to add error checking to
make the string 6 bytes.
Then, whenever you receive input from your COM port in Visual BASIC,
you can pick the string apart using the first byte to identify the
data. I would write your Visual BASIC OnComm code to accept the
entire string at once instead of a byte at a time (it's been a while
since I did this, but I remember that it works bertter this way --
see the MsComm examples).
Hope this helps!
Jim Cambron
you could fix it up on the stamp end to send a fixed length
string, with all your info in it, at the same place, each time.
then,
fix up the visual basic side to get the data from the string,
as required.
ie,
data1 - first five characters
data2 - next five characters
data3 - the five after that
etc...