Page 1 of 1

PLC Serial Communication

Posted: Mon Apr 15, 2019 9:01 am
by PdoubleU
Hey Guys

I am trying to control the Roboclaw via codesys PLC on a Raspberry Pi.

My general question is if its better to open and close the serial port everytime you send a command to the roboclaw or just keep it open all the time?

I think that if you keep it open you might run into problems regarding the handles etc. meaning that you exceed the maximum amount of handles.

Thanks

Re: PLC Serial Communication

Posted: Mon Apr 15, 2019 10:05 am
by Basicmicro Support
In general, you should keep the port open but when you do that you need to keep a reference to the handle. You should only have one handle to the port at a time.

If you can't do that(keep a reference to the handle) then you will have to close and then open the port each time you talk to the Roboclaw. This may add several milliseconds to your communications(or it may not, I have not tested port opening/closing latency on the RPi). It will definitely add some time but maybe not enough to matter.