RT
C
®
4 P
C
In
te
rf
a
ce
B
o
ar
d
R
e
v.
1.
3
e
9S
o
ft
w
a
re
67
Demo_intelliSCAN
// File
// intelliSCAN.cpp
// Abstract
// A console application for demonstrating the communication
// with the intelliSCAN
// Author
// Gerald Schmid, SCANLAB AG
// Comment
// Besides demonstrating of how to initialize the RTC4 and how to
// perform marking, this application also shows how to implicitly
// link to the RTC4DLL.DLL. For accomplishing implicit linking -
// also known as static load or load-time dynamic linking of a DLL,
// the header file RTC4impl.H is included and for building the
// executable, you must link with the (Visual C++) import library
// RTC4DLL.LIB.
// Necessary Sources
// RTC4impl.H, RTC4DLL.LIB
// NOTE: RTC4DLL.LIB is a Visual C++ library.
// Environment: Win32
// Compiler
// - tested with Visual C++ 6.0
// system header files
#include <stdio.h>
#include <conio.h>
// RTC4 header file
#include "rtc4impl.h"
#define MaxWavePoints 32768// maximum number of samples per channel
#defineSamplePeriod 1// sampling period [10us]
#defineSendStatus 0x0500// command codes for changing data on the status channel
#defineSendRealPos 0x0501
#defineSendStatus2 0x0512
#defineSendGalvoTemp 0x0514
#defineSendHeadTemp 0x0515
#defineSendAGC 0x0516
#defineSendVccDSP 0x0517
#defineSendVccDSPIO 0x0518
#defineSendVccANA 0x0519
#defineSendVccADC 0x051A
#defineHeadA 1
#defineXAxis 1
#defineYAxis 2
#defineStatusAX 1
#defineStatusAY 2
void delay(void)// 100us delay
{
for (short i=0; i<10; i++)
z_out(0);// dummy control function generates a 10us delay
}
void main(void)
{
long i;
shortErrorCode;
unsigned short WavePoints;
short Ch1[MaxWavePoints], Ch2[MaxWavePoints];
// Initialize: load correction and program file
ErrorCode = load_correction_file("cor_1to1.ctb",
1, // table; #1 is used by default
1.0, 1.0, // scale factor
0.0, // rotation in degrees, counterclockwise
0.0, 0.0); // offset in bits
if(ErrorCode) {
printf("Correction file loading error #%d\n",ErrorCode);
return;
}
ErrorCode = load_program_file("RTC4D2.hex");
if(ErrorCode) {
printf("Program file loading error #%d\n",ErrorCode);
return;
}
// get some status information from the head
control_command(HeadA, XAxis, SendGalvoTemp);// send X galvo temp on X status
channel
control_command(HeadA, YAxis, SendGalvoTemp);// send Y galvo temp on Y status
channel
delay();// wait until command is transfered to the head, executed and new status
data is updated
printf("Temperature X-Galvo: %4.1f degrees centigrade\n",0.1*get_value(StatusAX));
// read X status channel
printf("Temperature Y-Galvo: %4.1f degrees centigrade\n",0.1*get_value(StatusAY));
// 1bit = 0.1 degree
// display AGC voltage of each galvo
control_command(HeadA, XAxis, SendAGC);
control_command(HeadA, YAxis, SendAGC);
delay();
printf("AGC Voltage X-Galvo: %5.2f Volts\n",0.01*get_value(StatusAX));// 1bit =
10mV
printf("AGC Voltage Y-Galvo: %5.2f Volts\n",0.01*get_value(StatusAY));
// display internal status information
control_command(HeadA, XAxis, SendStatus2);
control_command(HeadA, YAxis, SendStatus2);
delay();
printf("Status2 X-Axis: %hX\n",get_value(StatusAX));
printf("Status2 Y-Axis: %hX\n",get_value(StatusAY));
// send back the XY real position on the status channels
control_command(HeadA, XAxis, SendRealPos); // real position
control_command(HeadA, YAxis, SendRealPos);