Filter löschen
Filter löschen

Simulink and Arduino - I can't read/get any data?

15 Ansichten (letzte 30 Tage)
DenverThingSpeak
DenverThingSpeak am 12 Mär. 2023
Kommentiert: DenverThingSpeak am 27 Mär. 2023
I have a very simple model displayed below, and I'm just trying to read the voltage using simulink in order to start learning. However when I check the scope I get nothing, similarly i get no values when using the display block as well. I'm running it in external mode, fixed step no-discrete, and I've correctly chosen the right arduino and the right COM port but despite that nothing. However, from what I can see, outputting data such as blinking an led works just fine. It's only reading the data that I have a problem with. Scope time is 50 sec and the digital input sample time 0.1sec

Antworten (1)

Sivapriya Srinivasan
Sivapriya Srinivasan am 27 Mär. 2023
Hello ,
I understand that you were not able to read the data despite being able to see blinking of the led of the Arduino using Simulink.
It's possible that there may be a few issues that could be causing the problem. Here are a few things to check:
1.Make sure that your Arduino code is properly configured to read the voltage from the analog pin.
2.Check that the sample time of the analog input block in Simulink matches the sample time in your Arduino code. If they don't match, you may not be capturing data at the right time.
3.Make sure that the data type of the output from the analog input block is compatible with the scope block or display block. For example, if the output of the analog input block is a double, but the scope block is set to display only integers, you won't see any data.
4.Try increasing the sample time of the scope or display block to see if data is being captured but not displayed due to the sample rate being too low.
5.Try adding a delay block before the scope or display block. This will ensure that the input signal has time to propagate through the system before being displayed.
If none of the above steps work, try re-uploading the code to the Arduino and resetting the simulation in Simulink. This may help to refresh the connection and resolve any communication issues.
Hopefully, one of these steps will help you to resolve the issue and start getting voltage readings in Simulink.
You can also refer this documentation for further understanding: https://www.mathworks.com/help/documentation-center.html
Hope this helps!
  1 Kommentar
DenverThingSpeak
DenverThingSpeak am 27 Mär. 2023
Hello, thank you for your answer.
Isn't Simulink supposed to generate the code for the arduino? How do i check if the sample time on the arduino code in that case?
And how do I check if the scope is set to show only certain data types?
For the rest of the solutions, since the I'm reading a constant voltage of 5v I feel like I should either ways get the data without having to add a delay

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Arduino Hardware finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by