A timeout occurred before the Terminator was reached.

8 years 11 months ago #29529333 by TechnoSam
I keep getting this error.

Warning: Unsuccessful read: A timeout occurred before the Terminator was reached.

I'm using MATLAB to access the serial port on an SDC2130.

I set up my serial objection, and then used:

s1.Terminator = 'CR/LF';

Then I used:

fprintf(s1,'?AI_');
out = fscanf(s1);

Then I get the error. The weird thing is that my code works. I get back:

AI=0:0:0:0

So why is it doing this? I can't think of why it's not finding the Terminator. The manual said that an underscore is taken as a carriage return. Is there something I'm missing?

I've tried using s1.Terminator = 'CR'; but then it doesn't work at all. So I have no idea why it takes so long to execute and still throws the error.

Can anyone help? Thanks.

Please Log in or Create an account to join the conversation.

8 years 11 months ago #29529334 by Griffin Baker
Replied by Griffin Baker on topic A timeout occurred before the Terminator was reached.
I don't have any experience with Matlab, but with our scripting, typically you need a small delay statement after a print, otherwise connection to the pc gets lost. Perhaps Matlab is having a similar issue.

Try adding a 1mS delay after the print.

Please Log in or Create an account to join the conversation.

8 years 11 months ago #29529335 by TechnoSam
That sounds right. A friend showed me some LabVIEW code, and he had a delay in it.

I tried the pause command, but nothing changed. I don't know if pause isn't the right command to use, or if it's just a different problem altogether. It really seems like I should need it somewhere though.

Anyway, I appreciate the help. I'll keep working at it.

Please Log in or Create an account to join the conversation.

8 years 11 months ago #29529336 by Griffin Baker
Replied by Griffin Baker on topic A timeout occurred before the Terminator was reached.
Try these and see if it works.

Wait()
delay()

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.078 seconds