Tag Archives: electronics

7 segment displays/keyboard decoders in SDK’s

There are a lot of old develop boards for all kinds for cpu’s.

These where build to learn machine code programming. Mostly made in the 80’s, and based on populair cpu’s at that time.

I own a some of these SDK’s (System Design Kits)

8085 – SDK85 i bought recently 8085 CPU
Microprofessor-1 (MPF-1) Z80 CPU
And my own 680x based computer

Most of these use a keyboard scanner which is also connected to 7 segment displays.

The way they work is practically the same. There is a VIA or PIA. Versitile interface adaptor, or Peripheral interface adaptor. These have two times 8 bits to control devices.
When using 4 bits and convert these to 16 lines by using a 75ls145 for example. If you put a counter on those 4 bits, you sequently activate 1 of 16 lines. These lines you can use to scan a keyboard matrix OR display a character on a 7 segment display. These display’s won’t hold the data (and show the character) when not activated. The trick is to update de display fast enough so you don’t see the flickering on/off.

Activate a line and read a byte with the VIA = Reading keyboard row
Activate a line and write a byte with the VIA = Display on a segment

These VIA/PIA’s where made with specific timings to match the CPU.
6522/6820/8255

Below you see some different implementations of these keyboard/display combo’s

Thaler 6502 kit
Microprofessor MPF-1 kit (ignore red circle)
SDK85 kit
Eltec 6800
My version using darlington arrays (ULN2003)

When looking at the 8085 version you see transistors being a ULN2003 is a chip with those transistors/amplification enclosed.
It doesn´t draw much current from the bus, and diodes protect the way the current flows.

Generic Matrix Keyboard Print

I only have to check my new design for a generic matrix keyboard once again, and then i’m going to order a few of these prints.

  • 32 keys (2 blocks of 16)
  • 1 key is changeable from generic key to reset signal key
  • jumper header connector VCC, GND, DataAvailable, Reset and 5 data lines

I’ve used the opensource tool freeroute to autoroute the coppertraces

  • From Kicad export PCB in Spectra DNS format
  • Open Freeroute and run autoroute
  • export as Spectra Session File
  • In kicad import this session file again

Autotraced …
Front
Back
Current setup

TODO: Look into charlieplexing ! For input and Led control

6502 update

  • New amplifier part using a LM386
  • Buzzer and led on VIA 2, blinky and sound timed by the internal timers of the 6522
  • ACIA testing still going on, writing software
  • Mini matrix keyboard removed, and used the temporary cursor buttons for the test with a rom which allows for a 8bits upload method using a arduino and the 6522. (I’m working on the big keyboard)

Work in progress code

PORT2B = $5000 		; VIA PORTB
PORT2A = $5001 		; VIA PORTA
DDR2B = $5002  		; Data direction register
DDR2A = $5003  		; Data direction register

PORTB = $6000 		; display
PORTA = $6001 		; control display + matrix keyboard
DDRB = $6002  		; data direction register
DDRA = $6003  		; data direction register
SID = $7000   		; sid base address

E  = %10000000		; enable bit
RW = %01000000		; RW bit 
RS = %00100000		; Register Select bit 
HOME = %00000010 	; VIA PORTB HOME command
DADDR = %00010000 	; VIA DADDRESS

LINENO = $0200		; temp address linenumber (move to other location)
NEXTLINE = 40		; 2x16 Chars but internally 40


  .org $8000

reset:
  ldx #$ff
  txs		; reset stack

; ###################################################
; #                 DISPLAY CONTROL                 #
; ###################################################
; VIA Setup

  lda #%11111111 	; Set all pins on port B to output
  sta DDRB
  lda #%11100000 	; Set top 3 pins on port A to output
  sta DDRA

; DISPLAY Setup
  lda #%00111000 	; Set 8-bit mode; 2-line display; 5x8 font
  jsr lcd_instruction
  lda #%00001110 	; Display on; cursor on; blink off
  jsr lcd_instruction
  lda #%00000110 	; Increment and shift cursor; don't shift display
  jsr lcd_instruction
  lda #$00000001 	; Clear display
  jsr lcd_instruction

