Index
RSS

Welcome Guest [ Log In | Register ]

 
Reply to this topicStart new topic
> Polling Values from UE9 Over Ethernet
bjorn_westergard
post Feb 3 2010, 12:11 PM
Post #1

Joined: 3-February 10
Posts: 11




I've configured the UE9 to use DHCP, and confirmed that it succesfully connected to the network by pinging it. Running the test mode of LJControl Panel when tethered via usb works fine - values show up, and respond appropriately when I ground pins. I've downloaded the LabJack Python source and am now trying to pull values (in whatever mode, stream or otherwise) over a TCP connection with python, but can't seem to figure out how to specify the IP address of the labjack I'd like to connect to.

For instance, in u3allio.py there is one line apparently dedicated to instantiating the U3 object, but no parameters are given. After changing the import line to include the ue9 class and attempting to set a few of the options based on what I gathered from the ue9.py file, I'm not getting anything more informative than a "LabJack not found" error. The python classes are meant for use over ethernet, right? Could someone post an example script in which a labjack is specified by IP (or found via UDP) and queried for data? Is there documentation on this I missed?

Thanks.
 
Quote Post
LabJack Support
post Feb 3 2010, 02:25 PM
Post #2

Joined: 9-June 03
Posts: 5527




The UE9 class is streamlined to make opening a single UE9 over USB very easy. In order to open a UE9 over TCP, you simply do the following:

CODE
>>> import ue9
>>> d = ue9.UE9( ethernet = True, ipAddress = "192.168.1.129")


After that, you can call all the functions of UE9 class as if you were connected over USB. Don't be afraid to open ue9.py. All of the functions intended for your use will have a docstring. This will help you if you are ever confused about what functions are available or the parameters they take. If you're in an interactive python session, you can always use the built in help() function.

I'll make an example so that other people don't run into the same problem.
 
Quote Post
bjorn_westergard
post Feb 4 2010, 05:44 AM
Post #3

Joined: 3-February 10
Posts: 11




QUOTE (LabJack Support @ Feb 3 2010, 03:25 PM) *
The UE9 class is streamlined to make opening a single UE9 over USB very easy. In order to open a UE9 over TCP, you simply do the following:

CODE
>>> import ue9
>>> d = ue9.UE9( ethernet = True, ipAddress = "192.168.1.129")


After that, you can call all the functions of UE9 class as if you were connected over USB. Don't be afraid to open ue9.py. All of the functions intended for your use will have a docstring. This will help you if you are ever confused about what functions are available or the parameters they take. If you're in an interactive python session, you can always use the built in help() function.

I'll make an example so that other people don't run into the same problem.


Ah, okay, so I was headed in the right direction.

Here is what I'd tried:

CODE
import ue9
d = ue9.UE9( ethernet = True, ipAddress = "10.0.0.58")

print "Test"


Which outputs...

CODE
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import ue9
  File "/usr/local/lib/python2.6/dist-packages/ue9.py", line 5, in <module>
    from LabJackPython import *
  File "/usr/local/lib/python2.6/dist-packages/LabJackPython.py", line 126, in <module>
    staticLib = _loadLibrary()
  File "/usr/local/lib/python2.6/dist-packages/LabJackPython.py", line 119, in _loadLibrary
    "Ethernet connectivity availability only.")
LabJackPython.LabJackException: Could not load labjackusb driver.  Ethernet connectivity availability only.


Notably absent is the printing of "test" (I had previously tried to print the dictionary contents, and thought the issue was there, but it seems as though program execution isn't even making it that far). In case it's not apparent, I'm somewhat new to python. Any ideas?

This is under ubuntu (Karmic Koala), though a similar error cropped up under windows 7.
 
Quote Post
bjorn_westergard
post Feb 4 2010, 05:55 AM
Post #4

Joined: 3-February 10
Posts: 11




QUOTE (LabJack Support @ Feb 3 2010, 02:25 PM) *
The UE9 class is streamlined to make opening a single UE9 over USB very easy. In order to open a UE9 over TCP, you simply do the following:

CODE
>>> import ue9
>>> d = ue9.UE9( ethernet = True, ipAddress = "192.168.1.129")


After that, you can call all the functions of UE9 class as if you were connected over USB. Don't be afraid to open ue9.py. All of the functions intended for your use will have a docstring. This will help you if you are ever confused about what functions are available or the parameters they take. If you're in an interactive python session, you can always use the built in help() function.

I'll make an example so that other people don't run into the same problem.


Here is the output from an interactive session:

CODE
>>> import ue9
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/ue9.py", line 5, in <module>
    from LabJackPython import *
  File "/usr/local/lib/python2.6/dist-packages/LabJackPython.py", line 126, in <module>
    staticLib = _loadLibrary()
  File "/usr/local/lib/python2.6/dist-packages/LabJackPython.py", line 119, in _loadLibrary
    "Ethernet connectivity availability only.")
LabJackPython.LabJackException: Could not load labjackusb driver.  Ethernet connectivity availability only.
>>> d = ue9.UE9( ethernet = True, ipAddress = "10.0.0.85")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'ue9' is not defined


Which to my untrained eye, and in conjunction with the output I'm getting from my test file, seems to indicate the library is not loading properly.
 
Quote Post
LabJack Support
post Feb 4 2010, 10:58 AM
Post #5

Joined: 9-June 03
Posts: 5527




I see. Because you don't have the Exodriver installed, the call the loadLibrary() is failing.

I made some changes so that shouldn't happen. Download the latest version of LabJackPython from GitHub and try again.
 
Quote Post
bjorn_westergard
post Feb 8 2010, 06:58 AM
Post #6

