Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

writeToExodriver Error


  • Please log in to reply
3 replies to this topic

#1 eoelker

eoelker
  • Members
  • 6 posts

Posted 27 October 2014 - 09:15 AM

I have a script running on loop which reads/writes from/to a U3 labjack every 0.1 seconds.  I keep getting the following error: 

 

Traceback (most recent call last):
  File "ServoCompsToEPICS.py", line 74, in <module>
    PVs[0].put(3.0/2.0*(PLL1.getAIN(1)-PLL1.getAIN(0)))#Subtract AIN0 to get rid of GND offset
  File "/usr/local/lib/python2.7/dist-packages/u3.py", line 567, in getAIN
    bits = self.getFeedback(AIN(posChannel, negChannel, longSettle, quickSample))[0]
  File "/usr/local/lib/python2.7/dist-packages/u3.py", line 740, in getFeedback
    rcvBuffer = self._writeRead(sendBuffer, readLen, [], checkBytes = False, stream = False, checksum = True)
  File "/usr/local/lib/python2.7/dist-packages/LabJackPython.py", line 541, in _writeRead
    self.write(command, checksum = checksum)
  File "/usr/local/lib/python2.7/dist-packages/LabJackPython.py", line 264, in write
    wb = self._writeToExodriver(writeBuffer, modbus)
  File "/usr/local/lib/python2.7/dist-packages/LabJackPython.py", line 214, in _writeToExodriver
    raise LabJackException( "Could only write %s of %s bytes." % (writeBytes, len(writeBuffer) ) )
LabJackPython.LabJackException: Could only write 0 of 10 bytes.
 

This seems to be an error which occured while reading an analog output. Sometimes the program hangs up while writing the DAC and Digital output channels as well (I get the same error).  The code for this loop is below.  I'm fairly new to this.  Am I doing anything obviously wrong, or do you have any suggestions on how I can make this more robust?  Please let me know

 

while True:
    PVs[0].put(3.0/2.0*(PLL1.getAIN(1)-PLL1.getAIN(0)))#Subtract AIN0 to get rid of GND offset
    PVs[1].put(3.0/2.0*(PLL1.getAIN(2)-PLL1.getAIN(0)))#Multiply by 3/2 to account for 0.667 AA filter gain
    PVs[2].put(3.0/2.0*(PLL1.getAIN(3)-PLL1.getAIN(0)))
    

    #Set Binary Outputs
    for i in BOUTChans:
        if (i==5 or i==6):
            iVal = not(PVs[i-1].get())        
            PLL1.setDOState(i,iVal) #Correct for error on Servo comps for boost En logic
        else:
            iVal = PVs[i-1].get()
            PLL1.setDOState(i,iVal)

    #Set DAC Outputs
    InOfsCurrent = PVs[14].get()
    if InOfsCurrent != InOfsOld:    
        PLL1.writeRegister(5000,CalcDACOutput(InOfsCurrent)) #Input Offset
        InOfsOld = InOfsCurrent
    OutOfsCurrent = PVs[15].get()    
    if OutOfsCurrent != OutOfsOld:    
        PLL1.writeRegister(5002,CalcDACOutput(OutOfsCurrent)) #Output Offset
        OutOfsOld = OutOfsCurrent
    #If Gain has changed, Set PWM duty cycle based on desired Gain
    GainCurrent=PVs[7].get()    
    if GainCurrent != GainOld:
        PLL1.getFeedback(u3.Timer0(Value=CalcPWMValue(GainCurrent),UpdateReset=True))
        GainOld = GainCurrent
    sleep(0.1)



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 27 October 2014 - 10:49 AM

What is the minimum you have to do to recover from the error?

 

Does the error seem related to your connections?  That is, if you run your program with nothing connected to the U3, except USB, do you still see the error?



#3 eoelker

eoelker
  • Members
  • 6 posts

Posted 28 October 2014 - 08:38 AM

I have no reason to suspect the connections, though I was trying to run the U3 with a USB-to-ethernet extender for a while (so it could reach my electronics rack) and the script was crashing all the time.  Now The labjack is plugged directly into the computer with the provided USB cable and I'm running a long D-sub cable over to my electronics rack with 8 BOUT, 4 ADC, and 2 DAC signals.

 

So far, I haven't tried running the U3 with just the USB connected.  I'll try that and see what happens.  Restarting the script seems to fix things.  Perhaps I can modify the script to close and reconnect to the labjack when this happens and see if this is sufficient.  That may be good enough for my application, though it would be nice to track this down...



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 28 October 2014 - 10:04 AM

To handle these kind of errors, on Linux and Mac OS X (Windows maintains the USB handle in the UD driver automatically) it is recommended to have exception handling to catch these errors, and close/open the device if necessary.

 

As for figuring out the cause, as previously mentioned you should try your code with no connections to your U3 except the USB connection to your computer. This could indicate a connection is causing an issue possibly causing your U3 to reset (LED will blink) or other error. Also, you may also want to try a different USB port on your computer in case there is an issue with it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users