The instructions that the protocol has to execute are written in a C function. So we have to create a function that contains all the orders for our new designed protocol. For instance, AutoMovePiezos(), Oscillate(), ForceRamp() are names of functions that perform a specific protocol. These functions are located in the ltcontrol.c file and predefined in the ltcontrol.h header file. The ControlTimer() function is responsible for calling the protocol algorithms 60 times per second. Therefore, a IF statement has to be added in ControlTimer() to call our new designed function when it is activated by the user.
The algorithm of the new protocol has to be designed considering that it will be called (and run) at 60 Hz. The following example shows the pseudocode to produce a pulling protocol at constant pulling rate.
IF <forceLimit> OR <positionLimit> TRUE <pullingRate> = - <pullingRate>; <newPosition> = ( <previousTime> - <Time> ) * <pullingRate>; <previousTime> = <Time>;
The protocol algorithm will have direct access to all the data structure that contains the information about the status of the instrument (time, force, motor and trap position, etc.). On the other hand, the CommandInstrument() function is the most important function to give orders to the instrument such as set the feedback algorithms (autoalign, constant force, passive mode), move the motors (gotos, motor speed), move the traps (set the piezos output voltage), etc.
So the protocol is written in a function that reads the status of the instrument and gives orders at 60 Hz.
JM Huguet 2014-02-12