Simple Event Recorder

Thread Starter

madaboutears

Joined Sep 29, 2015
9
Being a novice at data collection and manipulation I am looking for a simple (PC-Based?) event recorder. I have a sensor that provides a simple NO or NC contact output. I would like to be able to record each (real) time moment the switch is operated and the duration it remains operated - all over a 24 hour period. I have a feeling that there are some existing options to do this but am too inexperienced to find one. Any suggestions would be greatly appreciated - I am very willing to learn.
 

andrewmm

Joined Feb 25, 2011
526
The "problem" is that PC's for the last 20 years have tried very hard to stop people adding general IO to them.
The favourite used to be the LPT port, but that is long gone.

A more recent answer would be the USB interface. That needs a board to connect the USB to your sensor, a digital IO board or a data logger board.

very many around,
try these as a start ( I have no financial attachment to these people )

https://www.picotech.com/products/data-logger


A cheaper , and probably more fun option , would be an Arduino !!

many around, try these ,( I have no financial attachment to these people )

https://www.pjrc.com/teensy/


Using the Arduino, its fairly easy to detect a digital IO change state, and report it to the PC over the USB link, or even store the time of the event localy in the arduino , or a web server on the arduino !

many options
https://learn.adafruit.com/adafruit-data-logger-shield

https://forum.pjrc.com/threads/42309-Teensy-3-6-Datalogger

https://www.instructables.com/id/Log-High-Speed-ECG-Data-Continuously-for-Over-a-Mo/
 

Danko

Joined Nov 22, 2017
964
I would like to be able to record each (real) time moment the switch is operated and the duration it remains operated - all over a 24 hour period.
Try use this simple program.
It works exactly as you want.
For entering event, use right switch of mouse.
Connect in parallel to switch C-E of transistor
and send event's signal to B-E.
Result indicates on screen and in file "mouse_time.txt."
1598474142460.png
Mouse_time:
#include <iostream>  // cout
#include <fstream>   // myfile
#include <stdlib.h>  // standard
#include <cstdlib>   // console size
#include <iomanip>   // setprecision
#include <windows.h> // mouse events
#include <time.h>
using namespace std;

int main()
{
    system("MODE CON COLS=25 Lines=20");  //COLS=25 LINES=20");
 
    cout<< "\n       MOUSE_TIME \n\n";
    cout<< "     (C)2020 Danko  \n";
    cout<< "------------------------\n";
    cout<< "  Press Ctrl+C to Exit \n";
    cout<< "========================\n";

    HANDLE hin = GetStdHandle(STD_INPUT_HANDLE);
 
    LARGE_INTEGER freq;
    LARGE_INTEGER t1;
    LARGE_INTEGER t2;
 
    INT mark = 1;
    ofstream myfile;
    myfile.open ("mouse_time.txt");
    QueryPerformanceFrequency(&freq);
 
           while(1)
        {
            if ((GetKeyState(VK_RBUTTON) & 0x80) != 0)
            {  
                if (mark == 1)
                {
                    time_t now = time(0);
                    string dt = ctime(&now);
                    cout << dt;
                    myfile << dt;
                    QueryPerformanceCounter(&t1);
                    mark = 0;
                }
            }
            else
            {
                if (mark==0)
                {
                    QueryPerformanceCounter(&t2);
                    double dt = t2.QuadPart - t1.QuadPart;
                    double elapsed_time = dt / freq.QuadPart;
                    cout << fixed << setprecision(6) << elapsed_time << endl;
                    myfile << fixed << setprecision(6) << elapsed_time << endl;
                    mark = 1;
                }
            }
            FlushConsoleInputBuffer(hin);
        }
    myfile.close();
    return 0;
}
Download IDE for C++ programming: DEV-C++ 5.11.492
 

Attachments

Last edited:

dl324

Joined Mar 30, 2015
11,231
Being a novice at data collection and manipulation I am looking for a simple (PC-Based?) event recorder. I have a sensor that provides a simple NO or NC contact output. I would like to be able to record each (real) time moment the switch is operated and the duration it remains operated - all over a 24 hour period.
I'd use a Raspberry Pi Zero W. A Linux computer that you can access from your PC and plenty of I/O's for interfacing to its environment.
 

Thread Starter

madaboutears

