Clear Filters
Clear Filters

How can I adjust the setting of analog signal sampling with STM32 using Matlab Simulink.

13 views (last 30 days)
Hi everyone,
I want to see the AC signal I measured with STM32F746ZG in matlab simulink. The AC signal has offset and its frequency is 50 Hz. For example, I want to measure this AC signal with a 10 kHz sample. In the Matlab simulink analog input (MBED) block, only the pin and sample time (Note: The sample time in the block is entered as 1e-4) can be set. When I run it with Monitor and Tune, it measures with a sample of around 500 Hz in the data inspector section. Naturally, the graph is quite far from sinusoidal waveform. How should I configure in matlab simulink to measure this signal in real time and with 10 kHz sampling. The figure below shows the shape of the AC signal monitored in the data inspector.
Thank you for your advice.

Answers (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 30 Dec 2023
Increase data sampling rate, e.g., 2.5kHz or higher and re-collect your data. It will solve the problem.
  1 Comment
Eyke
Eyke on 31 Dec 2023
Thank you for the answer.
The block shown below reads the analog value directly as seen. There is no setting on the block for quantization and sample time etc. for setting. Besides, I could not find a setting in the model configuration parameters. What I want to ask is which steps can I follow to solve these problems on matlab. Also, setting the sample time does not make any difference when I run it with monitor and tune.

Sign in to comment.


Goutham Varanasi
Goutham Varanasi on 9 Jan 2024
Hi,
This is because logging with external mode is done at higher sample rate which requires higher data speeds along with the overhead of external mode.
As a workaround you may use the two-model approach where data logging is handled by a different model there by reducing the overhead of logging on the main model.
You may follow these examples for reference.

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!