Saturday, October 12, 2013

BEAM/Picaxe 20x2 Turbot

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.

The first Turbot was designed and named by Mark Tilden as "Turing Machine Robot" A turing machine is described by Turing himself as having "an unlimited memory capacity obtained in the form of an infinite tape marked out into squares, on each of which a symbol could be printed. At any moment there is one symbol in the machine; it is called the scanned symbol. The machine can alter the scanned symbol and its behavior is in part determined by that symbol, but the symbols on the tape elsewhere do not affect the behavior of the machine."

Tilden reasoned that this type of robot then in effect is operating with the earth itself as the "infinate string" and based on the string of information provided (gravity and light).

I initially was using the scruff circuit by J Wolfgang Goerlich and a Miller Solar Engine. I developed the 08m2 solar engine when I fried my miller solar engine, and added it to the turbot. It worked great, but there was a problem somewhere in the 74AC245 portion of the circuit, I could only get it to work if I shielded the eyes from light with a piece of black electrical tape. Bummer! I tried to troubleshoot the problem, but because I tightly freeformed the circuit inside the IC socket, and making changes to it were troublesome to say the least. I considered a few alternatives, like redoing the circuit or changing it so the '245 would only drive the motors under the Picaxe's direction. Finally I settled on using a Picaxe 20x2 that I had on hand.

Although I couldn't find and references on the 'net to anyone driving a motor directly from uC pins, but because the 74AC245 could drive them, I knew my motors (GM14a) were efficient enough... if I ganged up the outputs. The risk is you might toast your Picaxe chip by forcing it to source and sink too much current, but this is a risk I was willing to take. So after freeforming a new IC socket for the 20X2 and re-assembling this bot for (hopefully) the last time, I wrote a basic program that combines the solar engine and light sensing from the eyes and the solar panels. I made the program emulate the scruff circuit, by driving one motor or the other, forward or reverse, based on which side is up and which eye is seeing more light. I had to make sure that the Picaxe turned the outputs in just the right order to avoid a short circuit or wasted power dropped across both motors through the common connection. Using the dirsX and pinsX basic commands allowed me to achieve this.

It was alive! Next I tweaked the trigger level higher until it never triggered without having enough voltage to power the motors. It was tempting to set the trigger level low so it would work better in lower light conditions (a desk lamp), but testing with a multimeter revealed that a trigger level lower then 3.3v would sometimes activate and not spin the motors ,wasting it's charge. With lower voltage motors one could easily lower this number for better low light operation.

This Turbot's 'tail' is a 4x6 pin male header (actually (2) 2x6 super glued together) with the pins laid out such that by connecting jumpers to the proper pins you can change which motor moves which direction. It is like a switchboard allowing motor connections to be change on the fly, this allows for less thought when assembling as to which motor is going to spin which direction. I recommend taking the time to make this piece since it has proven very useful, and in this layout it is the perfect size.

The motors, IC socket, and male headers are all the same size, allowing a for unibody construction sandwiched between the (2) 4.2v 22mA solar panels. The up/down sensing is achieved by reading the ADC the midpoint of the two panels, thereby avoiding another set of eyes. The arms are made out of a wire handle from a fruit basket, washers, and dubro wheel collars. Super gluing the pieces of the arm together and then pouring JB Weld into the space in between the washers and the wire made very strong arms that are removable too.

Update: I can't stop blogger from stripping parts of the Picaxe code out every time I post it. If you have a solution to this issue please let me know so I can repost it or you can get it from pastebin here:

Saturday, September 28, 2013

SBSE v1 A new Picaxe 08m2 based solar engine

While working on a tiny turbot robot recently, I realized that I had the wrong trigger for my miller solar engine. A miller solar engine is a very reliable way to monitor power storage coming from a solar cell into a storage capacitor. When the voltage hits the 'trigger' voltage (decided by the type of 1381 IC used) it sends an high signal to an npn transistor which switches on a motor, drains the capacitor and then the whole cycle starts again. There are other types of solar engines too, but the miller is seen as the most reliable. Anyway I realized I had the wrong trigger voltage for my motors. It would trigger at 2.5 volts and that just was not quite enough to start up the 6 volt motors I am using. I added some diodes to increase the trigger voltage, and hooked it up to a power supply to test. POOF! like a small magic trick my solar engine went up in smoke! Well now I was out of 1381 IC's, and I really did not want to order any more. So out of necessity I made a new type of solar engine circuit.

