YS-210 Game of Life 
Written by AnubisTTP on 2009-09-23  

Device Overview

The Yilane Systems YS-210 is a compact driver circuit which runs the Game of Life cellular automata on an 8x8 LED matrix. The Game of Life was developed by the mathematician John Horton Conway in 1970, and is without question the iconic example of cellular automata. The game is carried out on a grid of cells, and the rules are simple:

-Any live cell with fewer than two live neighbors dies from underpopulation.
-Any live cell with more than three live neighbors dies from overcrowding.
-Any live cell with two or three live neighbors lives on to the next generation.
-Any dead cell with exactly three live neighbors becomes a live cell.

The YS-210 runs Conway's Game of Life on a matrix of 64 LEDs, using an initial seed pattern supplied by the user. Unlike other such devices, the YS-210 allows the user to edit the pattern used for the initial state of the game directly, without any extra hardware, through the use of buttons installed around the device's edge. The speed at which the simulation runs, and the number of cycles before a reset, can also be set by the user. Patterns and other settings are stored in nonvolatile Flash memory, and are retained when power is removed from the device.


YS-210, normal operation.

Since the YS-210 uses a 16F628 PIC microcontroller, it is capable of being reprogrammed with a PC and a minimal amount of commonly available programming hardware. We suggest that the user buy their own PIC chip to program on, instead of overwriting the pre-installed chip and consequently erasing the default program. This device is also compatible with the older but very popular 16F84A microcontroller, which can be obtained from many sources.


YS-210, LED matrix removed. The LED matrix and integrated circuits are socketed for easy removal.

Functions

Pressing the Mode button on the side of the device will cycle through the unit's different settings. Each press of the Mode button will step to the next user-settable option, which are explained below. A final press of the Mode button will return the device to normal operation. The settings and pattern are stored in flash memory.

Speed: The speed menu allows the user to set the amount of time the device will display each step of the Life algorithm. When the speed menu is selected, the top half of the LED matrix will display an "S" and the bottom half will display the current operating speed in binary. Pressing the Right button will decrease the operating speed, pressing the Left button will increase the speed, and a press of the Mode button will save the settings and step to the next menu option.

Cycles: The cycles menu allows the user to set the number of cycles that will be calculated for a given pattern before the device will reset. When the cycle menu is selected, the top half of the LED matrix will display a "C" and the bottom half will display the number of cycles to be calculated in binary. Values between 1 and 255 can be selected by pressing the Left and Right buttons. Pressing the Mode button will cycle to the next menu option.

Editor: The editor allows the user to change the pattern used for the Life algorithm. When the editor is selected, an "E" will be displayed on the LED matrix. To activate the editor, press the Left button; the LED matrix will change to display the current pattern. To edit the pattern, press the Left button to scroll the selection horizontally, the Right button to scroll the selection vertically, and the Mode button to turn the selected cell on or off. To exit the editor and save the pattern, press and hold the Right button while pressing the Mode button.

Reset Procedure: If the on-board memory of the YS-210 becomes corrupted, the unit may be reset to its factory defaults. To reset the unit, hold down the Mode button while powering up the unit. Once the memory reset is complete, the unit will perform a display test by alternately flashing the left and right banks of LEDs, before returning to normal operation.


YS-210 functional diagram.

Power Connections

For the YS-210 to operate, the user must supply a +5VDC supply to power the logic circuitry and LED display. A common DC 'wall wart' power supply can be bought anywhere for less than $10, or you can use the 5V connection on a standard desktop computer power supply to supply the necessary voltage. When making the power connections, be sure to observe correct polarity as shown in the diagram above, as a reversed connection could damage the device.


Examples

Shown below is an example presentation of this kit installed in a homemade case, constructed by our lead engineer, Richard Kline. In this example, the YS-210 was installed in a stained and sanded wooden box with a cut acrylic front panel and machine screws.


YS-210, installed in custom enclosure.

Example Code

For those who want to flash their own programs for the device, here is example code that demonstrates how to draw an image to the LED matrix. The example code is for a PIC 16F84A, which the user can buy from various retailers. The user should purchase a blank 16F84A instead of trying to re-flash the microcontroller already installed in the device, as doing so will permanently erase the built-in software.

; File LEDmatrixdemo.ASM
; Assembly code for PIC16F84 microcontroller

;
;

; CPU configuration

