Let's Make Robots!
tc  

Well... I finally wrapped up the little Turbot I have been working on. A Turbot is a robot that moves about using spinning flagella (arms) much like a bacteria moves about. Tumbling along, charging, looking for light and then moving towards it. With only two arms, a Turbot with bi-directional flagella is capable of a surprising number of gaits or series of motions that move it along. My favorite besides the basic forward tumble is a backward hop scoot that reminds me of a crab.

Edit: I added some pics and code below:

' ======  Constants  ======

  symbol      TestEyes = c.0					' set pin low to read 
  
  symbol	Panels = c.1					' adc9
  
  symbol          Eyes = c.7					' adc3
  
' ======  Variables  ======

  symbol TriggerLevel = b0
  
  symbol  TestResults = b1
  
  symbol PreviousTest = b2
  
  symbol     TestFreq = b3
  
  symbol    MaxOnTime = b4
  
  symbol       Motors = b5
  
  symbol     MotorCom = b6

    
' ======  Directives ======

  #picaxe 20x2
  
  #no_table
  
  #no_end
  
' ======================================= Begin Program =======================================

  high TestEyes						       	' disable photobridge until it's time to look around
  
  disablebod						        ' disable brown out detection to save power
   
  pullup  %00000010					    	' enable pullup on unused input only pin c.6
  
  let dirsB = %11111111						' set motor connections %xxxxyyyy as outputs ONLY in this format!!! %10101010 or anything
                                  ' else other than the %xxxxyyyy format will kill your picaxe. You have been warned!!!
  
  let dirsC = %00111101						' set motor common connection and TestEyes as outputs, ADC's and unused pin are inputs
  
  let adcsetup = %0000001000001000' setup adc 3 & 9
  
  let TriggerLevel = 80						' 87 = 3v  90 = 2.9v etc... Figure like this: 255/Desired Voltage * 1.024 = TriggerLevel
  
  let PreviousTest = 255					' start with a zero volt reading	
  
  let TestFreq = 1						' this number decides how long to wait between power storage capacitor samples
  
  let MaxOnTime = 2						' maximum amount of time to run a motor
  
  
test:

  setfreq k31

  sleep TestFreq						' store some electrons
  
  setfreq m8
  
  calibadc TestResults						' read ADC value of 1.024v internal voltage reference
  
  if TestResults >= TriggerLevel then goto test	' has the voltage of the storage capacitor reached our minimum? if not go store more electrons
  
  if TestResults < PreviousTest then goto save			' we are past trigger level, if our test was a lower value then voltage is still rising. save results

  goto enable							' if we are here then we are over the trigger voltage and the voltage has stopped rising. time to m
  
  
save:
  
  let PreviousTest = TestResults				' save the test results
  
  goto test							' go store more electrons
  
  
enable:
  
  readadc Panels, TestResults					' test the solar panels to see which side is pointing up
  
  if TestResults >= 127 then let MotorCom = %00111101 		' if high set portC motor common connection high
  
  else let MotorCom = %00000001					' or if low set portC motor common connection low
  
  endif
  
  low TestEyes							' enable the photobridge
    
  pause 1							' let the photobridge settle for 1ms
 
  readadc c.7, TestResults					' reuse our TestResults variable to save the results
  
  high TestEyes							' disable photobridge
  
  if TestResults >= 127 then let Motors = %11110000		' if high set portB motor connections !Warning %xxxxyyyy format ONLY!
  
  else let Motors = %00001111					' if low set portB motor connections !Warning %xxxxyyyy format ONLY!

  endif
  
  if MotorCom = %00111101 then let dirsC = %00000001		' if PortC is high we need to set portB high first. so make change portC into inputs temporarily
  
  endif
  
  if MotorCom = %00111101 then let pinsB = %11111111		' if PortC is high we need to set portB high first. so set portB high

  else let pinsB = %00000000					' or low (it should be already though through its default state)
  
  endif
  
  let dirsB = %00000000						' make portB into inputs temporarily
  
  let dirsC = %00111101						' portC is ready to go, change into outputs
  
  let pinsC = MotorCom						' and set the final signal to the motor common connection
  
  let dirsB = %11111111						' set portB to output. at this point the polarity will match the common connection
  
  enablebod                       				' turn on brown out protection, because we are to about to brownout the picaxe
  
  setfreq k31
  
  let pinsB = Motors						' set the final signal to the individual motors

  sleep MaxOnTime						' one of the motors is moving, for a max amount of time (if the power is there for it)
  
  reset								' it might drain the capacitor and brownout the picaxe, but maybe not. reset just in case

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
viswesh713's picture