While most solar engines activate at a certain voltage (type 1 SE) some activate based on elapsed time (type 2 SE). This new solar engine circuit is a type 3 SE... Which means it triggers based on whether the voltage on the storage capacitor is rising or stable (fully charged). If the solar cell is nominally outputting 4 volts in the noon sun it might only put out 3 volts in the evening either way the capacitor can only charge up to the voltage being output by the solar panel. This means that with a type 1 SE and a 3.5 volt trigger you will only charge up to the trigger level in strong lighting, But with a type 3 SE you can trigger in a greater range of light levels.

Enter the SBSE v1 (Smart Beam Solar Engine). This circuit samples the voltage in regular intervals and saves the result, comparing it to the previous reading. If the voltage has not risen since the last reading, then it knows it's topped off and not going to be charging much more, so it sends it's enable low signal to other circuitry to signal that it's time to go. There is also a variable voltage trigger. If the capacitor is only charging to 2.5 volts and you know your motors wont activate without at least 3 volts, you set the trigger level such that it will not activate unless there is enough voltage, and then only if the voltage on the storage capacitor has stopped rising.

How it works:

When the voltage on the storage cap reaches the minimum required voltage of the Picaxe 08m2, it turns on, sets the clock frequency of the picaxe to 31k to conserve power, and starts testing the voltage. It does this by making the cathode of the diode @ pin c.0 (TestVin) output low, allowing the voltage to pass through the 10k pullup and diode. Then the Picaxe samples the voltage drop across the diode with the pin c.1 (Vin) and when it is done it then sets pin c.0 high again (to save power the diode is only seeing voltage when testing). The ADC of the picaxe is set to return a value between 0 (Gnd) and 255 (Vcc). By measuring the voltage drop of the diode as shown, you return a value that changes depending on the voltage of the storage cap.

The cap has stored 3.5 volts = 255
The voltage drop of the diode is .7 volts (for a 1n914 signal diode)
So 255 / 3.5 = 73
73 * .7 = 51

So when our ADC reading drops to 51 or lower we are above 3.5 volts. The TriggerLevel has been met (if set at 51) and now the Picaxe starts saving test results to compare to new readings.

By varying the TriggerLevel we can therefore set the minimum voltage required for activation.

Now we have a small cap for storage maybe 3300uf, we want to set the TestFreq to a low setting to test the voltage frequently. This small cap charges fast so we need to test often to know when the voltage tops off. If you are using a super cap, you will want to adjust your TestFreq to sample the voltage less often. The reason being that it takes more time to charge a super cap so you want to sample slower to give it the required time to charge. Adjustment is required to allow for the size of the solar cell and size of capacitor.

Finally there is a MaxOnTime variable that sets how long you want to run the motor. This is useful for robots with a large super capacitor that you want to run in bursts, not completely draining the capacitor in each cycle. For my application I needed the turbot to move its arms a certain max amount at a time before stopping and re evaluating where the light is coming from.

Other notes:
If you want to drive a motor directly (for a photopopper or symet, etc...) use a transistor and series resistor from the enable pin c.4 (DumpPWR). If using an NPN transistor change the code to set the initial state of DumpPWR to low and the active state to high. Also change the 100k pullup resistor to a pulldown resistor. As is below though, the signal is an enable low.

Use the nap reference so set the timing. See the chart below. While 'napping' the Picaxe is in a very low power sleep mode to conserve power.

Thoughts for improvements:
For a further improvement in efficiency, pulling pin c.3 low with a resistor, and also pulling c.2 low and setting it to an output would cut the amount of current consumed by the picaxe.

One might use the unused ADC on pin c.2 to set the value of the TriggerLevel or TestFreq variables using a potentiometer wired as a voltage divider, thereby allowing 'tweaking' of the settings without re-programming the chip.

