Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Accessing serial (COM) port from Simulink

140 views
Skip to first unread message

Negar

unread,
Apr 18, 2009, 7:10:03 PM4/18/09
to
Hi,

Is there a way that I can assert/unassert the pins on the COM port (serial port) from Simulink without being have to open and close the port every time?

Scenario: I have a real time video processing model in Simulink. As the model is running in Simulink, I need to assert and unassert the DTR pin of the COM port several times. Right now I have to open the port each time I want to change to the pin's status, and then close it (I call a Matlab function from Simulink that does s=serial('com1'); fopen(s); s.dataterminalready='off'; fclose(s); delete(s); clear s). This is causing me several problems including undesired voltage jumps upon every fopen and fclose. Is there a way that I can assert/unassert the pins on the COM port from Simulink without being have to open and close the port every time? In other words, may I open the port just once before running my Simulink model and have access to it from Simulink throughout the running of my model? If yes, how can I do this?

Thank you,
Negar

Phil Goddard

unread,
Apr 20, 2009, 10:04:01 AM4/20/09
to
There are multiple way to achieve this, possibly the simplest would be to write a level-1 m-code S-Function that has a persistent variable.

During initialization open the serial connection and store the serial object in the persistent variable, then during termination close the connection.
This way you only open/close once per simulation.

Phil.

0 new messages