Serial Port, Time Between Characters

4 views (last 30 days)
We are developing a data acquisition system to equipment connected via serial port that needs 1 or 2ms between characters. The others properties are specified correctly, but we don't know how to set that time between every character. How do we set that time?

Accepted Answer

Walter Roberson
Walter Roberson on 19 Nov 2013
You have two choices:
1) only write one character at a time, pause, write another character (perhaps using a timer to implement the sending); or
2) use 110 baud or 300 baud and specify two stop bits: at less than 1000 baud, one stop bit is more than 1 ms. You might be able to get away with 1200 baud. (Sometimes systems are configurable for 600 baud, but that is not a standard rate.)
  1 Comment
Lucas
Lucas on 21 Nov 2013
Thank you very much, we tried both options and the result was wonderful.
The second choice didn't work, maybe because we forgot to say that the baudrate of the device is 9600, or fault for giving too little info.
The option 1 worked. We tried before but we didn’t realize that we had to send only characters, so the terminator has to be '' in order to send a character not a command.
Again thank you very much for your help
If someone has the same problem than us here is the code that worked, its sure that it needs to be developed, but at least it works.
s=serial(COM1)
set(s,'terminator','')
fprintf(s,'*')
pause(0.002)
fprintf(s,'I')
pause(0.002)
fprintf(s,'D')
pause(0.002)
fprintf(s,'N')
pause(0.002)
fprintf(s,'?')
pause(0.002)
set(s,'terminator','CR')
fprintf(s,'')
fscanf(s)

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!