Bonjour,

J'ai besoin l'aidée pour mettre en place une fonction qui retourne zéro dans une condition et 1 dans une autre. Ci joint mes 3 fichiers , pour m'aider si vous pouvez.

cdt merci

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
#include <stdio.h>
#include <stdlib.h>
#include "AdvProtect1.h"
 
#define SIGNAL_DEPTH   150
float Signal[ SIGNAL_DEPTH ] = { 10, 20, -31, 10};  // Changing values means changing signal. increasing the depth means increase the time.
unsigned char Alarm[ SIGNAL_DEPTH ] = { 0U };
int Pick_up=0;
 
int main(void)
int i = 0U;
int timeQuantum=0;
struct ProtectionConfig // protection configuration
{
    ProtectionConfig Threshold;
    DropOutThreshold=0, PickUpThreshold=0, SignalIn=0;
    return 0
}
enum Pick_up_Signal
{
   Pick_up_Signal Start_signal
};
SetPickUpThreshold(10);
set_DropOutThreshold(30);
 for( i = 0U; i < SIGNAL_DEPTH; i++ )
  {
     Alarm[ i ] = OvercurrentDetection (Signal[ i ] );
 
     return Pick_up;
 
 printf("The fault condition %d: \n", Pick_up);
}
--------------------------------------------------------------------
#include "AdvProtect1.h"
 
static ProtectionConfig DropOutThreshold; // private variable
void SetDropOutThreshold( ProtectionConfig n )
{
 DropOutThreshold = n;
}
int  GetDropOutThreshold ( void )
{
  return DropOutThreshold;
}
static ProtectionConfig PickUpThreshold; // private variable
void SetPickUpThreshold (ProtectionConfig d)
{
  PickUpThreshold = d;
}
ProtectionConfig GetPickUpThreshold (void)
{
  return PickUpThreshold;
}
ProtectionConfig OvercurrentDetection (Threshold.DropOutThreshold, Threshold.PickUpThreshold, Threshold.SignalIn) //threshold crosssing detection with hysteresis
{
if (SignalIn<=Threshold.DropOutThreshold)
{
    PickUp=0;
    timeQuantum+=1; //computing time quantum
    StartSignal=ResetState;
 };
else if (SignalIn>Threshold.PickUpThreshold)
 {
    Pick_up=1;
    timeQuantum-=1;//computing time quantum
    StartSignal=FaultState;
 }
else
{
PickSp=PickSp;
ResetState=previewState;
 
}
}
---------------------------------------------------------------
#ifndef ADVPROTECT1_H_INCLUDED
#define ADVPROTECT1_H_INCLUDED
 
#endif // ADVPROTECT1_H_INCLUDED
 
/// Protection Configuration
typedef struct ProtectionConfig ProtectionConfig;
struct ProtectionConfig
{
    float DropOutThreshold, PickUpThreshold, SignalIn;
};
 
typedef enum PickUpSignal PickUpSignalp_Signal;
enum PickUpSignal
{
    Fault_state, Reset_state, preview_state
};
 
/// Threshold getter and setter methods
void SetDropOutThreshold (ProtectionConfig n);
int GetDropOutThreshold (void);
 
void  SetPickUpThreshold (ProtectionConfig n);
int GetPickUpThreshold (void);
 
//void OvercurrentDetection (ProtectionConfig threshold, float Signal[i], PickUpSignal);