I am working with sonar (Raspberry Pi) and microsecond timing is important to measure the time-of-flight for the waves to bounce-off an object.
When I use the lguTime function ( GitHub - eugenedakin/lgpio-GPIO: Wrapper uses the new C-language gpiochip functions for the Raspberry Pi ) in a loop, it work satisfactory. I am trying to get more precise microsecond timing and have implemented an Interrupt. When I try to use the lguTime in the interrupt method, I always get a returned value of zero. If I am outside of the interrupt method, I get the accurate microsecond time from the lguTime call.
I attempted to use System.Microsecond with Xojo, but the microsecond time is almost the same (about 2400 microseconds).
Is there another command or way to get the microseconds when using an interrupt that is able to accurately retrieve microseconds in Xojo?
I can run this on a Pi with C, C++, and Python, but not with Xojo due to Xojo’s stuttering issues. Its a long-time issue with Xojo, and I was hoping someone had a work-around.
I tried some declares, and I’ll try a few more and see if I can make some progress.
Yes, this would work. Although I could use an entire Arduino written with C for the project, and I am trying to get Xojo to work.
Pardon my unprofessional spaghetti-code, attached is an example that I am trying to get to work. When Pin 17 receives a High (3.3-volt) signal, the callback fires and the EchoAlertCallback method fires. I need to determine the measured time in microseconds to calculate the distance of the object for the time-of-flight calculation.
In this (of many examples that I have tried) example, I am trying to save the microsecond value with the lguTimestamp declare in the lgpio Module. The InterruptModule.FinishEchoInterruptTime has a value of zero, even though it should have the microsecond value of lguTimeStamp.