Watlow LogicPro Manuel d'utilisateur Page 197

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 296
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 196
LogicPro Users Guide Chapter 11: User Defined Function Blocks
Doc.# 28002-00 Rev 3.00 Watlow Anafaze 181
functions. The structure and these three functions are listed in
the following example as they are generated by LogicPro.
#ifndef PCADD1UDFBHeader
#define PCADD1UDFBHeader
#define bool char
#define Int16 short
typedef struct {
Int16 A;
Int16 B;
Int16 C;
bool EN;
bool Q;
}ADD1Struct;
extern int ADD1(bool EN,bool *Q,ADD1Struct *ADD1StructA);
extern void InitADD1(ADD1Struct *ADD1StructA,Int16 A,Int16 B);
extern void ResetADD1(ADD1Struct *ADD1StructA);
extern void ExitADD1(ADD1Struct *ADD1StructA);
#endif
Let’s take a closer look at the main function and how to write
C code.
int ADD1(bool EN,bool *Q, ADD1Struct *ADD1StructA);
This function is called in the evaluation loop of your Program.
It is called when the rung of Ladder logic that it resides on, or
a Function Block diagram, is being evaluated.
All Boolean inputs are given to the function passed by their
copies. All other inputs are passed by reference through the
structure. In our example, ADD1, use the structure pointer
ADD1 StructA to get the value of either A or B.
Any output can use a pointer to exchange the value from the
Function Block to the variable specified by the Ladder
diagram. In this example, we use a pointer C to pass the value
of our arithmetic operation to the variable assigned in the
Ladder diagram.
The final parameter that is passed to the function is a pointer
to a structure.
Vue de la page 196
1 2 ... 192 193 194 195 196 197 198 199 200 201 202 ... 295 296

Commentaires sur ces manuels

Pas de commentaire