processor 16F84A
include
__config _XT_OSC & _WDT_OFF & _PWRTE_ON
;--------------------------------------------

; Declare variables

J equ H'1F'
K equ H'1E'
mux equ H'20'

;------------------------primary onscreen area
cella equ H'21'
cellb equ H'22'
cellc equ H'23'
celld equ H'24'
celle equ H'25'
cellf equ H'26'
cellg equ H'27'
cellh equ H'28'
temp equ H'29'
rox equ H'2A'
ceox equ H'43'
eset equ H'44'
;-----------------------------------------------------
; Program
org 0 ; start at address 0

; Set ports and initialize

movlw B'00111100'
tris PORTA
movlw B'00000000'
tris PORTB
movwf PORTA
movwf eset
movlw B'00000001'
movwf PORTB
movlw D'8'
movwf mux
movlw D'9'
movwf rox

;-----------------load the offscreen with default values (Change these to change the image displayed)

movlw B'11111111' ;
movwf cella
movlw B'10000001' ;
movwf cellb
movlw B'10111101' ;
movwf cellc
movlw B'10111101' ;
movwf celld
movlw B'10111101' ;
movwf celle
movlw B'10111101' ;
movwf cellf
movlw B'10000001' ;
movwf cellg
movlw B'11111111' ;
movwf cellh

;----------------begin main loop
mloop: bcf STATUS,C

;Insert code here... change the contents of cella - cellh to change what is on the LED's

call segsend ; include this in your main event loop--- refreshes the LED sceen.

; Waste some time by executing nested loops (change this to change execution speed.)

movlw D'40'
call delay1

goto mloop ;---------------- end main loop

;----------------- generic delay routine

delay1: movwf J ; J := w
zloop: movwf K ; K := w
yloop: call segsend
decfsz K,f ; K = K-1, skip next if zero
goto yloop
decfsz J,f ; J = J-1, skip next if zero
goto zloop
return

;----------------- draw to bitmap
segsend: movfw mux
movwf temp
decfsz mux,1 ;skip if zero
goto segsend2
movlw D'8' ;reset the mux level
movwf mux
bsf PORTA,1 ; serial line high, new cycle

;---- and now to figure out which row we are on
segsend2: movfw temp
SUBLW 7 ;check and see if lsd is higher than 7
BTFSS STATUS,C
goto segd1 ; and do this if it is
movfw temp
SUBLW 6 ;check and see if lsd is higher than 6
BTFSS STATUS,C
goto segd2 ; and do this if it is
movfw temp
SUBLW 5 ;check and see if lsd is higher than 5
BTFSS STATUS,C
goto segd3 ; and do this if it is
movfw temp
SUBLW 4 ;check and see if lsd is higher than 4
BTFSS STATUS,C
goto segd4 ; and do this if it is
movfw temp
SUBLW 3 ;check and see if lsd is higher than 3
BTFSS STATUS,C
goto segd5 ; and do this if it is
movfw temp SUBLW 2 ;check and see if lsd is higher than 2
BTFSS STATUS,C
goto segd6 ; and do this if it is
movfw temp
SUBLW 1 ;check and see if lsd is higher than 1
BTFSS STATUS,C
goto segd7 ; and do this if it is
goto segd8
;--- end frame checks, begin drawing
segd1: movfw cellh
movwf temp
goto segend
segd2: movfw cellg
movwf temp
goto segend
segd3: movfw cellf
movwf temp
goto segend
segd4: movfw celle
movwf temp
goto segend
segd5: movfw celld
movwf temp
goto segend
segd6: movfw cellc
movwf temp
goto segend
segd7: movfw cellb
movwf temp
goto segend
segd8: movfw cella
movwf temp
goto segend
;---- and now we finally draw to the screen

segend: movlw B'11111111'
movwf PORTB ;--------------clear the screen
bsf PORTA,0 ; clock line high
movfw temp
movwf PORTB ;--- draw it
bcf PORTA,1 ; and clear the serial line
bcf PORTA,0 ; clock line low
return

; ------- rotate a byte, not through carry
rotx: rlf temp,1
BTFSS STATUS,C ; was low bit low
goto cob1 ; then do this
bsf temp,0
goto cob2
cob1: bcf temp,0
cob2: nop
return

end

©2000-2025 Industrial Alchemy. All rights reserved. | Switch to mobile version | Contact |