FIGnition FUZE Guida all'applicazione

FUZE Hardware Ref
Contents
Introduction!4
1 Overview!5
1.1 System Circuit Diagram!6
2. Keypad!7
2.1 Circuit Diagram!7
2.2 Operation!8
2.2.1 Reading the switches.!8
2.2.2 Ghost Keys!9
2.2.3 Debouncing the Keypad!10
2.2.4 Converting Single and Double Keypresses to Characters!11
3 Video!13
3.1 Circuit Diagram!13
3.2 Operation!13
3.2.1 Composite Video Basics!13
3.2.2 Video Circuit Basics!15
3.2.3 Video Firmware Details!16
3.2.4 Composite Video Details!18
3.2.6 Bitmapped Video Basics!19
4. Audio!22
4.1 Circuit Diagram!22
4.2 Operation!22
4.2.1 Circuit Details!22
4.2.2 Using Timer 0 To Generate Audio!27
4.2.3 Making It Easy With Pitch> .!28
4.2.4 Audio In!31
5. Storage!32
5.1 Circuit Diagram!32
5.2 Hardware Operation!32

5.2.1. Electrical Connections!32
5.2.2 The SPI Protocol!33
5.2.3 The Flash Chip Commands!34
5.3 Firmware Operation!35
5.3.1 Virtual Blocks!35
5.3.2 Purging!37
5.3.3 Virtual Table Purging!39
5.3.4 Conclusions!40
6. RAM!41
6.1 Circuit Diagram!41
6.2 Operation!41
6.2.1. Electrical Connections!41
6.2.2 The SPI Protocol!41
6.3 Firmware Operation!42
6.3.1 Locality!43
6.3.2 Pipelining!43
6.3.3 Branch Caching!44
6.3.4 Conclusions!45
7. USB!46
7.1 Circuit Diagram!46
7.2 Hardware Operation!46
7.3 Firmware Operation!48
7.3.1 AVR Flash Memory Organization!48
7.3.2 The Bootloader Key!48
7.3.3 Realtime Requirements!48
7.3.4 Chicken And Egg!49
7.3.5 Licensing!49
8. Microcontroller!50
8.1 Circuit Diagram!50
8.2 Operation!50
8.2.1 How FIGnition Uses Pins!50
8.2.2 AVR Block Diagram!52
8.2.3 FIGnition's Firmware Overview!53
9. Expanding FIGnition!58

9.1 Circuit Diagram!58
9.2 Operation!58
9.2.1 Controlling the LED!59
9.2.2 Default I/O!60
9.2.3 Reading Analog Channel 5.!60
9.2.4 I/O Trade-Off!63
9.3 Using SPI to talk to an Arduino!64
9.4 Using I2C to talk to a Maxim Digital To Analogue Converter.!66
9.5 Using I2C to talk to a Microchip I/O Expander!68
9.6 Using SPI to backup the external Flash.!70
Appendix A: Potential Dividers!73
Circuit Diagram!73
Operation!73
Detailed Explanation!75
Simulation!79
Code Description!80
Appendix B Diodes!82
B.1 Signal Diodes!82
B.2 Zener Diodes!83
Appendix C Capacitors!85
C.1 How Capacitors Work!85
C.2 Capacitors As Temporary Power Sources!86
C.3 De-coupling Capacitors!87
C.4 Capacitors As Audio Filters!87

Introduction
FIGnition FUZE's hardware contains the essentials of a true computer: a keypad for typing
programs and entering text; a power supply connector; it can output data to the user (via
video and audio); it runs programs from RAM; it has built-in storage for when the computer
is turned off; it has a CPU for running programs and a built-in program which manages all
these features and implements a fully-featured programming language (FIGnition Forth).
All true computers are like this; the only difference is the level of sophistication for each of
these parts. This manual takes you through the design and construction of every aspect of
FIGnition: bottom up from the components themselves to the way they interface to FIGni-
tion's processor chip to the code that manages each part.
FIGnition is a computer designed to be built, programmed and understood. The firmware is
fully open-sourced and the circuit is Open-Source Hardware compliant. This document
covers its operation with a view to understanding it, but it is not a substitute for an electron-
ics or programming course. For this you would find this additional material useful:
•An Electronics Tutorial.
•The User Guide for the AtMega168 and AtMega328.
•The FIGnition firmware source, which is on GitHub at: https://github.com/Snial/FIGnition
•The FIGnition programming Tutorial, Topics and Command Reference guides.

1 Overview
The FIGnition PCB contains 51 components connected by ground planes; power and sig-
nal traces. The signals wind their way across the PCB to the various building blocks as
shown on the left and as a block diagram on the right.
Flash
RAM
CPU
Video
Audio
USB
Keypad
These blocks are:
1. Keypad. The keypad allows you to type in programs; enter data and initiate a firmware
upgrade.
2. Video. The Video Phono outputs composite video to a TV.
3. Audio. The Audio Phono provides Audio In/Out.
4. Flash. The External Flash memory is where all your programs are stored when the
computer is switched off.
5. RAM. The external RAM chip is loaded with a program and the program runs from it.
6. USB. The connector is used to power a FIGnition and upgrade the firmware as FIGni-
tion is improved.
7. The AVR Microcontroller. The Avr Microcontroller is the 'brains' behind it all. It contains
an 8-bit processor for running internal firmware and the internal firmware implements a
built-in programming language and the code that manages the USB, Audio, Video,
Keypad, Storage and RAM.

