CelePixel / CeleX4-OpalKelly

SDK for CeleX4 sensor.
Apache License 2.0
15 stars 10 forks source link

Event timestamps #2

Closed tbolten closed 5 years ago

tbolten commented 5 years ago

Hi,

when looking at the timestamps of the events in different configurations of the "EventFrameTime" and the "ClockRate", a question has arisen for me. I assumed that the changes to these parameters affect (among other things) the maximum achievable timestamp within a frame buffer.

Here an example for configuration:

pCelex->setEventFrameTime(60);
pCelex->setClockRate(25);
std::cout << "Used pCelex->getEventFrameTime() " << pCelex->getEventFrameTime() << std::endl;
std::cout << "Used pCelex->getClockRate() " << pCelex->getClockRate() << std::endl;
// [...]
std::cout << "\t" << "eventVector.front().t: " << eventVector.front().t << "     " << "eventVector.back().t: " << eventVector.back().t << std::endl;

The output for different configurations looks like:

Case 1 Used pCelex->getEventFrameTime() 60 Used pCelex->getClockRate() 25 eventVector.front().t: 0 eventVector.back().t: 749900

Case 2 Used pCelex->getEventFrameTime() 80 Used pCelex->getClockRate() 25 eventVector.front().t: 0 eventVector.back().t: 749908

Case 3 Used pCelex->getEventFrameTime() 60 Used pCelex->getClockRate() 35 eventVector.front().t: 0 eventVector.back().t: 749932

Case 4 Used pCelex->getEventFrameTime() 80 Used pCelex->getClockRate() 35 eventVector.front().t: 0 eventVector.back().t: 749848

My assumption for the timestamp (in a very active scene) of the last event were values around

ClockRate[Mhz] 1000 EventFrameTime[ms] / 2 Case 1: 25 1000 60 / 2 = 750.000 Case2: 25 1000 80 / 2 = 1.000.000 Case 3: 35 1000 60 / 2 = 1.050.000 Case 4: 35 1000 80 / 2 = 1.400.000

However, as you can see above no change occurs.

It is possible that the variable m_uiTimeStamp in the processData-Method of the FPGA-Dataprocessor is not updated correctly? Here the line

After changing m_uiTimeStamp into m_uiTimeSlice(which is updated) I get the assumed values:

Case 1: eventVector.front().t: 0 eventVector.back().t: 749968 Case 2: eventVector.front().t: 0 eventVector.back().t: 999892 Case 3: eventVector.front().t: 0 eventVector.back().t: 1049956 Case 4: eventVector.front().t: 0 eventVector.back().t: 1399880

Is my original assumption wrong?

CelePixel commented 5 years ago

@tbolten Your assumption is correct. eventVector.back().t should be changed along with the "EventFrameTime" and the "ClockRate", and m_uiTimeStamp needs to be changed as m_uiTimeSlice changes. We have fixed this bug in the file: "Sources/SDK/eventproc/fpgadataprocessor.cpp". Please check out our latest updated SDK. Thanks a lot for your insight questions.

tbolten commented 5 years ago

Thanks for your answer. I will update the SDK in my development environment and test it.

tbolten commented 5 years ago

I checked out the current master-branch and builded the SDK. When using a slightly modified version of your example 'Samples/GetFrameBufferByCallback'

--- a/Samples/GetFrameBufferByCallback/getFrameBufferByCallback.cpp
+++ b/Samples/GetFrameBufferByCallback/getFrameBufferByCallback.cpp
@@ -61,6 +61,7 @@ void SensorDataObserver::onFrameDataUpdated(CeleX4ProcessedData* pSensorData)
        }
        else if (EventMode == sensorMode)
        {
+               std::cout << "Yes, here is data coming ..." << std::endl;
                //get buffers when sensor works in EventMode
                if (pSensorData->getEventPicBuffer(EventBinaryPic))
                {
@@ -93,6 +94,8 @@ int main()

        pCelex->openSensor("");
        pCelex->setFpnFile(FPN_PATH);
+       //pCelex->setEventFrameTime(80);
+       //pCelex->setClockRate(30);
        emSensorMode sensorMode = EventMode; //EventMode, FullPic_Event_Mode or FullPictureMode
        pCelex->setSensorMode(sensorMode);

I get the expected output:

[...] API: setFEFrameTime 60 ms Address: 2; Value: 375000; Mask: 16777215 API: setFullPicFrameTime 40 ms Address: 2; Value: 1000000; Mask: 16777215 Address: 0; Value: 1; Mask: 1 Address: 0; Value: 0; Mask: 49152 Address: 0; Value: 0; Mask: 1 Yes, here is data coming ... Yes, here is data coming ... [...]

But, as soon I modify the eventFrameTime or the clockRate the program hangs:

[...] Address: 2; Value: 1000000; Mask: 16777215 API: setEventFrameTime 80 ms ***** API: setClockRate 30 MHz Address: 0; Value: 1; Mask: 1 Address: 0; Value: 0; Mask: 49152 Address: 0; Value: 0; Mask: 1 [... nothing is happening anymore ...]

I have not looked further, why this could be. Do you have an idea?

CelePixel commented 5 years ago

@tbolten Sorry, this is caused by a parameter typo in our source code "Sources/SDK/eventproc/fpgadataprocessor.cpp". It has been corrected in our latest updates. Please check it out. Thanks.

tbolten commented 5 years ago

I updated my development environment again - and now I get the expected values. Thank you for fixing this.