Esempio n. 1
0
def run():
  #roboveroConfig()

  heartbeatOff()
  aeroInit()
  setPID()
  setAngleLimit(LIMIT_ANGLE)
  toggleAltitudeControl(ALTITUDE_CONTROL)
  setTargetAltitude(TARGET_ALTITUDE)
  changeMew(MEW)
  setLowPassU(LOW_PASS_U)
  maintainConnection()

  writer.writerow([P1, P2, I1, I2, D1, D2])

  aeroLoopOn()

  setThrottle(INIT_THROTTLE)
  maintainConnection()

  throttle = INIT_THROTTLE
  count = 0

  try:
    while True:
      maintainConnection()
      logData(1)
      maintainConnection()
      c=myGetch()
      maintainConnection()
      if c=='s':
        throttle += 3

        if (throttle > TAKE_OFF_LIMIT):
          throttle = TAKE_OFF_LIMIT

        setThrottle(throttle)
      elif c=='a':
        throttle -=3

        if (throttle < INIT_THROTTLE):
          throttle = INIT_THROTTLE

        setThrottle(throttle)
      elif c=='':
        pass
      else:
        print "killed by key press"
        aeroLoopOff()
        exit()

      maintainConnection()

  except:
    print "killed due to exception"
    aeroLoopOff()
Esempio n. 2
0
def run():
	# no need for roboveroConfig()
	
	heartbeatOff()
	
	pinMode(BTN, INPUT)
	pinMode(LED, OUTPUT)
	
	while True:
		digitalWrite(LED, digitalRead(BTN))
Esempio n. 3
0
def run():
  heartbeatOff();
  roboveroConfig()

  MCPWM_Init(LPC_MCPWM)

  channelsetup=[]
  for i in range(3):
    channelsetup.append(MCPWM_CHANNEL_CFG_Type())

  channelsetup[0].channelType = MCPWM_CHANNEL_EDGE_MODE
  channelsetup[0].channelPolarity = MCPWM_CHANNEL_PASSIVE_LO
  channelsetup[0].channelDeadtimeEnable = FunctionalState.DISABLE
  channelsetup[0].channelDeadtimeValue = 0
  channelsetup[0].channelUpdateEnable = FunctionalState.ENABLE
  channelsetup[0].channelTimercounterValue = 0
  channelsetup[0].channelPeriodValue = 900
  channelsetup[0].channelPulsewidthValue = 450

  channelsetup[1].channelType = MCPWM_CHANNEL_EDGE_MODE
  channelsetup[1].channelPolarity = MCPWM_CHANNEL_PASSIVE_LO
  channelsetup[1].channelDeadtimeEnable = FunctionalState.DISABLE
  channelsetup[1].channelDeadtimeValue = 0
  channelsetup[1].channelUpdateEnable = FunctionalState.ENABLE
  channelsetup[1].channelTimercounterValue = 0
  channelsetup[1].channelPeriodValue = 900
  channelsetup[1].channelPulsewidthValue = 200

  channelsetup[2].channelType = MCPWM_CHANNEL_EDGE_MODE
  channelsetup[2].channelPolarity = MCPWM_CHANNEL_PASSIVE_LO
  channelsetup[2].channelDeadtimeEnable = FunctionalState.DISABLE
  channelsetup[2].channelDeadtimeValue = 0
  channelsetup[2].channelUpdateEnable = FunctionalState.ENABLE
  channelsetup[2].channelTimercounterValue = 0
  channelsetup[2].channelPeriodValue = 900
  channelsetup[2].channelPulsewidthValue = 200

  MCPWM_ConfigChannel(LPC_MCPWM, 0, channelsetup[0].ptr)
  MCPWM_ConfigChannel(LPC_MCPWM, 1, channelsetup[1].ptr)
  MCPWM_ConfigChannel(LPC_MCPWM, 2, channelsetup[2].ptr)

  #DC Mode
  MCPWM_DCMode(LPC_MCPWM, FunctionalState.ENABLE, FunctionalState.DISABLE, (0))

  MCPWM_Start(LPC_MCPWM, FunctionalState.ENABLE, FunctionalState.ENABLE, FunctionalState.ENABLE)

  try:
    while True:
      #MCPWM_WriteToShadow(LPC_MCPWM, 0, channelsetup[0].ptr) #Change the speed
      for i in range(6):
        BLDC_commutate(i)
  except:
    MCPWM_Stop(LPC_MCPWM, FunctionalState.ENABLE, FunctionalState.ENABLE, FunctionalState.ENABLE)
    heartbeatOn()
    print "you broke it"
