Read data from multiple analog inputs via Arduino-Computer serial link

5 次查看(过去 30 天)
I've configured the serialRunOnArduino and serialRunOnPC models to allow me to record data from an analog sensor on pin A0 of an Arduino Mega. However, I need to read data from two analog sensors, plot separately and save data to the workspace.
I'm struggling to do this so any help would be appreciated.
Here are some screenshots of the serial link models as it stands, including my attempt to add a second serial transmit block.
Best,
Jon

采纳的回答

Milton
Milton 2018-1-12
If you are using two serial output on Mega, then TX0/RX0 and TX1/RX1 are used.
You can check the schematic of Mega. You will find TX0/RX0(PE1/PE0) are connected to USB.
Thus, you will find TX1/RX1 are Pin 18&19. You need to connect this to PI to a TTL to USB board so that you computer can read.
If you just want to use the existing USB from Mega, you need to 'Byte Pack' block to packet two signal together then send it out. From you PC part, you will use 'Byte Unpack' to separate this two signal.
These two blocks are introduced in R2016b

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by