The manipulates flip-flops and performs data exchange with PC

The aim of this project was to design and build an LED
cube capable of displaying 3D images and communicating with PC via USB 2.0
(fig. 1.0).

Figure 1.0 Project block diagram.

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

 

It involved designing three PCB boards:

·        
Power board – for supplying 5V to the following two PCBs in
this list.

·        
Flip-flop board – for switching cube LEDs ON and OFF at high
speed, this way generating 3D visual picture.

·        
Controller board – containing PIC microcontroller which
manipulates flip-flops and performs data exchange with PC via USB connection.

However, beforehand a functioning prototype was built in
order to become familiar with all components involved in the project (fig 1.1).
After making sure that LED cube operates as expected all three PCB boards were
developed in Ultiboard program and printed.

The controller PCB board was designed to have ICSP
(In-Circuit Serial Programming) circuit with 5 pin socket for a PICKit2
programmer. That facilitated PIC microcontroller programming without physically
removing it from the board.

Figure 1.1 LED cube and controller prototype.

 

This report describes the main aspects of the software
(SW) and firmware (FW) development processes. The code for the user interface
was written in Visual C# 2010 Express program. A
special class was added to the C# project which contained
host software functions for performing USB HID communication. USB functions
were successfully used for data transmission between the host and PIC
controller. Firmware code was developed in the MPLAB program using C
programming language.

Both FW and SW codes with comments are available in
the appendix at the end of this report.

 

2. 
Literature survey

 

2.1 LED

Light-emitting diodes
(LEDs) are semiconductor devices that convert electrical current into light.
LED lighting is also called “solid state lighting” because the light is emitted
from a solid object rather than from a vacuum or gas tube, as in traditional incandescent
or fluorescent lights. Light-emitting diodes have significant potential
for energy savings compared to other illumination devices, for instance LEDs
are 10 times more efficient than incandescent lights. Even though LED
technology has existed in specialized applications since the 1960s but it
became widespread only after the invention of the blue LED which made white
light generation possible (Gereffi and Lowe, 2008).

 

LEDs have been used widely
to create the highly efficient red, green, and blue lights in devices such as
digital clocks, watches, televisions, dashboards, and traffic lights. In 1993
Japan’s Nichia Corporation devised a way to create white light from a single
diode. This discovery initiated the ongoing quest to develop an LED-based
technology that can produce a high-quality, “warm” white light suitable for
general illumination (Gereffi and Lowe, 2008).

 

General LED operation can
be described as follows: a current flows through a diode in the forward
direction, it consists of surplus electrons moving in one direc­tion in the
lattice and “holes” (voids in the lattice) moving in the other. Occasionally,
electrons can recombine with holes. When this happens the process releases
energy in the form of photons, i.e. light is produced. This is true of all
semiconductor junctions, but LEDs use materials that maximize the effect. The
colour of the light emitted (corresponding to the ener­gy of the photon) is
determined by the semiconduc­tor materials that form the diode junction (Tuite,
2013). A figure below shows internal parts of an LED.

 

Figure 2.1.0 Internal parts of an LED (Wikipedia, 2009).

 

 

2.2 Flip-Flop

D type flip-flops
(Fig. 2.2.0, a) are basic storage elements (memory cells) in digital
electronics. They transfer input data to the outputs on an edge (positive or
negative) transition of the clock input providing a robust interface between
asynchronous and synchronous systems (www.nxp.com, 2015).

a)

                       
 b)

Figure 2.2.0 D flip-flop block diagram
and logic diagram.

 

The
output Q (Fig. 2.20, b) tries to track the D input, but this happens only when
the CLK input is high. The instance when CLK signal becomes low the Q output
keeps the last D value until CLK becomes high again, then Q resumes tracking the
D input. The timing diagram on Fig. 2.2.1 shows that Q acquires D input value
only when CLK is high.

Figure 2.2.1 D flip-flop timing diagram.

 

However, octal
D flip-flops used in this project allow the Q to acquire value of the D input
only on the rising edge of the clock
as shown in Fig. 2.2.2 a and b.

a)

                 b)

Figure
2.2.2 D flip-flop truth table and timing diagram.

 

