SimpleTronic
Published © GPL3+

Lissajous Figures on 8x8 LED Matrix

Display dynamic Lissajous figures on an 8x8 LED matrix (or 64 discrete LEDs) with a PIC16F627 microcontroller.

IntermediateFull instructions provided5 hours305

Things used in this project

Hardware components

Microchip PIC16F627
×1
Texas Instruments SN74HC00
×1
Resistor 220 ohm
Resistor 220 ohm
×7

Story

Read more

Schematics

Lissajous Figures

Code

lissajous.HEX

Assembly x86
:020000040000FA
:100000008B1307309F008316003085008600831213
:10001000A001A101A6010130A7003F30A2003F309E
:10002000A300271437205E20A40B1228A71C1A282F
:100030000130A500A50B12282608103C031826281D
:100040002608303C031C2628A7142728A7102608BA
:100050003E3A031D2C2827102608013A031D31289B
:10006000271427183528A6033628A60A1228A30B1A
:1000700008003F302607A3002008163A0319452838
:10008000200847208500A00A0800A0010800820778
:10009000FD34FD34FD34FE34FE34FF34F834F434E2
:1000A000EC34BC34BC347C347C347C34BC34BC3460
:1000B000EC34F434F834FF34FE34FE34A20B080080
:1000C0003F30A2002108163A03196B2821086D2041
:1000D0008600A10A0800A10108008207013401344A
:1000E00001340234023404340834103420344034EF
:1000F00040348034803480344034403420341034F0
:08010000083404340234023417
:02400E0070211F
:00000001FF

lissajous.asm

Assembly x86
;####################################
;<<<<<<< LISSAJOUS ART V1.0 >>>>>>>>
;Marcelo Requena 2018 (SimpleTronic)
;####################################


;********************************
;	INIT
;********************************
	processor pic16f627a
	#include <p16f627a.inc>
	__config b'0010000101110000' ;intocc 4mc; portA<6> i/o
	ERRORLEVEL 1	

;******************
;    	INIT
;******************
		cblock	0x20
	loopA
	loopB
	iter
	iter2
	mod1
	mod2
	lfo
	flags ;( flags<0-1> ) 
		endc

#define	BANK_1	bsf STATUS,5
#define	BANK_0	bcf STATUS,5
#define	down	bcf flags,0
#define	up		bsf flags,0


	bcf		INTCON,7 ;disable GIE 
	movlw	B'00000111' ; enable portA i/o - disable comparators
	movwf	CMCON

	BANK_1
	movlw	b'00000000'
	movwf	TRISA
	movwf	TRISB
	BANK_0			;all to out (exc A5)

	clrf	loopA
	clrf	loopB
	clrf	lfo		
	movlw	b'00000001'
	movwf	flags
	movlw	.63
	movwf	iter
	movlw	.63
	movwf	iter2
	up

;***************************************
; Main Program Loop
;***************************************
ploopin
	call	SUB_A		
	call	SUB_B

;loop timer**********************************
	decfsz	mod1	;timer
	goto	ploopin	;timer
	btfss	flags,1 ;skip cycles if set
	goto $+3
	movlw	.1
	movwf	mod2
	decfsz	mod2	;timer
	goto	ploopin	;timer

;speed up cycle *************************
	movfw	lfo
	sublw	.16	; 	16-lfo 
	btfsc	STATUS,C	
	goto	normal	; result lfo= 0-16 continue

	movfw	lfo
	sublw	.48		; 48-lfo 
	btfss	STATUS,C	
	goto	normal	; continue	
	bsf		flags,1	; accel cycle
	goto	more	
normal
	bcf		flags,1	; normal cycle

;Up/Down *********************************
more
	movfw	lfo
	xorlw	.62
	btfss	STATUS,Z	
	goto	$+2
	down

	movfw	lfo
	xorlw	.1
	btfss	STATUS,Z	
	goto	$+2
	up

	btfsc	flags,0
	goto	$+3	
	decf	lfo
	goto	$+2
	incf	lfo
	goto	ploopin

;*************
SUB_A
;*************
	decfsz	iter2
	return			;1	
	movlw	.63		;0
	addwf	lfo,w
	movwf	iter2	

	movfw	loopA	
	xorlw	.22		; is it 22 ?	
	btfsc	STATUS,Z
	goto	$+6		;z=1 is 22 ,reset	
	movfw	loopA   ;z=0 not 22, continue
	call 	SUB_A_TABLE		
	movwf	PORTA	;insert to A	
	incf	loopA
	return
	clrf	loopA
	return			

;*************
SUB_A_TABLE	; port a ; bits <0:1> drive rows 1-2-3
;*************
	addwf	PCL	; w contains offset 1-22

	retlw	b'11111101'	;01 decoder
	retlw	b'11111101'	;01 decoder
	retlw	b'11111101'	;01 decoder
	retlw	b'11111110'	;02 decoder
	retlw	b'11111110'	;02 decoder
	retlw	b'11111111'	;03 decoder
	retlw	b'11111000' ;04
	retlw	b'11110100' ;05
	retlw	b'11101100' ;06
	retlw	b'10111100' ;07 skip A5
	retlw	b'10111100' ;07 skip A5
	retlw	b'01111100' ;08
	retlw	b'01111100' ;08
	retlw	b'01111100' ;08
	retlw	b'10111100' ;07
	retlw	b'10111100' ;07
	retlw	b'11101100' ;06
	retlw	b'11110100' ;05
	retlw	b'11111000' ;04
	retlw	b'11111111'	;03 decoder
	retlw	b'11111110'	;02 decoder
	retlw	b'11111110'	;02 decoder

;*************
SUB_B
;*************
	decfsz	iter
	return			;1	
	movlw	.63	;0
	movwf	iter

	movfw	loopB	
	xorlw	.22		; is it 22 ?	
	btfsc	STATUS,Z
	goto	$+6		;z=1 is 22 , reset	
	movfw	loopB   ;z=0 not 22, continue
	call 	SUB_B_TABLE
	movwf	PORTB	;insert to B	
	incf	loopB
	return
	clrf	loopB
	return	


;*************
SUB_B_TABLE	; port b
;*************
	addwf	PCL	; w contains offset 1-22

	retlw	b'00000001'	;01 
	retlw	b'00000001'	;01 
	retlw	b'00000001'	;01 
	retlw	b'00000010'	;02 
	retlw	b'00000010'	;02 
	retlw	b'00000100'	;03 
	retlw	b'00001000' ;04
	retlw	b'00010000' ;05
	retlw	b'00100000' ;06
	retlw	b'01000000' ;07 
	retlw	b'01000000' ;07 
	retlw	b'10000000' ;08
	retlw	b'10000000' ;08
	retlw	b'10000000' ;08
	retlw	b'01000000' ;07
	retlw	b'01000000' ;07
	retlw	b'00100000' ;06
	retlw	b'00010000' ;05
	retlw	b'00001000' ;04
	retlw	b'00000100'	;03 
	retlw	b'00000010'	;02 
	retlw	b'00000010'	;02 

	end

Credits

SimpleTronic

SimpleTronic

13 projects • 25 followers
Electronics hobbyist (>55yrs) - Music arranger / composer (>45yrs) - Recording engineer (>25yrs)

Comments