| GeneralumFish30.DLL is intended to support a greater number of programming languages with functions to operate the fischertechnik interfaces. The operating system ist Windows 32bit. There are to different interface for nearly the same functions the um style with some few functions and the access to an control block (ftiDCB) for the properties. The cs style interface has a greater number of functions an only an handle to an internal ftiDCB which can't access only via a function. This is used by languages, which can't access structures or have a special garbage collection which can't accept a fix address for an control block (like C # - CSharp). To recognize (nearly) all changes on the E-Inputs, they are polled in a sperate thread under control of the MultiMediaTimer CALLBACK routine. The application will read the values of the E-Inputs (indirectly) from the ftiDCB. This serves in addition to the request of an refresh of the M-Output at least every 0.3 sec. The CALLBACK routine has some more functions for counting all changes of the E-Inputs, controlling the on times off an M-Output (PWM - speed control) and the control of an special impulse counter to stop an M-Output after reaching the requested number of impulses, same is done if the special end switch is true. The sources for umFish30.DLL are located in umFish30.ZIP. StructureAbout names : Only function with the prefix um or cs are external functions. Access to the InterfaceConnection to the InterfaceThe connection to the interface is done with the function umOpenInterface. The function itself goes more in details beside of interface and operating system :
umOpenInterface makes the default settings for ftiDCB. umCloseInterface closes the connection to the interface (CloseInterfaceRT if accessed via driver). Ther is an control block ftiSave which contains the data of the last opened ftiDCB. With unload of umFish30.DLL by the operating system in DllMain a "forgotten" umCloseInterface of the application can be done here. Read of the E-Inputs - Refresh of the M-OutputsGetInputs is the central internal routine to do this job :
GetInputs first transfers ftiDCB.OutputStatus and than reads the values of all E-Inputs to ftiDCB.InputStatus. Read of the Analog-InputsGetAnalog is the central internal routine to do this job :
GetAnalog fills ftiDCB.Analogs[] and Intelligent Interface only, the ftiDCB.InputStatus. Polling the InterfaceThe olling of the interface is controlled by the MultiMediaTimer, it is done with the CALLBACK-Routine PollInterface. At the beginning of the routine the parameter DWORD DCB is converted in a better usable form : ftiDCB *d = (ftiDCB*)DCB; Testing of the E- and Analog-Inputs, Refresh M-Outputssave of the InputStatus : StatusAlt =
d->InputStatus;
Determining StatusDelta : StatusDelta = StatusAlt ^
StatusNeu; Loop for each M-OutputThe following operations will be executes in a loop for all available M-Outputs (Indices : iMot, iEnd, iImpuls) ImpulseCounter : Couting of the Impulses on the E-InputsDone if NormalMode (MotMode, separate for each M-Output) if(StatusDelta & EMaske[.] > 0) d-Counters[.]++; Position : ImpulsCounter-ControlDone if RobMode (ModMode, separate for each M-Output) if(StatusDelta & EMaske[.] > 0) d-Counters[.]--; Braking if Counter < 6 : d->SpeedStatus = ... Speed : Controling the On Time of the M-OutputsDone with Normal- and RobMode, if M-Ausgang is on (SollDirection >0) and Speed < Full and > off. d->OutputStatus &= MAus[.]; M-Output
off Application : Access to the Controlblock ftiDCBThe fucntion with the prefix um or cs can be used by the application alternatively. In many cases they only copy values from or to the ftiDCB. Function which access single E-Inputs or M-Outputs mask the corresponding ftiDCB.field. She are comfort functions. But not easy to handle e.g. in the case of Speed-Control. In this case the common routine SetMotorAll is used. A special thing is the function GetAnalogDirect. Here the polling is stopped uring reading the Analog value. Reason : Accessing the EX/EY lasts more time then accessing the other resources. Otherwise the poll interval must be increased. The um style functions need a parameter ftiDCB, to be situated in the application. The cs style function need handle to the internal ftiDCB as parameter. Internally they access the corresponding um styl functions or access directly the ftiDCB. csOpenInterface(Ex) is called without handle. It returns a handle to be used with the following functions. As parameter some ftiDCB values are in use. DetailsMultiMediaTimerThe MultiMediaTimer calls at fixed time intervals CALLBACK routine PollInterface. He is started in umOpenInterface : Interface.FID = timeSetEvent( The CALLBACK-Routine uses the following parameters : void CALLBACK PollInterface(UINT wTimerID, UINT msg, DWORD DCB, DWORD dw1, DWORD DW2) The most interesting parameter is DWORD DCB, which is copied to an ftiDCB pointer on the beginning of the routine. ftiDCB *d = (ftiDCB+)DCB; umCloseInterface cancels the polling : if(Interface.FID != 0) timeKillEvent(Interface.FID); Because of the CALLBACK routine runs in its own thread, a reliable cancel of the MultiMediaTimer is important (see also umCloseInterface). Last Update : 10.08.2004 |