Serial Port Connects but no transmission is possible (Time out error)

5 views (last 30 days)
Hello,
I'm working on a project where basically I need to connect to a Lab Insrument to measure Impedance for lithium cells. Its connection is of Serial Port type (COM). To controll it, my idea is to use MATLAB as I've already used it before to control other instruments and it has worked really good for me, but when I try to communicate with the instrument after connecting to the port with no problems, a Timeout occurrs. I have conigured the speed (BaudRate) equalt to the one configuerd in the Instrument (9600).
What's more, when I use Python to conrtol de instrument it actually works and I have no problems comunicating with it (I am making sure to properly close the channel after using python to avoid connection problems). Of course I could use python, but the deadline is close and I amb used to work on Matlab but not on python GUIs (I need to create a GUI to interact with the instruments).
While I'm trying to connect to this instrument, I'm beaing able to connect to other Instruments that also work with Serial Port, so it may be a problem of the instrument and not of MATLAB or my computer.
Is there any other think I can try?
Thank you very much,
Edu Mauri

Answers (1)

Sivapriya Srinivasan
Sivapriya Srinivasan on 6 Oct 2023
Hello ,
I understand that you are experiencing a timeout issue when communicating with Lab instrument through MATLAB, even though it works fine with Python
1.Adjust the timeout value: By default, MATLAB's serialport object has a timeout value of 10 seconds. If the instrument takes longer to respond, you can increase the timeout value to accommodate the response time. You can set the timeout value using the Timeout parameter when creating the serialport object.
2.Verify the instrument's settings: Double-check the instrument's settings, such as the baud rate, parity, stop bits, and flow control. Ensure that these settings match the configuration in MATLAB. You can use the configureTerminator and configureTerminatorMode functions to set the appropriate terminator characters and mode.
3.Try different read/write functions: Instead of using the default read and write functions, try using alternative functions such as readline, readasync, or writeasync to read and write data to the instrument. These functions provide different ways of handling data transfer and may work better with your instrument.
4.Test with a different computer: If possible, try connecting the Lab Instrument to a different computer and see if you encounter the same timeout issue. This will help determine if the problem is specific to your computer or if it persists across different systems.
5.Update MATLAB: Ensure that you have the latest version of MATLAB installed. Updates often include bug fixes and improvements that might address issues related to serial communication.
Hope this helps!

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!