Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Thursday, November 7, 2013

Bare Bones Propeller Update v1.4

BARE BONES PROPELLER UPDATE V1.4

THE MOST ESSENTIAL PROPELLER CHIP CIRCUIT

BARE BONES is one of our favorite Propeller chip machines and continuing projects. In under ten minutes, it's possible to whip up this circuit and run the virtual LED programmed in Spin, blinking it on and off, watching it on the serial terminal.

This is the latest updated schematic to construct the Bare Bones Propeller circuit with the mentioned improvements. It has the main chip protection circuit added to the schematic for crisscross wiring and decoupling capacitors, ensuring a greater longevity chip.

ADDITIONS
The main schematic addition is one resistor to activate the BOEn disable circuit so that the Propeller can operate on less voltage, at or below the 2.7 volt reset limit. This allows experimenting with solar cells, smaller batteries with less voltage and other supply circuits. It also allows a battery to function at increased discharge levels and the Propeller chip can boot at a lower voltage.

VERSION
This updated Bare Bones Schematic is currently at version 1.4 and is subject to change without notice. It replaces versions 1.0, 1.1, 1.2, and 1.3. Use the blog's search feature to find any future changes. The suggestions from this thread, and some from another thread are now incorporated into the circuit to maximize Propeller chip performance, reliability, and facilitate ease of assembly for beginners.


LOWER POWER
The circuit allows lower power operations, mainly 3-volts with two (1.5 volts each) AA batteries, and experiments at lower voltages. Bare Bones is a good reference circuit and starting point for many projects. By itself, Bare Bones is considered to be a simple machine project with provided software on the schematic and the ability to communicate with a serial terminal, providing virtual representations.


PROPELLER TOOL SOFTWARE
http://www.parallax.com/downloads/propeller-tool-software
BARE BONES CODE
With no crystal needed, the program runs in rcfast (~12 mHz) and at 1200 baud to blink a serial terminal LED on and off. Hosted at the Parallax Forum, the link for download is found below or simply cut and paste the code into BST or the Propeller Tool software.


' Terminal LED Test Program           http://humanoidolabs.blogspot.com/
' Author: Humanoido (c) 07.18.2013    Terms of Use MIT License
' Runs on Bare Bones Propeller
' Blinks one serial LED
' Boot to RCFAST (~12MHz)
OBJ
   PST : "Parallax Serial Terminal"
PUB main
pst.Start(1200)
pst.str (string(13,"Serial LCD Demo",13,"Blink LED On and Off",13))
repeat
 pst.str (string("LED ON  *",13))
 waitcnt(clkfreq/2 + cnt)
 pst.str (string("LED OFF o",13))
 waitcnt(clkfreq/2 + cnt)


Attached Files bare bones 1.spin‎ (477 Bytes)

Sunday, August 25, 2013

Robot Explorer Log 4 Light Sensor

Parallax Penguin Robot light system. Credit: Parallax
VERY SENSITIVE ROBOT EYE
ROBOT EXPLORER LOG 4

 

USING THE TLS230 LIGHT TO FREQUENCY SENSOR

A study of interplanetary and moon conditions shows that specific locations will have much less lighting than on the Earth. Even a robot explorer on the Earth can experience dawn to dusk like conditions of less intensive lighting. How does one effectively measure sub lighting conditions?

In the left schematic, the phototransistor or CaS cell will measure the intensity of reflected light. This is good for determining the surface reflectivity of the ground. The top cell can be turned skyward to create a baseline reference. The system uses only 2 pins and is based on ambient planetary or moon light levels.

The schematic at right shows a system that provides the light source, to be shown on objects. The reflected light is detected. This system can be used for obstacle detection and avoidance in dark conditions.

The interest here is in measuring the ground material based on the lighting conditions. The typical IR combo transmitter receiver pair could do detection by transmitting IR light like a flashlight and looking for its reflective signature.

Perhaps a better approach is to read the signature from available light if the probe is operating in known minimal dawn or dusk conditions, and use a more sensitive programmable light to frequency chip manufactured by TI.


TSL 230 R
The program sets the sensitivity level, while two sensor chips, one a reference chip and the other chip viewing the unknown ground material takes readings for analysis. Such great sensitiviy and programming convenience comes at a price, by using more pins. Two chips use six pins. A transmitter receiver obstacle avoidance/detection IR system will typically use three pins.