BEAM bots/

lumi's picture

Congrats dude \o/

Yahmez's picture
lumi's picture

Nice little BEAM bot. I would love to see more details, e.g. how did you program the MCU and how the motors are trigegred...i mean what is the scheme which motor is going to run next?

Youcan include the video directly into your post by clicking on "Edit" and pasting the URL in the fields for videos. There is a drop down list for video, click there...

Yahmez's picture

Thanks Lumi!

In the programming for this little guy, I emulated the original circuit I was trying to use. The Scuff turbot by J Wolfgang Goerlich used a circuit he designed called the 'Solar Turbot Latch'  Basically this circuit connects the motors together so there are three outputs, one motor can go forward or reverse, one at a time. The motors are connected to a common connection, this connection goes high or low based on an ADC reading of which solar cell is getting light.  The individual motor outputs are high and low based on the ADC of the photobridge (eyes). I had to use dirsX & pinsx commands to carefully switch the motors on without dropping power across both motors, or shorting anything out.

It's programmed through his 'tail' there were extra pins for serin, serout & gnd. Or you can just pull the chip and program from a breadboard.

The other pins and jumpers are a switchboard and allow for changing motor and direction on the fly, programming without programming. 

Snippit of code:

  readadc Panels, TestResults ' test the solar panels to see which side is pointing up

  if TestResults >= 127 then let MotorCom = %00111101 ' if high set portC motor common connection high

  else let MotorCom = %00000001 ' or if low set portC motor common connection low

  endif

  low TestEyes ' enable the photobridge

  pause 1 ' let the photobridge settle for 1ms

  readadc eyes, TestResults ' reuse our TestResults variable to save the results

  high TestEyes ' disable photobridge

  if TestResults >= 127 then let Motors = %11110000 ' if high set portB motor connections !Warning %xxxxyyyy format ONLY!

  else let Motors = %00001111 ' if low set portB motor connections !Warning %xxxxyyyy format ONLY!

  endif

  if MotorCom = %00111101 then let dirsC = %00000001 ' if PortC is high we need to set portB high first. so make change portC into inputs temporarily

  endif

  if MotorCom = %00111101 then let pinsB = %11111111 ' if PortC is high we need to set portB high first. so set portB high

  else let pinsB = %00000000 ' or low (it should be already though through its default state)

  endif

  let dirsB = %00000000 ' make portB into inputs temporarily

  let dirsC = %00111101 ' portC is ready to go, change into outputs

  let pinsC = MotorCom ' and set the final signal to the motor common connection

  let dirsB = %11111111 ' set portB to output. at this point the polarity will match the common connection

  let pinsB = Motors ' set the final signal to the individual motors


lumi's picture

Thanks for your detailed explanation, now I understand. I am not familiar with Picaxe at all, so it's only for my personal reference :-)

Yahmez's picture

Oops double post

Yahmez's picture

No problem Lumi. Truthfully I am very much a novice when it comes to picaxe & programming in general. Hell this is the first program I have ever wrote from scratch that has some actual use. I have enjoyed working with the picaxe in basic it has been fairly straightforward and its simple to download the programs.

lumi's picture

For the first program it's quite impressive :-)

I've got a Picaxe from my friend isotope but did not have time yet to play with it...will give it a try after the weekend.

Yahmez's picture

Thanks MetalMonkeyLad.

I would argue that using a uC is not necessarily outside the realm of beam. Some of the first solar engines Mark Tilden made used 'Happy Birthday Singer Modules' as the time trigger. That's the chip inside old greeting cards that played a preprogrammed happy birthday tune. Although most 'beam' bots do not utilize a uc, I don't believe BEAM's inherent design philosophy prohibits them either.

Speaking of KISS I managed to drop off a decent amount of components just switching from one 20 pin chip (74AC245) to another (Picaxe 20x2). Plus ganging up outputs to drive the motors directly makes it more beam in my head at least.

I guess I think about this stuff too much! =P