Send data from Simulink to Proteus for Arduino Co-Simulation

 Here it is shown how to send data from Simulink to Arduino in Proteus for Proteus Simulink co-simulation. This is a continuation of the previous tutorial Interfacing Proteus and MATLAB/SIMULINK for Co-Simulation in which we showed how an Arduino to which a LED is connected can be turned on or off using a switch in Simulink model. The data was sent from Simulink using Serial Send block via com port and was received by Arduino serial port by means of RS232 serial connector called COMPIM in Proteus.

What is illustrated here is the same thing in that simulink is used to control LED in Proteus via Arduino. But the difference now is that instead of using two constant blocks were used for data 0 and 1 now string constant block is used. The string is "0" and "1" and are converted to ASCII character using the String to ASCII block. Then the output from these are connected to a manual switch the output of which is connected to a delay block. The delay block is then connected to the Serial Send block. This simulink model is shown below.

Send data from Simulink to Proteus for Arduino Co-Simulation

The two string constant blocks are set to "0" and "1" and there is nothing more to do here. There is also nothing to configure in the two string to ASCII blocks. The manual switch block is configured properly in its default settings. The delay block must be configured which is shown below.

delay block

In the delay block the sample time was set to 1/9600. The delay block is necessary because the serial send block does not work in continuous mode. That is say we connected the switch directly to the serial send block then we will get simulink error. However it is also unusual that if we set the sample time to -1 which means inherited the simulink will not throw any error.

To test the simulation model see the previous Proteus Simulink co-simulation for Arduino tutorial post mentioned above. Or you can just watch the following video.

Summary

In summary, article explained how to send data from Simulink to Arduino in Proteus for Proteus Simulink co-simulation. The article builds upon a previous tutorial that showed how an Arduino connected to an LED could be controlled by Simulink using a switch. Instead of using constant blocks, a string constant block is used in this article to send data to the Arduino via the Serial Send block. The string constant block is set to "0" and "1", and is converted to ASCII using the String to ASCII block. The output from these blocks is connected to a manual switch, the output of which is connected to a delay block and then the Serial Send block. The delay block is set to a sample time of 1/9600 to account for the fact that the Serial Send block does not work in continuous mode. The article concludes by directing the reader to a previous tutorial for testing the simulation model or by watching a video.

In the next tutorial Send Arduino data from Proteus to Simulink it is shown how to transfer Arduino data from Proteus to Simulink.

References

[1] Interfacing Proteus and MATLAB-SIMULINK for Co-Simulation

[2] Send data from Simulink to Proteus for Arduino Co-Simulation

[3] Serial communication from PC to Proteus

[4] Arduino in Proteus co-simulation with Simulink: Advantages & Applications

[5] Programming Arduino using Matlab/Simulink

Post a Comment

Previous Post Next Post