74HC374
Octal D-type flip-flops (Fig. 2.2.3) have 3-state outputs and the capability to
drive 15 LSTTL (Low-Power Schottky Transistor-Transistor Logic) loads. The
eight edge-triggered flip-flops enter data through D0 to D7 pins into their
registers on the LOW to HIGH transition of clock (CLK) (Fig. 2.2.2 a). The output
enable (OE) controls the 3-state outputs (Q0 to Q7 pins) and is independent of
the register operation. When OE is HIGH, the outputs are in the high-impedance
state and when it is LOW the chip outputs values that were store in it (Texas
Instruments, 2014).

Figure
2.2.3 74HC374 Octal D-type flip-flop pinout.

 

2.3 De-Mux

A decoder is a device which does
the reverse operation of an encoder, undoing the encoding so that the original
information can be retrieved. It is a combinational circuit that converts
binary information from n input lines to a maximum of 2n unique
output lines (Wikipedia, 2015). The decoders are designed to be used in memory-decoding
or data routing applications requiring very short propagation delay times.

Figure 2.3.0 shows 3-line to 8-line
decoder pinout. The conditions at the binary-select inputs (A, B and C) and
three enable inputs select one of eight output lines. Two active-low and one
active-high enable inputs (G1,

2A and

2B) reduce the need for external gates or inverters when
expanding. An enable input can be used as a data input in demultiplexing
application, such as this project. It has a propagation delay time of only 15
ns (Texas Instruments, 2003).

Figure
2.3.0 S74HC138 De-Mux pinout.

 

The table below shows how inputs
can be decoded using S74HC138 chip.

Table
2.3.0 S74HC138 De-Mux functional table.

 

2.4
PIC

A microcontroller
is a small computer on a single integrated circuit (IC) containing a processor
core, memory, and programmable input/output peripherals. Microcontrollers are
designed for embedded applications, in contrast to the microprocessors used in
personal computers or other general purpose applications.

Microcontrollers are used in automatically
controlled products and devices, such as automobile engine control systems,
implantable medical devices, remote controls, office machines, appliances,
power tools, toys and other embedded systems. By reducing the size and cost
compared to a design that uses a separate microprocessor, memory, and
input/output devices, microcontrollers make it economical to digitally control
even more devices and processes (Wikipedia,
2014).

Figure 2.4.0 displays 40 pin 18F4550 PIC
microcontroller which has high computational performance at an economical
price, with the addition of high endurance and enhanced Flash program memory.
This device incorporates a fully featured USB (Universal Serial Bus)
communications module that is compliant with the USB Specification Revision
2.0. The module supports both low-speed and full-speed communication for all
supported data transfer types. It also incorporates its own on-chip transceiver
and 3.3V regulator. The Flash cells for both program memory and data EEPROM are
rated to last for many thousands of erase/write cycles – up to 100,000 for
program memory and 1,000,000 for EEPROM (Microchip, 2006).

 

Figure 2.4.0 PIC 18F4550 Microcontroller (Microchip, 2006).

 

2.5 Switching
Voltage Regulators

A voltage regulator is designed to automatically maintain a constant
voltage level (Wikipedia, 2015). LM2576 voltage regulator (Fig. 2.5.0) is monolithic integrated circuit
that provides all the active functions for a step-down (buck) switching
regulator, capable of driving 3A load with excellent line and load regulation.
These devices are available in fixed output voltages of 3.3V, 5V, 12V, 15V, and
as adjustable output version. Requiring only a few external components, these
regulators are very simple to use and include internal frequency compensation
and a fixed-frequency oscillator. The LM2576 series offers a high-efficiency
replacement for popular three-terminal linear regulators. It substantially
reduces the size of the heat sink, and in some cases no heat sink is required
(Texas Instruments, 2013). A typical application of LM2576 is shown below in
Fig. 2.5.1.

Other features include a
specified ± 4% tolerance on output voltage within specified input voltages and
output load conditions, and ± 10% on the oscillator frequency. External
shutdown is included, featuring 50 ?A (typical) standby current. The output
switch includes cycle-by-cycle current limiting, as well as thermal shutdown for
full protection under fault conditions (Texas Instruments, 2013).

 

Figure 2.5.0
LM2576 IC (ti.com, 2015).

 

 

Figure
2.5.1 LM2576 Application circuit from datasheet (ti.com, 2013).

 

2.6 USB

USB is currently a very popular computer interface
specification used to connect various peripheral devices to computers and
microcontrollers. Some microcontrollers provide built-in USB modules. The
18F4550, for example, has built-in USB interface capabilities.

