umFish30 Notes

ftComputing : Programme für die fischertechnik-Interfaces und -konstruktionskästen
  
ftComputing.de
Home
Back
Sitemap
Index
Links
Impressum
Mail
 

General

umFish30.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.

Structure

About names : Only function with the prefix um or cs are external functions.

Access to the Interface

Connection to the Interface

The connection to the interface is done with the function umOpenInterface. The function itself goes more in details beside of interface and operating system :

  • umOpenInterface
    • OpenInterfaceCOM : Intelligent Interface
    • OpenInterfaceLPT : Universal (parallel) Interface (direct)
      • OpenInterfaceRT : access via driver

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-Outputs

GetInputs is the central internal routine to do this job :

  • GetInputs
    • GetInputsCOM1 : Intelligent Interface only
    • GetInputsCOM2 : with extension module
    • GetInputsRT : via driver
    • GetInputsLPT : direct access

GetInputs first transfers ftiDCB.OutputStatus and than reads the values of all E-Inputs to ftiDCB.InputStatus.

Read of the Analog-Inputs

GetAnalog is the central internal routine to do this job :

  • GetAnalog
    • GetAnalogCOM1 : Intelligent Interface only
    • GetAnalogCOM2 : with extension module
    • GetAnalogRT : via driver
    • GetAnalogLPT : direct access

GetAnalog fills ftiDCB.Analogs[] and Intelligent Interface only, the ftiDCB.InputStatus.

Polling the Interface

The 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-Outputs

save of the  InputStatus : StatusAlt = d->InputStatus;
Set StatusNeu

  • Intelligent Interface :
    • GetInputs(*d); if AnalogScan = 0
    • changing GetAnalog(*d, 0/1); if AnalogScan = true
  • Universal (parallel) Interface :
    • GetInputs(*d);
    • chhanging GetAnalog(*d, 0/1); if AnalogScan = true

Determining StatusDelta : StatusDelta = StatusAlt ^ StatusNeu;
Set ftiDCB : d->InputStatus = StatusNeu;

Loop for each M-Output

The 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-Inputs

Done if NormalMode (MotMode, separate for each M-Output)

if(StatusDelta & EMaske[.] > 0) d-Counters[.]++;

Position : ImpulsCounter-Control

Done 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-Outputs

Done with Normal- and RobMode, if M-Ausgang is on (SollDirection >0) and Speed < Full and > off.

d->OutputStatus &= MAus[.];  M-Output off
SpeedValue = ...; according the OnOffTab[.] M-Output on / off.
d->OutputStatus |= AktDirection; new OutputStatus

Application : Access to the Controlblock ftiDCB

The 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.

Details

MultiMediaTimer

The MultiMediaTimer calls at fixed time intervals CALLBACK routine PollInterface. He is started in umOpenInterface :

Interface.FID = timeSetEvent(
    Interface.PollInterval,   // Time interval
    0,                                     // with older systems :
                                            // max value for that system
    PollInterface,                  // Address of the CALLBACK routine
    DWORD(&Interface),            //  address of the ftiDCB as DWORD
    TIME_PERIODIC);                 //  Periodic call

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