Creating a dynamic function generator with DASYLab and ODBC Marcel P. Chabot Software Engineer InSyS Corp. www.insyscorp.com In many testing situations an arbitrary wave form can be used to control an Analog output or a sequence of events inside DASYLab. The DASYLab Sequence Generator allows users to create a static waveform quickly and easily. In some test situations the wave form needs to change. However in many cases, such as DASYLab RUNTIME, it is not possible or feasible to have the end user edit the DASYLab Sequence Generator. Using ODBC, Excel and DASYLab an excel spreadsheet can be used to create the waveform dynamically. The first step in this process is to create your wave form in Excel as a series of steps, exactly as you would in the DASYLab Sequence Generator. The Excel spreadsheet must include a “Step” column, “End Value” column and “Duration” column. You should notice that these columns will match up inside the DASYLab sequence Generator. The only special consideration is that each column must include one additional entry of a -1 to indicate the last step. Step 1 2 3 4 5 6 EndValue 1 5 3 2 1 -1 Duration 1 2 3 2 1 -1 Next we must register this spreadsheet with the ODBC System. Detailed instructions of this can be found in the “DASYLab Hands On Guide” (www.dasylab.net). Now it’s time to read the values in and create our Sequence Generator. Typically this is done using two worksheets. The first worksheet is to read the values into global variables and the second to actually run the sequence generator. In the first worksheet we must configure the global variables. These global variables must be written to the INI file so they will persist between the two worksheets. In DASYLab click Options; Define Global Variables. Select a number of global variables twice the count of the number of steps you have. In our case I have 5 steps, and will need 10 variables. Now we can start to read the data into DASYLab. ODBC can only read data into a single variable, therefore we will have to read each value into a single location, and then copy it to its final location. Controlling this operation will be a Generator module outputting a Square Wave at 1hz. To facilitate the read/copy sequence we will need to configure the ODBC Input to read each value into one location, then we can copy it out. For this we will use Global Variable 100 to hold the end value, 101 to hold the Duration and 102 for the counter. Now for the Action Module to read everything into the Global Variables. We will use an Action Module with 1 input and 16 Actions. This action module will set the defaults, read the variables and copy them to their final locations. The first action occurs on Experiment Start, received by DASYLab and causes a Variable Set, variable 102 to 1. This sets the first line to read to line 1. Action 1 is exactly the same as action except the Variable is 1-3 and the value is 6. This will be the first location that the “Duration” value is copied to. Action 2 actually reads the data from the database: Action 3 copies the “End Value” data from it’s temporary location at variable 100 to it’s new location. It so happens that in this example that the final location is the same as the step count (Variable 102). The notify option is used to increment variable 102, in effect increasing the step counter and the next location to save data. Action 4 is almost the same as action 3, however the “To Number:” has changed to variable 103 and the from has changed to 101, to indicate the location of the data and where to save it. You should remember that variable 102 starts at 6. The last series of steps allow for a little data control. This module reads variable 101. When the read is complete the last duration of -1 will be read into 101. When the combi trigger sees a value less that 0 the timing sequence is blocked From here you have several options on how to get to your next worksheet, however I recommend using the DASYLab worksheet sequencer. The easiest is to trigger the worksheet change off the Falling Edge of the Combi-Trigger. (More information in the DASYLab Hands On Guide.) In the new worksheet, configure the global variables to “Read from INI File at Start of Experiment”. Now we are ready to create our sequence. Drop a Sequence Generator on your worksheet. Open it and click sequence. In our case were have a 5 step sequence, however this could be expanded to many more steps, as well as using an unknown number of steps by creating a final step with a duration beyond our test duration. From our reading in of the data we know that the “End Values” start at Global Variable 1 and end at Global Variable 5. The Durations start at Global Variable 6 and end at Global Variable 10. Using these in place of number we can create a sequence that looks like this: NOTE: all values are “End Value Absolute”. This completes the construction of our dynamic sequence generator. By editing the Excel spreadsheet and running the first worksheet, a new sequence is read into DASYLab and is ready to run.