Serial Terminal:

Controlling RealTerm from Scilab

RealtermDemo.sci is on Download page

 

Contents

Scilab is a free matlab like programming language, with good maths and plotting capabilities. However Scilab doesn't have any native serial port support, and doesn't have ActiveX support. (n.b. You may be able to call the Realterm interface directly, or make an interface DLL. I don't know how)

Scilab can be controlled using the commandline interface. Realterms FIRST parameter sends the commandline to the first instance of Realterm. This lets you control a running Realterm with more command lines.

  • Capture and Sendfile are the most important
  • SendRep and Senddly let you automatically repeat commands at regular intervals with no programming
  • SendString, CR and LF let you send simple commands without putting them into a file
  • Quit lets you shutdown Realterm

A Simple Demo

Download


unix('realterm.exe') //Start Realterm
//might need a pause to let it start
//Don't forget to start with FIRST. This is what send commands to
the existing instance instead of starting a new instance of
Scilab

unix('realterm.exe first capture=c:\temp\capsci.txt') //set
capture file. Starts Capturing



//Sendfile can be used to send both ascii and binary data

unix('realterm.exe first sendfile=startlogging.txt'); //sends
initialsation commands to data logger



unix('realterm.exe first sendfile=read_voltage.txt'); //send
commands to read a voltage



//Now open capsci.txt and read the data...



//send str can be used for short ascii commands.

unix('realterm.exe first CR LF sendstr="VOLTS?"
sendstr="AMPS?" ');



//read the results



//the following line sends commands every 1 second, for ever

unix('realterm.exe first capture=c:\temp\capsci.txt senddly=1000
sendrep=0 sendfile=read_voltage.txt');



unix('realterm.exe first quit') //close Realterm down

back to contents


Using Capture

When you want to get data from an instrument, and process it in Scilab, just capture data to a file with Realterm, then have Scilab read the file. This is a "design pattern" that appears ugly, but has been easy to get going, and sucessful. It is well decoupled, which is what makes it so easy to do.

The key point is that you can open a file for READ with Scilab, while Realterm has it open for WRITE.

How:

Simple DataLogging

Just a single line is all that is needed to start and run logging.

unix('realterm.exe first capture=c:\temp\capsci.txt senddly=1000 sendrep=0 sendfile=read_voltage_command.txt');

SendDly sets the pause after sending file until it is sent again. SendRep=0 will repeat endlessly. If you want to run the logger for some period, use CAPSECS to set the run time. CAPQUIT can be used to quit Realterm when done.

back to contents


Books


Contact Us

crun@users.sourceforge.net

back to contents