Joined: 3-February 10
Posts: 11




QUOTE (LabJack Support @ Feb 4 2010, 10:58 AM) *
I see. Because you don't have the Exodriver installed, the call the loadLibrary() is failing.

I made some changes so that shouldn't happen. Download the latest version of LabJackPython from GitHub and try again.


Thank you for your timely response. After grabbing the update from git it appears I am able to connect. If I run...

CODE
import ue9
d = ue9.UE9( ethernet = True, ipAddress = "10.0.0.85")
print d.commConfig()


I get...

CODE
<class 'LabJackPython.LabJackException'>: Could not load labjackusb driver.  Ethernet connectivity availability only.
{'Subnet': '255.255.255.0', 'LocalID': 1, 'CommFWVersion': '1.43', 'SerialNumber': 272263498, 'MACAddress': '00:50:C2:3A:69:4A', 'IPAddress': '10.0.0.85', 'PortB': 52361, 'PortA': 52360, 'PowerLevel': 0, 'ProductID': 9, 'HWVersion': '1.10', 'Gateway': '10.0.0.1', 'DHCPEnabled': False}


Those values look correct, so I know there is some communication going on successfully, which makes the issue I now have all the more mystifying. If I run...

CODE
import ue9
d = ue9.UE9( ethernet = True, ipAddress = "10.0.0.85")
print d.commConfig()
count = 0;
while 1:
    #print d.singleIO(4, 2, Dir = 0, BipGain = 0x01, Resolution = 12, SettlingTime = 0)
    print d.feedback(AIN1_0_BipGain = o1)
    count = (count + 1) % 120
    print "x" * count


I get nothing but 0 values... using singleIO, as on the commented out line, garners the same result:

CODE
{'AIN4': 0, 'AIN5': 0, 'CIODir': 0, 'AIN7': 0, 'EIODir': 0, 'AIN1': 0, 'AIN2': 0, 'AIN3': 0, 'MIOState': 7, 'AIN8': 0, 'AIN9': 0, 'CIOState': 15, 'AIN0': 0, 'AIN6': 0, 'Counter0': 0, 'Counter1': 0, 'EIOState': 255, 'TimerC': 0, 'TimerB': 0, 'TimerA': 0, 'MIODir': 0, 'FIODir': 0, 'AIN14': 0, 'AIN15': 0, 'AIN12': 0, 'AIN13': 0, 'AIN10': 0, 'AIN11': 0, 'FIOState': 255}


Using the labjackconfig app under windows I get non-zero values that float between 1 and 0, and when I ground pins they get closer to 0. No amount of pin-grounding (or connection to VS through a resistor) produces any result from python's point of view.

Also of note, I seem to be able crash the labjack by grounding whatever analog input pin I'm reading from using singleIO and I very often have to power cycle the labjack to get it to connect again (the connection process simply hangs otherwise). Waiting for about 10 seconds improves the chances of connecting, but sometimes powercycling is the only way. I've read 5.3.3 in the user manual and messed around with options a bit, but can't find anything that seems relevant. This honestly doesn't bother me all that much, but I mention it as it might be related to my polling issues.
 
Quote Post
LabJack Support
post Feb 8 2010, 12:42 PM
Post #7

Joined: 9-June 03
Posts: 5527




While I was looking into your problem, I found a few issues with the UE9 class and fixed them. Before doing anything else, please grab a new copy of LabJackPython from GitHub.

QUOTE (bjorn_westergard @ Feb 8 2010, 06:58 AM) *
I get nothing but 0 values... using singleIO, as on the commented out line, garners the same result


I think that's because you weren't filling in all the values that feedback needs, especially AINMask. In this case I have a jumpers set from GND to AIN0, and from VS to AIN1:

CODE
>>> import ue9
>>> d = ue9.UE9( ethernet = True, ipAddress = "192.168.1.239")
>>> d.feedback(AINMask = 255)
{'AIN4': 0, 'AIN5': 0, 'CIODir': 0, 'AIN7': 0, 'EIODir': 0, 'AIN1': 64096, 'AIN2': 0, 'AIN3': 0, 'MIOState': 7, 'AIN8': 0, 'AIN9': 0, 'CIOState': 15, 'AIN0': 144, 'AIN6': 0, 'Counter0': 0, 'Counter1': 0, 'EIOState': 255, 'TimerC': 0, 'TimerB': 0, 'TimerA': 0, 'MIODir': 0, 'FIODir': 0, 'AIN14': 0, 'AIN15': 0, 'AIN12': 0, 'AIN13': 0, 'AIN10': 0, 'AIN11': 0, 'FIOState': 255}


5.3.3 of the UE9 User's Guide describes what all the parameters to feedback mean. Because the default for all the parameters is 0, you have to make sure you set everything you need.

As for why your singleIO isn't working, I can't say. Did you mean to be reading from AIN2?

This works for me:
CODE
>>> d.singleIO(4, 0, Dir = 0, BipGain = 0x01, Resolution = 12, SettlingTime = 0)
{'AIN0': 288.0}
>>> d.singleIO(4, 1, Dir = 0, BipGain = 0x01, Resolution = 12, SettlingTime = 0)
{'AIN1': 65520.0}


QUOTE (bjorn_westergard @ Feb 8 2010, 06:58 AM) *
I seem to be able crash the labjack by grounding whatever analog input pin I'm reading from using singleIO and I very often have to power cycle the labjack to get it to connect again (the connection process simply hangs otherwise).


I wasn't able to recreate this problem. Could you explain a little bit more about how the problem occurs?

Remember to NEVER connect a VS to a GND pin by jumper.
 
Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
RSS