REXYGEN Community Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Login
    1. Home
    2. Jan Reitinger
    3. Posts
    J
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 65
    • Best 1
    • Controversial 0
    • Groups 1

    Posts made by Jan Reitinger

    • RE: Issue with the SAT block

      @stepan-ozana
      The problem is caused by a large value in the parameters tn and tp. The change occurs, but it is very slow. For a faster transition between values, set lower parameter values. For an immediate change, set 0.

      posted in REXYGEN Studio
      J
      Jan Reitinger
    • RE: Issue with the SAT block

      @stepan-ozana Hello,
      thank you for your report.

      Please, what version of REXYGEN are you using? I've tested it now on 3.0.4.17197 and everything seems to work. I'm attaching a printscreen and the project.
      327187a5-26b0-4640-99c3-20348af4e7b4-image.png myproject_exec.mdl myproject_task.mdl

      Best regards,
      Jan

      posted in REXYGEN Studio
      J
      Jan Reitinger
    • RE: Remote parameter setting

      Hello Štěpán,

      Thanks for the detailed summary — that’s really helpful!

      Regarding the first experiment with the SETPS command:
      The reason the CNSTEST1:scv parameter wasn’t updated is due to the SETF parameter of the SETPS block being set to "on". In this configuration, the value is only updated on a rising edge at the SET input.
      To allow the value to be updated continuously, set SETF to "off". This way, the parameter will be updated in each cycle regardless of input transitions.

      As for the issue with setting the CNA:filename parameter:
      The filename specified here is not part of the application on the target device. Instead, the file resides on the host PC, and its contents are imported into the project during compilation.
      That’s why the filename parameter cannot be changed online — it only serves as a reference for the compiler, not as a runtime variable.
      Similarly, updating the nmax parameter isn't possible either, because REXYGEN does not support dynamic arrays — both the size and content of arrays are fixed during compilation.

      As a general rule, parameters that can be modified online via SETP blocks are the same ones you can manually change in Watch mode — in other words, those that are not greyed out in the parameter list. If a parameter is greyed out, it means it’s read-only during runtime and cannot be changed programmatically either.

      8f72a40a-bfcf-4242-832a-7caabc2017e3-image.png

      Cheers,
      Jan

      posted in REXYGEN Studio
      J
      Jan Reitinger
    • RE: EKF example

      @stepan-ozana
      Thanks, that looks great! I'll modify the schema a little more to match the conventions of the other blocks and include it in the installation.

      posted in REXYGEN Studio
      J
      Jan Reitinger
    • RE: EKF example

      @stepan-ozana Thank you for your valuable insights! Your contribution to the collection of examples is greatly appreciated.

      In the original 'EKF.zip' file mentioned at the beginning of this thread, the timing parameters were incorrectly set—my apologies for that. The best way to correct them is by changing the start and stop values in the task1 block to -1, as outlined in the manual. The log message 'CoreWarning GTimer: Period overtime.' appears whenever the task execution exceeds the maximum allowed time, which can be observed in Diagnostics. If this warning appears in the log while the Max time in Diagnostics does not exceed the allocated execution time (20 ms in the case of EKF.zip), it indicates an error.

      We would greatly appreciate any further insights and improvements from your side. I had planned to simulate measurement noise similarly to your approach—by adding white noise to the measurement vector—but I hadn’t considered process noise. For your reference, I’m sharing the updated version of the example, which includes your reference model and the corrected timing parameters.

      Linear system.zip

      posted in REXYGEN Studio
      J
      Jan Reitinger
    • RE: EKF example

      @stepan-ozana
      First of all, thank you very much for adding the reference model. If you agree, I would like to add this model to the example on EKF, which is already part of the daily version of REXYGEN.

      As for the timing. I think the problem may be in the Python block, which takes significantly longer to execute than the native blocks. Try looking in the Diagnostics and at the statistics on the execution of the task.
      17766e3a-d6bf-46ee-9616-28465ebb2c74-image.png

      posted in REXYGEN Studio
      J
      Jan Reitinger
    • RE: EKF example

      EKF - Linear System Model

      This document describes the use of the Extended Kalman Filter (EKF) in the REXYGEN environment for state estimation of a linear system.

      System Description

      The system is described by the following differential equations:

      \begin{aligned}
      \frac{dx(t)}{dt} &= f(x(t), u(t)) + w(t),\\
      y(t) &= h(x(t), u(t)) + v(t),\\
      \hat{x}(t) &\sim \mathcal{N}(x, P),\\
      w(t) &\sim \mathcal{N}(0, Q),\\
      v(t) &\sim \mathcal{N}(0, R).
      \end{aligned}
      

      where:

      • $ x(t) $ is the state vector,
      • $ u(t) $ is the input vector,
      • $ y(t) $ is the output vector,
      • $ w(t) $ is the process noise,
      • $ v(t) $ is the measurement noise,
      • $ \hat{x}(t) $ is the estimated state vector,
      • $ x $ is the mean (expected value),
      • $ P $ is the state estimation covariance matrix,
      • $ Q $ is the process noise covariance matrix,
      • $ R $ is the measurement noise covariance matrix.

      State Model of the System

      The system dynamics are defined by the function $ f(x(t), u(t)) $:

      f(x(t), u(t)) =
      \begin{bmatrix}
      \frac{dx_1(t)}{dt} \\
      \frac{dx_2(t)}{dt} \\
      \frac{dx_3(t)}{dt} \\
      \frac{dx_4(t)}{dt}
      \end{bmatrix}
      =
      \begin{bmatrix}
      -x_1(t) + x_2(t) \\
      -x_2(t) + x_3(t) \\
      -x_3(t) + x_4(t) \\
      -x_4(t) + u_1(t)
      \end{bmatrix}.
      

      Jacobian of the State Function

      The Jacobian $ f(x, u) $ with respect to the state vector $ x $ is given as:

      \frac{df(x(t), u(t))}{dx} =
      \begin{bmatrix}
      -1 & 1 & 0 & 0 \\
      0 & -1 & 1 & 0 \\
      0 & 0 & -1 & 1 \\
      0 & 0 & 0 & -1
      \end{bmatrix}
      

      Output Measurements

      The first set of output measurements (which, in this example, depend linearly on the state variables) for input EKF:nz = 1 is defined as:

      y(t) = h_1(x(t), u(t)) = 
      \begin{bmatrix}
      x_1(t) \\
      2 x_2(t) + 0.5 x_4(t)
      \end{bmatrix},
      

      with the corresponding Jacobian:

      \frac{dh_1(x(t), u(t))}{dt} =
      \begin{bmatrix}
      1 & 0 & 0 & 0 \\
      0 & 2 & 0 & 0.5 \\
      \end{bmatrix}.
      

      The second set of output measurements (for input EKF:nz = 2) is not used.


      The system description is programmed into the REXLANG block.

      This description serves as a basis for implementing the EKF in REXYGEN using the EKF function block. Further details can be found in the official documentation: EKF Block in REXYGEN.

      posted in REXYGEN Studio
      J
      Jan Reitinger
    • RE: EKF example

      @bech Hi,
      here is a Markdown file describing the system, which is implemented in the REXLANG block. To view the equations correctly, copy the file's contents into an online editor, such as this one: https://markdownlivepreview.org

      posted in REXYGEN Studio
      J
      Jan Reitinger
    • RE: EKF example

      @bech Hi,

      I'm sending an example of using EKF for a linear model. Please take a look at the code in the REXLANG block. Unfortunately, I don't have time to document the example in more detail right now. However, I should have time next week, so I'll send an improved version then.

      Best regards,
      Jan
      EKF.zip

      posted in REXYGEN Studio
      J
      Jan Reitinger
    • RE: REXduino - Communication failure between Raspberry PI and Arduino_MEGA

      @mtomek Hello,
      I'm really sorry—I somehow overlooked the fact that you were posting in this old thread. The "Warning 1 1" indicates that the buffer for serial communication between the Master and Slave devices is full:

      #define WARNING_SERIAL 1
      #define WARNING_SERIAL_BUFFER_FULL 1
      

      Have you added any new data communication or changed the communication speed recently? I’d also like to point out that REXduino is a third-party project, and we don’t have direct control over it. I found the explanation for the warning directly in the source code here:
      https://github.com/jaroslavs/REXduino/blob/master/REXduino_slave/REXduino_slave.ino

      Cheers,
      Jan

      posted in General
      J
      Jan Reitinger
    • RE: EPC timing, elapsed time

      Hi @stepan-ozana,

      The delay you're observing in Windows is likely due to process prioritization and interruption handling, which are less efficient and harder to control compared to a Linux-based system like Debian or Raspberry Pi OS. In Linux, you have better control over how processes are scheduled and managed, allowing the system to run more smoothly and minimizing the BUSY signal duration. Windows, on the other hand, tends to introduce more overhead when executing external processes, even if the script itself does nothing, due to the way it handles process management at the system level.

      Additionally, our systems on Raspberry Pi use a real-time kernel, which further improves the timing and responsiveness of processes. That's why we recommend running time-critical processes on Debian-based systems.

      Cheers,
      Jan

      posted in General
      J
      Jan Reitinger
    • RE: Raspberry pi 5 with Book worm

      @MikeyH Hi Mike,
      The driver for controlling the GPIO pins on the Raspberry Pi 5 is finally available. I apologize for the delay. In the end, we had to develop an entirely new driver. This driver can also be used on older versions of Raspberry Pi, provided they are running Linux 5.10 or newer. The documentation for the driver is still being developed. However, everything should be described in the 0410_GPIO and 0411_PWM examples if you install the latest daily build of REXYGEN: https://download.rexcontrols.cz/partner/daily/

      Cheers,
      Jan

      posted in General discussion
      J
      Jan Reitinger
    • RE: REXYGEN 3.0.0 is available

      @Scoobsalamander Hi Kris,
      I am sending the promised example from our developers: ethercat_basic_example.zip. A readme file with a brief description is included. Please let us know if anything is unclear.

      Cheers,
      Jan

      posted in Development tools
      J
      Jan Reitinger
    • RE: Modbus Tcp/IP communication Rpi(Rexygen)<->PC(Matlab)

      @stepan-ozana Thanks for sharing your solution! Unfortunately, I don't have the required toolboxes to run the script on my computer. However, the code is well-documented and well-organized, which should make it easy for anyone with the necessary Matlab toolboxes to use it without any issues.

      'modbus' requires one of the following:
        Industrial Communication Toolbox
        MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms
      
      Error in example_ModbusTcpIP_Comm_RpiToPC (line 9)
      m = modbus('tcpip', IP_ADDR,MODBUS_PORT)  %establish communication with the server (client)
      

      Cheers,
      Jan

      posted in Communication (RS232
      J
      Jan Reitinger
    • RE: Modbus Tcp/IP communication Rpi(Rexygen)<->PC(Matlab)

      @stepan-ozana
      That's good news. I believe your confusion arises from different terminology. The Master/Slave terminology is used in the original context, which we are still adhering to for now. However, the Server/Client terminology is more commonly used nowadays. In the earlier terminology, the client was referred to as master and the server as slave.

      posted in Communication (RS232
      J
      Jan Reitinger
    • RE: REST API communication example

      @stepan-ozana
      Thank you for confirmation. I will update the example. Unfortunately, quite large changes occur across Matlab versions, and there are situations where a script from older versions stops working in newer ones.

      Cheers,
      Jan

      posted in Communication (RS232
      J
      Jan Reitinger
    • RE: REST API communication example

      @stepan-ozana
      Dear Štěpán,
      I can confirm that the Matlab script behaves the same way for me as it does for you. Thanks for reporting the bug. Can you please test the following modified script? This modification works for me:

      clc;
      clear all;
      
      serviceUrl = 'http://192.168.100.2:8008';
      username = 'admin';
      password = ''; 
      
      % Data to be written
      value_double = 17.89;
      value_long = 1234;
      value_bool = 1;
      value_string = "External string";
      
      % URLs of the data points
      url_double = "/api/tasks/rest_api_task/CNR_IN:ycn";
      url_long =   "/api/tasks/rest_api_task/CNI_IN:icn";
      url_bool =   "/api/tasks/rest_api_task/CNB_IN:YCN";
      url_string = "/api/tasks/rest_api_task/CNS_IN:scv";
      
      % Basic authentication header
      credentials = base64encode([username ':' password]);
      authHeader = ['Basic ' credentials];
      
      % Writing data type double
      data_double = struct('v', value_double);
      writeData(serviceUrl, url_double, data_double, authHeader);
      
      % Writing data type long
      data_long = struct('v', value_long);
      writeData(serviceUrl, url_long, data_long, authHeader);
      
      % Writing data type Boolean
      data_bool = struct('v', value_bool);
      writeData(serviceUrl, url_bool, data_bool, authHeader);
      
      % Writing data type string
      data_string = struct('v', value_string);
      writeData(serviceUrl, url_string, data_string, authHeader);
      
      % Function to encode base64
      function encoded = base64encode(str)
          encoder = java.util.Base64.getEncoder();
          encoded = char(encoder.encodeToString(uint8(str)));
      end
      
      % Function to write data to the server
      function writeData(serviceUrl, url, data, authHeader)
          options = weboptions('RequestMethod', 'post', ...
                               'ContentType', 'json', ...
                               'MediaType', 'application/json', ...
                               'HeaderFields', {'Authorization', authHeader});
          try
              response = webwrite(strcat(serviceUrl, url), data, options);
              disp(['Successfully wrote data to ', url]);
          catch ME
              fprintf('Error writing data to %s:\n%s\n', url, ME.message);
          end
      end
      

      Cheers,
      Jan

      posted in Communication (RS232
      J
      Jan Reitinger
    • RE: Modbus Tcp/IP communication Rpi(Rexygen)<->PC(Matlab)

      @stepan-ozana

      Hi Stepan,

      I believe there might be a misunderstanding in the way the connection is being set up. It seems there might be a confusion between the roles of Master and Slave in Modbus TCP communication.

      In Modbus communication, the Slave holds the Modbus table, meaning the Master should connect to the Slave. Therefore, the correct approach should be:

      1. Upload the REXYGEN Slave to your Raspberry Pi.
      2. Try to connect to the Raspberry Pi from Matlab using the following command, where Matlab acts as the Modbus Master:
      m = modbus('tcpip', '192.168.111.2', 'Port', 502);
      

      This way, you are ensuring that the Master (Matlab) is correctly connecting to the Slave (Raspberry Pi with REXYGEN).

      Please let us know if you encounter any further issues.

      Best regards,
      Jan

      posted in Communication (RS232
      J
      Jan Reitinger
    • RE: Raspberry pi 5 with Book worm

      @MikeyH Hi Mike, I think the fix should be ready within 14 days.
      Cheers,
      Jan

      posted in General discussion
      J
      Jan Reitinger
    • RE: Raspberry pi 5 with Book worm

      @MikeyH Hi Mike, we have to modify the RPi driver to be compatible with the RPi5. We are sorry for complications.
      Cheers,
      Jan

      posted in General discussion
      J
      Jan Reitinger