필터 지우기
필터 지우기

Simulink Arduino Mega 2560 digital input - PWM signal uncorrect value

조회 수: 5 (최근 30일)
Maximilian Müller
Maximilian Müller 2018년 1월 3일
편집: Maximilian Müller 2018년 1월 6일
Dear Professionals,
I have got an Arduino Mega 2560 and a ultrasonic sound sensor. I am trying to read the PWM signal which comes from the Arduino (picture attached). To determine the error, I take the response of the ultrasonic sound sensor in the case of measurement without results. In this case the Arduino should send a PWM signal on high level for 0.2 seconds. Unfortunately, the scope of my model shows only a high-level signal for less than 0.1 seconds. I tried a lot but I still not find any solutions why it is like this. What I could have found out is, that the simulation time in external mode is not in real time. And if I change parameters in the model configuration that makes it more slow as real time the high level signal is shown less than 0.05 seconds. So, I think it is an issue of not simulating it in real time. How can I simulate it in real time or how can I avoid the issue that the scope is not showing the right values if the model is not simulated in real time?
I hope I descripted it well enough.
To determine the correct distance, I need a sample time of 0.0001 of the Arduino input block.
Cheers Max

답변 (2개)

Nick Sarnie
Nick Sarnie 2018년 1월 5일
편집: Nick Sarnie 2018년 1월 5일
Hi Maximilian,
You are correct in that it is not possible to run true real-time simulations on the Mega 2560.
Using External Mode places additional stress on the hardware, which is documented here: https://www.mathworks.com/help/supportpkg/arduino/ug/tune-and-monitor-model-running-on-arduino-mega-2560-hardware.html#bue1b5i-16

Maximilian Müller
Maximilian Müller 2018년 1월 6일
편집: Maximilian Müller 2018년 1월 6일
So, this means I can never evaluate a PWM signal which needs a calculation of 0.00001 steps with the Arduino Mega 2560 in connection with a Serial transmit / receive block in Simulink. So, I Need to convert the digital Signal to a analog signal by an additional Hardware. Right?
If I put the sample time to 0.00001 of the model which I deploy to the Arduino hardware the Serial receive model does get only an Zero line. What did I not consider to solve this issue?

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by