; ###################################################
; #             PRINT MESSAGE LINE NO 0             #
; ###################################################
  lda #0  		; set line number
  sta LINENO      	; store for subroutine
  jsr gotoline		; move cursor

  ldx #0		; message index pointer
print:
  lda message0,x 	; start of message
  beq nextprint      	; stop when null in message (asciiz <- Zero padded)
  jsr print_char	; print char
  inx			; incr index
  jmp print		; resume print
; ###################################################
; #             PRINT MESSAGE LINE NO 1             #
; ###################################################
nextprint:
  lda #1  		; set line number
  sta LINENO      	; store
  jsr gotoline
  ldx #0  		; index pointer                 
print2:
  lda message1,x  	; absolute address message + x in A
  beq sidsound        	; if x is 0, end of message     
  jsr print_char  	; jump subroutine
  inx             	; increment x
  jmp print2      	; loop print2



; ###################################################
; #             SID SOUND                           #
; ###################################################
sidsound:
  lda #0		
  sta SID+$5		; attack/decay duration
  	
  lda #250
  sta SID+$6		; sustain level/release duration
  	
  lda #$95		; frequency voice 1 low byte
  sta SID+$0
  	
  lda #$44		; frequency voice 1 high byte
  sta SID+$1
  
  lda #%00100001	; sawtooth + gate
  sta SID+$4		; control register voice 1
  
  lda #$0f		; filter mode and volume (bits 3-0 main volume)
  sta SID+$18		; filter mode and volume



; ###################################################
; #             2ND VIA                             #
; ###################################################
  lda #%11111111 	; set port A output
  sta DDR2A

  lda #%11111111	; all ones!
  sta PORT2A
; ###################################################
  lda #%11111111 	; set port A output
  sta DDR2A

  lda #%11111111	; all ones!
  sta PORT2A



; ###################################################
; #             MAIN PROGRAM LOOP                   #
; ###################################################
loop:
  jmp loop
;                   1234567812345678
message0: .asciiz  "VIA 1,2 SID TEST"
message1: .asciiz  "   FASH  2022   "

; ###################################################
; #             ONLY SUBROUTINES                    #
; ###################################################

; ###################################################
; #             Subroutine gotoline                 #
; # Moves character placement position on display   #
; # Needs : $LINENO ADDRESS                         #
; # Exit values : -                                 #
; # Destroys registers: -                           #
; ###################################################

gotoline:
  pha                             ; store a
  txa
  pha                             ; store x
  ldx LINENO
  lda #HOME                       ; cursor down
  jsr lcd_instruction
  lda #$80
nextline:
  ldx LINENO
  cpx #00
  beq endnextlines
loopline:
  adc #40
  jsr lcd_instruction
  dex
  stx LINENO
  jmp nextline
endnextlines:
  pla                             ; pop a
  tax                             ; a to x
  pla                             ; pop a
  rts




; ###################################################
; #             LCD SUBROUTINES                     #
; ###################################################
lcd_wait:
  pha
  lda #%00000000  ; Port B is input
  sta DDRB
lcdbusy:
  lda #RW
  sta PORTA
  lda #(RW | E)
  sta PORTA
  lda PORTB
  and #%10000000
  bne lcdbusy
  lda #RW
  sta PORTA
  lda #%11111111  ; Port B is output
  sta DDRB
  pla
  rts
lcd_instruction:
  jsr lcd_wait
  sta PORTB
  lda #0         ; Clear RS/RW/E bits
  sta PORTA
  lda #E         ; Set E bit to send instruction
  sta PORTA
  lda #0         ; Clear RS/RW/E bits
  sta PORTA
  rts
print_char:
  jsr lcd_wait
  sta PORTB
  lda #RS         ; Set RS; Clear RW/E bits
  sta PORTA
  lda #(RS | E)   ; Set E bit to send instruction
  sta PORTA
  lda #RS         ; Clear E bits
  sta PORTA
  rts

