For different simulation instants Simulink shows different values read from the serial port for the same input on the ADC pin.

2 views (last 30 days)
Hello Matlab Community!
I have been trying to use Simulink to read the voltage sensor data output through the ADC pin on the Microcontroller board. However, there are a lot of issues I fail to address. If anyone has any idea on how to resolve these problems, please guide me through.
Problem :
1. Starting simulation at different times gives different values without changing any thing in the setup. As you can see in the attached video(Click Here), I have to stop and start simulation file multiple times before I get the right data from the port. I want the program to perform exactly the same way all the time if there is no change in hardware/program setup. How do I ensure this using simulink?
2. The noise on the ADC is very high. I need to extract the DC value from the signal shown in the scope. I have tried using IIR filter, Moving average as well as Running Mean. But none of them give the proper value. There is always +-2V error in the values read.Program
Setup
I look forward to your help and guidance.
Thank you!
Regards,
Prashant

Answers (1)

Mark McBroom
Mark McBroom on 2 Jan 2023
When you push the simulation button for the model on the left ( untitled1 ), the model is not running on the actual hardware. You need to push the "Run on Hardware" button on the "hardware" tab for the Simulink model to actually run on the microcontroller board and read the A/D.

Community Treasure Hunt

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

Start Hunting!