Beckhoff BX9000 to VisualBasic problem!

klikopc

Member
Join Date
Jun 2009
Location
Ptuj
Posts
64
Hi!

I have a Beckhoff BX9000 controler and would like to make Visualisation in Visual Basic.
I have tried the UDP communication and it works, I opened the ports and used the FB_IpSend and FB_IpRecieve and that works fine.

But is there a way to use the TwinCAT.Ads.dll library or the ActiveX(ADS-OCX) to communicate with the BX9000?

I tried using the ADS-OCX but I get a error reply from the BX9000 everytime I send a command to the BX!
 
Hi Steve!

I'm using VB 2008 .NET! I tried using the OCX, but i get nothing, no reply from the controller. But if I use the TwinCAT.ads.dll and generate a TcClient and then use a read method(i.e. : .AdsReadWrite,Index Group = 0), then I catch an error "wrong index group"!

I'll look into the link you posted, but can you give me some pointers on where to start?

Thank you Steve

Matic
 
Sure, I had to try it myself to make sure. For VB2008, the .NET interface is the way to go. I started with .NET Sample 1 here...
http://infosys.beckhoff.com/content/1033/tcsample_net/html/twincat.ads.sample01.html

I had to modify two lines in the form load...

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
tcClient = New TcAdsClient()
' Connect by ADS Address and Port number for BX9000 is port 800, not 801
tcClient.Connect("10.12.64.12.1.1", 800)

Try
' hVar = tcClient.CreateVariableHandle("MAIN.PLCVar")

Catch err As Exception
MessageBox.Show(err.Message)
End Try

End Sub


Then, in the btnRead_Click, change the read Variable to Read by Index Group and Offset...
Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click
Try
Dim dataStream As New AdsStream(100 * 2)
Dim binRead As New BinaryReader(dataStream)

'Read by Index Group and Offset, by Variable not supported by BC/BX
tcClient.Read(16416, 0, dataStream, 0, 100)

lbArray.Items.Clear()
dataStream.Position = 0
Dim i As Integer
For i = 0 To 99
lbArray.Items.Add(binRead.ReadInt16().ToString())
Next
Catch err As Exception
MessageBox.Show(err.Message)
End Try
End Sub

That should work for you, it reads from the array on the BX declared at %MB0. Code attached.
 
Steve, That is perfect!!!!!!

YOU'RE A GENIOUS!:geek:
If you're ever in Slovenia, there's a beer waiting for you!🍺

Thanks again!

Matic
 

Similar Topics

Hi, What is the trick (if there is one) to accessing a Bx9000 over a VPN? I know there is something finicky with network config when even local...
Replies
6
Views
2,103
Hi all, I have a machine with a Beckhoff BX9000 cpu that looses the source code every few days in the production. The name and the network...
Replies
0
Views
1,646
I am newbie in using the Twincat software. I have tried to connect between Beckhoff BX9000 and Twincat. But I was not successful. In the Twincat...
Replies
3
Views
5,673
Hi Has anyone tried connecting multiple PCs to a single BX9000 or BC9000/BC9050 via ADS ethernet protocol? I made two GUI application that use...
Replies
3
Views
3,832
Hi I have a Beckhoff BX9000 and want to connect it via SERIAL PORT(COM1) to a TouchPanel(Weintek) that uses Modbus RTU! I downloaded the example...
Replies
2
Views
3,901
Back
Top Bottom