Hello,
I am trying to use the U3 counters. I would like to be able to get both counting at the same time, which is proving difficult.
I am using python 2.7. The LJControlPanel says the unit has the latest f/w.
The code I am trying to run is:
#========================================
d = u3.U3() # Get the
#print d.config()
#d.SetToFactoryDefaults(1)
#d.open()
d.setDefaults() # Put everything back to factory default
#d.debug = True
LED_delay = 1.0
LEDloop = 0
lastGUIcounter = GUIcounter
exittest = 0
#d.configIO(FIOAnalog = 15)
start_time = time.time()
LEDnext_time = start_time + LED_delay
print temperatureC(d)
mains_on_off( d, 0 ) # Off to start with
#d.configIO(FIOAnalog=0)
#d.configIO(NumberOfTimersEnabled = 2)
d.configIO(EnableCounter0=1, TimerCounterPinOffset = 4 )
d.configIO(EnableCounter1=1, TimerCounterPinOffset = 5 )
#d.configIO(EnableTimer0=0, TimerCounterPinOffset = 6 )
#d.configIO(EnableTimer1=0, TimerCounterPinOffset = 7 )
print "Starting Loop"
while ExitNow == 0:
current_time = float( time.time() )
if current_time > LEDnext_time:
count0 = d.getFeedback(u3.Counter0(Reset = False))
print count0
count1 = d.getFeedback(u3.Counter1(Reset = False))
print count1
LEDnext_time += LED_delay
LEDloop += 1
#print LEDloop
#print LEDnext_time
loopCounter += 1
print loopCounter
# check GUI is still running, exit if it is not
if GUIcounter > lastGUIcounter:
lastGUIcounter = GUIcounter
exittest = 0
else:
exittest += 1
if exittest > 10:
ExitNow = 1 # give up
time.sleep(0.25)
print "mainloop() exit"
#========================================
The error I get is:
27.8735856006
Starting Loop
Exception in thread Thread-2:
Traceback (most recent call last):
File "c:\python27\lib\threading.py", line 810, in __bootstrap_inner
self.run()
File "c:\python27\lib\threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "ST230.py", line 91, in mainloop
count0 = d.getFeedback(u3.Counter0(Reset = False))
File "c:\python27\lib\site-packages\u3.py", line 754, in getFeedback
raise LowlevelErrorException("\nThis Command\n %s\nreturned an error:\n %s" % (culprit , lowlevelErrorToString(rcvBuffer[6])))
LowlevelErrorException:
This Command
<u3.Counter0( Reset = False )>
returned an error:
XBR_CONFIG_ERROR (7)
If I use one counter at a time, it works fine.
Any ideas?
Thanks & Regards
David