Exemplo n.º 1
0
def ctr6(d):
  global u3channels_saved
  i=6
  if u3channels_saved[i] == 'ctr':
    return d.getFeedback(u3.Counter0( Reset = True ) )
  else:
    print "Error trying to get counter data from FIO"+str(i)+".  You didn't set it up for counter input."
    print "ctr"+str(i)+" exiting.  Bye bye."
    raise RuntimeError('Sorry...')
Exemplo n.º 2
0
def ctr7(d):
  global u3channels_saved
  i=7
  if u3channels_saved[i] == 'ctr':
    if u3channels_saved[6] == 'ctr':           #Then there are two counters, so FIO7 is counter 1 and FIO6 is counter 0
      return d.getFeedback(u3.Counter1( Reset = True ) )
    else:
      return d.getFeedback(u3.Counter0( Reset = True ) )
  else:
    print "Error trying to get counter data from FIO"+str(i)+".  You didn't set it up for counter input."
    print "ctr"+str(i)+" exiting.  Bye bye."
    raise RuntimeError('Sorry...')
Exemplo n.º 3
0
def ReadCounter0():
    '''
    Desc: Reads counter0 
    !!! Before using it make sure than the counter is really enabled!!!
     
    Ex: 
    >>> LJU3HV.ResetCounter0()
    []
    Conter 0 was reset
    '''

    return d.getFeedback(u3.Counter0(Reset=True))
Exemplo n.º 4
0
def ResetCounter0():
    '''
    Desc: Performs a reset of counter0 
    !!! Before using it make sure than the counter is really enabled!!!
     
    Ex: 
    >>> LJU3HV.ResetCounter0()
    
    Conter 0 was reset
    '''

    d.getFeedback(u3.Counter0(Reset=True))
Exemplo n.º 5
0
class U3Resource(object):
    timer0 = u3.Timer0()
    timer1 = u3.Timer1()
    counter = u3.Counter0()
    _reset_offset = 0

    def __init__(self, instance, horigin, lorigin, high, low):
        self.instance = instance
        self.horigin = horigin
        self.lorigin = lorigin
        self.high = high
        self.low = low

    def get_monotonic(self):
        high, low = self.instance.getFeedback(self.timer1, self.timer0)
        b_high = '{:b}00000000000000000000000000000000'.format(high -
                                                               self.high)
        b_low = '{:032b}'.format(low - self.low)
        tick = int(b_high, 2) + int(b_low, 2)
        return tick * 2.5e-07
        # tick = '{:b}{:032b}'.format(high-self.high, low-self.low)
        # return int(tick, 2) * 2.5e-07
    def get_time(self):
        return self.get_monotonic() - self._reset_offset

    def get_origin(self):
        high, low = self.instance.getFeedback(self.timer1, self.timer0)
        b_high = '{:b}00000000000000000000000000000000'.format(high -
                                                               self.high)
        b_low = '{:032b}'.format(low - self.low)
        tick = int(b_high, 2) + int(b_low, 2)
        return tick * 2.5e-07
        # high, low = self.instance.getFeedback(self.timer1, self.timer0)
        # tick = '{:b}{:032b}'.format(high-self.horigin, low-self.lorigin)
        # return int(tick, 2) * 2.5e-07
    def get_counter(self):
        return self.instance.getFeedback(self.counter)[0]

    def reset_counter(self):
        raise NotImplementedError

    def reset_timer(self):
        self._reset_offset = self.get_monotonic()
Exemplo n.º 6
0
 def resetCounter0(self):  # Reset the content counter 0
     return self.labjackModule.getFeedback(u3.Counter0(Reset=True))
Exemplo n.º 7
0
 def readCounter0(self):  # Return the content counter 0
     return self.labjackModule.getFeedback(u3.Counter0())