The USB is a high-speed serial interface that can also
provide power to devices connected to it. According to the specification, the
maximum distance of a device from its host is about thirty meters, accomplished
by using five hubs. For longer-distance bus communications, other methods such
as use of Ethernet are recommended.

The USB bus specification comes in three versions:

·        
The earlier version, USB1.1, supports 11Mbps.

·        
USB 2.0 supports up to 480Mbps.

·        
While the new version USB 3.0 supports the payload
throughput up to 4 Gbps.

However, this project implements USB 2.0 and therefore all
further information is related only to USB 2.0 version.

The maximum power available to an external USB device is
limited to about 100mA at 5.0V (Ibrahim, 2008).

Figure 2.6.0 shows
typical USB connectors.

Figure 2.6.0 USB connector.

 

USB is a four-wire interface implemented using a four-core shielded
cable. Two types of connectors are specified and used: type A and type B. The
pin-out of each type is shown below in figure 2.6.1.

Figure 2.6.1 Type A and B connector.

 

All four wires have specified colours. The pins and wire
colours of a Type A or Type B connector are given in table 2.6.0 below.

Pin #

Name

 Colour

1

+ 5.0 V

Red

2

Data –

White

3

Data +

Green

4

GND

Black

Table 2.6.0 USB connector pins.

 

2.7 Ultiboard

Ultiboard is a rapid printed circuit board
(PCB) prototyping environment used by engineering professionals, educators,
makers, and students across many applications. Its seamless integration with
Multisim helps circuit designers save hours of development time with the
ability to complete circuit schematics, SPICE simulation, and PCB layout in the
same environment. Ultiboard benefits include the following (National Instruments, 2015):

Flexible environment
optimized for rapid design and accurate part or copper placement.
Engineer-friendly interface
for laying out and routing PCBs.
Seamless integration with
Multisim to ensure accurate transfer of simulated designs.
Comprehensive database of
connector footprints for custom designing NI hardware and test platforms.
Easy export to
industry-standard Gerber or DXF formats for prototyping and fabrication.

 

2.8 Multisim

Multisim
is an industry-standard, best-in-class SPICE simulation environment. It is the
cornerstone of the NI circuits teaching solution to build expertise through
practical application in designing, prototyping, and testing electrical
circuits. The Multisim design approach helps to save prototype iterations and
optimize printed circuit board (PCB) designs earlier in the process (National
Instruments, 2015).

 

2.9 MPLAB

MPLAB IDE is a software program that runs on a PC
(Windows, Mac OS, Linux) to develop applications for Microchip microcontrollers
and digital signal controllers. It is called an Integrated Development
Environment (IDE), because it provides a single integrated
“environment” to develop code for embedded microcontrollers. MPLAB
supports C Compiler for PIC18 (Microchip, 2015).

 

2.10 C Compiler for PIC18

The
MPLAB C Compiler for PIC18 MCUs (also known as MPLAB C18) is a full-featured ANSI
compliant C compiler for the PIC18 family of PICmicro 8-bit MCUs. MPLAB C is a
32-bit Windows console application as well as a fully integrated component of
Microchip’s MPLAB Integrated Development Environment (IDE), allowing source
level debugging with MPLAB’s software and hardware debug engines (Microchip,
2015).

Features:

·               
ANSI ’89 compatibility.

·               
Integration with the MPLAB IDE for easy-to-use project management and
source-level debugging.

·               
Compatibility with object modules generated by the MPASM assembler,
allowing complete freedom in mixing assembly and C programming in a single
project.

·               
Transparent read/write access to external memory.

·               
Efficient code generator engine with multi-level optimization.

·               
Extensive library support, including PWM, SPI, I2C, UART, USART, string
manipulation and math libraries.

·               
Full user-level control over data and code memory allocation.

·               
MPLIB allows easy use of included libraries and for user created
libraries.

·               
Extensive multi-pass optimizations.

·               
Supports new PIC18F extended mode instructions.

 

2.11
Microsoft Visual C#

C# is a programming language that is designed for
building a variety of applications that run on the .NET Framework. C# is
simple, powerful, type-safe, and object-oriented. The many innovations in C#
enable rapid application development while retaining the expressiveness and
elegance of C-style languages.

