Skip to content

Technical Questions on Simulation

Hi,

I'm very interested in using the PLCnext simulation tool for testing my C++ controller program.

I couldn't find technical details about this simulation. Would you mind elaborating on these:

  1. How much free virtual disk memory does the simulation come with?
    1. Is the simulation's memory footprint configurable to simulate additional SD card memory?
  2. Can the simulation access the Internet? (So, does wget work?)
  3. For CI/CD purposes: Can I load and launch the simulation without using PLCnext Engineer – from the command line?
    1. What are the commands necessary to load and launch the simulation from the command line?
  4. Can I debug my C++ controller program, running in the simulation, from Microsoft Visual Studio?
  5. How do I feed bus I/O packages to the simulation without any device connected?
  6. Can Modbus traffic be scripted/simulated, too?
    1. Is simulated bus traffic being logged for evaluation?
  7. Can I set/change the ports used by the simulation?

Your answers are very much appreciated.

Comments

  • Firstly, the simulation is not intended to be an identical replica of physical PLC. It's is mainly intended to allow the logic in POUs to be tested without PLC hardware. And it does not simulate any field devices that might be configured in the project, e.g. Profinet devices.

    How much free virtual disk memory does the simulation come with?

    You can ssh into port 5555 of the "device" and check this using the linux df command. 

    Is the simulation's memory footprint configurable to simulate additional SD card memory?

    In theory this may be possible by editing the .simboot.conf file in the relevant images directory, but we do not recommend or support this.

    Can the simulation access the Internet? (So, does wget work?)

     Not by default.

    For CI/CD purposes: Can I load and launch the simulation without using PLCnext Engineer – from the command line? What are the commands necessary to load and launch the simulation from the command line?

    This is possible in theory. The simulator uses qemu, so you would need to have some background knowledge on how to start qemu and load an image with arguments. That is beyond the scope of our support offering, but others in the Community (or on other forums) may be able to help.

    Can I debug my C++ controller program, running in the simulation, from Microsoft Visual Studio?

    In theory, yes. The "device" includes gdb, but the port would need to be mapped (see below).

    How do I feed bus I/O packages to the simulation without any device connected?

    You can't. The simulation is not designed to provide this feature. 

    Can Modbus traffic be scripted/simulated, too? 

    Modbus/TCP just uses TCP communications, which should work with suitable port mapping.

    Is simulated bus traffic being logged for evaluation?

     No, there is no "simulated bus traffic" generated by the simulator.

    Can I set/change the ports used by the simulation?

    Yes. In the the .simboot.conf file you can see the port mapping between the simulation and the host machine. For example the ssh port (22) on the simulator is mapped to port 5555 on the host machine. This port mapping can be modified and/or extended, but we do not recommend or support this.

  • Hi Martin,

    You answered that simulation can't access Internet by default.

    How could this default behaviour be changed so as to make the Internet access possible?

  • If you look at the .conf in your simulator-folder it's just arguments for the qemu-system-arm.exe.

    You can put all of that on the command line, or in a .ps1 file to run the simulator, i.e.

    ..\..\..\qemu\qemu-system-arm.exe -machine virt,highmem=off -cpu cortex-a15 -smp 2 -m 512M -device virtio-net-pci, ...

    I don't recommend removing or changing the first adapter, because that breaks integration with Engineer.

    But you can add another. On Windows you can install the TAP Adapter V9 (from OpenVPN) and use that for QEMU:

           "-device virtio-net-pci,netdev=net1,mac=A8:74:1D:12:34:03",

           "-netdev tap,id=net1,ifname=QEMU",

    You may be able to connect that to the outside world, via a bridge. How to do that is QEMU/host OS specific, I haven't attempted that myself.


    Here's a piece of powershell that you can put in the sim-folder, if you pass it the .conf it will run the simulator:

    # Get the path to the JSON file

    $json_file_path = $args[0]


    # Read the JSON file

    $json = Get-Content -Path $json_file_path

    $qemu_args = $json | ConvertFrom-Json


    # Create a list of arguments for qemu-system-arm

    $qemu_args_list = @()

    foreach ($arg in $qemu_args.arguments) {

       $qemu_args_list += $arg

    }


    # Call qemu-system-arm with the list of arguments

    Start-Process ..\..\..\qemu\qemu-system-arm.exe $qemu_args_list

Sign In or Register to comment.