# Visual Basic question

K

#### Kevin

What's the best book on the market for "intro to Visual Basic" especially dealing with "connection" to PLC's for data access and display?

G

#### Glass, Philip

You've got two completely different subjects you want covered. You can find intro-level books on VB and you can find books on comm programming.
You won't find a book that has both because comm programming is not a task a beginner would undertake.

If you are completely new to VB and programming in general, I would recommend a Que book 2nd edition called "Using Excel Visual Basic for
Applications". I assume you are familiar with Excel? Starting with VBA will make your transition to VB much easier. Using Excel, you can get results much easier and faster. For example, if you want to expiriment with looping constructs, you could easily build a for-next loop
that changes the cell background colors of a1:a5.
You could get results easy in VB by laying down objects but in Excel you can manipulate objects already on the screen.

I couldn't begin to tell you where to find books for communicating with PLC's using VB. This depends on a number of things. What PLC? What protocol? What drivers are available for that PLC?

This isn't something you can learn overnight.

Good luck!

Phil

B

#### Bill Mars

Some where on a CD I have VBasic source code that allowed me to send data to/from a SLC500. I haven't look at it for a couple of years. Is that what you're looking for?

J

#### Joe Jansen/ENGR/HQ/KEMET/US

Kevin,

If you buy a copy of visual studio, the MSDN library that you get with it is surprisingly good. There are good technical papers, etc., and the sample code has fewer bugs in it than MS help usually does. Note that they are far from perfect, but you can usually debug them quickly. Read through some of the papers in MSDN, and play with the code they supply.

For communication, the best and the easiest method is to find someone that sells an OCX (or ActiveX) component to do this for you. Automated
solutions (www.automatedsolutions.com I think) is one that I have used successfully for AB, and they make others. These are packages that you can
drop onto your main form, much like a button or text box. You use them by assigning some values to their needed properties, for example, on the one I used I would set things like:

(note: This is an example. Property names may not be exact, or even close, but you get the idea!)

CommObject.Words = 10

Then I would call the actual read function:

and I would get back:

CommObject.DataWord(0) = {whatever is in N7:20}
CommObject.DataWord(1) = {whatever is in N7:21}
.
.
.
CommObject.DataWord(9) = {whatever is in N7:29}

That's It!!!

Writing is similar in that you load up the array, and then call the write function.

Visual Basic is extremely easy to use. The project described above was the first program I ever wrote in VB. It would read and write data to a PLC that controlled a network of PLC's doing data collection and tag printing.

Another benefit of going with a purchased communication component is that they will supply some sample code, and their app engineers are excellent at helping debug programs. The guy I worked with (I forgot his name) helped me trace a particularly nasty problem that was happening when I moved my app from Win98 to WinNT. We spent weeks on this, and they finally rolled
me a patch to fix the problem. You can't beat service like that! The whole thing was around $1000, and WELL worth it. Hope that this helps! --Joe Jansen L #### Luc I have read dozen of MS-VB and PLC books but the one that I remember the most is: Home Automation Basics : Practical Applications Using Visual Basic 6 by Tom E. Leonik. This book looks like lightweight tech. reading. Don't be fooled, this is cool stuff. Right to point and fun. Check it out and enjoy. Luc. A #### Al-Van Hello, does your PLC have a MEWTOCOL? if it does I may be able to give some help. If the PLC your using can communicate using a MEWTOCOL protocol, you can use the VB MS communication control and depending on how you program the PLC it may be able to provide you with data to be interpreted. example %01# command %01$ correct command
%01! incorrect command
I may not be able to give you book title, but I may be able to help how to write the progam. I had already developed several VB program that will
read, send data to a PLC for our BMS projects(Building Management System) email for additional info

K

#### Kevin MacMillan

> Somewhere on a CD I have VBasic source code that allowed me to send data to/from a SLC500. I haven't look at it for a couple of years. Is that what you're looking for? >

I am looking for a sample to send data to/from a SLC500. If you have that sample I would really appreciate it if you could e-mail it to me.

[email protected]

W

#### Wael Hassan

My PLC supports MEWTOCOL, but whenever I try to send anything, I do not get any response from the PLC, not even an error message. If you can help me out please reply to me on [email protected]

A

#### Anonymous

Hi!
Can you send me a source code for me.if it is pls. mail me on [email protected].

kalpesh patel

A

#### Anonymous

I would also be interest in any code examples you may have that would allow direct communcation between VB and an AB ContolLogix.

W

#### wi

i will write VB programm to read PLC Register (with MEWTOCOL), can you give me some tips how to do this? thank's in advance for your help and may be some source code

[email protected]

S

#### Stephen Fierro

I have a PLC that uses MEWTOCOL (Aromat FP Sigma) and I would like to write a simple program that will read from the PLC's data registers and write that data to an Excel file. If you could send me a sample of what you wrote I would appreciate it greatly, thanks. (Send to [email protected])

> Hello, does your PLC have a MEWTOCOL?
> if it does I may be able to give some
> help. If the PLC your using can communicate
> using a MEWTOCOL protocol, you can use the VB
> MS communication control and depending on how you
> program the PLC it may be able to provide you with data to be interpreted.
>
> example
> %01# command
> %01\$ correct command
> %01! incorrect command
> I may not be able to give you book title, but I may be able to help how to write the progam. I had already developed several VB program that will
> read, send data to a PLC for our BMS projects(Building Management System) email for additional info
>
>
>
>

K

#### Karel

i'm looking for such abook to
If you find it ,let me know
thanks,karel
[email protected]