Fwd: support read information from plc to pc using c++

442 views
Skip to first unread message

Михаил Рогушков

unread,
Mar 17, 2014, 2:10:39 AM3/17/14
to beckhof...@googlegroups.com
Hello, I used one of the sample from your webcite(http://infosys.beckhoff.com/content/1033/tcsample_vc/html/tcadsdll_api_cpp_sample17.htm?id=18610). When i read information from PLC, I get an error when calling AdsSyncReadWriteReq (see picture). Could you tell me what's wrong or what this error means?Встроенное изображение 1
I used port, indexGroup and indexOffset from twincat.Встроенное изображение 2
Twincat is up and running with the controller


2014-03-05 11:53 GMT+04:00 Support Verl <Sup...@beckhoff.com>:

Hallo

In case you want to connect to a BC or other PC, ( it is the same bahaviour) you need a TwinCat for ADS-routing in the system from that you want to connect to the devices.

Then you can use the c++ (or whatever) . in the infosystem you can find a lot of samples for this kind of connection, the only difference is that the BC has a Port 800.

 

http://infosys.beckhoff.com/content/1033/tcsample_vc/html/note.htm?id=18587

 

 

Bei weiteren Fragen zögern Sie nicht uns zu kontaktieren

In case of further questions, don’t hesitate to contact us

 

Mit freundlichen Grüßen / with kind regards

Udo Heinrichs

 

BECKHOFF New Automation Technology 

Technischer Support

Hülshorstweg 20

D-33415 Verl

Germany

 

phone:    +49 (0)5246-963-157

fax:          +49 (0)5246-963-9157

mail:       mailto:Sup...@beckhoff.de

http:        www.beckhoff.com

 

 

Beckhoff Automation GmbH | Managing Director: Dipl. Phys. Hans Beckhoff, Arnold Beckhoff

Registered office: Verl, Germany | Register court: Gütersloh HRB 1803

 

 

 

 

Von: Михаил Рогушков [mailto:rogu...@gmail.com]
Gesendet: Mittwoch, 5. März 2014 08:43
An: Support Verl
Betreff: support read information from plc to pc using c++

 

Hello! 

How i could read information from plc(BC9020) to pc using c++? Could you give me some example or documentation? 

 

​​
--

Best regards,

Michael Rogushkov!

 


Beckhoff Automation GmbH | Managing Director: Dipl. Phys. Hans Beckhoff, Arnold Beckhoff
Registered office: Verl, Germany | Register court: Gütersloh HRB 1803




--

Best regards,

Michael Rogushkov!


ADS_Demo_SumReq.cpp

Stian Arevoll

unread,
Mar 17, 2014, 5:12:11 AM3/17/14
to beckhof...@googlegroups.com
Hello Michael.

I think there are a few things missing here. The error message is most likely not a valid one (Because its signed). What kind of datatype are you using for nErr?

As I interpret it from the screenshots and your texts, I think that you are trying to read/write the process image of the physical I/O directly. You cannot do that - you need a sync master for the I/O-bus. You need either a PLC task with variables linked to the I/O or an "Additional Task" with variables linked to the I/O. When you have linked the I/O to your task, you need to get the IndexGroup/IndexOffset for the specific variables to read them.

If you do not plan to use a PLC task, you can look at Beckhoff Information system on Additional tasks:

When you add an additional task, you add input/output variables by right clicking the respective type and create it with an appropriate data type. Then you link it to the desired I/O's.
Remember that the ADS port you should use for an additional task is default 301 for the first task. You also have to remember to check on the "Auto start" checkbox.
When you're happy with your configuration, you must hit "Activate configuration" and make sure TwinCAT is going to Run-mode afterwards.



Hope it helps!
 

With best regards,
Stian Arevoll


kl. 07:10:39 UTC+1 mandag 17. mars 2014 skrev Михаил Рогушков følgende:
Hello, I used one of the sample from your webcite(http://infosys.beckhoff.com/content/1033/tcsample_vc/html/tcadsdll_api_cpp_sample17.htm?id=18610). When i read information from PLC, I get an error when calling AdsSyncReadWriteReq (see picture). Could you tell me what's wrong or what this error means?Встроенное изображение 1
I used port, indexGroup and indexOffset from twincat.Встроенное изображение 2
Twincat is up and running with the controller
2014-03-05 11:53 GMT+04:00 Support Verl <>:

Hallo

In case you want to connect to a BC or other PC, ( it is the same bahaviour) you need a TwinCat for ADS-routing in the system from that you want to connect to the devices.

Then you can use the c++ (or whatever) . in the infosystem you can find a lot of samples for this kind of connection, the only difference is that the BC has a Port 800.

 

http://infosys.beckhoff.com/content/1033/tcsample_vc/html/note.htm?id=18587

 

 

Bei weiteren Fragen zögern Sie nicht uns zu kontaktieren

In case of further questions, don’t hesitate to contact us

 

Mit freundlichen Grüßen / with kind regards

Udo Heinrichs

 

BECKHOFF New Automation Technology 

Technischer Support

Hülshorstweg 20

D-33415 Verl

Germany

 

phone:    +49 (0)5246-963-157

fax:          +49 (0)5246-963-9157

http:        www.beckhoff.com

 

 

Beckhoff Automation GmbH | Managing Director: Dipl. Phys. Hans Beckhoff, Arnold Beckhoff

Registered office: Verl, Germany | Register court: Gütersloh HRB 1803

 

 

 

 

Von: Михаил Рогушков [mailto:rogu...@gmail.com]
Gesendet: Mittwoch, 5. März 2014 08:43
An: Support Verl
Betreff: support read information from plc to pc using c++

 

Hello! 

How i could read information from plc(BC9020) to pc using c++? Could you give me some example or documentation? 

 

​​
--

Best regards,

Michael Rogushkov!

 


Beckhoff Automation GmbH | Managing Director: Dipl. Phys. Hans Beckhoff, Arnold Beckhoff
Registered office: Verl, Germany | Register court: Gütersloh HRB 1803


Михаил Рогушков

unread,
Mar 17, 2014, 7:15:47 AM3/17/14
to beckhof...@googlegroups.com
when i connected to plc, i have to specify my AmsNetId from command AdsGetLocalAddress(pAddr) or write AmsNetId of plc (for example:   Addr.netId.b[0] = 172;
  Addr.netId.b[1] = 16;
  Addr.netId.b[2] = 22;
  Addr.netId.b[3] = 50;
  Addr.netId.b[4] = 1;
  Addr.netId.b[5] = 1;) ?


понедельник, 17 марта 2014 г., 13:12:11 UTC+4 пользователь Stian Arevoll написал:

Stian Arevoll

unread,
Mar 17, 2014, 11:05:01 AM3/17/14
to beckhof...@googlegroups.com
I am sorry, but what is the question?

-
Stian

Михаил Рогушков

unread,
Mar 17, 2014, 11:12:31 AM3/17/14
to beckhof...@googlegroups.com
how correct connect to plc? use example AdsGetLocalAddress(pAddr) -> than i get my local machine AmsNetId. Or i need use AmsNetId for PLC.
In example(http://infosys.beckhoff.com/content/1033/tcsample_vc/html/tcadsdll_api_cpp_sampleintro.htm?id=18637) use AdsGetLocalAddress, but i need connect to plc
 
понедельник, 17 марта 2014 г., 19:05:01 UTC+4 пользователь Stian Arevoll написал:

Stian Arevoll

unread,
Mar 19, 2014, 5:33:08 AM3/19/14
to beckhof...@googlegroups.com
Hi,

You need to use the PLC's AMS Netid. And the PLC also needs to know your computer, so you have to create an AMS route on the PLC with AMS net id of your PC and your IP-address or hostname. Then its really important that TwinCAT on the PLC gets restarted.

If you provide me with information about what kind of PLC you are using, I can help you further.

Best regards,
Stian
Reply all
Reply to author
Forward
0 new messages