Multiple Arduino with same simulink block diagram

24 次查看(过去 30 天)
Hello all,
I am getting the data (speed pulses) from one sensor (encoder) using Arduino due in simulink interface. Now, I want to use the same data in a controller block diagram in same simulink block diagram page/code, but the controller code should be uploaded in a different arduino board.
Due to very high transfer rate of speed data to first arduino, I am not able to use controller in first arduino (due to lcock speed limitation/memory limitation). Hence, i decided to use two arduinos in same simulink page block diagram.
Please let me know, how can I do this? or Is there any alternate solution for this problem?
Really need help!
Thanks in Advance :)

回答(1 个)

Namnendra
Namnendra 2023-4-27
Hey Aakash,
One solution is to use the Simulink Support Package for Arduino Hardware to communicate between the two Arduinos. You can use one Arduino to acquire the speed pulses and send the data to the other Arduino, which runs the controller. Here are the steps to do this:
  1. Connect the two Arduinos to your computer and make sure they are recognized by Simulink.
  2. Open a new Simulink model and add two Arduino IO setup blocks, one for each Arduino board.
  3. Configure the input block to read the speed pulses from the encoder on the first Arduino board.
  4. Configure the output block to send the speed data to the second Arduino board.
  5. Add a controller block to the model and connect the input from the second Arduino board to the controller.
  6. Upload the code for the input and output blocks to the first Arduino board and the code for the controller block to the second Arduino board.
  7. Run the simulation and verify that the controller is receiving the speed data from the first Arduino board.
Alternatively, you can use a serial communication protocol such as UART to transfer the data between the two Arduinos. You would need to add a UART module to each Arduino board and use Simulink's serial communication blocks to send and receive the data. This method requires more programming, but it can be faster and more flexible than using the Arduino IO setup blocks.

类别

Help CenterFile Exchange 中查找有关 Modeling 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by