sranger_hwi_control.h

Go to the documentation of this file.
00001 /* Gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  * 
00005  * Copyright (C) 1999,2000,2001,2002,2003 Percy Zahl
00006  *
00007  * Authors: Percy Zahl <zahl@users.sf.net>
00008  * additional features: Andreas Klust <klust@users.sf.net>
00009  * WWW Home: http://gxsm.sf.net
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00024  */
00025 
00026 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&R" -*- */
00027 
00028 #ifndef __SRANGER_HWI_CONTROL_H
00029 #define __SRANGER_HWI_CONTROL_H
00030 
00031 #include "gxsm/app_profile.h"
00032 #include "FB_spm_dataexchange.h" // SRanger data exchange structs and consts
00033 
00034 typedef enum Destination { DestDSP, DestHwI };
00035 
00036 typedef union AmpIndex {
00037         struct { unsigned char ch, x, y, z; } s;
00038         unsigned long   l;
00039 };
00040 
00041 typedef struct Mover_Param{
00042         /* Mover Control */
00043         double MOV_Ampl, MOV_Speed, MOV_Steps;
00044         
00045 #define DSP_AFMMOV_MODES 4
00046         double AFM_Amp, AFM_Speed, AFM_Steps;  /* STM/AFM Besocke Kontrolle -- current */
00047         double AFM_usrAmp[DSP_AFMMOV_MODES];  
00048         double AFM_usrSpeed[DSP_AFMMOV_MODES];
00049         double AFM_usrSteps[DSP_AFMMOV_MODES]; /* Parameter Memory for different Mover/Slider Modes */
00050 
00051 #define MOV_MAXWAVELEN 4096
00052 #define MOV_WAVE_SAWTOOTH 0
00053 #define MOV_WAVE_SINE     1
00054 #define MOV_WAVE_CYCLO    2
00055 #define MOV_WAVE_LAST     3
00056         int MOV_output, MOV_mode, MOV_waveform_id;
00057         int MOV_wave_len;
00058         short MOV_waveform[MOV_MAXWAVELEN];
00059         double final_delay;
00060 };
00061 
00062 typedef enum pv_mode { PV_MODE_NONE, PV_MODE_IV, PV_MODE_FZ, PV_MODE_PL, PV_MODE_LM, PV_MODE_AC };
00063 typedef enum make_vector_flags { MAKE_VEC_FLAG_NORMAL=0, MAKE_VEC_FLAG_VHOLD=1, MAKE_VEC_FLAG_RAMP=2, MAKE_VEC_FLAG_END=4 };
00064 
00065  
00066 class DSPControl : public AppBase{
00067         friend class sranger_hwi_dev;
00068 
00069 #define DSP_FB_ON  1
00070 #define DSP_FB_OFF 0
00071 
00072 #define FLAG_FB_ON       0x01 // FB on
00073 #define FLAG_DUAL        0x02 // Dual Data
00074 #define FLAG_SHOW_RAMP   0x04 // show ramp data
00075 #define FLAG_INTEGRATE   0x08 // integrate and normalize date of all AIC data point inbetween
00076 
00077 #define FLAG_AUTO_SAVE   0x01 // auto save
00078 #define FLAG_AUTO_PLOT   0x02 // auto plot
00079 
00080  public:
00081         DSPControl ();
00082         virtual ~DSPControl();
00083 
00084         void AddProbeModes (GtkWidget *notebook);
00085 
00086         void save_values (NcFile *ncf);
00087         void load_values (NcFile *ncf);
00088         void update();
00089         void updateDSP(int FbFlg=-1);
00090         static void ChangedNotify(Param_Control* pcs, gpointer data);
00091         static int ChangedAction(GtkWidget *widget, DSPControl *dspc);
00092         static int feedback_callback(GtkWidget *widget, DSPControl *dspc);
00093         static int choice_Ampl_callback(GtkWidget *widget, DSPControl *dspc);
00094         static int auto_probe_callback(GtkWidget *widget, DSPControl *dspc);
00095         static int LockIn_exec_callback(GtkWidget *widget, DSPControl *dspc);
00096         static int LockIn_read_callback(GtkWidget *widget, DSPControl *dspc);
00097         static int LockIn_write_callback(GtkWidget *widget, DSPControl *dspc);
00098         static int Probing_exec_IV_callback(GtkWidget *widget, DSPControl *dspc);
00099         static int Probing_write_IV_callback(GtkWidget *widget, DSPControl *dspc);
00100         static int Probing_exec_FZ_callback(GtkWidget *widget, DSPControl *dspc);
00101         static int Probing_write_FZ_callback(GtkWidget *widget, DSPControl *dspc);
00102         static int Probing_exec_PL_callback(GtkWidget *widget, DSPControl *dspc);
00103         static int Probing_write_PL_callback(GtkWidget *widget, DSPControl *dspc);
00104         static int Probing_exec_LM_callback(GtkWidget *widget, DSPControl *dspc);
00105         static int Probing_exec_RF_callback(GtkWidget *widget, DSPControl *dspc);
00106         static int Probing_write_LM_callback(GtkWidget *widget, DSPControl *dspc);
00107         static int Probing_eventcheck_callback(GtkWidget *widget, DSPControl *dspc);
00108         static int Probing_graph_callback(GtkWidget *widget, DSPControl *dspc);
00109         static int Probing_save_callback(GtkWidget *widget, DSPControl *dspc);
00110         static int change_source_callback (GtkWidget *widget, DSPControl *dspc);
00111         static int callback_change_AC_option_flags (GtkWidget *widget, DSPControl *dspc);
00112         static int callback_change_AC_auto_flags (GtkWidget *widget, DSPControl *dspc);
00113         static int callback_change_IV_option_flags (GtkWidget *widget, DSPControl *dspc);
00114         static int callback_change_IV_auto_flags (GtkWidget *widget, DSPControl *dspc);
00115         static int callback_change_FZ_option_flags (GtkWidget *widget, DSPControl *dspc);
00116         static int callback_change_FZ_auto_flags (GtkWidget *widget, DSPControl *dspc);
00117         static int callback_change_PL_option_flags (GtkWidget *widget, DSPControl *dspc);
00118         static int callback_change_PL_auto_flags (GtkWidget *widget, DSPControl *dspc);
00119         static int callback_change_LM_option_flags (GtkWidget *widget, DSPControl *dspc);
00120         static int callback_change_LM_auto_flags (GtkWidget *widget, DSPControl *dspc);
00121         static int DSP_expert_callback (GtkWidget *widget, DSPControl *dspc);
00122         int probedata_length () { return current_probe_data_index; };
00123         void push_probedata_arrays ();
00124         GArray** pop_probedata_arrays ();
00125         void init_probedata_arrays ();
00126         static void free_probedata_array_set (GArray** garr, DSPControl *dc);
00127         void free_probedata_arrays ();
00128 
00129         void add_probedata(double data[13]);
00130         void add_probevector();
00131         void set_probevector(double pv[9]);
00132 
00133         void add_user_event_now (gchar* message, gint addflag=FALSE);
00134 
00135         void StartScanPreCheck ();
00136         pv_mode write_vector_mode;
00137 
00138         void store_values ();
00139 
00140         double frq_ref;           // Frquency Reference: i.e. feedback, scan, ... dataaq. sampling rate
00141         int    feedback_flag;
00142         // -- section ANALOG_VALUES --
00143         double bias;              // Bias (usually applied to the sample)
00144         // -- section SPM_PI_FEEDBACK --
00145         double current_set_point; // Current Setpoint (STM; log mode)
00146         double voltage_set_point; // Universal SetPoint (AFM,...; lin mode)
00147         double usr_cp, usr_ci;    // Feedback: Const Proportional, Const Integral [user visible values]
00148 
00149         // -- section AREA_SCAN --
00150         double dynamic_zoom;      // on-the-fly zooming, 1 = normal
00151         double move_speed_x;      // in DAC (AIC) units per second, GXSM core computes from A/s using X-gain and Ang/DAC...
00152         double scan_speed_x;      // in DAC (AIC) units per second
00153         double gain_ratio;        // may be used later for compensation of direction dependence of speed in case of different X/Y gains. 
00154                                   // i.e. it is gain-X/gain-Y
00155         int pre_points;
00156 
00157         // UserEvent sensitive:
00158         double ue_bias;
00159         double ue_current_set_point;
00160         double ue_voltage_set_point;
00161         double ue_usr_cp, ue_usr_ci;
00162         double ue_scan_speed_x;
00163 
00164         double volt_points[10];
00165         int    num_points[10];
00166 
00167         // LockIn
00168         double AC_amp, AC_frq, AC_phaseA, AC_phaseB;
00169         double AC_phase_span, AC_phase_slope, AC_final_delay;
00170         int AC_points;
00171         int AC_repetitions;
00172         int AC_lockin_avg_cycels;
00173         int AC_option_flags;
00174         int AC_auto_flags;
00175         GtkWidget *AC_status;
00176 
00177         // Probing
00178         int probe_trigger_raster_points_user;
00179         int probe_trigger_raster_points;
00180         int probe_trigger_single_shot;
00181         int Source, XSource, PSource;
00182         int probe_ready;
00183         gchar *probe_fname;
00184         int probe_findex;
00185 
00186         // STS (I-V)
00187         void make_auto_n_vector_elments (double fnum);
00188         double make_Vdz_vector (double Ui, double Uf, double dZ, int n, double slope, int source, int options, double long &duration, make_vector_flags flags);
00189         double make_ZXYramp_vector (double dZ, double dX, double dY, int n, double slope, int source, int options, double long &duration, make_vector_flags flags);
00190         double make_phase_vector (double dPhi, int n, double slope, int source, int options, double long &duration, make_vector_flags flags);
00191         double make_delay_vector (double delay, int source, int options, double long &duration, make_vector_flags flags);
00192         void append_null_vector (int options, int index);
00193         double IV_start, IV_end, IV_slope, IV_slope_ramp, IV_final_delay, IV_recover_delay;
00194         double IV_dz;
00195         int    IV_points;
00196         int    IV_repetitions;
00197         int    IVdz_repetitions;
00198         int    IV_option_flags;
00199         int    IV_auto_flags;
00200         GtkWidget *IV_status;
00201 
00202         // FZ (Force-Z(Distance))
00203         double FZ_start, FZ_end, FZ_slope, FZ_slope_ramp, FZ_final_delay;
00204         int    FZ_points;
00205         int    FZ_repetitions;
00206         int    FZ_option_flags;
00207         int    FZ_auto_flags;
00208         GtkWidget *FZ_status;
00209 
00210         // PL (Puls)
00211         double PL_duration, PL_slope, PL_volt, PL_final_delay;
00212         int    PL_repetitions;
00213         int    PL_option_flags;
00214         int    PL_auto_flags;
00215         GtkWidget *PL_status;
00216 
00217         // LM (Lateral Manipulation)
00218         double LM_dx, LM_dy, LM_dz, LM_slope, LM_final_delay;
00219         int    LM_repetitions;
00220         int    LM_points;
00221         int    LM_option_flags;
00222         int    LM_auto_flags;
00223         GtkWidget *LM_status;
00224 
00225 
00226         // -- Profile Displays
00227         int last_probe_data_index;
00228 
00229         // dynamic temporary probe data storage
00230         GSList *probedata_list;
00231         int num_probe_events;
00232         // -- Array of full expanded probe data set
00233 #define NUM_PROBEDATA_ARRAYS 25
00234         GArray *garray_probedata[NUM_PROBEDATA_ARRAYS];
00235         int current_probe_data_index;
00236         int nun_valid_data_sections;
00237 #define PROBEDATA_ARRAY_INDEX 0 // Array [0] holds the probe index over all sections
00238 #define PROBEDATA_ARRAY_TIME  1 // Array [1] holds the time
00239 #define PROBEDATA_ARRAY_X0    2 // Array [2] holds X-Offset
00240 #define PROBEDATA_ARRAY_Y0    3 // Array [3] holds Y-Offset
00241 #define PROBEDATA_ARRAY_PHI   4 // Array [4] holds Z-Offset
00242 #define PROBEDATA_ARRAY_XS    5 // Array [5] holds X-Scan
00243 #define PROBEDATA_ARRAY_YS    6 // Array [6] holds Y-Scan
00244 #define PROBEDATA_ARRAY_ZS    7 // Array [7] holds Z-Scan
00245 #define PROBEDATA_ARRAY_U     8 // Array [8] holds U (Bias)
00246 #define PROBEDATA_ARRAY_SEC   9 // Array [9] holds Section Index
00247 #define PROBEDATA_ARRAY_AIC5OUT_ZMON 10 // Array [10] holds ZMON (AIC5 out)
00248 #define PROBEDATA_ARRAY_AIC6OUT_UMON 11 // Array [11] holds UMON (AIC6 out)
00249 #define PROBEDATA_ARRAY_AIC5_FBS     12 // Array [12] holds FBS (Feedback Source, i.e. I, df, force, ...)
00250 #define PROBEDATA_ARRAY_AIC0         13 // Array [13] holds AIC0 in
00251 #define PROBEDATA_ARRAY_AIC1         14 // Array [14] holds AIC1 in
00252 #define PROBEDATA_ARRAY_AIC2         15 // Array [15] holds AIC2 in
00253 #define PROBEDATA_ARRAY_AIC3         16 // Array [16] holds AIC3 in
00254 #define PROBEDATA_ARRAY_AIC4         17 // Array [17] holds AIC4 in
00255 #define PROBEDATA_ARRAY_AIC6         18 // Array [18] holds AIC6 in (not used yet)
00256 #define PROBEDATA_ARRAY_AIC7         19 // Array [19] holds AIC7 in (not used yet)
00257 #define PROBEDATA_ARRAY_LCK0         20 // Array [20] holds LockIn0st
00258 #define PROBEDATA_ARRAY_LCK1A        21 // Array [21] holds LockIn1st
00259 #define PROBEDATA_ARRAY_LCK1B        22 // Array [22] holds LockIn22st
00260 #define PROBEDATA_ARRAY_LCK2A        23 // Array [23] holds LockIn1st
00261 #define PROBEDATA_ARRAY_LCK2B        24 // Array [24] holds LockIn22st
00262 
00263 
00264         int    current_auto_flags;
00265         int    raster_auto_flags;
00266         GtkWidget *save_button;
00267 
00268  protected:
00269         void read_dsp_state (); // FB on/off
00270         void write_dsp_state ();
00271         
00272         void conv_dsp_feedback ();
00273         void read_dsp_feedback (); // cp, cp, setpoint
00274         void write_dsp_feedback ();
00275         
00276         void conv_dsp_analog ();
00277         void read_dsp_analog (); // bias
00278         void write_dsp_analog ();
00279 
00280         void conv_dsp_scan ();
00281         void read_dsp_scan ();
00282         void write_dsp_scan ();
00283         
00284         void conv_dsp_probe ();
00285         void read_dsp_probe ();
00286         void write_dsp_probe (int start=0, pv_mode pvm=PV_MODE_NONE);
00287         
00288         void conv_dsp_vector ();
00289         void read_dsp_vector (int index);
00290         void write_dsp_vector (int index);
00291         
00292         void conv_dsp_cr_out_pulse ();
00293         void read_dsp_cr_out_pulse ();
00294         void write_dsp_cr_out_pulse ();
00295         
00296  private:
00297         SPM_STATEMACHINE dsp_state;
00298         SPM_PI_FEEDBACK  dsp_feedback;
00299         ANALOG_VALUES    dsp_analog;
00300         AREA_SCAN        dsp_scan;
00301         PROBE            dsp_probe;
00302         DATA_FIFO        dsp_fifo;
00303         CR_OUT_PULSE     dsp_cr_out_pulse;
00304         PROBE_VECTOR     dsp_vector;
00305 
00306         #define MAX_PV 50
00307         PROBE_VECTOR     dsp_vector_list[MAX_PV]; // copy for GXSM internal use only
00308 
00309         GSList *RemoteEntryList;
00310         UnitObj *Unity, *Volt, *Angstroem, *Current, *SetPtUnit, *Speed, *PhiSpeed, *Frq, *Deg, *Vslope, *Time, *msTime;
00311         
00312         int expert_mode;
00313 };
00314 
00315 
00316 class DSPMoverControl : public AppBase{
00317 public:
00318         DSPMoverControl();
00319         virtual ~DSPMoverControl();
00320 
00321         void update();
00322         void updateDSP(int sliderno=-1);
00323         static void ExecCmd(int cmd);
00324         static void ChangedNotify(Param_Control* pcs, gpointer data);
00325         static int config_mode (GtkWidget *widget, DSPMoverControl *dspc);
00326         static int config_waveform (GtkWidget *widget, DSPMoverControl *dspc);
00327         static int config_output (GtkWidget *widget, DSPMoverControl *dspc);
00328         static int CmdAction(GtkWidget *widget, DSPMoverControl *dspc);
00329         static int StopAction(GtkWidget *widget, DSPMoverControl *dspc);
00330 
00331         void create_waveform (double amp, double duration);
00332         Mover_Param mover_param;
00333 
00334 private:
00335         void create_folder();
00336 
00337         UnitObj *Unity, *Volt, *Time, *Length;
00338 };
00339 
00340 #endif
00341 

Generated on Sat Apr 1 09:04:18 2006 for GXSM by  doxygen 1.4.6