Joined Sep 29, 2015
9
The "problem" is that PC's for the last 20 years have tried very hard to stop people adding general IO to them.
The favourite used to be the LPT port, but that is long gone.

A more recent answer would be the USB interface. That needs a board to connect the USB to your sensor, a digital IO board or a data logger board.

very many around,
try these as a start ( I have no financial attachment to these people )

https://www.picotech.com/products/data-logger


A cheaper , and probably more fun option , would be an Arduino !!

many around, try these ,( I have no financial attachment to these people )

https://www.pjrc.com/teensy/


Using the Arduino, its fairly easy to detect a digital IO change state, and report it to the PC over the USB link, or even store the time of the event localy in the arduino , or a web server on the arduino !

many options
https://learn.adafruit.com/adafruit-data-logger-shield

https://forum.pjrc.com/threads/42309-Teensy-3-6-Datalogger

https://www.instructables.com/id/Log-High-Speed-ECG-Data-Continuously-for-Over-a-Mo/
Thank you kindly, I have a lot to learn, will spend some time on your suggestions and may come back for more wisdom!
 

Picbuster

Joined Dec 2, 2013
1,020
Being a novice at data collection and manipulation I am looking for a simple (PC-Based?) event recorder. I have a sensor that provides a simple NO or NC contact output. I would like to be able to record each (real) time moment the switch is operated and the duration it remains operated - all over a 24 hour period. I have a feeling that there are some existing options to do this but am too inexperienced to find one. Any suggestions would be greatly appreciated - I am very willing to learn.
If your pc has a serial port then use the CTS signal use the RTS as reference voltage.
else buy a converter usb to serial and do the same as above.

The program is simple in C, c++, pascal, basic as long as serial port is supported.

Picbuster
 

Thread Starter

madaboutears

Joined Sep 29, 2015
9
Try use this simple program.
It works exactly as you want.
For entering event, use right switch of mouse.
Connect in parallel to switch C-E of transistor
and send event's signal to B-E.
Result indicates on screen and in file "mouse_time.txt."
View attachment 215715
Mouse_time:
#include <iostream>  // cout
#include <fstream>   // myfile
#include <stdlib.h>  // standard
#include <cstdlib>   // console size
#include <iomanip>   // setprecision
#include <windows.h> // mouse events
#include <time.h>
using namespace std;

int main()
{
    system("MODE CON COLS=25 Lines=20");  //COLS=25 LINES=20");

    cout<< "\n       MOUSE_TIME \n\n";
    cout<< "     (C)2020 Danko  \n";
    cout<< "------------------------\n";
    cout<< "  Press Ctrl+C to Exit \n";
    cout<< "========================\n";

    HANDLE hin = GetStdHandle(STD_INPUT_HANDLE);

    LARGE_INTEGER freq;
    LARGE_INTEGER t1;
    LARGE_INTEGER t2;

    INT mark = 1;
    ofstream myfile;
    myfile.open ("mouse_time.txt");
    QueryPerformanceFrequency(&freq);

           while(1)
        {
            if ((GetKeyState(VK_RBUTTON) & 0x80) != 0)
            { 
                if (mark == 1)
                {
                    time_t now = time(0);
                    string dt = ctime(&now);
                    cout << dt;
                    myfile << dt;
                    QueryPerformanceCounter(&t1);
                    mark = 0;
                }
            }
            else
            {
                if (mark==0)
                {
                    QueryPerformanceCounter(&t2);
                    double dt = t2.QuadPart - t1.QuadPart;
                    double elapsed_time = dt / freq.QuadPart;
                    cout << fixed << setprecision(6) << elapsed_time << endl;
                    myfile << fixed << setprecision(6) << elapsed_time << endl;
                    mark = 1;
                }
            }
            FlushConsoleInputBuffer(hin);
        }
    myfile.close();
    return 0;
}
Download IDE for C++ programming: DEV-C++ 5.11.492
 

Thread Starter

madaboutears

Joined Sep 29, 2015
9
Try use this simple program.
It works exactly as you want.
For entering event, use right switch of mouse.
Connect in parallel to switch C-E of transistor
and send event's signal to B-E.
Result indicates on screen and in file "mouse_time.txt."
View attachment 215715
Mouse_time:
#include <iostream>  // cout
#include <fstream>   // myfile
#include <stdlib.h>  // standard
#include <cstdlib>   // console size
#include <iomanip>   // setprecision
#include <windows.h> // mouse events
#include <time.h>
using namespace std;

