def SetBitOff(BitChanX):
    '''Set a digital channel to 0V output'''
    UL.cbDConfigBit(
        BoardNum, PortType, BitChanX, UL.DIGITALOUT
    )  # necessary otherwise setting voltage directly does not work
    #Syntax : int cbDConfigBit(int BoardNum, int PortType, int BitNum, int Direction)
    UL.cbDBitOut(BoardNum, PortType, BitChanX, 1)
while cmd.lower() != 'q':
    print('Current position = '),position
    print('Current delta angle request = '),angle
    cmd=raw_input('What to do now? (a: choose angle, p:set position value here, g:go,s:stop moving! q:quit) ')
    if cmd.lower() == 'a':
        anglestring=raw_input('Input angle to move by in +- degrees ' )
        angle=float(anglestring)
    elif cmd.lower() == 'p':
        positionstring=raw_input('Input current position angle ' )
        position=float(positionstring)
    elif cmd.lower()=='q' :
        chk=raw_input('Really quit? (y,n) ')
        if chk.lower()!='y':
            cmd='b'
    elif cmd.lower()=='g' :
        npulses=int(abs(angle)*80)
        dir=0
        if angle < 0:
            dir=1 
        UL.cbDBitOut(0,10,1,dir)
        for i in range(0,npulses+1):
            try:
                UL.cbDBitOut(0,10,0,1)
                UL.cbDBitOut(0,10,0,0)
            except KeyboardInterrupt:
                break
        position=position+(1.-2.*dir)*i/80.

                

    
Ejemplo n.º 3
0
if FirstPort == UL.AUXPORT:
    devNum = 1
    UL.cbGetConfig(UL.DIGITALINFO, BoardNum, devNum, UL.DIDEVTYPE, FirstPort)

if FirstPort == UL.FIRSTPORTA:
    FirstBit = 0
elif FirstPort == UL.FIRSTPORTB:
    FirstBit = 8
elif FirstPort == UL.FIRSTPORTCL:
    FirstBit = 16
elif FirstPort == UL.FIRSTPORTCH:
    FirstBit = 20
else:
    FirstBit = 0

Direction = UL.DIGITALOUT
UL.cbDConfigPort(BoardNum, FirstPort + 1, Direction)
DataValue = 5
BitLevel = 1
for BitNum in range(8):
    if BitNum == DataValue and BitLevel == 1:
        BitValue = 1
    elif BitNum == DataValue and BitLevel == 0:
        BitValue = 0
    else:
        BitValue = 0

    PortType = UL.FIRSTPORTA
    UL.cbDBitOut(BoardNum, PortType, FirstBit + BitNum, BitValue)
Ejemplo n.º 4
0
if FirstPort == UL.AUXPORT:
    devNum = 1
    UL.cbGetConfig(UL.DIGITALINFO, BoardNum, devNum, UL.DIDEVTYPE, FirstPort)

if FirstPort == UL.FIRSTPORTA:
    FirstBit = 0
elif FirstPort == UL.FIRSTPORTB:
    FirstBit = 8
elif FirstPort == UL.FIRSTPORTCL:
    FirstBit = 16
elif FirstPort == UL.FIRSTPORTCH:
    FirstBit = 20
else:
    FirstBit = 0

Direction = UL.DIGITALOUT
UL.cbDConfigPort(BoardNum, FirstPort + 1, Direction)
DataValue = 5
BitLevel = 1
for BitNum in range(8):
    if BitNum == DataValue and BitLevel == 1:
        BitValue = 1
    elif BitNum == DataValue and BitLevel == 0:
        BitValue = 0
    else:
        BitValue = 0

    PortType = UL.FIRSTPORTA
    UL.cbDBitOut(BoardNum, PortType, FirstBit + BitNum, BitValue)