RS485 & Visual Basic

U

Thread Starter

USWest

Anyone with experience using Visual Basic to monitor a RS485 network. Is it the same as setting up RS232? Any help would be appreciated.
Thanks
 
What are you going to use to talk on the 485 bus? If it is a Digiboard or something with drivers that will look like COM ports it isn't a big deal. Just open the port using the standard library calls and go for it.

Another way is to go to telebyte (I think they are still around) who sell RS-232 to RS-485/422 adapters. Then it really is just open the COM port and go. These adapters can either automagically set the direction for the 485 bus (tx or rx) or use DTE or DSR signals (the former is recommended).

Assuming things haven't changed much there are a handful of calls, OpenComm, CloseComm, ReadComm, WriteComm, and GetCommError that allow working the serial ports.

There is a book out there called "Visual Basic How-To" published by the Waite Group which I used the first time I needed to do something with Visual Basic. Also look at the examples suppled by Microsoft. I think they supply something like a terminal program written in VB (maybe that was VC++) ... but there should be something.

I hope this is helpful.

Tom Bray
 
J
Hi, I have used Visual basic to manage a modbus protocol as master for the PC. In my mind, the sole difference between rs232 and RS485 form the PC point of view is the management of line.
When you write on the serial port, you have to put high the line, and put it down just after finishing wiriting. With the MScomm32 OCX, it is easy to read and write on a serial port. But on VB, you can't manage the line manually. (you have to use the Rts Toggle option) to let VB managing the line. My experience was concerning Modbus RTU protocol ( and I had some difficulties because the line was not managed efficiency by VB). The device I was commnicating with had a true modbus protocol. The detection of the end of a message is consisting in a blank of 3,5 characters, after that the device was answering. From time to time, the device was trying to answering the PC while PC had not put the line down. So I doubt with the efficiency of automatic line management with VB in severe conditions of time. But I just have a limited experience with communication.
Regards.
J-F Portala
SoViLor company
[email protected]
 
Hello everyone .
I have the same trouble here on RS485 Program.
That is using VB control the RS485 network. All client with a RS485 port is connect on the bus.every client have a jumper to make a ID to different to other. But every data to send to client must lead with one byte of ID , the ID must have 8+1 bit , the 1 bit is the party bit, it must be set as 1. And any one could give me some suggest how VB control that bit.

thanks a lot for any nfo.
seeker
 
L
Hello everyone .
I have the same trouble here on RS485 Program.
The clients use the 9 bit multidrop mode for addresse recognition, the ID must have 8+1 bit , the 1 bit is the parity bit, it must be set as 1. And any one could give me some suggest how VB control that bit.If somebody has information
please reply

[email protected]




 
G

Greg Schiller

The only way I can see it being done with MSComm is to set and reset the parity each time.

MSComm1.Settings = "19200,M,8,1"
MSComm1.Output = "" & IDNum 'Send out the ID
MSComm1.Settings = "19200,S,8,1"
MSComm1.Output = "" & IDNum 'Send out the rest of the message

Unfortunately this can create delays between when the ID and the message gets sent. Most of the time when this gets implemented most people are using C with an embedded controller to "toggle" the parity setting very quickly. It may work for your situation though.

Regards and good luck,

Greg Schiller
Eason Technology
214B Center St.
Healdsburg, CA 95448
P:(707)433-2854x24
F:(707)433-3706
E:[email protected]
 
R

Rob Hulsebos Philips CFT

You mght try to use ID's for which the parity bit is (after calculation) always 1.
This way there is no need to toggle the comm-port settings.

Rob Hulsebos


 
Top