millisec counter

hello!
iam doing my final project. and i've to write c++ code as distance relay.in this code for example if the certain condition comes true after 1800 millisecond cout>> 1 ....
See the <chrono> documentation http://en.cppreference.com/w/cpp/chrono

1
2
3
4
5
6
7
8
9
10
11
12
#include <chrono>

//...

    typedef std::chrono::high_resolution_clock clck;
    std::chrono::time_point<clck> beg = clck::now();
    //...
    std::chrono::time_point<clck> end = clck::now();
    int msec = std::chrono::duration_cast<std::chrono::milliseconds>(end - beg).count();

    if (msec > 1800)
        some_bool = true;
You might also want ot use threading to let timer work asynchronous. Read <future> header documentation as well. We do not know what do you want exactly, so we can only give general pointers to you.
my project about distance protection for power transmission lines which uses the distance numerical relay which use the microprocessor, and i have to simulate the system using matlab (simulink) and to write c++ code the simulate the microprocessor calculation.
The lines is divided into three zone, the relay revive three measured values of voltage and current and calculate the impedance and compare it with setting values if the fault in zone the relay should give output 1 instantly if the fault in zone 2 give output 1 in 0.8sec (800 millisecond) if the fault in zone 3 output 1 in 1.2sec (1200 millisecond)
Topic archived. No new replies allowed.