RTC6 boards
Doc. Rev. 1.0.21 en-US
6 Developing RTC6-User Programs
127
Example Code (Delphi)
The following example Delphi source code shows
how to check which RTC6 PCIe Board is the master
and which one is slave.
The code must be included in a user program, see
Chapter 6.2.5 ”Example Code (C)”, page 100.
if init_rtc6_dll() <> 0 then halt; // Initialize the RTC6 DLL
if rtc6_count_cards() <> 2 then halt; // Are 2 RTC6 in the PC?
for CardNo := 1 to 2 do // Load program and 3D correction files onto both boards
begin
// Stop RTC6 if a task is currently still running. Optional:
// n_stop_execution(CardNo);
if n_load_program_file(CardNo, nil) <> 0 then halt;
if n_load_correction_file(CardNo, nil, 1, 2) <> 0 then halt;
end;
// Check for Errors (Bit #12...Bit #15)
if (n_get_sync_status(1) and $F000 = 0) and (n_get_sync_status(2) and $F000 = 0) then
begin
// Detect master board
// Is board 1 the master and board 2 a single slave?
if (n_get_master_slave(1) = 2) and (n_get_master_slave(2) = 1) then
begin
Master := 1;
Slave := 2;
end else
// Is board 2 the master and board 1 a single slave?
if (n_get_master_slave(1) = 1) and (n_get_master_slave(2) = 2) then
begin
Master := 2;
Slave := 1;
end
else
halt; // Something wrong with master-slave configuration
end else
halt;
n_select_cor_table(Master, 1, 0);
n_select_cor_table(Slave, 1, 0);
n_set_control_mode(Master, 1 + 8); // Master slave, activate Start Stop control
n_set_control_mode(Slave, 1 + 8);
n_sync_slaves(Master); // Synchronize master and slave boards
// check synchronization status at any time
// provide an
External Start
or a simulated
External Start
before checking
n_simulate_ext_start_ctrl(Master); // for
RBF 618
Result = n_get_sync_status(Master) and $3FF; // must be 640
Result = n_get_sync_status(Slave) and $3FF; // must be <4
// MasterCfg, SlaveCfg must be defined elsewhere, see manual
n_master_slave_config(Master, MasterCfg);
n_master_slave_config(Slave, SlaveCfg);