Visual C# is an implementation of the C#
language by Microsoft. Visual Studio supports Visual C# with a
full-featured code editor, compiler, project templates, designers, code
wizards, a powerful and easy-to-use debugger, and other tools. The .NET
Framework class library provides access to many operating system services and
other useful, well-designed classes that speed up the development cycle
significantly (Microsoft, 2015).

 

2.12 Flicker fusion
threshold

The flicker fusion threshold (or flicker fusion rate) is a concept in the psychophysics of vision.
It is defined as the frequency at which an intermittent light stimulus appears
to be completely steady to the average human observer. Flicker fusion threshold
is related to persistence of vision. Although flicker can be detected for many
waveforms representing time-variant fluctuations of intensity, it is
conventionally, and most easily, studied in terms of sinusoidal modulation of
intensity. There are seven parameters that determine the ability to detect the
flicker (Wikipedia, 2015):

The
frequency of the modulation.
The
amplitude or depth of the modulation (i.e., what is the maximum percent
decrease in the illumination intensity from its peak value).
The
average (or maximum-these can be inter-converted if modulation depth is
known) illumination intensity.
The
wavelength (or wavelength range) of the illumination (this parameter and
the illumination intensity can be combined into a single parameter for
humans or other animals for which the sensitivities of rods and cones are
known as a function of wavelength using the luminous flux function).
The
position on the retina at which the stimulation occurs (due to the
different distribution of photoreceptor types at different positions).
The degree
of light or dark adaptation, i.e., the duration and intensity of previous
exposure to background light, which affects both the intensity sensitivity
and the time resolution of vision.
Physiological
factors such as age and fatigue.

 

2.13 LED Cube

LED cube can be separated into columns and layers. The cathode legs of
every LED in a layer are soldered together, and all the anode legs in one
column are soldered together as in fig. 2.13.0 b) and a) accordingly.

                                    a)                                                                                 b)

Figure
2.13.0 LED cube. Columns (a) and layers (b).

 

Each of the 64 anode columns are connected to a separate current source
controlled by the microcontroller. This way each column can be actuated independently.
Then all eight layers have a separate connection to the sink switch connected
to the microcontroller as well. By operating sink switches controller can sink
the current from one layer at a time, i.e. the image projected on the 64 anode
wires can be displayed on the layer which is currently enabled.

To display the image on the first layer the controller closes the sink
switch for layer one, disables all other layers (opens their sink switches) and
outputs the desired bit pattern (image) on 64 columns (anodes). To display a
different image on the second layer the first layers is disabled, the second
layer is enabled and 64 bit pattern is changed on anodes. In this manner all
layers are updated with different 2D images. This multiplexing produces a 3D
image provided that all operations on layer such as update and refresh are
performed fast enough that human eye cannot see the flickering effect.  

 

 

 

 

 

3. Methodology (hardware)

 

3.1 LED Cube

The size of
LED cube was chosen to be 8x8x8 LEDs as this produces sufficient resolution to
display 3D images such that they could be recognized by an observer. In
addition to that small dimensions of the cube are important as this is a
portable device designed for presentations. 

Monochrome
LEDs were chosen over RGB LEDS for four reasons:

1.     
Monochrome LEDs are much cheaper than RGB
LEDs.

2.     
The wiring is reduced two times (monochrome
LEDs have 2 pins, RGB – 4 pins).

3.     
Colour blending is not required and
therefore the code is less complex.

4.     
Monochrome LEDs have better visibility in a
well-lit environment.

Another
important point on LEDs was their viewing angle which is the maximum angle at which an LED can be viewed with
acceptable visual performance. Since the cube can be looked at from different
angles the viewing angle had to be as wide as possible. Usually clear LEDs have
narrow viewing angles; consequently the choice fell on diffused LEDs even
though they are slightly dimmer than clear LEDs.

750 pieces
of 5 mm LEDs were purchased with the following specifications:

Manufacturer:

Kingbright

Product Category:

Standard LEDs – Through Hole

Luminous Intensity:

20 mcd

Wavelength/Colour Temperature:

565 nm

Lens Colour/Style:

Diffused

Forward Current:

10 mA

LED Size:

T-1 3/4

Mounting Style:

Through Hole

Table 3.1.0
LED specs.

 

Some LEDs had defects on them as shown in
fig. 3.1.0, thus, all LEDs had to be checked before proceeding to the next step.