The RCX-Datalog

The datalog represents a flexible storage of information inside of the RCX. Using the datalog might seem complicated. Here some advice:

1. Before using the datalog you have to define its size. You do this by sending the immediate instruction SetDatalog(Size) through a program running on your computer. Remember that immediate instructions may not be run inside of an RCX-program, but are to be sent to the RCX using the infrared-tower. Size must be a positive integer-number. The available size depends on the actual use of the RCX-memory. Its maximum is about 2kB. SetDatalog(0) clears the datalog.
2. Every time your RCX-program wants to store a value in the datalog, you'll have to call the DatalogNext(Source, Number) instruction. See the technical reference book for the specification of the source and number parameter.
3. The upload of the data stored in the datalog is managed by using the UploadDatalog(From, Size) instruction from the computer. This is the most difficult part of the task. First you must get the real size of the datalog. You will then have to check, whether the data is in variant-format. After this you will upload the datalog in packages of minimum 1 and maximum 50 single datas. Put attention not to try to upload 0 data. This will cause a DivisionByZero error-message. Here an example:

var data: variant;

procedure getTheDatalog;
 data:=spirit1.uploadDatalog(0,1);   {get the first data datalog}
 if VarIsArray(data) then iUpper:=data[2,0] else exit;  {data must be variant type, then get the size}
 if iUpper=0 then exit;  {you can't upload zero data}
 uploads:=trunc(iUpper/50);  {the trunc-function in turbo-pascal is comparable to the Int-function in Basic}
 if (iUpper mod 50)=0 then uploads:=uploads-1;  {this line solves an interesting problem, if the size is a multiple of 50}
 for iCounter:=0 to uploads do
   If iUpper<=50 then data:=spirit1.UploadDatalog(iLower,iUpper)
  if varIsArray(data) then {data must be variant type}
       for idx:=VarArrayLowBound(data,2) to VarArrayHighBound(data,2) do  {variant-functions}
             {do something with data[2,idx]}
             {in data[0,idx] you'll find an index, in data[1,idx] the source-type, in data[2,idxx] the number-value}
In the case of the scanner, we want to transform data into a bitmap-picture. If you want to collect data and make mathematical transformation in order to provide function-plot, you should use ROBOLAB, which has plenty of features.

 RetourMain page