Simulink and Arduino - I can't read/get any data?
32 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Sivapriya Srinivasan
2023-3-27
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!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!