One good, tried and true, method is that system used by the Parallax Penguin Robot. The schematic shows two systems utilized by this beloved little robot. It's a very powerful walking robot with many applications. The circuit uses RC methods to determine resistance which in turn is based on the level of light.

The Propeller program below is a snippet from the Parallax demo coded by Paul Baker and can be found at the link.




CON
  _clkmode = xtal1 + pll16x
  _XinFREQ = 5_000_000
  pin = 0 'pin connected to tsl230 output
  cbase = 1 'pin connected to S0 (S1 connected to cbase + 1)
  scale = %10 'scale value for tsl230 (=off,%01=x1,%10=x10,%11=x100)
  ctrmode = $28000000 'mode value for counter to operate as a frequency counter
OBJ
  term : "tv_text"
PUB go | old
  dira := %11 << cbase 'set scale pins to output
  outa := scale << cbase 'set scale value
  term.start(12) 'start terminal
  frqa := 1 'set counter to increment by one
  ctra := ctrmode + pin 'start counter
  repeat
   waitcnt(80_000_000 / 10 + cnt) 'wait for 100ms
   term.dec(phsa) 'output counter value
   term.out($0D) 'line feed
   phsa := 0 'reset counter value

Another program variation may be useful, as seen below. This depends on two objects, tv_text and tsl230.

tsl230 DEMO.spin
CON
_clkmode = xtal1 + pll16x
_XinFREQ = 5_000_000
OBJ
term : "tv_text"
lfs : "tsl230"
PUB Go
term.Start(12)
lfs.Start(0,1,10,true)
repeat
waitcnt(80_000_000 / 10 + cnt)
term.dec(lfs.GetSample)
term.out($0D)

AND yet here is another even more simplified demo. These programs were not found in the OBEX but rather on the Parallax Forum along with other code, including an object update by Mr. Degn. (see links)

CON
        _clkmode = xtal1 + pll16x
        _XinFREQ = 5_000_000
OBJ
  term : "tv_text"
  lfs  : "tsl230"
PUB Go
  term.start(12)
  lfs.Start(0,1,10,true)
  repeat
    waitcnt(80_000_000 / 10 + cnt)
    term.dec(lfs.GetSample)
    term.out($0D)


LINKS
Penguin Robot Society PRS 
http://www.p-robot.com/

Penguin Parallax Forum
http://forums.parallax.com/showthrea...061#post977061

Penguin Sticky
http://forums.parallax.com/showthread.php/97288-Penguin-Resources

Penguin Manual with Schematics
http://www.parallax.com/Portals/0/Downloads/docs/prod/robo/27313-6PenguinDoc-v1.0.pdf

Parallax Manual for TSL 230 R
http://www.parallax.com/Portals/0/Downloads/docs/prod/audiovis/27924-TSL230R-v1.0.pdf

TSL 230 R Chip Apps
http://www.thereminworld.com/Forums/T/26460/a-one-chip-theremin

TSL 230 R Sparkfun Source
https://www.sparkfun.com/products/retired/8940

TSL 230 R Data Sheet 
http://www.sparkfun.com/datasheets/Sensors/TSL230R-LF-e3.pdf

Forum Downloads for tsl230.spin & sts230 DEMO.spin
http://forums.parallax.com/showthread.php/117955-TSL230-Program-Question

Bug Fixes to tsl230 Object by Duane Degn
http://forums.parallax.com/showthread.php/148769-Bug-Fixes-to-TSL230-Object-in-Propeller-Tool-Library 

Thursday, August 1, 2013

Propeller Simple Spin Board Part 6

PROPELLER SIMPLE SPIN BOARD - PART 6

LOOP SWITCH
MAKE a loop switch (see photo) from a curved insulated wire, to switch from BOE ON to BOE OFF. With the BOE Brown Out Enable switch off, low power experiments can be conducted. With BOE ON, when the voltage supply approaches 2.7 volts, a Propeller reset will occur.

SIMPLE LED ON PROGRAM
As promised this is a more simple program to activate the LED on pin 15. With only four code lines, it will turn on the LED and keep in on. Add this simple 4-step program to your code repository for future experiments.

PUB LedOn          ' Method declaration
    dira[15] := 1  ' Set P16 to output
    outa[15] := 1  ' Set P16 high
 repeat            ' Keep LED on

Monday, October 15, 2012

How to Make Life in the Universe

A Universe Inside the Big Brain Achieves Life on March 1st, 2011
Big Brain's universe of life
HOW TO MAKE LIFE IN THE BRAIN UNIVERSE 
Big Brain Achieves Cellular Automatronic Life - Propeller Program gives life to the Brain 