int main()
{
    system("MODE CON COLS=25 Lines=20");  //COLS=25 LINES=20");

    cout<< "\n       MOUSE_TIME \n\n";
    cout<< "     (C)2020 Danko  \n";
    cout<< "------------------------\n";
    cout<< "  Press Ctrl+C to Exit \n";
    cout<< "========================\n";

    HANDLE hin = GetStdHandle(STD_INPUT_HANDLE);

    LARGE_INTEGER freq;
    LARGE_INTEGER t1;
    LARGE_INTEGER t2;

    INT mark = 1;
    ofstream myfile;
    myfile.open ("mouse_time.txt");
    QueryPerformanceFrequency(&freq);

           while(1)
        {
            if ((GetKeyState(VK_RBUTTON) & 0x80) != 0)
            { 
                if (mark == 1)
                {
                    time_t now = time(0);
                    string dt = ctime(&now);
                    cout << dt;
                    myfile << dt;
                    QueryPerformanceCounter(&t1);
                    mark = 0;
                }
            }
            else
            {
                if (mark==0)
                {
                    QueryPerformanceCounter(&t2);
                    double dt = t2.QuadPart - t1.QuadPart;
                    double elapsed_time = dt / freq.QuadPart;
                    cout << fixed << setprecision(6) << elapsed_time << endl;
                    myfile << fixed << setprecision(6) << elapsed_time << endl;
                    mark = 1;
                }
            }
            FlushConsoleInputBuffer(hin);
        }
    myfile.close();
    return 0;
}
Download IDE for C++ programming: DEV-C++ 5.11.492
Try use this simple program.
It works exactly as you want.
For entering event, use right switch of mouse.
Connect in parallel to switch C-E of transistor
and send event's signal to B-E.
Result indicates on screen and in file "mouse_time.txt."
View attachment 215715
Mouse_time:
#include <iostream>  // cout
#include <fstream>   // myfile
#include <stdlib.h>  // standard
#include <cstdlib>   // console size
#include <iomanip>   // setprecision
#include <windows.h> // mouse events
#include <time.h>
using namespace std;

int main()
{
    system("MODE CON COLS=25 Lines=20");  //COLS=25 LINES=20");

    cout<< "\n       MOUSE_TIME \n\n";
    cout<< "     (C)2020 Danko  \n";
    cout<< "------------------------\n";
    cout<< "  Press Ctrl+C to Exit \n";
    cout<< "========================\n";

    HANDLE hin = GetStdHandle(STD_INPUT_HANDLE);

    LARGE_INTEGER freq;
    LARGE_INTEGER t1;
    LARGE_INTEGER t2;

    INT mark = 1;
    ofstream myfile;
    myfile.open ("mouse_time.txt");
    QueryPerformanceFrequency(&freq);

           while(1)
        {
            if ((GetKeyState(VK_RBUTTON) & 0x80) != 0)
            { 
                if (mark == 1)
                {
                    time_t now = time(0);
                    string dt = ctime(&now);
                    cout << dt;
                    myfile << dt;
                    QueryPerformanceCounter(&t1);
                    mark = 0;
                }
            }
            else
            {
                if (mark==0)
                {
                    QueryPerformanceCounter(&t2);
                    double dt = t2.QuadPart - t1.QuadPart;
                    double elapsed_time = dt / freq.QuadPart;
                    cout << fixed << setprecision(6) << elapsed_time << endl;
                    myfile << fixed << setprecision(6) << elapsed_time << endl;
                    mark = 1;
                }
            }
            FlushConsoleInputBuffer(hin);
        }
    myfile.close();
    return 0;
}
Download IDE for C++ programming: DEV-C++ 5.11.492
This is great DanKo, it works brilliantly and is exactlwhat I need. I will wire up the interface to the mouse Right-Click contacts. Thanks again!
 
Being a novice at data collection and manipulation I am looking for a simple (PC-Based?) event recorder. I have a sensor that provides a simple NO or NC contact output. I would like to be able to record each (real) time moment the switch is operated and the duration it remains operated - all over a 24 hour period. I have a feeling that there are some existing options to do this but am too inexperienced to find one. Any suggestions would be greatly appreciated - I am very willing to learn.
Someone's been raiding the good stuff in the fridge?
 
Top