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

add example for DAC0/1 #23

Open
stefan894 opened this issue Dec 13, 2024 · 3 comments
Open

add example for DAC0/1 #23

stefan894 opened this issue Dec 13, 2024 · 3 comments

Comments

@stefan894
Copy link

would be nice if labjack would also provide an example for DAC0/1, as this is not the case, I did one on my own.
Published here as help for others

under Labjack T7 I got DAC0/1 working with this example:

from labjack import ljm

print(ljm.__version__)


class labjack_T7_dac:

      def __init__(self):
          # Open Labjack T7 device, Any connection, Any identifier
          self.handle = ljm.openS("T7", "ANY", "ANY")


      def write_dac(self, dac0: float = 0, dac1: float = 0):
          if (0 <= dac0 <= 5.0) and (0 <= dac1 <= 5.0):
              self.aDAC = ["DAC0", "DAC1"]
              self.aValueDAC = [dac0, dac1]
              self.numFrames = len(self.aDAC)
              ljm.eWriteNames(self.handle, self.numFrames, self.aDAC, self.aValueDAC)
          else:
              print("DAC values out of range")


      def close(self):
          ljm.close(self.handle)


      def main(self):
          self.write_dac(5.0,1.2)
          self.close()


if __name__ == '__main__':
  c = labjack_T7_dac()
  c.main()
@davelopez01
Copy link
Contributor

The DACs are one of the easiest features to use. There is no configuration, just write to the register. We provide examples like eWriteName.py and eWriteNames.py to demonstrate generally how to write registers. They also both set a DAC.

I am worried that our documentation was not sufficient. Was DAC usage not clear?

@stefan894
Copy link
Author

Hi Davel,

As there was an example for ADC, I was also expecting an example for DAC..

As you see, I was able to figure it out and provided the example here, so that others just can use it, without going through documentation ;-)

@davelopez01
Copy link
Contributor

Thanks for bringing this to our attention. I will look into adding a DAC example that supports all T-series devices.

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

No branches or pull requests

2 participants