def main(): USB1208LS=MCCDAQ() WConio.clrscr() print "Demonstration of cbDIn()\n"\ "Press any key to quit.\n\n"\ "You may change a bit by applying a TTL high or\n"\ "a TTL low to the corresponding pin# on port A.\n" print "The first 7 bits are: pin32 to pin 39\n"\ "0 1 2 3 4 5 6 7\n " (a,a,a,a,a,a,a,a,a,a,row)=WConio.gettextinfo() USB1208LS.DConfigPort (0, FIRSTPORTB, DIGITALIN) while (WConio.kbhit()==False): DataValue=USB1208LS.DIn(0, FIRSTPORTB) WConio.gotoxy(0,row) print "Port Value: %d " %DataValue # parse DataValue into bit values to indicate on/off status */ for I in range (8): if (DataValue & 2**I): BitValue = 1 else: BitValue = 0 print "%d " %BitValue,
def main(): USB1208LS=MCCDAQ() WConio.clrscr() print "Demonstration of AIn()\n"\ "Press any key to quit.\n" # get the A/D channel to sample Chan = int ( raw_input('Enter the channel to display: ') ) print "\nThe raw data value on Channel %u is: " %Chan, (a,a,a,a,a,a,a,a,a,col,row)=WConio.gettextinfo() print "\nThe voltage on Channel %u is: " %Chan, # collect the sample from the channel until a key is pressed while (WConio.kbhit()==False): DataValue=USB1208LS.AIn (0, Chan, BIP5VOLTS) EngUnits =USB1208LS.ToEngUnits (0, BIP5VOLTS, DataValue) WConio.gotoxy(col,row) print "%5d" %DataValue, WConio.gotoxy(col,row+1) print "%.2fV" %EngUnits,
usb, all_servos, analog_channels = rcs.robust_read('CA0USM', 3) firmware_version = usb[2] disabled = (all_servos[-1][-1] == -1) # Servo and Analog Display Page servo_mode = IDLE # Set up variables for running servos command_mode = INIT accel_dif = False accel_list = [1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 255] display_once(firmware_version) # Display static and initial items while True: if len(all_servos) == 16: #check for valid servo data display_update() # 'Q' to quit, otherwise sequence through the servo command modes if WConio.kbhit(): key_num, key_str = WConio.getch() if key_str.upper() == 'Q': try: rcs.robust_write('C') #stop all servos at exit del(rcs) #close serial port except: pass exit() elif command_mode is INIT: command_mode = RUN elif command_mode is RUN: command_mode = BRAKE elif command_mode is BRAKE: command_mode = IDLE else: