AXC F 2152 with IF CAN C++ ArpPlcGds process time

Hello, I am using a AXC F 2152(2404267) in combination with the IF CAN (2702668). The purpose of the unit is to receive, combine and send CAN-bus data. The data combining is done with general application code base on “C” this is compolied in the C++ code that is running on the PLC. All of this is working but there is a problem with the CAN-bus data processing. We get and send data to the IF CAN by ArpPlcGds_BeginRead and ArpPlcGds_BeginWrite. After some debugging I descovered that these command consume more then 6ms. This is a problem to support CAN-bus data at 250kbs 50% busload. The main loop speed is ~60MHz. Is there any other way how to exces this CAN-bus data at at least 500us? Arpversion: 21.0.5.35585 Example: // Read data from a fieldbus input frame void SmartLinkPlcCanDriver::readPortData(char* pValue, size_t valueSize) { if(!this->_initAxioline) { return; } TGdsBuffer* gdsBufferCanIn; size_t offsetCanIn; if(!ArpPlcIo_GetBufferPtrByPortName("Arp.Io.AxlC", IO_PORT_IN, &gdsBufferCanIn;)) { Log::Error("ArpPlcIo_GetBufferPtrByPortName in failed"); return; } if(!ArpPlcGds_GetVariableOffset(gdsBufferCanIn, IO_PORT_IN, &offsetCanIn;)) { Log::Error("ArpPlcGds_GetVariableOffset in failed"); return; } // Begin read operation, memory buffer will be locked char* readDataBufferPage; if(ArpPlcGds_BeginRead(gdsBufferCanIn, &readDataBufferPage;)) { // Copy data from GDS buffer char* dataAddress = readDataBufferPage + offsetCanIn; memcpy(pValue, dataAddress, valueSize); // Unlock buffer if(!ArpPlcGds_EndRead(gdsBufferCanIn)) { Log::Error("ArpPlcGds_EndRead failed"); } } else { Log::Error("ArpPlcGds_BeginRead failed"); ArpPlcGds_EndRead(gdsBufferCanIn); } // Release the GDS buffer and free internal resources if(gdsBufferCanIn != NULL) { if(!ArpPlcIo_ReleaseGdsBuffer(gdsBufferCanIn)) { Log::Error("ArpPlcIo_ReleaseGdsBuffer failed"); } } } Wilco.

Hello Wilco, I see in code, you are using the direct access to AXIO-Frame (CAN-Process Data), do you also tried to define the ports and connect it in PLCnEng with CAN processdata via GDS? //#port //#attributes(Input) uint8 PD_IN[64]; //#port //#attributes(Output) uint8 PD_OUT[64]; In the fist Step I would like to recommend you to connect the process Data via GDS and start the Cpp-program in 1ms Task. The goal should be to send/receive the CAN-Data in 1ms cyclic. Second step: AXC F 2152(2404267) allows to start 1ms-Tasks, If you would like to use 500us Task, you can use the AXC F 3152 controller with more performance. I hope it helps, if not please send me a short feedback. Best Regards Eduard