Esempio n. 4
0
def run():
  roboveroConfig()
  pinMode(LED, OUTPUT)
  heartbeatOff()

  # Initialize script
  myscript=Script([["GPIO_ClearValue", 3, 2000000],
    ["delay",10000000],
    ["GPIO_SetValue", 3, 2000000]])
  print "script added"

  try:
    while True:
      raw_input("Press Enter to run script")
      print myscript.run()
      print "script done"
      # append to script
      myscript.append("delay",10000000)
      myscript.append("GPIO_ClearValue", 3, 2000000)
      myscript.append("delay",10000000)
      myscript.append("GPIO_SetValue",3, 2000000)
  except:
    heartbeatOn()
    print "goodbye"
Esempio n. 5
0
def run():
  # control the LED manually
  heartbeatOff()
  pinMode(LED, OUTPUT)
  
  # setup EINT0 on pin 2.10
  PinCfg = PINSEL_CFG_Type()
  PinCfg.Funcnum = 1
  PinCfg.OpenDrain = 0
  PinCfg.Pinmode = 0
  PinCfg.Pinnum = 10
  PinCfg.Portnum = 2
  PINSEL_ConfigPin(PinCfg.ptr)
  EXTI_Init()
  
  # register the callback
  registerCallback(IRQn_Type.EINT0_IRQn, EINT0Callback)
  
  # enable EINT0
  NVIC_EnableIRQ(IRQn_Type.EINT0_IRQn)
  
  # the callback does everything from here
  while True:
  	sleep(1)
Esempio n. 6
0
             "I'm afraid I can't let you do that, Dave. Also,", "Hammer says")


def EINT0Callback():
    """Callback function for EINT0.
	"""
    while not digitalRead(BTN):
        sleep(0)
    print "%s don't touch that!" % choice(responses)
    state = digitalRead(LED)
    digitalWrite(LED, state ^ 1)
    EXTI_ClearEXTIFlag(0)


# control the LED manually
heartbeatOff()
pinMode(LED, OUTPUT)

# setup EINT0 on pin 2.10
PinCfg = PINSEL_CFG_Type()
PinCfg.Funcnum = 1
PinCfg.OpenDrain = 0
PinCfg.Pinmode = 0
PinCfg.Pinnum = 10
PinCfg.Portnum = 2
PINSEL_ConfigPin(PinCfg.ptr)
EXTI_Init()

# register the callback
registerCallback(IRQn_Type.EINT0_IRQn, EINT0Callback)
Esempio n. 7
0
"""Control the LED with the pushbutton using the Arduino API.
"""

from robovero.arduino import pinMode, digitalWrite, digitalRead, BTN, LED
from robovero.arduino import INPUT, OUTPUT
from robovero.extras import heartbeatOff

__author__ =			"Neil MacMunn"
__email__ =				"*****@*****.**"
__copyright__ = 	"Copyright 2010, Gumstix Inc."
__license__ = 		"BSD 2-Clause"
__version__ =			"0.1"

# no need for roboveroConfig()

heartbeatOff()

pinMode(BTN, INPUT)
pinMode(LED, OUTPUT)

while True:
	digitalWrite(LED, digitalRead(BTN))