LabJackPython outputSinDAC error | LabJack
 

LabJackPython outputSinDAC error

2 posts / 0 new
Last post
NatashaB
NatashaB's picture
LabJackPython outputSinDAC error

I'm using the U6 for some development work with Python. To understand how the U6 communicates with Python, I downloaded LabJackPython-5-26-2015 and have been looking at the example code. However several of the examples throw errors. Specifically, I am working to get outputSinDAC.py integrated with my code. However, when run by itself as part of the example code, an error appears in the console(attached and also shown below).

This program will attempt to generate a sine wave with a frequency of 10 Hz, updating once every 0.005 seconds.
Opening LabJack...Traceback (most recent call last):
  File "C:/Users/nb45921/Desktop/LabJackPython-5-26-2015/Examples/outputSinDAC.py", line 87, in <module>
    signal.signal(signal.SIGALRM, dacs.handleSetDac)
AttributeError: 'module' object has no attribute 'SIGALRM'
 Done

Process finished with exit code 1

signal.py is a module that outputSinDAC.py is importing from the python library, so I'm unsure how to address this error. Note that everything highlighted yellow in the attached file cannot be found in signal.py

For reference I have:

LabJack U6 FW version: 1.430

PyCharm version: 4.5.3

LabJack Support
labjack support's picture
It looks like the

It looks like the outputSinDAC.py example currently only works on Linux and Mac OS X. signal.SIGALRM isn't available on Windows causing the error you are seeing.

Until we update this example in the LabJackPython download to be more cross-platform, you can replace code after:

    # Create our DacSetter
    dacs = DacSetter(FREQUENCY, UPDATE_INTERVAL)

To something like this which doesn't use a signal:

    import time

    # Run for ~10 seconds.
    signalcount = int(10/UPDATE_INTERVAL)
   
    # Print the current time, just to let you know something is happening.
    print "Start:", datetime.now()
   
    for i in range(signalcount):
        dacs.setDac()
        dacs.handleSetDac(0, 0)
        time.sleep(UPDATE_INTERVAL)
           
    # Print the stop time, in case you wanted to know.
    print "Stop:", datetime.now()
   
    # Print short summary of the difference between how may updates were
    # expected and how many occurred.
    print "# of Updates = %s" % (dacs.count)