Big Brain Date March 1st, 2011  08:27 am
Code p17#333 

Above Actual photo of this amazing Universe of Life, which is still unfolding inside the Propeller Brain, has evolved over a time period of one hour! Looking like stars in the galaxy, these are actually evolutionary cellular life forms.

Left Wired for Evolving Automatronic Life, the Brain is alive as seen in this window of the unfolding Universe portal, made possible by a Parallax 3.5-inch TV as a viewer and computational Propeller chips.

Sometimes you find life in the strangest of places living under the strangest conditions. This is one such example, which is developed by Cambridge mathematician John Conway. In this Brain Automata, Life is created through collections of living cells that are born, breed and die, based on the mathematical conditions imposed upon Universe life. Throughout their lifetime, they form groups and patterns of considerable importance.


Conway's work was popularized in a 1970 Scientific American article. It has become a must know/must read work for Artificial Intelligence followers as well as a litmus for various fields of mathematical academia.

The universe of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in various states, alive, breeding, or dead. Each cell interacts with eight neighbors, which are horizontally, vertically, or diagonally adjacent.

During each step of evolutionary time, the following happens: 


For a space that is 'populated'

  • Each cell with one or no neighbors dies, as if by loneliness.
  • Each cell with four or more neighbors dies, as if by overpopulation.
  • Each cell with two or three neighbors survives.
