Author Topic: VBasic comms  (Read 59720 times)

Dan Morgan

  • Guest
VBasic comms
« on: August 28, 2002, 11:26:54 AM »
Does anyone have some sample code for polling a plc in visual basic 5 or 6? I wrote a small program in qbasic it worked great. But in visbasic I get an echo of Cntrl E but the command always comes back ER*. It's something silly but I don't have a clue.

Thanks for any input.

Dan
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: VBasic comms
« Reply #1 on: February 06, 2003, 01:27:25 PM »
We have created a sample program in Visual Basic that can handle both point-to-point and multi-point protocol. You can download the program including full source code from the following link:

http://www.tri-plc.com/applications/VBsample.htm

This program allows you to setup the communication parameters and send test host link messages, as shown below:

« Last Edit: December 31, 1969, 04:00:03 PM by -1 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:VBasic comms
« Reply #2 on: February 03, 2006, 03:52:02 PM »
A user Mr Julian Stone of The United Kingdom has kindly contributed a Visual BASIC .NET class and some additional command for communication with the M-series PLCs. The file is located at:

http://www.tri-plc.com/appnotes/VBasicDotNetComm.htm
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

newbie-06

  • Newbie
  • *
  • Posts: 7
  • I'm a llama!
    • View Profile
Re:VBasic comms
« Reply #3 on: June 27, 2010, 11:07:30 AM »
dear support...
i dunno what's wrong with my PLC TMD100 1616..
i try to connect with TLserver 3.0 using wind XP..
when i type command "IR*", the TLserver reply well, they sent back the response,,,
but when i type command "RVDnnnn*" the TLserver reply "No response from PLC"...
plis help me,,,
thanks a lot, support

for additional hereby i include the screenshoot from TLserver

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:VBasic comms
« Reply #4 on: June 28, 2010, 02:31:40 PM »
TLServer only supports multi-point protocol except for "IR*" command. So you need to enter "@01RVDxxxx00*" - 00 is the wildcard FCS, but you can also click the "FCS" button to enter the real FCS.

Note that the address is in Hexadecimal notation. So if you want to read DM[3904] you need to convert it to Hexadecimal which is 0F40.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

newbie-06

  • Newbie
  • *
  • Posts: 7
  • I'm a llama!
    • View Profile
Re:VBasic comms
« Reply #5 on: June 28, 2010, 07:04:33 PM »
thank you for the answer..
let me try it later..
:D

i must have skipped reading the manual...
:D
« Last Edit: June 28, 2010, 07:10:52 PM by newbie-06 »

newbie-06

  • Newbie
  • *
  • Posts: 7
  • I'm a llama!
    • View Profile
Re:VBasic comms
« Reply #6 on: July 25, 2010, 10:16:04 PM »
Hai all,,
I'd like to ask again
Im using my laptop for the connection to PLC
Because Laptop has no serial communication, I purchase a usb to rs232 converter
I was using the usb port for communication, the port comm number is around 17, 18, 19
when i was using TLserver there are no problem, but when i was using sample vb6 program from
Code: [Select]
http://www.tri-plc.com/applications/SerialComm.zip i have problem that the combo box "port choice" won't work when the port number is above COM8...
can someone tell me what wrong with the code?

here is the screenshoot



because i need the port opened at COM arround 17,18, 19
thanks before

regards ;D
« Last Edit: July 25, 2010, 10:27:44 PM by newbie-06 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:VBasic comms
« Reply #7 on: July 26, 2010, 08:21:36 AM »
You can add the correct COM port number in the COM port list in Visual Basic source code.

Alternatively, you can use the control panel to fix your USB-RS232 adapter to a COM port number that matches one of those shown on VB choice box.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

newbie-06

  • Newbie
  • *
  • Posts: 7
  • I'm a llama!
    • View Profile
Re:VBasic comms
« Reply #8 on: August 05, 2010, 09:44:57 PM »
i wanna ask another thing...
this time i wanna try a simple ladder that would be access through TLServer 3.0...


here is the screenshot of the ladder



then here is the screenshot of the TLServer


I type @01WI0101 command
the response should be @01WI*
but the TLServer response was  @01FE42*

I dont understand how that could happen...
or maybe i wrote the wrong command?
« Last Edit: August 05, 2010, 09:45:32 PM by newbie-06 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:VBasic comms
« Reply #9 on: August 06, 2010, 12:13:40 AM »
You need to append two bytes of FCS to your command.  You can use TLServer to compute the FCS (click the FCS button!) and then add to the end of the string before *.

For testing you can also use "00" as the wildcard FCS if the PLC is in Automatic protocol mode.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

newbie-06

  • Newbie
  • *
  • Posts: 7
  • I'm a llama!
    • View Profile
Re:VBasic comms
« Reply #10 on: August 06, 2010, 04:48:54 PM »
thank you,,
let me try it..

by the way,,
i wanna ask about the data,,,
it says


can u describe about the data?


from my simple ladder,if i wanna turn on the output i have to execute input in channel 01..
but what number i should put on the data?
is it just any number or i have to define it in the ladder or what?
thank you

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:VBasic comms
« Reply #11 on: August 08, 2010, 12:30:28 PM »
These host commands are for a external host computer or an external PLC to access the PLC's internal I/O via Serial Port or Ethernet port.  These are NOT commands to be used in the ladder program.

What you need to do in the ladder program is to define a label name for each I/O you are using and then create the ladder program by picking the I/O from the I/O definition table.

The channel 01 for say the "WI01" command maps to the input #9 to #16. So if your external PC sends a "WI01FF" serial command to the PLC it will turn on the input #9 to #16. But because the inputs will be refreshed by the PLC program when it does an I/O scan it will be changed again immediately. But the PLC program can actually pick up the effect.

A better demo is to use "WO01FF" which will write to output #9 to #16 and if these are not controlled by the PLC program then they will stay ON after you send the command.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

newbie-06

  • Newbie
  • *
  • Posts: 7
  • I'm a llama!
    • View Profile
Re:VBasic comms
« Reply #12 on: August 08, 2010, 08:41:49 PM »
These host commands are for a external host computer or an external PLC to access the PLC's internal I/O via Serial Port or Ethernet port.  These are NOT commands to be used in the ladder program.

yes, actually i wanna controlled a PLC T100MD1616+ through vb as GUI.
im using vb sample from http://www.tri-plc.com/applications/VBsample.htm#VB6sample#VB6sample
and im working on it right now

The channel 01 for say the "WI01" command maps to the input #9 to #16. So if your external PC sends a "WI01FF" serial command to the PLC it will turn on the input #9 to #16.

Ooh i see it and i have tried it...
but can i turn on the input #9 without make the input #10 to #16 turn on?
thank you
« Last Edit: August 08, 2010, 08:45:51 PM by newbie-06 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:VBasic comms
« Reply #13 on: August 08, 2010, 11:04:10 PM »
Please use the Wb command if you wish to turn on a single bit.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

newbie-06

  • Newbie
  • *
  • Posts: 7
  • I'm a llama!
    • View Profile
Re:VBasic comms
« Reply #14 on: August 09, 2010, 11:36:07 PM »
Please use the Wb command if you wish to turn on a single bit.

thank you for the answer
;D



regards

newbie-06