nmi:
  rti

irq:
  rti

  .org $fffa
  .word nmi
  .word reset
  .word irq
;  .word $0000

So i wasn’t being stupid designing a dual matrix keyboard thingy

As previously posted, i had an idea to create a dual matrix keyboard mashup using available components.

I mentioned that “it should theoretically work”. But only being using atf22v10c for a couple of days. It was a long shot.

I’ve put it to the test .. and it worked first time.

I can use above, to connect my extended matrix keyboard to a 6522 VIA chip using 5 pins and sending a data available signal to CA1.

This keyboard i was planning to use

Generic matrix keyboard

In this case designed for my 6502, but it is a generic setup.

I it just a dual 16key matrix decoder merged together. You can probably use this with raspberries, arduinos etc.

I wanted to use 74C923 but these are nowhere to be found. And even then, the number of keys wil be 20.
So i am tying together two 74C922 using some logic in a PLD.

First draft

It wil be something like above. Using the data availabe signal i can combine both 16key matrixes. (In theory .. it is all untested)

PLD Code

GAL22V10
Address Decoder

PHI2 DA0 DA1 D01 D02 D03 D04 D11 D12 D13 D14 GND
NC D0 D1 D2 D3 D4 DA NC NC NC NC VCC

DA = DA0 + DA1
D0 = D01 & DA0 + D11 & DA1
D1 = D02 & DA0 + D12 & DA1
D2 = D03 & DA0 + D13 & DA1
D3 = D04 & DA0 + D14 & DA1
D4 = DA1 

DESCRIPTION
Key matrix merger

I’ve got my new keys of the keyboard in today!

  • 0-F – hex keys
  • G = Go
  • R = Reset
  • S = Step
  • M = Memory
  • Cursor keys (up/down for memory locations)
  • ??? I’ve got room for 8 more keys

My inkscape template (keys are 10/10mm)

Printed on white and red paper

https://media.henriaanstoot.nl/keyboardmatrix.svg

6502 Update

New address decoder in place!
Connected RAM/ROM/SID/VIA1/VIA2 and ACIA

ROM8000-FFFF
SID7000-700F (sound)
VIA16000-60xx (Hex key matrix)
ACIA6800-68xx (serial)
VIA25000-50xx (led test at the moment)
RAM0000-3FFF

To plan: Bigger maxtrix keyboard and other displays

ACIA 6551

Got a serial connection working between the 6502 and my linux machine!

At the moment when a reset occurs , hello is being printed.
Text typed in the minicom terminal, is echo-ed back and displayed on the LCD display.

Things learned: Do not trust internet schematics blindly!

