IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Simulink Discussion :

Bloc de construction digital Driver pour Target


Sujet :

Simulink

  1. #1
    Candidat au Club
    Homme Profil pro
    Responsable d'exploitation informatique
    Inscrit en
    Novembre 2017
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : Maroc

    Informations professionnelles :
    Activité : Responsable d'exploitation informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Novembre 2017
    Messages : 2
    Points : 2
    Points
    2
    Par défaut Bloc de construction digital Driver pour Target
    salut Tout le monde ,
    je veux creer un bloc de construction Digital Driver en Matlab pour Target xPC et j ai le code qui ete programme pour OATS,qui peut m informer sur ce sujet

  2. #2
    Modérateur
    Avatar de le fab
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2005
    Messages
    1 881
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2005
    Messages : 1 881
    Points : 3 429
    Points
    3 429
    Par défaut
    bonjour

    la question est un peu vague ...
    as tu commencé à faire quelque chose ?
    si oui, ou bloques tu ?

    Fabien

  3. #3
    Candidat au Club
    Homme Profil pro
    Responsable d'exploitation informatique
    Inscrit en
    Novembre 2017
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : Maroc

    Informations professionnelles :
    Activité : Responsable d'exploitation informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Novembre 2017
    Messages : 2
    Points : 2
    Points
    2
    Par défaut
    salut le fab ,
    mon devoir c est de creer un driver Digital Input /Output für Matlab.
    j ai le code (en C) en main ,qui etait programme pour OATS,je dois maintenent le faire en Matlab (convertir le code pour qui il soit compatible pour Matlab).comme vous le savez qu on creent un Bloc en Matlab avec les variable d entrer et de sorter on va avoir tois Function void -Start() et void-Output() et void-Terminate()

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
     
    	                                      WASCO_12_S_Digital_Input                   
    	                                      +----------------------------+
    	                                      |                                      |
     WASCO_12_S_Digital_Carrier -| Carrier------------Carrier  |- WASCO_12_S_Digital_Carrier
    	                             UINT -| Channel                Value |- BOOL
    	                                      |                                Err  |- UINT
    	                                      +----------------------------+
     
     
    #undef _debug_print
     
    //------------------------------------------------------------------
    // include files as needed
     
    #include "oats.h"
    #include "wa12dc.h"
    #include "wa12dcs.h"
    #include "wa12di.h"
    #ifdef _debug_print
    	#include "stdio.h"
    #endif 
     
    //------------------------------------------------------------------
    // public symbols and prototypes for the functions required by OATs
     
    #ifndef _WIN32
    extern "C" OATsClass ClassDef;	// referenced within the OATs library
    #endif // _WIN32
     
    unsigned int OATSCALLBACK WASCO_12_S_Digital_InputInitInstance(WASCO_12_S_Digital_Input* pInstance);
    unsigned int OATSCALLBACK WASCO_12_S_Digital_InputKillInstance(WASCO_12_S_Digital_Input* pInstance);
    int OATSCALLBACK WASCO_12_S_Digital_InputFirstRun(WASCO_12_S_Digital_Input* pInstance);
    int OATSCALLBACK WASCO_12_S_Digital_InputOperate(WASCO_12_S_Digital_Input* pInstance);
     
     
    #ifdef _WIN32
    // for protected mode modules using floating point uncomment next line
    //  extern "C" const int _fltused = 1;
    #endif // _WIN32
     
    //------------------------------------------------------------------
    // OATs class structure
     
    #ifdef _WIN32
    extern "C" __declspec(dllexport) OATsClass	ClassDef =
    #else // _WIN32
    OATsClass		ClassDef =
    #endif // _WIN32
    {
    	InitClassDummy,
    	KillClassDummy,
    	(InitInstanceFunction)WASCO_12_S_Digital_InputInitInstance,
    	(KillInstanceFunction)WASCO_12_S_Digital_InputKillInstance,
    	(FirstRunFunction)WASCO_12_S_Digital_InputFirstRun,
    	(OperateFunction)WASCO_12_S_Digital_InputOperate,
    	NULL,
     
     
    void ReadValue(WASCO_12_S_Digital_Input* pInstance)
    {
    	char cHelp;
    	switch(pInstance->PortUsed)
    	{
    	case PortAUsed:		
    		cHelp = pInstance->Carrier->PortA_shadow = pInstance->servFunc->pReadPortA(pInstance->Carrier); // read port A
    		cHelp &= andMask[pInstance->BitInPort]; // separate out selected bit
    		if (cHelp == andMask[pInstance->BitInPort])
    			pInstance->Value = 1; // bit in port is used
    			else
    			pInstance->Value = 0; // bit in port is not used
    		break;
    	case PortBUsed:		
    		cHelp = pInstance->Carrier->PortB_shadow = pInstance->servFunc->pReadPortB(pInstance->Carrier);
    		cHelp &= andMask[pInstance->BitInPort];
    		if (cHelp == andMask[pInstance->BitInPort])
    			pInstance->Value = 1;
    		else
    			pInstance->Value = 0;		
    		break;
    	case PortCLUsed:		
    		cHelp = pInstance->Carrier->PortC_shadow = pInstance->servFunc->pReadPortC(pInstance->Carrier);
    		cHelp &= andMask[pInstance->BitInPort];
    		if (cHelp == andMask[pInstance->BitInPort])
    			pInstance->Value = 1;
    		else
    			pInstance->Value = 0;		
    		break;
    	case PortCHUsed:
    		cHelp = pInstance->Carrier->PortC_shadow = pInstance->servFunc->pReadPortC(pInstance->Carrier);
    		cHelp &= andMask[pInstance->BitInPort];
    		if (cHelp == andMask[pInstance->BitInPort])
    			pInstance->Value = 1;
    		else
    			pInstance->Value = 0;		
    		break;
    	}
    }
     
    unsigned int BitOfPort(WASCO_12_S_Digital_Input* pInstance)
    {
    	unsigned int cHelp;
    	cHelp = pInstance->Channel;
     
    	if (cHelp < 8) // channel belongs to port A
    	{
    		pInstance->PortUsed = PortAUsed;
    		pInstance->BitInPort = cHelp;
     
    		#ifdef _debug_print
    			printf("Port A used\n");
    			printf("Bit %i used\n", cHelp);
    		#endif
     
    		return 0;
    	}
    	else if (cHelp < 16) // channel belongs to port B
    	{
    		pInstance->PortUsed = PortBUsed;
    		cHelp -= 8;
    		pInstance->BitInPort = cHelp;
     
    		#ifdef _debug_print
    			printf("Port B used\n");
    			printf("Bit %i used\n", cHelp);
    		#endif
     
    		return 0;
    	}
    	else if (cHelp < 20) // channel belongs to port C
    	{
    		pInstance->PortUsed = PortCLUsed;
    		cHelp -= 16;
    		pInstance->BitInPort = cHelp;
     
    		#ifdef _debug_print
    			printf("Port C LOW used\n");
    			printf("Bit %i used\n", cHelp);
    		#endif
     
    		return 0;
    	}
    	else if (cHelp < 24) // channel belongs to port C
    	{
    		pInstance->PortUsed = PortCHUsed;
    		cHelp -= 16;
    		pInstance->BitInPort = cHelp;
     
    		#ifdef _debug_print
    			printf("Port C HIGH used\n");
    			printf("Bit %i used\n", cHelp);
    		#endif
     
    		return 0;
     
    	}
    	else 
    		return OATsError_IOInvalidChannelNo;
    }
     
     
    unsigned int OATSCALLBACK WASCO_12_S_Digital_InputInitInstance(WASCO_12_S_Digital_Input* pInstance)
    {
    	if ( pOATsService->pInitInstanceDefault(&ClassDef, &pInstance->m_Base) == 0 )
    		return 0;
     
    	// add instance specific initialisation
     
    	return sizeof(WASCO_12_S_Digital_Input);
    }
     
    unsigned int OATSCALLBACK WASCO_12_S_Digital_InputKillInstance(WASCO_12_S_Digital_Input* pInstance)
    {
    	// add instance specific cleanup if required
     
     
    	if ( pOATsService->pKillInstanceDefault(&ClassDef, &pInstance->m_Base) == 0 )
    		return 0;
     
    	return sizeof(WASCO_12_S_Digital_Input);
    }
     
    int OATSCALLBACK WASCO_12_S_Digital_InputFirstRun(WASCO_12_S_Digital_Input* pInstance)
    {
    	pInstance->Err = 0;
     
    	pInstance->servFunc = pInstance->Carrier->servFunc;
     
    	pInstance->Err = BitOfPort(pInstance); // detect bit and port number
     
    	if (pInstance->Err)
    		return 0;
     
    	pInstance->Err = pInstance->servFunc->pDefineIOMode(pInstance->Carrier, input_mode, (int)pInstance->PortUsed);
     
    	if (pInstance->Err)
    		return 0;
     
    	pInstance->servFunc->pCreateCSR(pInstance->Carrier);
     
    	return 0;										// OK
    }
     
    		// steady part of the real time operation
    		// this function often contains the complete functionality
    		// return 0=ok, 1=error
    int OATSCALLBACK WASCO_12_S_Digital_InputOperate(WASCO_12_S_Digital_Input* pInstance)
    {
    	if (pInstance->Err)
    		return 0;
     
    	ReadValue(pInstance);
     
    	return 0;										// OK
    }
     
    avec :
    struct WASCO_DC_serv_func;
     
    enum InputOutputMode
    {
    	io_undefined,
    	input_mode,
    	output_mode
    };
     
    struct WASCO_12_S_Digital_Carrier
    {
    	//{ OATs interface, DO NOT MODIFY
    	Instance			m_Base;
    	IEC1131_WORD		Port;
    	//} end of OATs interface
    	// any private data for each instance has to follow here
    	InputOutputMode PortMode[4];
    	unsigned char CounterMode[3];
    	unsigned char PortA_shadow, PortB_shadow, PortC_shadow, CSR_shadow, TCR_shadow;
    	WASCO_DC_serv_func* servFunc;
    };
     
    #endif // __wa12sdc_H__
    enum PortUsedType
    {
    	PortAUsed,
    	PortBUsed,
    	PortCLUsed,
    	PortCHUsed
    };
     
    struct WASCO_12_S_Digital_Input
    {
    	//{ OATs interface, DO NOT MODIFY
    	Instance			m_Base;
    	OATsClass*		pCarrierRequiredClass;
    	WASCO_12_S_Digital_Carrier*		Carrier;
    	IEC1131_UINT		Channel;
    	IEC1131_BOOL		Value;
    	IEC1131_UINT		Err;
    	//} end of OATs interface
    	// any private data for each instance has to follow here
    	WASCO_DC_serv_func* servFunc;
    	PortUsedType PortUsed;
    	char BitInPort;
    };
     
    unsigned char andMask[8] = { 0x01, 0x02, 0x04, 0x08,
    			 0x10, 0x20, 0x40, 0x80 };
    	pInstance->servFunc = new WASCO_DC_serv_func;
    	pInstance->servFunc->pDefineIOMode = DefineIOMode;
    	pInstance->servFunc->pCreateCSR = CreateCSR;
    	pInstance->servFunc->pDefineCounterMode = DefineCounterMode;
    	pInstance->servFunc->pCreateTCR = CreateTCR;
    	pInstance->servFunc->pReadPortA = ReadPortA;
    	pInstance->servFunc->pReadPortB = ReadPortB;
    	pInstance->servFunc->pReadPortC = ReadPortC;
    	pInstance->servFunc->pReadCnt = ReadCnt;
    	pInstance->servFunc->pWritePortA = WritePortA;
    	pInstance->servFunc->pWritePortB = WritePortB;
    	pInstance->servFunc->pWritePortC = WritePortC;
    	pInstance->servFunc->pWriteCSR = WriteCSR;
    	pInstance->servFunc->pWriteCnt = WriteCnt;
    	pInstance->servFunc->pWriteTCR = WriteTCR;	
    	return sizeof(WASCO_12_S_Digital_Carrier);
    }
     
    		// destruction of an instance
    		// the function will be called several times
    		// return size of struct WASCO_12_S_Digital_Carrier or 0 on errors
    unsigned int OATSCALLBACK WASCO_12_S_Digital_CarrierKillInstance(WASCO_12_S_Digital_Carrier* pInstance)
    {
    	// add instance specific cleanup if required
     
     
    	if ( pOATsService->pKillInstanceDefault(&ClassDef, &pInstance->m_Base) == 0 )
    		return 0;
    	delete pInstance->servFunc;
     
    	return sizeof(WASCO_12_S_Digital_Carrier);
    }
     
    unsigned int OATSCALLBACK DefineIOMode(WASCO_12_S_Digital_Carrier* pInstance, InputOutputMode m, int portIndex)
    {
    	#ifdef _debug_print
    		printf("Defining IO-Mode to %i, Port Index: %i\n", m, portIndex);
    	#endif 
     
    	if ((pInstance->PortMode[portIndex] == io_undefined) || (pInstance->PortMode[portIndex] == m))
    	{
    		pInstance->PortMode[portIndex] = m; // set IO mode
    		return 0;	// ok no error
    	}
    	else if (pInstance->PortMode[portIndex] == input_mode)
    		return OATsError_IOPortAsInputUsed; // error, wrong IO mode
    	else
    		return OATsError_IOPortAsOutputUsed; // error, wrong IO mode
    }
     
    void OATSCALLBACK CreateCSR(WASCO_12_S_Digital_Carrier* pInstance)
    {
    	pInstance->CSR_shadow = 0x80;
     
    	if (pInstance->PortMode[0] == input_mode) // port A input?
    		pInstance->CSR_shadow |= 0x10;
     
    	if (pInstance->PortMode[1] == input_mode) // port B input?
    		pInstance->CSR_shadow |= 0x02;
     
    	if (pInstance->PortMode[2] == input_mode) // port C low nibble input?
    		pInstance->CSR_shadow |= 0x01;
     
    	if (pInstance->PortMode[3] == input_mode) // port C high nibble input?
    		pInstance->CSR_shadow |= 0x08;
     
    	WriteCSR(pInstance, pInstance->CSR_shadow); // write status word
    }
     
    unsigned int OATSCALLBACK DefineCounterMode(WASCO_12_S_Digital_Carrier* pInstance, char m, char CounterIndex)
    {
    	#ifdef _debug_print
    		printf("Defining Counter-Mode to %i, Counter No: %i\n", m, CounterIndex);
    	#endif 
     
    	if (m > 5)
    		return OATsError_IOInvalidCounterMode;
    	else if ((pInstance->CounterMode[CounterIndex] == 6) || (pInstance->CounterMode[CounterIndex] == m))
    	{
    		pInstance->CounterMode[CounterIndex] = m; // set counter mode
    		return 0;	// ok no error
    	}
    	else
    		return OATsError_IOInvalidCounterMode; // error, wrong counter mode
    }
     
    void OATSCALLBACK CreateTCR(WASCO_12_S_Digital_Carrier* pInstance, char CounterIndex, char bcd, char ReadValue)
    {
    	if (ReadValue)
    		pInstance->TCR_shadow = 0x0;
    	else 
    		pInstance->TCR_shadow = 0x30;
     
    	pInstance->TCR_shadow |= (CounterIndex * 0x40);
    	pInstance->TCR_shadow |= (pInstance->CounterMode[CounterIndex] * 0x2);
     
    	if (bcd)
    		pInstance->TCR_shadow |= 0x01;
     
    	WriteTCR(pInstance, pInstance->TCR_shadow);
    }
     
    char OATSCALLBACK ReadPortA(WASCO_12_S_Digital_Carrier* pInstance)
    {
    	return _inp(pInstance->Port + 0x4);
    }
     
    char OATSCALLBACK ReadPortB(WASCO_12_S_Digital_Carrier* pInstance)
    {
    	return _inp(pInstance->Port + 0x5);
    }
     
    char OATSCALLBACK ReadPortC(WASCO_12_S_Digital_Carrier* pInstance)
    {
    	return _inp(pInstance->Port + 0x6);
    }
     
    char OATSCALLBACK ReadCnt(WASCO_12_S_Digital_Carrier* pInstance, char CounterIndex)
    {
    	return _inp(pInstance->Port + 0x8 + CounterIndex);
    }
     
    void OATSCALLBACK WritePortA(WASCO_12_S_Digital_Carrier* pInstance, char value)
    {
    	_outp(pInstance->Port + 0x4, value);
    }
     
    void OATSCALLBACK WritePortB(WASCO_12_S_Digital_Carrier* pInstance, char value)
    {
    	_outp(pInstance->Port + 0x5, value);
    }
     
    void OATSCALLBACK WritePortC(WASCO_12_S_Digital_Carrier* pInstance, char value)
    {
    	_outp(pInstance->Port + 0x6, value);
    }
     
    void OATSCALLBACK WriteCSR(WASCO_12_S_Digital_Carrier* pInstance, char value)
    {
    	#ifdef _debug_print
    		printf("CSR: 0x%X\n", value);
    	#endif 
     
    	_outp(pInstance->Port + 0x7, value);
    }
     
    void OATSCALLBACK WriteCnt(WASCO_12_S_Digital_Carrier* pInstance,char CounterIndex, char value)
    {
    	_outp(pInstance->Port + 0x8 + CounterIndex, value);
    }
     
    void OATSCALLBACK WriteTCR(WASCO_12_S_Digital_Carrier* pInstance, char value)
    {
    	_outp(pInstance->Port + 0xB, value);
    }

Discussions similaires

  1. Driver pour carte reseau d`un portable toshiba
    Par redabadache3 dans le forum Dépannage et Assistance
    Réponses: 2
    Dernier message: 24/11/2005, 17h47
  2. Choix du driver pour ati radeon 9250
    Par doctorlove dans le forum Matériel
    Réponses: 2
    Dernier message: 29/10/2005, 21h45
  3. Drivers pour 2 versions differentes de red hat
    Par schnourf dans le forum Matériel
    Réponses: 2
    Dernier message: 21/10/2005, 11h18
  4. Quelle driver pour une HIS 9800 pro ice Q
    Par Death83 dans le forum Composants
    Réponses: 9
    Dernier message: 29/09/2005, 14h14
  5. Problème d'installation de driver pour une carte réseaux
    Par black is beautiful dans le forum Matériel
    Réponses: 3
    Dernier message: 19/07/2004, 21h33

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo