LORD-MicroStrain / MSCL

MicroStrain Communication Library
https://www.microstrain.com/software/mscl
MIT License
76 stars 57 forks source link

3DM CV7-AHRS activate trigger #375

Open gmurrayrv9a opened 7 months ago

gmurrayrv9a commented 7 months ago

I have been unable to get an output trigger working on GPIO1. Please verify I am setting all fields correctly. Here is my C++ code:

// 0x0C41 GPIO CONFIGURATION
mscl::GpioConfiguration gpio_config;
gpio_config.pin = 1;
gpio_config.feature = GpioConfiguration::Feature::GPIO_FEATURE;
gpio_config.behavior = GpioConfiguration::GpioBehavior::GPIO_OUTPUT_LOW_BEHAVIOR;
                 //   also tried GpioConfiguration::GpioBehavior::GPIO_OUTPUT_HIGH_BEHAVIOR

m_inertialNode->setGpioConfig(gpio_config);       

// 0x0C2F EVENT ACTION CONFIGURATION
EventActionConfiguration eacConfig;
eacConfig.instance = 1;
eacConfig.trigger = 1;
eacConfig.type = EventActionConfiguration::Type::GPIO;
eacConfig.parameters.gpio.pin = 1;
eacConfig.parameters.gpio.mode = EventActionGpioParameter::Mode::ACTIVE_HIGH;

m_inertialNode->setEventActionConfig(eacConfig, true);

// 0x0C2E EVENT TRIGGER CONFIGURATION
EventTriggerConfiguration etcConfig;
etcConfig.instance = 1;
etcConfig.trigger = EventTriggerConfiguration::Type::THRESHOLD_TRIGGER;
etcConfig.parameters.threshold.type = EventTriggerThresholdParameter::Type::INTERVAL_TYPE;
etcConfig.parameters.threshold.channel(MipTypes::ChannelField::CH_FIELD_SENSOR_SHARED_REFERENCE_TIMESTAMP, 1); // (0x80D5, index)
etcConfig.parameters.threshold.highThreshold = 1000.0 / (double)m_triggerHz;// * 1000000.0; // m_triggerHz = 20
etcConfig.parameters.threshold.lowThreshold   = etcConfig.parameters.threshold.highThreshold / 2.0;

m_inertialNode->setEventTriggerConfig(etcConfig);

m_inertialNode->setEventTriggerMode(1, EventControlMode::ENABLED);
msclissa commented 7 months ago

Device: 3DM-CV7-AHRS Config Documentation: CV7 Manual | Synchronized Square Wave Output

Apologies for the confusion! It looks like overall your setup is correct but you may have switched the Threshold and Interval values.

lowThreshold is Threshold from documentation (first of the two threshold defining parameters) highThreshold is Interval from documentation (second of the two threshold defining parameters)

This naming in MSCL is definitely inconsistent for configuring Interval Threshold triggers - we need to clean that up. With your current configuration and assuming m_triggerHz = 20 as indicated in comments, the values as written will result in:

I'm not an expert in troubleshooting setup for this particular application but if I'm understanding correctly this will trigger GPIO pin 1 high for the first 50 nanoseconds of every 25 nanosecond interval which seems to me would result in the pin always outputting high. I also suspect working at the nanosecond time scale might result in the interval being completely missed. It looks like you were multiplying by 1,000,000 to bring that time scale back up to microseconds but I assume that was removed in an effort to troubleshoot unexpected behavior. In this scenario I would guess that the event would never trigger and the pin would always output low.

Is this consistent with the behavior you're experiencing? I would recommend bringing those values back up to the millisecond time scale and switching the values assigned to highThreshold and lowThreshold.

If those changes don't result in expected behavior it would be helpful to know what output behaviors you are seeing for different config combinations you try.

Sorry again for the confusion, let us know how it goes trying these suggestions!

gmurrayrv9a commented 7 months ago

Thanks for the information. It was helpful to know the settings used were proper. I tried as you suggested with the threshold/interval times although it did not make a difference.

As of today I am getting triggers from the IMU at the expected rate. We believe the issue was a loose wire at our connector to the MicroStrain.

We will do further tests to verify this. Sorry to bother you with what likely is a HW issue of our own making.

Best Regards, Glenn

From: msclissa @.> Sent: Tuesday, February 13, 2024 12:46 PM To: LORD-MicroStrain/MSCL @.> Cc: Glenn Murray @.>; Author @.> Subject: [EXTERNAL] Re: [LORD-MicroStrain/MSCL] 3DM CV7-AHRS activate trigger (Issue #375)

Device: 3DM-CV7-AHRS Config Documentation: CV7 Manual | Synchronized Square Wave Outputhttps://s3.amazonaws.com/files.microstrain.com/CV7+Online/user_manual_content/app_notes/Example%20Square%20Wave%20Output.htm

Apologies for the confusion! It looks like overall your setup is correct but you may have switched the Threshold and Interval values.

lowThreshold is Threshold from documentation (first of the two threshold defining parameters) highThreshold is Interval from documentation (second of the two threshold defining parameters)

This naming in MSCL is definitely inconsistent for configuring Interval Threshold triggers - we need to clean that up. With your current configuration and assuming m_triggerHz = 20 as indicated in comments, the values as written will result in:

I'm not an expert in troubleshooting setup for this particular application but if I'm understanding correctly this will trigger GPIO pin 1 high for the first 50 nanoseconds of every 25 nanosecond interval which seems to me would result in the pin always outputting high. I also suspect working at the nanosecond time scale might result in the interval being completely missed. It looks like you were multiplying by 1,000,000 to bring that time scale back up to microseconds but I assume that was removed in an effort to troubleshoot unexpected behavior. In this scenario I would guess that the event would never trigger and the pin would always output low.

Is this consistent with the behavior you're experiencing? I would recommend bringing those values back up to the millisecond time scale and switching the values assigned to highThreshold and lowThreshold.

If those changes don't result in expected behavior it would be helpful to know what output behaviors you are seeing for different config combinations you try.

Sorry again for the confusion, let us know how it goes trying these suggestions!

— Reply to this email directly, view it on GitHubhttps://github.com/LORD-MicroStrain/MSCL/issues/375#issuecomment-1942090393, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AI5DR2PUXJPOEVVAD5I6MUDYTORFXAVCNFSM6AAAAABCVKTUR2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBSGA4TAMZZGM. You are receiving this because you authored the thread.Message ID: @.***>