Simulation controller and plant error in analog in(stm32)

Hello, I was trying to emulate a controller subsystem, but the “Analog In” block is showing an error.

How can i fix this?

motor_CC.plecs (96.0 KB)

Hi Rafael, thanks for reporting this issue. I’ll bring this up with the developers to see if they have any insight into the issue you’ve run into.

In the meantime, you could:

  • swap out your “Analog In” with an “Analog In (Triggered)” stm block
  • to keep your model equivalent to what you have, you can keep the “Trigger Source” parameter to be “Determined Automatically”

Let me know if that helps resolve your issue.

1 Like

Hello Rafael

The error is thrown because the Analog In block expects discrete-time signals, but the provided signal is a continuous-time signal. The block also works with continuous-time signals, and in older versions of PLECS only a warning was returned in this case. We will upgrade the block to accept continuous-time signals as well as discrete-time signals. In the mean time, you can restore the previous PLECS behavior by going into Simulation–>Simulation Parameters–>Diagnostics and changing “Continuous sample time conflict” from error to warning.

The Analog In block converts measurements asynchronously and is intended for sampling low-priority signals or signals with slow time constants. For your control application, using a triggered ADC would likely be advantageous. By using an Analog In (Triggered) block, you will can configure the ADC to convert measurements with a defined frequency.

The frequency can be defined manually by configuring the trigger chain (you can read more on this in the STM32 Target Support User Manual). If no trigger chain is defined in the model, the Analog In (Triggered) block will configure ADCs to convert measurements with the control task frequency, which is defined by the discretization step size specified in the Coder Options menu. By doing this, your control algorithm will use updated measurements every time that the control loop executes.

1 Like