Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPS capture driver (not PPS clock synchronization) #18849

Merged
merged 15 commits into from
Dec 17, 2021
Merged

Conversation

Igor-Misic
Copy link
Member

PPS - pulse per second
RTC - real-time clock
EXTI - external interrupt
HRT - high-resolution timer

This is a driver that uses PPS from GNSS module to calculate time correction separately from the RTC. It uses GPIO EXTI as it is intended to be used at boards where is not possible to connect PPS to a pin that can capture HRT timestamp.
For boards that have an RTC clock synchronized with PPS, this driver is not needed.

This PR also brings improvements for camera capture and camera trigger.

int _channel{-1};
uint32_t _pps_capture_gpio{0};
uORB::Publication<pps_capture_s> _pps_capture_pub{ORB_ID(pps_capture)};
uORB::Subscription _sensor_gps_sub{ORB_ID(sensor_gps)};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having multiple GPS units is becoming common.

#include <board_config.h>
#include <parameters/param.h>

#ifdef BOARD_WITH_IO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you apply #18860?

@@ -172,6 +172,7 @@ void LoggedTopics::add_default_topics()
add_optional_topic_multi("sensor_accel", 1000, 4);
add_optional_topic_multi("sensor_baro", 1000, 4);
add_topic_multi("sensor_gps", 1000, 2);
add_topic("pps_capture", 1000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
add_topic("pps_capture", 1000);
add_optional_topic("pps_capture", 1000);


PPSCapture::PPSCapture() :
ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::hp_default)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_pps_capture_pub.advertise(); (for logging)

Igor-Misic and others added 15 commits December 16, 2021 18:44
- start pps_capture before pwm_out
… is important, since it takes over an FMU pin which can no longer be used for actuator output.
When using an FMU channel as PPS capture GPIO, the rtc_edge_time is now set as well. The delay between actual capture and callback is compensated with the elapsed time of the rtc clock.
- camera_trigger module always publishes the camera_trigger msg (independent of the camera feedback)
- Use camera_trigger msg and set the feedback flag
- Subscribing modules determine if the message is relevant based on the feedback message
The existing implementation has about 100ms difference to a reference clock. With the changes this error less than 25us.
- Use sensor_gps messages with hrt timestamps as RTC reference and not the system realtime clock. The PPS interrupt can then be aligned with the GPS clock system.
- Keep fallback based on system RTC when no PPS pulse was captured
@bkueng bkueng merged commit 2d680df into master Dec 17, 2021
@bkueng bkueng deleted the pr-pps_capture branch December 17, 2021 06:56
@Igor-Misic Igor-Misic restored the pr-pps_capture branch December 17, 2021 18:48
@Igor-Misic Igor-Misic deleted the pr-pps_capture branch December 17, 2021 18:49
@dagar dagar mentioned this pull request Feb 1, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants