Motorized stages, Piezo stages Presented by Sun-Uk Hwang 2009-03-30 DEPT. MECHATRONICS, GIST Nanoscale Simulations Lab Motorized Stage (MCAPI) www.thorlabs.com Reference: Motion Control Application Programming Interface MCAPI Reference Manual Revision 3.4 DEPT. MECHATRONICS, GIST [2] Specifications DEPT. MECHATRONICS, GIST [3] Sample Specimen Control Sample specimen control: Focusing, translation 4.45um bead Sample specimen mounted to motorized stage Motor Focused by moving stage Objective lens CCD DEPT. MECHATRONICS, GIST [4] Motorized Stage API PC mcapi.h mcapi32.lib Motorized Stage API PCI Interface DEPT. MECHATRONICS, GIST [5] Motorized Stage Basic Function List Functions MCOpen() MCGetConfiguration() MCGetPositionEx() MCMoveRelative() MCIsAtTarget() MCClose() MCOpen() MCGetConfiguration() MCMoveRelative() MCGetPositionEx() MCIsAtTarget() N Y MCClose() DEPT. MECHATRONICS, GIST [6] Example code DEPT. MECHATRONICS, GIST [7] Motorized Stage (APT) Motorized Actuators MT3/M-Z8 www.thorlabs.com Reference: APT System Software Developer Support Motor control Programming DEPT. MECHATRONICS, GIST [8] Specification MT3-Z8 Value Travel 0.47" (12 mm) Maximum Vertical Load 10 lbs (4.5 kg) Maximum Horizontal Load 20 lbs (9 kg) Orthogonality <2 mrad Runout 150 µrad Bearing Type Ball on Hardened V-Grooves Motor Type DC Servo (Z812) Motor Drive Voltage 12 V Maximum Recommended Current 80 mA Lead Screw Pitch 1.0 mm Calculated Resolution 29 nm Feedback Hall Effect Encoder Encoder Counts per Revolution of Lead Screw 34,304 Planetary Gear Head Ratio 67:1 Limit Switches Electromechanical Speed Range 0.050 to 3.0 mm/s Recommended Controller TDC001 [9] DEPT. MECHATRONICS, GIST Motorized Stage Active X control PC mgmotorctrl1.h mgmotorctrl1.cpp Motorized Stage USB communication Active X control MT3/M-Z8 [10] DEPT. MECHATRONICS, GIST Controller for Motorized Stage • Ideal Controller for Z8 Series Actuators • Control via Overlay or Computer • Compact Footprint The TDC001 is the DC Motor Controller of our T-Cube Family. This single channel controller features a control panel on top, which offers Move/Jog buttons to move the actuator's leadscrew in discrete steps and a Velocity Potentiometer to move the leadscrew at various velocities. The TDC001 can be connected to a computer using USB 2.0 and controlled via Thorlabs' APT software. [11] DEPT. MECHATRONICS, GIST Motorized Stage Basic Function List Functions StartCtrl() SetVelParams() SetJogStepSize() MoveJog() StopCtrl() StartCtrl() SetVelParams() SetJogStepSize() MoveJog() Find Target? Y StopCtrl() [12] DEPT. MECHATRONICS, GIST N Example code • • Active X control using MFC application (Reference : VC++(2003) APT Tutorial) Select the MFC Application item [13] DEPT. MECHATRONICS, GIST Example code (cont’d) Insert the ActiveX Control in the dialog box [14] DEPT. MECHATRONICS, GIST Example code (cont’d) Add variable m_Motor1 that will be used to access the Motor Control [15] DEPT. MECHATRONICS, GIST Example code (cont’d) Set the serial number and call the StartCtrl() function [16] DEPT. MECHATRONICS, GIST Example code (cont’d) Motion control of the motorized stage (1) Call the Move home of the motor at Button1 [17] DEPT. MECHATRONICS, GIST Example code (cont’d) Motion control of the motorized stage (2) Call the absolute move of the motor at Button1 [18] DEPT. MECHATRONICS, GIST NI DAQ, Nanopositioner Reference: NATIONAL INSTRUMENT, “NI-DAQ 7, DAQmx C Reference Help ”, 2004 NATIONAL INSTRUMENT, “DAQ, 6534X User Manual”, 2001 nPoint, “C-300 Series Controller Manual”, Version 1.2, 2005 DEPT. MECHATRONICS, GIST [19] NI DAQ ? NI DAQ (National Instrument Data Acquisition) : Collecting and measuring the same kinds of electrical signals with analog-to-digital and/or digital devices plugged into a PC, and possibly generating control signals with digital-to-analog and/or digital devices in the same PC. PC-BASED DATA ACQUISITION Figure referred to www.ni.com Two libraries for NI DAQ - Traditional NI DAQ, difficult to understand and implement - NIDAQmx: new library, easy to understand and implement DEPT. MECHATRONICS, GIST [20] PCI-6534 DAQ Device www.ni.com PCI - 6534 32 (5 V TTL/CMOS) digital input/output lines 20 MHz (80 Mbytes/s) maximum transfer rate 8, 16, or 32-bit transfers Start and stop triggering, pattern and change detection 32 MB onboard memory per data path (group) (NI 6534 only) NI-DAQ driver simplifies configuration and measurements DEPT. MECHATRONICS, GIST Operating Systems •Windows 2000/NT/XP/Me/9x • Mac OS 9* Recommended Software • LabVIEW • Measurement Studio for Visual Other Compatible Software • Visual Basic • C/C++ Driver Software (included) • NI-DAQ [21] NI-DAQmx Key Concepts Task: A task is a collection of one or more channels, timing, triggering, and other properties that apply to the task itself. Conceptually, a task represents a measurement or generation you want to perform. Channel: Virtual channels are software entities that encapsulate the physical channel. The physical channel can be configured as data output channel or data input channel. Timing, Triggering: The timing section explains clocks. The triggering section goes over the triggers such as a Start Trigger and a Reference Trigger, Analog Edge Trigger, Digital Edge Trigger. Buffer: A buffer is a temporary storage in computer memory for acquired or to-be-generated samples. DEPT. MECHATRONICS, GIST [22] Basic NI DAQmx Functions for PCI-6534 Device Task Configuration/Control: DAQmxCreateTask (), DAQmxStartTask(), DAQmxStopTask(), DAQmxClearTask, DAQmxIsTaskDone (), etc. Channel Creation: DAQmxCreateDOChan(), DAQmxCreateDIChan() Timing: DAQmxCfgSampClkTiming() Write: DAQmxWriteDigitalU8(), DAQmxWriteDigitalU16(), DAQmxWriteDigitalU32() Read: DAQmxReadDigitalU8(), DAQmxReadDigitalU16(), DAQmxReadDigitalU32() DEPT. MECHATRONICS, GIST [23] DAQ Flowcharts Finite Sample Writing to DAQ device Finite Sample reading from DAQ device DAQmxCreateTask DAQmxCreateTask DAQmxCreateDOChan DAQmxCreateDIChan DAQmxCfgSampClkTiming DAQmxWriteDigitalU16 DAQmxStartTask DAQmxCfgSampClkTiming DAQmxStartTask DAQmxReadDigitalU16 DAQmxStopTask DAQmxStopTask DAQmxClearTask DAQmxClearTask DEPT. MECHATRONICS, GIST [24] Example code (data output) Include “nidaqmx.lib” in the project setting DEPT. MECHATRONICS, GIST [25] Example code (data input) Include “nidaqmx.lib” in the project setting DEPT. MECHATRONICS, GIST [26] Nanopositioner Control by NI-DAQ www.nPoint.com, DEPT. MECHATRONICS, GIST [27] Data Flow for Nanopositioner Control Programming using DAQ API Input data Feedback data PCI-6534 Generating & collecting data Tilt mirror 20bits(524287) 10V Digital controller Transferring data Objective positioner DEPT. MECHATRONICS, GIST 3D laser focal point control [28] Timing diagram of digital controller PCI-6534 card has 2 external clock ports and 2 trigger ports for synchronization of data transfer with external devices. According to the timing diagram of the external device, clock and trigger signals of PCI card should be set well using DAQmxCfgSampClkTiming() and DAQmxCfgDigEdgeStartTrig() functions for proper operation of external devices. Output: Data is outputted on falling edge of REQ1 and rising edge of STARTTRIG1 from PCI card to the nPoint interface Input: Data is inputted on falling edge of REQ2 and rising edge of STARTTRIG2 from the nPoint interface to PCI card Input Output Timing diagram of nPoint digital controller DEPT. MECHATRONICS, GIST [29] Time Delay of DAQ Device It takes long time to update new control data to DAQ device if a number of sample points are used. 41667 points/sec 2083 points/sec In real time applications where the control data changes with time by user input, this makes undesirable (discontinuous) motion. DEPT. MECHATRONICS, GIST [30] Detailed Analysis of NI-DAQ Time Delay CPU-RAM-PROGRAM-OS (1): Elapsed time to generate control data in RAM RAM-TO-PCI-BOARD (2): Elapsed time to transfer control data to PCI board PCI-BOARD-TO-AMP (3): Elapsed time to transfer control data from PCI board to the controller AMP-PCI BOARD-RAM (4): Elapsed time to retrieve feedback data The sample points are sent in 24us interval. Elapsed times are increasing with increased number of points. Elapsed time (3) is not a delay. This is the time nanopositioner move. Total time delay = (1)+(2)+(4) Elapsed time (4) is very small Elapsed times (2),(1) is critical parameters in total time delay. Input data Feedback data Programming using DAQ API Generating & collecting data Tilt mirror Transferring data DEPT. MECHATRONICS, GIST Objective positioner [31] Number of sample points with minimum time delay minimum time delay 1~4 sample points give minimum time delay. Therefore, control data composed of a number of sample points can be transferred by 4 samples at a time to minimize time delay in real time applications. (0.6ms/4 points 6666 points/sec) DEPT. MECHATRONICS, GIST [32] Example code Include “nidaqmx.lib” in the project setting DEPT. MECHATRONICS, GIST [33] Control data is being transferred by 4 samples at a time Save input data in the feedback data memory DEPT. MECHATRONICS, GIST [34] Clock and trigger signal setting for data output Clock and trigger signal setting for data input DEPT. MECHATRONICS, GIST DEPT. MECHATRONICS, GIST [36] MCL motorize stage DEPT. MECHATRONICS, GIST [37] MCL piezo stage Basic Function List MCL_InitHandle() Functions MCL_InitHandle() MCL_GetProductInfo() MCL_GetCalibration() MCL_SingleWriteN() MCL_SingleReadN() MCL_ReleaseHandle() MCL_GetProductInfo() MCL_GetCalibration() MCL_SingleWriteN () MCL_SingleReadN() Satisfied? N Y MCL_ReleaseHandle() DEPT. MECHATRONICS, GIST [38] Example code (Connect/disconnect) Include “MADLib.lib” in th project setting bool MCLControl::Connect() { unsigned long axis; /* Prior to calling any other device function MCL_InitHandle() should be called */ handle = MCL_InitHandle(); if(handle == 0) { //Cannot get a handle to the device\n"; return false; } void MCLControl::Disconnect(){ /* MCL_ReleaseHandle() should be called before the program exits */ MCL_ReleaseHandle(handle); } /* Fills a structure with information about the NanoDrive */ MCL_GetProductInfo(&pi, handle); /*Loop 3 times. Check if X is valid. Check if Y is valid. Check if Z is valid. */ for(int i = 0; i < 3; i++) { /*Checks if an axis is valid*/ if((pi.axis_bitmap & (0x01 << i)) == 0) continue; /*Move a valid axis to 50% of its range of motion*/ axis = i+1; cal[i] = MCL_GetCalibration(axis, handle); } connectionFlag = true; return true; } DEPT. MECHATRONICS, GIST [39] Example code (write/read) Include “MADLib.lib” in th project setting void MCLControl::SetPos(int axis, double position){ //position values are should be in the range of 0 to 200 um if(connectionFlag == true){ if(axis > 0 && axis < 4){ if(position >= 0 && position <= cal[axis-1]){ MCL_SingleWriteN(position, axis, handle); pos[axis-1] = position; } } } } double MCLControl::GetPos(int axis){ return MCL_SingleReadN(axis, handle); } DEPT. MECHATRONICS, GIST [40] Example code (function write) Include “MADLib.lib” in th project setting void CMCLRampWaveform::ramp_waveform_generator(int acquisition) { /*Simple example of synchronous waveform acquisition. -MCL_Setup_LoadWaveFormN loads the position control waveform to the axis -MCL_Setup_ReadWaveFormN sets some internal values in the NanoDrive -MCL_TriggerWaveformAcquisition triggers both waveforms simultaneously -MCL_Trigger_LoadWaveFormN */ … error = MCL_Setup_LoadWaveFormN(axis_index+1, datapoints, milliseconds, waveform, handle); if(error != MCL_SUCCESS) goto FAIL; … if( acquisition == true ) { error = MCL_Setup_ReadWaveFormN(axis_index+1, datapoints, milliseconds, handle); } … DEPT. MECHATRONICS, GIST [41] if( acquisition != true ) error = MCL_Trigger_LoadWaveFormN(axis_index+1, handle); else error = MCL_TriggerWaveformAcquisition(axis_index+1, datapoints, waveform, handle); printf("Waveform Functionality Tested Successfully\n"); /*Print the waveform data points.*/ if( acquisition == true ) { FILE* file_ptr; file_ptr = fopen("babo.txt","w"); for(i = 0; i < datapoints; i++) fprintf(file_ptr, "%d:\t%f\t%f\t%f\n", i, waveform_command[i], waveform[i], waveform_command[i]-waveform[i]); fclose(file_ptr); } } DEPT. MECHATRONICS, GIST [42]