For a space that is 'empty' or 'unpopulated' Each cell with three neighbors becomes populated.The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed — births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick (each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations.

Starter Code Downloads - PropBASIC demo program
"Conway's Game of Life" 
Here is another PropBASIC demo program. This is Conway's game of life on a 256x192 matrix. The pbas code will run under Propbasic language and spin code runs with Spin language - both are written for the Parallax Propeller chip. Output is NTSC from the Demo board.  Code presented by Bean at the Parallax Forum:
http://forums.parallax.com/showthread.php?124495-Fill-the-Big-Brain&p=981338&viewfull=1#post981338
Download here
video_life.pbas

video_life.spin

MonoVid.spin
 

Expanding the Code
Try changing the variables. For example, the number of life generations can indicate the level of evolution of a given life form's technology. Try making cells into equivalent neural maturations and relate their effectual evolutionary traits.

Hardware
The code runs on the Big Brain. The starter code shown here will run on the Parallax Propeller Demo Board. See parallax.com.

Friday, October 5, 2012

Propeller Nano Pulsar

GMM Microscope image of a Nano Pulsar
PROPELLER CHIP NANO PULSAR
NANO Technology is here for the Propeller chip! Take a look at this Nano Pulsar created from Propeller SPIN code that operates inside a single Parallax Propeller chip!

This Nano Pulsar is a mere 10-ns to one side and represents the fastest machine inside the chip, currently known in the Propeller world!

Propeller aficionados may be aware of some techniques provided by Parallax to enable the programming of registers belonging to a configurable state machine. There are 32 different modes that program the most spectacular machines. There are two counter modules per Cog with eight Cogs to a single chip for a total of sixteen powerful state machines. The Brain has taken just one Propeller Counter Module and configured it to a powerful Nanotechnology 10-ns Machine.

{
      ************************************************************************
      ************************************************************************
      ***                                                                  ***
      ***                     Propeller Nano Pulsar 2                      ***
      ***                        Nano Result at Pin                        ***
      ***                        prop_pulsar2.spin                         ***
      ***                                                                  ***
      ***                                                                  ***
      ***                             V01.0                                ***
      ***                           Humanoido                              ***
      ***                                                                  ***
      ***                                                                  ***  

      ************************************************************************
}
CON

                 ' Declare constants, Feedback/PLL multiplier  
   _clkmode = xtal1 + pll16x 
                 ' External oscillator 6.25 MHz Crystal for 100MHz
   _xinfreq = 6_250_000     
                 ' 200MIPs, 25MIPs/Cog PUB Toggle3(Pin)
                 'Use cog's counter module, toggle at clock speed
dira[Pin]~~      'Set I/O pin to output
                 ' mode PLL BPIN APIN
ctra := 100_000 << 23 + 1 << 9 + Pin

                 'Establish mode and APIN (BPIN ignored)
                 'Set FRQA so PHSA[31] toggles every clock
frqa := $8000_0000
repeat           'infinity loop

Thursday, February 2, 2012

New Math & Fibonacci

NEW MATH & FIBONACCI PACES BIG BRAIN In 7th grade, New Math was introduced. I simply did not get it. In an effort to help, my mother took New Math class in the evenings. New Math was so time demanding, she dropped out of class! The next year, New Math was dropped from the school curriculum. I somehow made it past those days and went on to graduate from the university with a degree in Mathematics.

New Math is being introduced to the Big Brain. Don't worry, it's not the old version, but rather a sequence of mathematical applications designed to pace the Big Brain in various ways. The following is a list of potential math applications to run with Propeller chips from which there's an enormous amount of web based information. One area of interest is in the generation of Fibonacci numbers. You can play with these numbers using the Online Generator  or take a look at Bomber's creation of code posted at the Parallax Forum.

Code below. Description quote: "Using a Basic Stamp version of a Fibonacci number generator, I created a Propeller version. It is able to generate Fibonacci numbers up to 1,836,311,903! It is designed to run off of a C3 (using only TV output and an LED hooked up to pin 15). The code can be easily modified to give output to the PST or VGA output. EDIT: Rev 1.4 of code released. The main differencs are as follows: 1) No "magic" numbers  2) Waits for the monitor to 'initalize' (our monitor takes several seconds to realize it is recieving a signal)  3) Increased timing duration. EDIT: Rev 1.5 of code released. Adds a zero at the beginning of the sequence."

List of Big Brain Math Applications &
Numerical Subjects for Development
-------------------------------------------
Derivative calculator
Integral calculator
Definite integrator
Limit calculator
Equation solver
Expression simplifier
Factoring calculator
Expression calculator
Inverse function
Taylor series
Matrix calculator
Matrix arithmetic
Prime numbers
Number factoring
Fibonacci numbers
Bernoulli numbers
Euler numbers
Complex numbers
Factorial calculator
Gamma function
Combinatorial calculator
Fractions calculator
Statistics calculator
Equation editor
Graphing calculator


Program to Calculate Fibonacci Numbers
by Bomber

CON
  _clkmode = xtal1 + pll16x                            ' define clock frequency
  _xinfreq = 5_000_000
  
  CR          = $D                                     ' Carriage Return    
  
OBJ
 time    : "Timing"                                    ' Timing conviences
 TVtxt    : "tv_text"                                  ' Television Display Object

VAR
  long a, b, c                                         ' a and b are the last two numbers in the sequence
                                                       ' c is the new number being added to the end of the sequence.


PUB Main                                  
 TVtxt.start(12)                                       ' Start TV terminal       
 dira [15] := 1                                        ' Enable blinky light
 outa [15] := 1                                        ' Turn off blinky light (active low)   

 TVtxt.out($0)                                         ' Set the text color as on  
 TVtxt.out(0)
    
 a := 1                                                ' Make variable a = 1
 b := 1                                                ' Make variable b = 1


 repeat                                                ' Endless repeat


   a := b                                              ' Make a equal to b 
   b := c                                              ' Make b equal to c   
   c := a + b                                          ' Add a + b (stored in c)


   TVtxt.dec(c)                                        ' Display number
   TVtxt.out(CR)                                       ' Carriage Return
   
   if c == 1836311903                                  ' Prevent sequence from carrying over
     End
     
   time.Pause(250)                                     ' Wait for 1/4 of a second (250ms)
PUB End
  TVtxt.str(string(CR, "END OF COMPUTABLE SEQUENCE"))  ' Display error message
  
 repeat                                                ' Endless repeat
   outa [15] := 0                                      ' Blink LED (P15)
   time.Pause(250)
   outa [15] := 1
   time.Pause(250)  

Thursday, December 29, 2011

Brain Bouncing Computing Algorithm

BRAIN BOUNCING COMPUTING ALGORITHM
This technique is an algorithm that engages a bouncing method in the Big Brain chip Partitions and arrays to employ the use of available chips for computing in the collective. A code is used to bounce from chip to chip and determine the in-use status based on chip self flagging. A chip is flagged busy when its tied up thinking. The bouncing code bypasses a busy flag chip and collects chips for use that are not busy. The Bounce Code is as follows:

Chip Status:
Flag = Busy
  or
Flag = Not Busy
If Flag = Busy then Bounce
If Flag = Not Busy then Engage

Definitions
Brain Bouncing - algorithm used to find chips available for use. Code is used to bounce from chip to chip and determine the in-use status based on chip self flagging.