Hello Eduard, Thanks for your quick response! I have created a new test project in Eclipse under windows, DownloadLink zip file for workspace with example code. In the end it is working like I had expected. Along the way I discovered that the 1ms Log::Info handling caused a task handling delay of ~70 ms each ~140ms. Probably because it has to be written to flash at some point. Solved this “debuging” problem by putting the debug information in the transmitting CAN-bus messages :slight_smile: So with the PLC it is possible to handle 100% busload :slight_smile: Next step is to implement my own application code that is written in C. Still problems with this. Added *.c compile option to CMakeLists.txt (not in example code) this solved to problem to compile C code. But gives me a multiple definition of main' problem. See below for build output. When I remove the SHARED option in the CMakeList.txt it is possible to build but then gives problems with deploying: add_library(SmartLinkPlc [b]SHARED[/b]${Headers} ${Sources}) cmd.exe /c ""C:\\\Program Files\\\PHOENIX CONTACT\\\PLCnCLI\/plcncli.exe" deploy -p"C:/workspacesEclipse2021/SmartLinkPlc/SmartLinkPlc" -b Release -t"AXCF2152,2021.0.5 LTS (21.0.5.35585)" -s"src"" No library file was found in the path 'C:\\\workspacesEclipse2021\\\SmartLinkPlc\\\SmartLinkPlc\\\bin\\\AXCF2152_21.0.5.35585\\\Release'. Can you help me with this are could you sudgest me an other approch to make this work? I have application code that only require some platform functions like send and receive CAN-bus messages beside this there are also some I/O's that we have to set and read. The application I have at the moment is running in a while condition, this could be adjusted to a cyclic task function. [code type="markup"] cmd.exe /c ""C:\\\Program Files\\\PHOENIX CONTACT\\\PLCnCLI\/plcncli.exe" generate code -p"C:/workspacesEclipse2021/SmartLinkPlc/SmartLinkPlc" -s"src"" Generating all files with the 'code' generator for C:\\\workspacesEclipse2021\\\SmartLinkPlc\\\SmartLinkPlc. Successfully generated all files with the 'code' generator for C:\\\workspacesEclipse2021\\\SmartLinkPlc\\\SmartLinkPlc. cmd.exe /c ""C:\\\Program Files\\\PHOENIX CONTACT\\\PLCnCLI\/plcncli.exe" generate config -p"C:/workspacesEclipse2021/SmartLinkPlc/SmartLinkPlc" -s"src"" Generating all files with the 'config' generator for C:\\\workspacesEclipse2021\\\SmartLinkPlc\\\SmartLinkPlc. Successfully generated all files with the 'config' generator for C:\\\workspacesEclipse2021\\\SmartLinkPlc\\\SmartLinkPlc. cmd.exe /c ""C:\\\Program Files\\\PHOENIX CONTACT\\\PLCnCLI\/plcncli.exe" build -p"C:/workspacesEclipse2021/SmartLinkPlc/SmartLinkPlc" -b Release -t"AXCF2152,2021.0.5 LTS (21.0.5.35585)"" Requested build for targets AXCF2152,21.0.5.35585 Starting build for target AXCF2152,21.0.5.35585 Checking if CMake needs to be reconfigured... [cmake]: [cmake]: C:\\\workspacesEclipse2021\\\SmartLinkPlc\\\SmartLinkPlc\\\intermediate\\\cmake\\\AXCF2152,21.0.5.35585\\\Release>set PATH=C:\\\Program Files\\\eclipse\\\plugins\\\PLCnCLI_SDK_2021.0.5_LTS_Windows_AXC_F_2152\\\sysroots\\\x86_64-pokysdk-mingw32\\\usr\\\bin;C:/Users/Wilco/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_16.0.1.v20210528-1205/jre/bin/server;C:/Users/Wilco/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_16.0.1.v20210528-1205/jre/bin;C:\\\Program Files (x86)\\\Common Files\\\Oracle\\\Java\\\javapath;C:\\\Python\\\Python37\\\Scripts\\\;C:\\\Python\\\Python37\\\;C:\\\WINDOWS\\\system32;C:\\\WINDOWS;C:\\\WINDOWS\\\System32\\\Wbem;C:\\\WINDOWS\\\System32\\\WindowsPowerShell\\\v1.0\\\;C:\\\WINDOWS\\\System32\\\OpenSSH\\\;C:\\\Program Files\\\PuTTY\\\;C:\\\WINDOWS\\\system32\\\config\\\systemprofile\\\\.dnx\\\bin;C:\\\Program Files\\\Microsoft DNX\\\Dnvm\\\;C:\\\Program Files\\\Microsoft SQL Server\\\130\\\Tools\\\Binn\\\;C:\\\Program Files\\\Microsoft VS Code\\\bin;C:\\\Program Files\\\dotnet\\\;C:\\\Program Files\\\Git\\\cmd;C:\\\Qt\\\Tools\\\QtCreator\\\lib;C:\\\Program Files (x86)\\\ConfuserEx;C:\\\Program Files (x86)\\\Flash Magic;C:\\\Program Files (x86)\\\IVI Foundation\\\VISA\\\WinNT\\\Bin\\\;C:\\\Program Files\\\IVI Foundation\\\VISA\\\Win64\\\Bin\\\;C:\\\Program Files (x86)\\\IVI Foundation\\\VISA\\\WinNT\\\Bin;C:\\\Program Files\\\TortoiseSVN\\\bin;C:\\\Program Files\\\Nordic Semiconductor\ rf-command-line-tools\\\bin\\\;C:\\\Program Files (x86)\\\Vector CANdb++ 3.1\\\Exec32;C:\\\Program Files (x86)\\\dotnet\\\;C:\\\Users\\\Wilco\\\AppData\\\Local\\\Microsoft\\\WindowsApps;C:\\\Users\\\Wilco\\\AppData\\\Local\\\GitHubDesktop\\\bin;C:\\\Program Files (x86)\\\Flash Magic;;C:\\\Users\\\Wilco\\\AppData\\\Local\\\Microsoft\\\WindowsApps;C:\\\Users\\\Wilco\\\\.dotnet\\\tools;C:\\\Program Files\\\PHOENIX CONTACT\\\PLCnCLI\\\;C:\\\Users\\\Wilco\\\eclipse\\\cpp-2021-06\\\eclipse; [cmake]: make[1]: Entering directory 'C:/workspacesEclipse2021/SmartLinkPlc/SmartLinkPlc/intermediate/cmake/AXCF2152,21.0.5.35585/Release' [cmake]: make[2]: Entering directory 'C:/workspacesEclipse2021/SmartLinkPlc/SmartLinkPlc/intermediate/cmake/AXCF2152,21.0.5.35585/Release' [cmake]: Scanning dependencies of target SmartLinkPlc [cmake]: make[2]: Leaving directory 'C:/workspacesEclipse2021/SmartLinkPlc/SmartLinkPlc/intermediate/cmake/AXCF2152,21.0.5.35585/Release' [cmake]: make[2]: Entering directory 'C:/workspacesEclipse2021/SmartLinkPlc/SmartLinkPlc/intermediate/cmake/AXCF2152,21.0.5.35585/Release' [cmake]: [ 2%] Building C object CMakeFiles/SmartLinkPlc.dir/CMakeFiles/3.13.1/CompilerIdC/CMakeCCompilerId.c.o [cmake]: [ 4%] Building C object CMakeFiles/SmartLinkPlc.dir/CMakeFiles/feature_tests.c.o [cmake]: [ 7%] Building CXX object CMakeFiles/SmartLinkPlc.dir/intermediate/code/SmartLinkPlcComponent.meta.cpp.o [cmake]: [ 9%] Building CXX object CMakeFiles/SmartLinkPlc.dir/intermediate/code/SmartLinkPlcComponentProgramProvider.cpp.o [cmake]: [ 11%] Building CXX object CMakeFiles/SmartLinkPlc.dir/intermediate/code/SmartLinkPlcLibrary.cpp.o [cmake]: [ 14%] Building CXX object CMakeFiles/SmartLinkPlc.dir/intermediate/code/SmartLinkPlcLibrary.meta.cpp.o [cmake]: [ 16%] Building CXX object CMakeFiles/SmartLinkPlc.dir/src/SmartLinkPlcComponent.cpp.o [cmake]: [ 19%] Building CXX object CMakeFiles/SmartLinkPlc.dir/src/SmartLinkPlcProgram.cpp.o [cmake]: [ 21%] Building C object CMakeFiles/SmartLinkPlc.dir/src/builds/smartlink_mx/services_implementation/buzzer/buzzer.c.o [cmake]: [ 23%] Building C object CMakeFiles/SmartLinkPlc.dir/src/builds/smartlink_mx/services_implementation/can/can.c.o [cmake]: [ 26%] Building C object CMakeFiles/SmartLinkPlc.dir/src/builds/smartlink_mx/services_implementation/notify/notify.c.o [cmake]: [ 28%] Building C object CMakeFiles/SmartLinkPlc.dir/src/builds/smartlink_mx/services_implementation/platform/platform.c.o [cmake]: [ 30%] Building C object CMakeFiles/SmartLinkPlc.dir/src/builds/smartlink_mx/services_implementation/timer/timer.c.o [cmake]: [ 33%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/MQTT/MQTT.c.o [cmake]: [ 35%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/average_filter/average_filter.c.o [cmake]: [ 38%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/battery_information/battery_information.c.o [cmake]: [ 40%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/battery_ratings/battery_ratings.c.o [cmake]: [ 42%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/cJSON/cJSON.c.o [cmake]: [ 45%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/coffee_can/coffee_can.c.o [cmake]: [ 47%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/crc_ccitt/crc_ccitt.c.o [cmake]: [ 50%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/crc_stream/crc_stream.c.o [cmake]: [ 52%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/event_storage/event_storage.c.o [cmake]: [ 54%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/ftoa/ftoa.c.o [cmake]: [ 57%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/item_queue/item_queue.c.o [cmake]: [ 59%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/list/list.c.o [cmake]: [ 61%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/master_information/master_information.c.o [cmake]: [ 64%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/memory_stream/memory_stream.c.o [cmake]: [ 66%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/platform/platform.c.o [cmake]: [ 69%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/qrcodegen/qrcodegen.c.o [cmake]: [ 71%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/queue/queue.c.o [cmake]: [ 73%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/shared_stream/shared_stream.c.o [cmake]: [ 76%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/storage_tester/storage_tester.c.o [cmake]: [ 78%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/stream/stream.c.o [cmake]: [ 80%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/tasks/tasks.c.o [cmake]: [ 83%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/time_provider/time_provider.c.o [cmake]: [ 85%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/trace/trace.c.o [cmake]: [ 88%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/transition/transition.c.o [cmake]: [ 90%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/unit_test/unit_test.c.o [cmake]: [ 92%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/value_conversion/value_conversion.c.o [cmake]: [ 95%] Building C object CMakeFiles/SmartLinkPlc.dir/src/services/value_storage/value_storage.c.o [cmake]: [ 97%] Linking CXX shared module libSmartLinkPlc.so [cmake]: make[2]: Leaving directory 'C:/workspacesEclipse2021/SmartLinkPlc/SmartLinkPlc/intermediate/cmake/AXCF2152,21.0.5.35585/Release' [cmake]: c:/program files/eclipse/plugins/plcncli_sdk_2021.0.5_lts_windows_axc_f_2152/sysroots/x86_64-pokysdk-mingw32/usr/bin/arm-pxc-linux-gnueabi/../../libexec/arm-pxc-linux-gnueabi/gcc/arm-pxc-linux-gnueabi/9.3.0/real-ld.exe: CMakeFiles/SmartLinkPlc.dir/CMakeFiles/feature_tests.c.o: in function main’: [cmake]: feature_tests.c:(.text.startup+0x0): multiple definition of `main’; CMakeFiles/SmartLinkPlc.dir/CMakeFiles/3.13.1/CompilerIdC/CMakeCCompilerId.c.o:CMakeCCompilerId.c:(.text.startup+0x0): first defined here [cmake]: collect2.exe: error: ld returned 1 exit status [cmake]: make[2]: *** [CMakeFiles/SmartLinkPlc.dir/build.make:693: libSmartLinkPlc.so] Error 1 [cmake]: make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/SmartLinkPlc.dir/all] Error 2 [cmake]: make[1]: Leaving directory ‘C:/workspacesEclipse2021/SmartLinkPlc/SmartLinkPlc/intermediate/cmake/AXCF2152,21.0.5.35585/Release’ [cmake]: make: *** [Makefile:130: all] Error 2 cmake process exited with error [/code] Eclipse IDE for C/C++ Developers Version: 2021-06 (4.20.0) Build id: 20210612-2011 PLCnext Technology C++\t21.0.0.489\tcom.phoenixcontact.plcnext.cplusplus.feature.feature.group\tPHOENIX CONTACT GmbH & Co. KG