How to read voltage from multiplexer that connected to Arduino with Simulink?

19 views (last 30 days)
Hi,
I would like to read the voltage from my sensors. The sensors are connected to my 16-1 multiplexer and the multiplexer is connected to my arduino mega board. I am able to read and display all of the voltage of the 16 sensors by using my multiplexer with one analog pin(on arduino) on arduino ide. I would like to do the exactly same thing on the Simulink. I have tried S-function builder block at first but it does not work.
Is there a way to read the voltage from multiplexer that connected to arduino on Simulink?
Thank you.

Accepted Answer

Animesh
Animesh on 6 Mar 2023
Hello,
To read voltage from a multiplexer that is connected to an Arduino board using Simulink, you can use the "Arduino IO Read" block provided by the Simulink Support Package for Arduino Hardware.
Here are the steps to read voltage from a multiplexer using Simulink:
  1. Connect your Arduino board to your computer and open Simulink.
  2. Create a new Simulink model and add the "Arduino IO Read" block to your model.
  3. Double-click the "Arduino IO Read" block to open the block parameters dialog.
  4. In the block parameters dialog, select the appropriate input pin of the Arduino that is connected to the multiplexer. You may need to refer to the Arduino pin mapping to determine the correct pin number.
  5. Set the "Output data type" parameter to "double" if you want to read voltage values as double precision numbers.
  6. Set the "Sample time" parameter to the desired sampling time for reading voltage values.
  7. Connect the "Arduino IO Read" block to a "Scope" block or a "To Workspace" block to visualize or store the voltage data.
  8. Configure and run the Simulink model to start reading voltage data from the multiplexer.
Note that the voltage values read from the multiplexer may need to be scaled and calibrated to obtain the actual voltage values of the measured quantity. This depends on the specific hardware and measurement setup used in your application.

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!