Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twincat3 - ubuntu error code 6 #226

Open
kkk3449 opened this issue Apr 3, 2024 · 2 comments
Open

twincat3 - ubuntu error code 6 #226

kkk3449 opened this issue Apr 3, 2024 · 2 comments

Comments

@kkk3449
Copy link

kkk3449 commented Apr 3, 2024

Our current goal is to establish TCP/IP communication through an Ethernet cable between an Intel NUC (Ubuntu 20.04) - BECKHOFF PC CX5140 (TwinCAT3). The most desired method of communication is ROS-TwinCAT3.
connect_img

For communication, we have:
Successfully made the ADS git on the Ubuntu PC,

Communicated using ADSLib based on C++ for ROS,

Communicated using pyads,

Communicated using C++ based ADSLib from the ADS GitHub,

Added a route connection on the BECKHOFF PC.

However, all attempts have failed due to the same error code 6. We have disabled the firewalls on both the Ubuntu and BECKHOFF PCs.

We have set up the following in this order.

  1. BECKHOFF PC IP, AmsNetId setting
  • IP : 192.168.0.2
  • AmsNetId: 192.168.0.2.1.1
  • config mode

image-1712122961376 jpg3604331265164534897
1000003046

  • Add Route
    image-1712123642048 jpg2826945836975280154

  • Also add at StaticRouts.xml( I saw another Issues post and then setting it)
    image-1712122661348 jpg8454602938898796227

  1. ubuntu setting

ubuntu : 192.168.0.5

AmsnetId: 192.168.0.5.1.1
Untitled (1)

  • check Routs
    image-1712122585335 jpg5527650708302205370

  • try method 1 : example.cpp
    Untitled (2)

  • ADSError: error code 6
    Untitled (3)

  • try method 2 :pyads

import pyads

plc = pyads.Connection('192.168.0.2.1.1', 851)  

value = plc.read_by_name('MAIN.myFloatVAR')  

plc.write_by_name('MAIN.myFloatVAR', 123, pyads.PLCTYPE_INT)  
plc.close()
#include "AdsLib.h"
#include "AdsNotification.h"
#include "AdsVariable.h"
#include "ros/ros.h"

int main(int argc, char *argv[]) {
  // ROS node init
  ros::init(argc, argv, "tctalker");
  ros::NodeHandle n;

  ROS_INFO_STREAM("running good");

  static const AmsNetId remoteNetId{192, 168, 0, 2, 1, 1};
  static const char remoteIpV4[] = "192.168.0.2";

  AdsDevice route{remoteIpV4, remoteNetId, AMSPORT_R0_PLC_TC3};
//  AdsDevice route{remoteIpV4, remoteNetId, 351};
  AdsVariable<double> variable_to_write{route, "MAIN.myFloatVAR"};

  ros::Rate loop_rate(0.1);

  while (ros::ok()) {
    variable_to_write = 12.0;
    ROS_INFO_STREAM("changed variable on sps");
    ros::spinOnce();
    loop_rate.sleep();
  }

  return 0;
}
  • error : error code 6

  • control pc
    Untitled (6)

Untitled (7)

We are able to successfully send pings and it feels like we have tried every possible method. Is there any other solution you could suggest? Thank you.
Untitled

@pbruenn
Copy link
Member

pbruenn commented Apr 3, 2024

Is your PLC in RUN mode?

@kkk3449
Copy link
Author

kkk3449 commented Apr 3, 2024

Is your PLC in RUN mode?

Switching to run mode and executing the code, methods 1 (C++ ADS) and 2 (Python) worked well. Method 3 (ROS) still encounters a 1797 error, but I will try modifying variables to fix it. Before editing the .xml file, it did not work even in RUN mode, but it seems to work after modifying the .xml file. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants