Loading...
Searching...
No Matches
AnalogOut
Analog

Contains the representation of the analogical output segment. More...

Collaboration diagram for AnalogOut:

## Classes

class | libm2k::analog::M2kAnalogOut
| Controls the analogical output compound. More...

## Functions

virtual std::vector< int > | libm2k::analog::M2kAnalogOut::getOversamplingRatio ()=0
| Retrieve the global oversampling ratio.
virtual int | libm2k::analog::M2kAnalogOut::getOversamplingRatio (unsigned int chn)=0
| Retrieve the oversampling ratio for the given channel.
virtual std::vector< int > | libm2k::analog::M2kAnalogOut::setOversamplingRatio (std::vector< int > oversampling_ratio)=0
| Set the value of the oversampling ratio for each channel.
virtual int | libm2k::analog::M2kAnalogOut::setOversamplingRatio (unsigned int chn, int oversampling_ratio)=0
| Set the oversampling ratio for the given channel.
virtual std::vector< double > | libm2k::analog::M2kAnalogOut::getSampleRate ()=0
| Retrieve the sample rate of both DACs.
virtual double | libm2k::analog::M2kAnalogOut::getSampleRate (unsigned int chn)=0
| Retrieve the sample rate for the given channel.
virtual std::vector< double > | libm2k::analog::M2kAnalogOut::getAvailableSampleRates (unsigned int chn)=0
| getAvailableSampleRates
virtual std::vector< double > | libm2k::analog::M2kAnalogOut::setSampleRate (std::vector< double > samplerates)=0
| Set the sample rate for both channels.
virtual double | libm2k::analog::M2kAnalogOut::setSampleRate (unsigned int chn, double samplerate)=0
| Set the sample rate for the given channel.
virtual void | libm2k::analog::M2kAnalogOut::setCyclic (bool en)=0
| Enable or disable the cyclic mode for all digital channels.
virtual void | libm2k::analog::M2kAnalogOut::setCyclic (unsigned int chn, bool en)=0
| Enable or disable the cyclic mode for all digital channels.
virtual bool | libm2k::analog::M2kAnalogOut::getCyclic (unsigned int chn)=0
| Retrieve the value of the cyclic mode.
virtual double | libm2k::analog::M2kAnalogOut::getScalingFactor (unsigned int chn)=0
| Retrieve the scaling factor for the given channel.
virtual double | libm2k::analog::M2kAnalogOut::getFilterCompensation (double samplerate)=0
| Retrieve the filter compensation for the given sample rate.
virtual void | libm2k::analog::M2kAnalogOut::pushBytes (unsigned int chnIdx, double *data, unsigned int nb_samples)=0
| Send the samples to the given channel.
virtual void | libm2k::analog::M2kAnalogOut::pushRawBytes (unsigned int chnIdx, short *data, unsigned int nb_samples)=0
| Send the samples to the given channel.
virtual void | libm2k::analog::M2kAnalogOut::pushInterleaved (double *data, unsigned int nb_channels, unsigned int nb_samples)=0
| Send samples to all the channels.
virtual void | libm2k::analog::M2kAnalogOut::pushRawInterleaved (short *data, unsigned int nb_channels, unsigned int nb_samples)=0
| Send samples to all the channels.
virtual void | libm2k::analog::M2kAnalogOut::push (unsigned int chnIdx, std::vector< double > const &data)=0
| Send the samples to the given channel.
virtual void | libm2k::analog::M2kAnalogOut::pushRaw (unsigned int chnIdx, std::vector< short > const &data)=0
| Send the samples to the given channel.
virtual void | libm2k::analog::M2kAnalogOut::push (std::vector< std::vector< double > > const &data)=0
| Send samples to channels.
virtual void | libm2k::analog::M2kAnalogOut::pushRaw (std::vector< std::vector< short > > const &data)=0
| Send samples to channels.
virtual void | libm2k::analog::M2kAnalogOut::stop ()=0
| Stop all channels from sending the signals.
virtual void | libm2k::analog::M2kAnalogOut::stop (unsigned int chn)=0
| Stop the given channels from sending the signals.
virtual void | libm2k::analog::M2kAnalogOut::cancelBuffer ()=0
| Cancel all buffer operations of enabled channels.
virtual void | libm2k::analog::M2kAnalogOut::cancelBuffer (unsigned int chn)=0
| Cancel all buffer operations of the given channel.
virtual void | libm2k::analog::M2kAnalogOut::enableChannel (unsigned int chnIdx, bool enable)=0
| Enable or disable the given digital channel.
virtual bool | libm2k::analog::M2kAnalogOut::isChannelEnabled (unsigned int chnIdx)=0
| Check if the given channel is enabled.
virtual bool | libm2k::analog::M2kAnalogOut::isPushDone (unsigned int chnIdx) const =0
| Check if the generation of the signal (only for non-cyclic buffer) is done.
virtual void | libm2k::analog::M2kAnalogOut::setKernelBuffersCount (unsigned int chnIdx, unsigned int count)=0
| Set the kernel buffers to a specific value.
virtual unsigned int | libm2k::analog::M2kAnalogOut::getKernelBuffersCount (unsigned int chnIdx) const =0
| Get the number of kernel buffers.
virtual short | libm2k::analog::M2kAnalogOut::convertVoltsToRaw (unsigned int channel, double voltage)=0
| Convert the volts value of a sample into raw.
virtual double | libm2k::analog::M2kAnalogOut::convertRawToVolts (unsigned int channel, short raw)=0
| Convert the raw value of a sample into volts.
virtual struct IIO_OBJECTS | libm2k::analog::M2kAnalogOut::getIioObjects ()=0
| Get access to IIO channels, buffers, devices and context.
virtual unsigned int | libm2k::analog::M2kAnalogOut::getNbChannels ()=0
| Retrieve the number of analogical channels.
virtual std::string | libm2k::analog::M2kAnalogOut::getChannelName (unsigned int channel)=0
| Get the channel name for each DAC channel.
virtual double | libm2k::analog::M2kAnalogOut::getMaximumSamplerate (unsigned int chn_idx)=0
| Get the maximum samplerate for the DAC.
virtual unsigned short | libm2k::analog::M2kAnalogOut::setVoltage (unsigned int chn_idx, double volts)=0
| Sets the voltage output of the DAC channel.
virtual unsigned short | libm2k::analog::M2kAnalogOut::setVoltageRaw (unsigned int chn_idx, unsigned short raw)=0
| Sets the raw output of the DAC channel.
virtual libm2k::M2kHardwareTrigger * | libm2k::analog::M2kAnalogOut::getTrigger ()=0
| Get the hardware trigger handler.
virtual void | libm2k::analog::M2kAnalogOut::setBufferRearmOnTrigger (bool enable)=0
| Allows sequential output of multiple buffers with each trigger event.
virtual bool | libm2k::analog::M2kAnalogOut::getBufferRearmOnTrigger () const =0
| Retrieve the value of the attribute that controls buffer rearm on trigger.

## Detailed Description

Contains the representation of the analogical output segment.

## Function Documentation

## cancelBuffer() [1/2]

virtual void libm2k::analog::M2kAnalogOut::cancelBuffer | ( |  | ) |

pure virtual

Cancel all buffer operations of enabled channels.

Note
  Should be used to cancel an ongoing data write.

## cancelBuffer() [2/2]

virtual void libm2k::analog::M2kAnalogOut::cancelBuffer | ( | unsigned int | chn | ) |

pure virtual

Cancel all buffer operations of the given channel.

Parameters

  chn | The index corresponding to the channel

Note
  Should be used to cancel an ongoing data write.

## convertRawToVolts()

virtual double libm2k::analog::M2kAnalogOut::convertRawToVolts | ( | unsigned int | channel,
|  | short | raw )

pure virtual

Convert the raw value of a sample into volts.

Parameters

  channel | The index corresponding to the channel
  raw | The raw value of a sample

Returns
  The value of a sample converted into volts

## convertVoltsToRaw()

virtual short libm2k::analog::M2kAnalogOut::convertVoltsToRaw | ( | unsigned int | channel,
|  | double | voltage )

pure virtual

Convert the volts value of a sample into raw.

Parameters

  channel | The index corresponding to the channel
  voltage | The volts value of a sample

Returns
  The value of a sample converted into raw

## enableChannel()

virtual void libm2k::analog::M2kAnalogOut::enableChannel | ( | unsigned int | chnIdx,
|  | bool | enable )

pure virtual

Enable or disable the given digital channel.

Parameters

  chnIdx | The index corresponding to the channel
  enable | A boolean value corresponding to the channel's state

Exceptions

  EXC_OUT_OF_RANGE | No such channel

## getAvailableSampleRates()

virtual std::vector< double > libm2k::analog::M2kAnalogOut::getAvailableSampleRates | ( | unsigned int | chn | ) |

pure virtual

getAvailableSampleRates

Parameters

  chn | The index corresponding to the required channel

Returns
  The list of available samplerates for this device

## getBufferRearmOnTrigger()

virtual bool libm2k::analog::M2kAnalogOut::getBufferRearmOnTrigger | ( |  | ) | const

pure virtual

Retrieve the value of the attribute that controls buffer rearm on trigger.

Note
  The buffer rearm on trigger is disabled by default.
  The attribute is shared between both channels.
  Only available from firmware v0.33.

Returns
  A boolean value corresponding to the state of the rearm on trigger.

## getChannelName()

virtual std::string libm2k::analog::M2kAnalogOut::getChannelName | ( | unsigned int | channel | ) |

pure virtual

Get the channel name for each DAC channel.

Parameters

  channel | - unsigned int representing the index of the channel

Returns
  std::string - name of the channel

## getCyclic()

virtual bool libm2k::analog::M2kAnalogOut::getCyclic | ( | unsigned int | chn | ) |

pure virtual

Retrieve the value of the cyclic mode.

Parameters

  chn | The index corresponding to the channel

Returns
  A boolean value corresponding to the state of the cyclic mode

## getFilterCompensation()

virtual double libm2k::analog::M2kAnalogOut::getFilterCompensation | ( | double | samplerate | ) |

pure virtual

Retrieve the filter compensation for the given sample rate.

Parameters

  samplerate | A double value representing the sample rate

Returns
  The value of the filter compensation

## getIioObjects()

virtual struct IIO_OBJECTS libm2k::analog::M2kAnalogOut::getIioObjects | ( |  | ) |

pure virtual

Get access to IIO channels, buffers, devices and context.

Note
  Can be used when debugging directly with libiio.

Returns
  IIO_OBJECTS structure.

## getKernelBuffersCount()

virtual unsigned int libm2k::analog::M2kAnalogOut::getKernelBuffersCount | ( | unsigned int | chnIdx | ) | const

pure virtual

Get the number of kernel buffers.

Parameters

  chnIdx | The index corresponding to the channel

Returns
  the number of previously set kernel buffers (saved in this session)

## getMaximumSamplerate()

virtual double libm2k::analog::M2kAnalogOut::getMaximumSamplerate | ( | unsigned int | chn_idx | ) |

pure virtual

Get the maximum samplerate for the DAC.

Parameters

  chn_idx | - unsigned int representing the index of the channel

Returns
  double - the value of the maximum samplerate

## getNbChannels()

virtual unsigned int libm2k::analog::M2kAnalogOut::getNbChannels | ( |  | ) |

pure virtual

Retrieve the number of analogical channels.

Returns
  The number of channels

## getOversamplingRatio() [1/2]

virtual std::vector< int > libm2k::analog::M2kAnalogOut::getOversamplingRatio | ( |  | ) |

pure virtual

Retrieve the global oversampling ratio.

Returns
  The value of the global oversampling ratio

## getOversamplingRatio() [2/2]

virtual int libm2k::analog::M2kAnalogOut::getOversamplingRatio | ( | unsigned int | chn | ) |

pure virtual

Retrieve the oversampling ratio for the given channel.

Parameters

  chn | The index corresponding to the channel

Returns
  The oversampling ratio value

## getSampleRate() [1/2]

virtual std::vector< double > libm2k::analog::M2kAnalogOut::getSampleRate | ( |  | ) |

pure virtual

Retrieve the sample rate of both DACs.

Returns
  A list containing the sample rates

## getSampleRate() [2/2]

virtual double libm2k::analog::M2kAnalogOut::getSampleRate | ( | unsigned int | chn | ) |

pure virtual

Retrieve the sample rate for the given channel.

Parameters

  chn | The index corresponding to the channel

Returns
  The value of the sample rate

## getScalingFactor()

virtual double libm2k::analog::M2kAnalogOut::getScalingFactor | ( | unsigned int | chn | ) |

pure virtual

Retrieve the scaling factor for the given channel.

Parameters

  chn | The index corresponding to the channel

Returns
  The value of the scaling factor

Exceptions

  EXC_OUT_OF_RANGE | No such channel

## getTrigger()

virtual libm2k::M2kHardwareTrigger * libm2k::analog::M2kAnalogOut::getTrigger | ( |  | ) |

pure virtual

Get the hardware trigger handler.

Returns
  A pointer to the hardware trigger

## isChannelEnabled()

virtual bool libm2k::analog::M2kAnalogOut::isChannelEnabled | ( | unsigned int | chnIdx | ) |

pure virtual

Check if the given channel is enabled.

Parameters

  chnIdx | The index corresponding to the channel

Returns
  A boolean value corresponding to the state of the channel

Exceptions

  EXC_OUT_OF_RANGE | No such channel

## isPushDone()

virtual bool libm2k::analog::M2kAnalogOut::isPushDone | ( | unsigned int | chnIdx | ) | const

pure virtual

Check if the generation of the signal (only for non-cyclic buffer) is done.

Parameters

  chnIdx | The index corresponding to the channel

Returns
  True if the push process is done, false otherwise

Note
  This function takes the number of kernel buffers into consideration.
  If a new session is started without unplugging the board and the number of kernel buffers was modified in the previous session
  (default value = 4) a DAC calibration must be performed before calling isPushDone in order to compute the
  current number of kernel buffers or call again the function setKernelBuffersCount.
  Available only in firmware versions newer than 0.23.

## push() [1/2]

virtual void libm2k::analog::M2kAnalogOut::push | ( | std::vector< std::vector< double > > const & | data | ) |

pure virtual

Send samples to channels.

Parameters

  data | A list containing lists of samples

Note
  The index of each list of samples represents the channel's index
  Streaming data is possible - required multiple kernel buffers
  The given channel won't be synchronized with the other channel
  Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers)
  The samples in the buffer can be repeated until the buffer reaches the size requirements

## push() [2/2]

virtual void libm2k::analog::M2kAnalogOut::push | ( | unsigned int | chnIdx,
|  | std::vector< double > const & | data )

pure virtual

Send the samples to the given channel.

Parameters

  chnIdx | The index corresponding to the channel
  data | A list of doubles containing all samples

Note
  Streaming data is possible - required multiple kernel buffers
  The given channel won't be synchronized with the other channel
  Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers)
  The samples in the buffer can be repeated until the buffer reaches the size requirements

Exceptions

  EXC_OUT_OF_RANGE | No such channel

## pushBytes()

virtual void libm2k::analog::M2kAnalogOut::pushBytes | ( | unsigned int | chnIdx,
|  | double * | data,
|  | unsigned int | nb_samples )

pure virtual

Send the samples to the given channel.

Parameters

  chnIdx | The index corresponding to the channel
  data | A pointer to the samples
  nb_samples | the number of samples

Note
  Streaming data is possible - required multiple kernel buffers
  The given channel won't be synchronized with the other channel
  Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers)
  The samples in the buffer can be repeated until the buffer reaches the size requirements

Exceptions

  EXC_OUT_OF_RANGE | No such channel

## pushInterleaved()

virtual void libm2k::analog::M2kAnalogOut::pushInterleaved | ( | double * | data,
|  | unsigned int | nb_channels,
|  | unsigned int | nb_samples )

pure virtual

Send samples to all the channels.

Parameters

  data | A pointer to the interleaved data
  nb_channels | the number of channels on which we want to push
  nb_samples | the number of samples total (samples_per_channel * channels)

Note
  Make sure the samples are interleaved
  Streaming data is possible - required multiple kernel buffers
  The given channel will be synchronized with the other channel
  Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers)
  The samples in the buffer can be repeated until the buffer reaches the size requirements

## pushRaw() [1/2]

virtual void libm2k::analog::M2kAnalogOut::pushRaw | ( | std::vector< std::vector< short > > const & | data | ) |

pure virtual

Send samples to channels.

Parameters

  data | A list containing lists of samples

Note
  The index of each list of samples represents the channel's index
  Streaming data is possible - required multiple kernel buffers
  The given channel won't be synchronized with the other channel
  Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers)
  The samples in the buffer can be repeated until the buffer reaches the size requirements

## pushRaw() [2/2]

virtual void libm2k::analog::M2kAnalogOut::pushRaw | ( | unsigned int | chnIdx,
|  | std::vector< short > const & | data )

pure virtual

Send the samples to the given channel.

Parameters

  chnIdx | The index corresponding to the channel
  data | A list of shorts containing all samples

Note
  Streaming data is possible - required multiple kernel buffers
  The given channel won't be synchronized with the other channel
  Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers)
  The samples in the buffer can be repeated until the buffer reaches the size requirements

Exceptions

  EXC_OUT_OF_RANGE | No such channel

## pushRawBytes()

virtual void libm2k::analog::M2kAnalogOut::pushRawBytes | ( | unsigned int | chnIdx,
|  | short * | data,
|  | unsigned int | nb_samples )

pure virtual

Send the samples to the given channel.

Parameters

  chnIdx | The index corresponding to the channel
  data | A pointer to the raw samples
  nb_samples | the number of samples

Note
  Streaming data is possible - required multiple kernel buffers
  The given channel won't be synchronized with the other channel
  Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers)
  The samples in the buffer can be repeated until the buffer reaches the size requirements

Exceptions

  EXC_OUT_OF_RANGE | No such channel

## pushRawInterleaved()

virtual void libm2k::analog::M2kAnalogOut::pushRawInterleaved | ( | short * | data,
|  | unsigned int | nb_channels,
|  | unsigned int | nb_samples )

pure virtual

Send samples to all the channels.

Parameters

  data | A pointer to the interleaved raw data
  nb_channels | the number of channels on which we want to push
  nb_samples | the number of samples total (samples_per_channel * channels)

Note
  Make sure the raw samples are interleaved
  Streaming data is possible - required multiple kernel buffers
  The given channel will be synchronized with the other channel
  Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers)
  The samples in the buffer can be repeated until the buffer reaches the size requirements

## setBufferRearmOnTrigger()

virtual void libm2k::analog::M2kAnalogOut::setBufferRearmOnTrigger | ( | bool | enable | ) |

pure virtual

Allows sequential output of multiple buffers with each trigger event.

Parameters

  enable | A boolean value that enables or disables the buffer rearm functionality.

Note
  When disabled, all buffers will be sent at once. Opt to concatenate multiple small buffers into a single buffer to avoid timing problems.
  When enabled, each previously pushed buffer will be sent sequentially with each trigger event.
  For non-cyclic mode each buffer is sent only once.
  In cyclic mode:
  - If rearm is disabled, the buffer will be sent continuously.
  - If rearm is enabled, the buffer will be sent once for every trigger event.
  Due to hardware limitation, in non-cyclic mode, the channel will idle with the first sample of the next buffer.
  Only available from firmware v0.33.

## setCyclic() [1/2]

virtual void libm2k::analog::M2kAnalogOut::setCyclic | ( | bool | en | ) |