8. Arduino Headers.
The block diagram tells you some basic information about the structure of the computer.
For example, the arrow between USB and CPU is two-headed, because data goes in both
directions. The arrow from the keypad is single-headed, because data only goes from the
keypad. RAM and Flash share a multi-head arrow, because data transfer is shared be-
tween them.
1.1 System Circuit Diagram
A circuit diagram for FIGnition represents a detailed, logical diagram of the computer, a
schematic; showing all components and their connections to every signal. Every section of
the FIGnition hardware reference starts with its part of the circuit diagram.
As you can see, components on the circuit schematic don't look like real-life. In addition
some of them aren't in the same places as on the PCB (e.g. USB isn't really in the middle
of the PCB) and this is done to make the logical relationships clearer. Finally, the keypad
looks like it's disconnected, but it's not really, instead each disconnected wire is labelled
and wherever else you see the same label the wire continues from there. For example,
/SWROW1 on the keypad also appears on the right-hand edge of the U1 rectangle, next to
the number 13 . This means the /SWROW1 connection on the keypad connects to pin 13 of
U1 (the CPU).

2. Keypad
The keypad uses 8 switches and 6 input ports on the AVR Microcontroller to implement a
switch-matrix keypad. Using individual keys and combinations of two keys pressed one
after the other a full set of letters, numbers and symbols can be typed.
2.1 Circuit Diagram
Fig 2.1
The visible part of the circuit includes only the switches, but inside the microcontroller, the
column signals are set up to connect to some 'pull-up' resistors which are connected to
VCC. PortC, bits 3 to 0 are always set up as inputs. PortB0 and PortD7 are normally set
up as inputs without pull-up resistors, and when we're actually reading keys either PortB0
or PortD7 (but never both together) are set up as outputs.
To understand how the switches themselves work you'll need to first understand Potential
Dividers (Appendix A).

!Fig 2.2a!Fig2.2b
In the opposite way that a small resistor is like a wire causing a tiny voltage to drop across
it; an open switch is like a nearly infinite resistor taking the place of R2; so R1 will pull a
PortC input up to very nearly 5v [Fig 2.2a]. But when the switch is pressed, it connects to
0v and so its PortC input would read as 0 [Fig 2.2b].
Fig 2.3
When either PortB0 or PortD7 is set as an input, it has an extremely high resistance com-
pared with a PortC 'pull-up' resistor causing its PortC input to read as a 1 even if the switch
is pressed [Fig 2.3].
2.2 Operation
Even for something as simple as the set of switches making up the keypad there are sev-
eral layers to its operation.
2.2.1 Reading the switches.
We can see from Fig 2.1, pressing a single switch will connect exactly one row signal to
one column input (for example, pressing SW1 will connect PortD7 to PortC0). In the initial
case (when keys aren't pressed), the voltage at every column input will be high, because
all the keys behave as in Fig 2.2.
If we set PortD7 to an output and make it output 0, then any pressed keys (on the top row)
will connect to 0v and will be read as 0s by PortC [Fig 2.4]

Fig 2.4
Here, SW5 and SW3 are the only keys pressed and because only SW3 is connected to 0v,
only PortC2 reads as 0.
SW5 is also pressed, but because PortB0 is set up as an input, it means the switch acts as
in Fig 2.3.
To read the bottom row, we set up PortD7 back to being an input and make PortB0 an out-
put, ouputting 0. This time SW3 has no effect on PortC inputs, but SW5 does, meaning
PortC3 to PortC0 will read 1110.
In the FiGnition firmware, the basic switch reading is handled by the 'C' function KeyScan-
Raw in the manner described here.
2.2.2 Ghost Keys
A switch-matrix keyboard can't read more than two keys at a time without getting con-
fused. Let's see what happens if we press SW1, SW3 and SW5. When the bottom row is
being read we can see that there is also a connection between PortC2 and PortB0, be-
cause PortC2 connects to SW3 which connects to SW1 which connects to PortC0. So it
looks like SW7 is also being pressed [Fig 2.5].

Fig 2.5
Normal computer keyboards suffer from the same problem. If I press any pair of keys (e.g.
'w' and 'n') then it will choose to display both and repeat one of them. However, if I press
(e.g 'e', 'd' and 'u') on my laptop simultaneously then the laptop recognizes that there could
be a ghost key and types nothing at all.
2.2.3 Debouncing the Keypad
In a simple circuit with a switch and a light-bulb, we press the switch, the light comes on
and we think that it's as simple as that. But to electronic circuits that operate at anything
above a few hundred Hz, a keypress appears to bounce several times before settling
down, as though you'd pressed it many times very quickly [Fig 2.6].
Indice

