The circuit and program:

'       _                       _
'   ___| |__  ___  ___  /\   /\/ |
'  / __| '_ \/ __|/ _ \ \ \ / /| |
'  \__ \ |_) \__ \  __/  \ V /_| | James White
'  |___/_.__/|___/\___|   \_/(_)_| 9/20/13
'                      Schematic:
'                          SMART BEAM SOLAR ENGINE TYPE 3
'  <-----------------------------------------------+  
'   GROUND                                         |  
'  <-------------------------------------------+   |  
'   SERIAL IN                                  |   |  
'  >-------------------------------+           |   |  
'   ENABLE                 ____    |    ____   |   |  
'  <---------------+  +---(____)---+---(____)--+   |  
'                  |  |     22k          10k   |   |  
'   Vcc           _|__|_    .----+--+----.     |   |  
'  <----+--------/ |  | \--[|Vcc '--' Gnd|]----+   |  
'       |          |  |     |   PICAXE   |         |  
'       |          |  +----[|C.5      C.0|]--------+--|<|--+        
'       |   ____   |        |    08M2    |           1N914 |         
'       +--(____)--+-------[|C.4      C.1|]----------------+         
'       |   100k            |            |                 |         
'       |               NC [|C.3      C.2|] NC             |       
'       |                   `------------'                 |
'       |                        ____                      |
'       +-----------------------(____)---------------------+
'                                 10k

|===  Nap Reference  ===
|     value  time
| 0  = 18ms
| 1  = 32ms
| 3  = 72ms
| 4  = 144ms
| 5  = 288ms
| 6  = 576ms
| 7  = 1.1s
| 8  = 2.3s
| 9  = 4s
| 10 = 8s
| 11 = 16s
| 12 = 32s
| 13 = 64s
| 14 = 128s

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

  symbol      TestVin = c.0    ' connect to cathode of diode
  symbol          Vin = c.1    ' connect to anode of diode and to 10k pullup resistor
  symbol      DumpPWR = c.4    ' enable low output
' ======  Variables  ======

  symbol TriggerLevel = b0     ' min voltage to dump power  (set @ 45 for 3v trigger)
  symbol  TestResults = b1     ' results from voltage test
  symbol PreviousTest = b2     ' previous test results to compare to most recent test
  symbol     TestFreq = b3     ' how long to wait in between checking the voltage
  symbol    MaxOnTime = b4     ' maximum amount of time to dump power in one go
' ======  Directives ======

  #picaxe 08m2

' =============================== Begin Program ===============================

  setfreq k31                  ' set clock speed to lowest setting to conserve power
  high DumpPWR                 ' this pin has a 10k pullup
  high TestVin                 ' we want this pin high until time to sample the voltage
  let TriggerLevel = 45        ' min voltage at which the SE will trigger
  let PreviousTest = 255       ' start with a zero volt reading    
  let TestFreq = 8             ' this number decides how long to wait between samples
  let MaxOnTime = 9            ' maximum amount of time to dump power


  nap TestFreq

  low TestVin
  readadc Vin, TestResults
  high TestVin
  if TestResults >= TriggerLevel then goto test
  if TestResults < PreviousTest then goto save

  goto enable
  let PreviousTest = TestResults
  goto test

  low DumpPWR
  nap MaxOnTime

Monday, September 23, 2013


Well it's really about time I set up a place where I can put all of my projects, for the world to see. I look forward to sharing my successes and failures alike as I do what I love... making!

I have quite a few finished items I will be adding to the completed projects section as I have time. I have added the Sunflower Robot & Herbie the Bristlebot to my completed project pages. I also have a few current projects that I will start updating progress on. These include:

  • Triclops - a three eyed light seeking Symet.
  • An as of now unnamed Turbot, based on the scuff circuit by J Wolfgang Goerlich
  • SBSEv1 - A type 3 solar engine based on the picaxe 08m2
I'm sure there are a few surprises I'll add in too, like tips, tools and lessons learned. Stay tuned!