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

DAC trigger support #359

Merged
merged 9 commits into from
Sep 20, 2024
Merged

DAC trigger support #359

merged 9 commits into from
Sep 20, 2024

Conversation

Adrian-Stanea
Copy link
Contributor

@Adrian-Stanea Adrian-Stanea commented Feb 15, 2024

Introduce support for START and STOP trigger events in the M2KAnalogOut.
Ensure predictable reset of the interface at 0V

Features:

  • Trigger events:
    • START: initiates DAC output based on a trigger event. This trigger can be customized using the rearm functionality, allowing for different behaviors in response to each trigger event.
    • STOP: stops the DAC output, applicable only to cyclic buffers.

Output Reset:
Utilize the raw and raw_enable attributes to ensure outputs are reset to 0V. This is particularly important in scenarios where external programs may have altered the raw IIO attribute or when the DAC output remains in the last sample hold state.

Demo Example:
A Python demo has been added to showcase the START trigger capabilities

NOTES:

  • STOP Trigger: the STOP trigger is functional only with cyclic buffers. In non-cyclic mode, if all samples are already sent and the channel is in the last sample hold state, the STOP trigger will have no impact.

  • START Trigger with Non-Cyclic Buffers: When using the START trigger with non-cyclic buffers and with rearm functionality disabled, it is recommended to merge all buffers into a single buffer. This addresses potential unpredictable behavior due to race conditions in HDL. In this scenario, since all buffers will be sent regardless, merging them will standardize the outcome.

@Adrian-Stanea Adrian-Stanea changed the title Add support for triggered output signals DAC trigger support Jun 13, 2024
src/m2k_impl.cpp Outdated Show resolved Hide resolved

std::vector<std::string> M2kHardwareTriggerV033Impl::m_trigger_source_out = {
"none",
"trigger-Ti",
Copy link
Contributor

Choose a reason for hiding this comment

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

is T intentionally uppercase?

@AlexandraTrifan
Copy link
Contributor

otherwise looks good
i'll run some tests as well with the new fw

Copy link
Contributor Author

@Adrian-Stanea Adrian-Stanea left a comment

Choose a reason for hiding this comment

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

is T intentionally uppercase?

The name was defined to match the attribute definition within the firmware.

@Adrian-Stanea Adrian-Stanea force-pushed the src/output_triggers branch 2 times, most recently from 336b683 to 33c0f6d Compare August 28, 2024 14:39
- Analog output interface can execute start/stop actions based on trigger events.
- Available trigger sources are: TI pin, ADC and LA.
- Added functions to control the TI trigger source when aout is triggered by this source.
- ADC and LA sources use the configuration of the corresponding interface.
- Add get trigger handler from the AnalogOut interface.

Signed-off-by: Adrian Stanea <[email protected]>
… versions

- AnalogOut trigger features are only available in fw0.33 and onwards. Show error messages for older versions.

Signed-off-by: Adrian Stanea <[email protected]>
- Introduce the auto_rearm attribute to the AnalogOut class.
- This attribute controls the behavior of the DAC when configured to start on a trigger event.
- When auto_rearm is disabled, all previously loaded buffers will be sent to the DAC output upon the trigger event.
- When auto_rearm is enabled, each previously loaded buffer will be sent to the DAC output on each trigger event.

Signed-off-by: Adrian Stanea <[email protected]>
- The Python script is designed as a demo to showcase
the capabilities of the START trigger for the AnalogOut.

Signed-off-by: Adrian Stanea <[email protected]>
- This update ensures the `raw_enable` attribute is automatically set
to `enabled` when the M2kAnalogOut class is instantiated and after a reset.
- With raw_enable active, the output reflects the value set in the `raw` attribute.
- During buffer operations involving DMA, the firmware temporarily disables
`raw_enable` to allow proper DMA output. Once the DMA transaction completes,
`raw_enable` is restored to its initial state, ensuring consistent behavior.
- The change introduced in this commit sets `raw` to 0 and ensures `raw_enable`
is set. This guarantees that, upon restart, the output begins at 0V, avoiding
the use of old raw values or residual samples from the last sample hold state.

Signed-off-by: Adrian Stanea <[email protected]>
- Make clear that functions intend to override a function definition in the base class

Signed-off-by: Adrian Stanea <[email protected]>
- Use the 'override' keyword to explicitly denote that the base class destructor is virtual.
- Implement virtual destructors to guarantee their invocation when utilizing pointers to the base class, ensuring proper resource cleanup across the inheritance hierarchy.

Signed-off-by: Adrian Stanea <[email protected]>
- This change ensures that the IIO attributes of the trigger are properly
reset when the context is closed. As a result, the interfaces remains in
a usable state, and any previously configured triggers are set to
a condition that always triggers.

Signed-off-by: Adrian Stanea <[email protected]>
@AlexandraTrifan AlexandraTrifan merged commit 2bc17a9 into main Sep 20, 2024
12 checks passed
@AlexandraTrifan AlexandraTrifan deleted the src/output_triggers branch September 20, 2024 13:17
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.

2 participants