The crystal used for the ACIA (pin 6/7 1.8432Mhz needs a 1M ohm resistor parallel over the crystal, and a 30nF capacitor from pin 7 to GND

When using a terminal emulator, and using 3 wires. Disable hardware handshake.

Keyboard rewired.

What didn´t work as planned:

New amplifier schematic for the SID. There is too much noise.

Amplifier with a LM628

Bought a dual power supply (5V and 12V). But this one has a lot of signal noise on the SID part and even my battlestation speakers!

LED test 2nd via

PORTB = $5000 ; VIA PORTB
PORTA = $5001 ; VIA PORTA
DDRB = $5002  ; Data direction register
DDRA = $5003  ; Data direction register

LED  = %10000000

	.org $8000

reset:

	lda #%11100000 ; Set top 3 pins on port A to output
	sta DDRA

	lda LED 
	sta PORTA

loop:		; done loop until doomsday
	jmp loop

irq:
nmi:
	.org $fffa
	.word nmi
	.word reset
	.word irq

ACIA part

ACIA_RX = $6800
ACIA_TX = $6800
ACIA_STATUS = $6801
ACIA_COMMAND = $6802
ACIA_CONTROL = $6803

    lda #$00
    sta ACIA_STATUS
    lda #$0b
    sta ACIA_COMMAND
    lda #$1f
    sta ACIA_CONTROL

Programming ATF22V10 PLD – 7 Segment with Linux

The ATF22V10 is a Programmable Logic Device. This means you can program the logic in the chip.

Internally it looks like a big matrix of connections which you can program to connect/disconnect from certain logic.

It has just a bunch of inputs/outputs

So if we want to have a 7 Segment decoder (you can easily buy a BCD decoder .. but these only work for displaying 0-9 and not 0-9A-F for displaying HEX numbers)

7 Segment display
Binary IN7 Segment decodedDisplays
D C B AA B C D E F G
0 0 0 01 1 1 1 1 1 00
0 0 0 10 1 1 0 0 0 0 1
0 0 1 0 1 1 0 1 1 0 12
0 0 1 11 1 1 1 0 0 13
0 1 0 00 1 1 0 0 1 14
0 1 0 11 0 1 1 0 1 15
0 1 1 0 1 0 1 1 1 1 16
0 1 1 1 1 1 1 0 0 0 0 7
1 0 0 01 1 1 1 1 1 18
1 0 0 11 1 1 1 0 1 19
1 0 1 01 1 1 0 1 1 1A
1 0 1 10 0 1 1 1 1 1B
1 1 0 0 1 0 0 1 1 1 0C
1 1 0 10 1 1 1 1 0 1D
1 1 1 01 0 0 1 1 1 1E
1 1 1 11 0 0 0 1 1 1F

Now we see that segment A is 1 in the case of (0,2,3,5,6,7,8,9,A,C,E,F)

When programming the PLD we can write that as: (note / means inverted a plus is OR, and * is AND)
So A is 0 in case of input being (1,4,B,D)

/QA = /D1 * /C1 * /B1 * A1
    + /D1 * C1 * /B1 * /A1
    + D1 * /C1 * B1 * A1
    + D1 * C1 * /B1 * A1

Complete code for galasm

Compiling and burning

GAL22V10
7SEGMENT

Clock   D1   C1   B1   A1    D2   C2    B2    A2    NC  NC   GND
/OE   NC    NC  NC  QG    QF    QE    QD   QC    QB   QA   VCC


/QA =   /D1 * /C1 * /B1 * A1
        + /D1 * C1 * /B1 * /A1
        + D1 * /C1 * B1 * A1
        + D1 * C1 * /B1 * A1

/QB=    /D1 * C1 * /B1 * A1
        + /D1 * C1 * B1 * /A1
        + D1 * /C1 * B1 * A1
        + D1 * C1 * /B1 * /A1
        + D1 * C1 * B1 * /A1
        + D1 * C1 * B1 * A1

/QC =   /D1 * /C1 * B1 * /A1
        + D1 * C1 * /B1 * /A1
        + D1 * C1 * B1 * /A1
        + D1 * C1 * B1 * A1


/QD=      /D1 * /C1* /B1 * A1
        + /D1 * C1 * /B1 * /A1
        + /D1 * C1 * B1 * A1
        + D1 * /C1 * B1 * /A1
        + D1 * C1 * B1 * A1

/QE =     /D1 * /C1 * /B1 * A1
        + /D1 * /C1 * B1 * A1
        + /D1 * C1 * /B1 * /A1
        + /D1 * C1 * /B1 * A1
        + /D1 * C1 * B1 * A1
        + D1 * /C1 * /B1 * A1

/QF =     /D1 * /C1 * /B1 * A1
        + /D1 * /C1 * B1 * /A1
        + /D1 * /C1 * B1 * A1
        + /D1 * C1 * B1 * A1
        + D1 * C1 * /B1 * A1

/QG =     /D1 * /C1 * /B1 * /A1
        + /D1 * /C1 * /B1 * A1
        + /D1 * C1 * B1 * A1
        + D1 * C1 * /B1 * /A1

DESCRIPTION
A 7 segment hex decoder

galasm 7seghex.gal

minipro -p ATF22V10CQZ -w 7seghex.jed

minipro -p ATF22V10CQZ -w 7seghex.jed
Found TL866II+ 04.2.129 (0x281)
Warning: Firmware is newer than expected.
  Expected  04.2.128 (0x280)
  Found     04.2.129 (0x281)

VPP=12V
Warning! JED file doesn't match the selected device!

Declared fuse checksum: 0x98D5 Calculated: 0x98D5 ... OK
Declared file checksum: 0x40B3 Calculated: 0x41A8 ... Mismatch!
JED file parsed OK

Use -P to skip write protect

Erasing... 0.33Sec OK
Writing jedec file...  5.01Sec  OK
Reading device...  0.32Sec  OK
Writing lock bit... 0.35Sec OK
Verification failed at address 0x16C6: File=0x01, Device=0x00 < ------------------ Gives error, but burning seems okay

henri@zspot:~/projects/galasm$ minipro -p ATF22V10CQZ -r 7seghex.out
Found TL866II+ 04.2.129 (0x281)
Warning: Firmware is newer than expected.
  Expected  04.2.128 (0x280)
  Found     04.2.129 (0x281)
Reading device...  0.32Sec  OK

Gives all zeros as output, but device works!

Address decoding with split IO

Made a simulation of my new address decoder.
It uses a 74LS138 and a bunch of NAND gates.
You can safe using 4 NAND gates if you are not going to use split IO

Address
8000-FFFFROMROM
7000-7FFFSound chipSID
6000-6FFFDisplay + cursorVIA1
5000-5FFFKeymatrixVIA2
4800-4FFFsplit ioIO
4000-47FFsplit ioIO – ACIA
0000-3FFFUses clockRAM
Above part is a single chip 74LS138

UPDATE: Found some 74LS139, so i could have changed some things around.

Simplified schematic 74LS139

Try it over here:

https://simulator.io/board/W8sQkHl1We/1

Eurocards

I found some stuff while sorting out some old computer stuff.
Way back, when my Amiga was my main computer, i wanted to make my own version. A modular one.

So i started to segmentize the amiga, to put it on several exchangeable cards.

Eurocards are standardized prints 150mm x 100mm, mostly with a DIN41612 connector.

DIN41612
Eurocard example

When you make modules you can change/upgrade/test, you can have a very easy interchangeable system using a backplane like this

So i started planning those modules:

  • CPU – 68000 but upgradeable to 68030 or alike
  • Memory – With expansion
  • Sound
  • Video
  • More IO possibilities
  • Keyboard (see more at the bottom of this page)

I had a nice case which could hold a big backplane, custom powersupply. And a front panel containing drives, leds and knobs. (I know i have more info on this somewhere on my fileserver)

A nice example picture i found on danceswithferrets website

I never finished this project.
I used Tech Manuals and print layouts to understand how things where done.

Part of schematic

I started to draw the modules like they where placed on the print on semi transparent (chalk)paper, the kind of paper that was used for electronic and mechanic diagrams.

6502 news

Divers new additions to the 6502 project

Above is my design for a hex keyboard to enter opcodes in hex using a simple monitor program.
i used a 74ls922 which can decode a 4×4 matrix. I’d rather had a 74ls723 which can encode 20 keys.

Nowhere to be found. So i have to think of a new plan.

Now it is configured as follows:

CDEF
89AB
4567
0123

When pressing the alternate key

addr
(to implement)
run
(1/2 implemented)
reset
(to implement)
step instruction
(to implement)
memory next
memory previous
PCB design for matrix hexboard with place for notes

Meanwhile i’ve ordered new keys (the ones i’ve been using for my photomanager project and wnat to have a setup like this:

??addrrunreset
CDEF?
89ABstep
4567mem next
0123mem prev

When you want to show the status of busses and alike, you can’t use a led and restistor directly on the bus, it will require too much current.
So i’ve been using below schematic which uses a darlington array.

Now i can display databus, address bus and i’ve been using this for address decoding logic and hex keyboard.

I’ve implemented a second VIA chip, and ordered components to amplify the SID sound part