pure virtual

Enable or disable the cyclic mode for all digital channels.

Parameters

  en | If true, enable cyclic mode

Exceptions

  EXC_OUT_OF_RANGE | No such channel

## setCyclic() [2/2]

virtual void libm2k::analog::M2kAnalogOut::setCyclic | ( | unsigned int | chn,
|  | bool | en )

pure virtual

Enable or disable the cyclic mode for all digital channels.

Parameters

  chn | The index corresponding to the channel
  en | If true, enable cyclic mode

Exceptions

  EXC_OUT_OF_RANGE | No such channel

## setKernelBuffersCount()

virtual void libm2k::analog::M2kAnalogOut::setKernelBuffersCount | ( | unsigned int | chnIdx,
|  | unsigned int | count )

pure virtual

Set the kernel buffers to a specific value.

Parameters

  chnIdx | The index corresponding to the channel
  count | the number of kernel buffers

## setOversamplingRatio() [1/2]

virtual std::vector< int > libm2k::analog::M2kAnalogOut::setOversamplingRatio | ( | std::vector< int > | oversampling_ratio | ) |

pure virtual

Set the value of the oversampling ratio for each channel.

Parameters

  oversampling_ratio | A list containing the ratios for each channel (as integers)

Returns
  A list containing the oversampling ratio value for each channel

## setOversamplingRatio() [2/2]

virtual int libm2k::analog::M2kAnalogOut::setOversamplingRatio | ( | unsigned int | chn,
|  | int | oversampling_ratio )

pure virtual

Set the oversampling ratio for the given channel.

Parameters

  chn | The index corresponding to the channel
  oversampling_ratio | Integer value to set the oversampling ratio to

Returns
  The current oversampling ratio value

## setSampleRate() [1/2]

virtual std::vector< double > libm2k::analog::M2kAnalogOut::setSampleRate | ( | std::vector< double > | samplerates | ) |

pure virtual

Set the sample rate for both channels.

Parameters

  samplerates | A list containing the sample rates of each channel

Returns
  A list containing the previously set sample rates

## setSampleRate() [2/2]

virtual double libm2k::analog::M2kAnalogOut::setSampleRate | ( | unsigned int | chn,
|  | double | samplerate )

pure virtual

Set the sample rate for the given channel.

Parameters

  chn | The index corresponding to the channel
  samplerate | A double value to set the sample rate to

Returns
  The value of the sample rate

## setVoltage()

virtual unsigned short libm2k::analog::M2kAnalogOut::setVoltage | ( | unsigned int | chn_idx,
|  | double | volts )

pure virtual

Sets the voltage output of the DAC channel.

Parameters

  chn_idx | - unsigned int representing the index of the channel
  volts | - actual value to be set

Note
  In scenarios where the DMA is not active, such as when an output buffer is destroyed, the DAC will revert to using the raw value set by this function.

Returns
  unsigned short - the corresponding raw value for the given voltage

## setVoltageRaw()

virtual unsigned short libm2k::analog::M2kAnalogOut::setVoltageRaw | ( | unsigned int | chn_idx,
|  | unsigned short | raw )

pure virtual

Sets the raw output of the DAC channel.

Parameters

  chn_idx | - unsigned int representing the index of the channel
  raw | - actual value to be set

Note
  In scenarios where the DMA is not active, such as when an output buffer is destroyed, the DAC will revert to using the raw value set by this function.

Returns
  unsigned short - the value set in the raw attribute

## stop() [1/2]

virtual void libm2k::analog::M2kAnalogOut::stop | ( |  | ) |

pure virtual

Stop all channels from sending the signals.

Note
  Both DACs will be powered down

## stop() [2/2]

virtual void libm2k::analog::M2kAnalogOut::stop | ( | unsigned int | chn | ) |

pure virtual

Stop the given channels from sending the signals.

Parameters

  chn | The index corresponding to the channel

Note
  The corresponding DAC will be powered down

Exceptions

  EXC_OUT_OF_RANGE | No such channel