0
votes

I am running a code on arduino which works fine in arduinoide, I want to get those values in simulink for real time using serial connection.

I am burnig a program in arduino and want to access both send and receive function of serial monitor, on simulink. I want these to plot graphs in real time and run PID algorithm using simulink.

But for some odd reason, simulink values are either not updating(in external mode) or fluctuating some odd values(in normal mode). Any help.

1

1 Answers

1
votes

If you are doing a communication between the Arduino and Simulink there might be some problems in your connection. I'm assuming you are using the Serial Send and Serial Receive block to do the communication.

I did a complete tutorial how to connect both platforms in my Github page.


By your description I can think of this problems:

Simulink is not updating?

If your Simulink is not updating probably because it is waiting Arduino to send some serial data, but is not receiving anything. Some possible causes of this problem might be:

  • Wrong Serial baud rate
  • Wrong data type (i.e. If you are sending Arduino float you have to receive a single in Simulink.)
  • Wrong data size
  • Different step time (Remember to use the same step time in Simulink and Arduino)

Simulink receiving odd values?

If Simulink is updating but showing odd values, the communication between both might be damaged.

  • Desynchronization of the communication - Try to use a Header and a Terminator in the Serial Send and Serial Receive block and remember to set this in your Arduino code.
  • Different step time - Make sure both application are sending and receiving at same rate.
  • Verify what you are sending - You can check what exactly you are sending to the serial with a scope, remember that in the Serial Send block the input signal must be a byte. If you are using a single or double remember to cast it to byte with a Byte Pack block.