You are on page 1of 68

Building Blocks 1

BERGEN COUNTY ACADEMIES


Invention Lab

















BUILDING BLOCKS













Project Director: Bahadir Karuv
Final Report
May 29, 2003


Building Blocks 2
CONTENTS

Introduction 3
The Design Process 4
Spin-off Projects 5
Project Results 6
Future Development 6
Conclusion 7
Acknowledgements 7

APPENDIX A
Pictures 8

A1. First Circuit Boards Developed in the Invention Lab. 9
A2. Some of the Project Students Completed. 10
A3. Keyboard for the Physically Challenged 11

APPENDIX B
Final Board 12

B1. Schematic Diagram for the Double Sided Multi-purpose Board. 13
B2. Board Layout Diagram of the Double Sided Generic Board. 14
B3. Silk Screen for the Component Side (Gerber File). 15
B4. Gerber File for the Component Side. 16
B5. Gerber File for the Solder Side 17
B6. Solder Stop Gerber File for the Final Design (Component Side). 18
B7. Solder Stop Gerber File for the Final Design (Solder Side). 19
B8. Component Side of Final Board 20
B9. Solder Side of Final Board 20

APPENDIX C
Circuit Diagrams 21

C1. Schematic Diagram of the Single Sided Multi-purpose Circuit 22
C2. Layout Diagram for the Single Sided Generic Circuit 23
C3. Schematic Diagram of the Generic IR Controller 24
C4. Board Layout Diagram for the Generic IR Controller 25
C5. Schematic Diagram for IR Remote Controller 26
C6. Board Layout Diagram for the IR Remote Controller 27
C7. Schematic Diagram for the Stepper Controller. 28
C8. Board Layout of the Stepper Controller 29
C9. Schematic Diagram for the Voice Unit 30
C10. Board Layout Diagram of the Voice Unit 31
C11. Schematic Diagram of the X10 and Servo Motor Controller. 32
C12. Board Layout of the X10 and Servo Motor Controller 33
Building Blocks 3

APPENDIX D
C Programs 34

D1. Liquid Crystal Display C Program Listing 35
D2. Stepper Motor Controller C Program Listing 38
D3. Servo Motor Controller C Program Listing 40
D4. Timer with Interrupt C Program Listing 43
D5. I2C Library for 24LC32 SEEPROM 43
D6. RS232 Library for Serial Communication 49
D7. X10 Protocol Communication Library 51

APPENDIX E 56
Awards Won by some of the Students Working in the Toyota TAPESTRY Project

APPENDIX F 58
Expenses

APPENDIX G 59
Senior experience report of one of the students who worked in Building Blocks Project
Building Blocks 4


Project: Building Blocks
Project Director: Bahadir Karuv
Final Report
May 29, 2003


INTRODUCTION:
Building Blocks is an attempt to produce an inventors kit for young minds. In this project
we designed a multi-purpose programmable circuit board for the use of students. We also
developed software libraries to support the many built in functions of the circuit. The unit
is based on Microchips PIC16F877 microcontroller and contains an RS232 serial
communication port, an IR receiver and an IR transmitter. It also has an in-circuit-
debugging port for downloading and debugging the programs and an X-10 protocol port
to communicate to X10 modules for appliance control. The unit can control stepper
motors and servomotors and uses a serial EEPROM as external memory.
The electronics research program at Bergen County Academies (BCA) has been
extremely successful in developing ideas since its inception in 1996. Out of the
Invention Lab at BCA have come three ISEF projects (one second place in the computer
science category), eleven NSTA/Duracell finalists (including two second and three third
places), many strong local winners, and a patent application in partnership with IBM. In
total, students have entered 105 projects in science fairs, culminating in 267 awards. Of
the many projects developed in the Invention Lab, 55 of them have been based on
electronics that utilize a microprocessor.
We always felt that there was a strong need for a generic electronic design which would
speed up the time from the conception of the idea to the working prototype. With the
support of a Toyota TAPESTRY grant we were given the opportunity to design the Swiss
army knife of the Invention Lab: the Building Blocks.
Building Blocks 5
THE DESIGN PROCESS:
Four of our seniors joined the project at the beginning of the 2002-2003 academic year,
and sixteen underclassmen also joined later. We began by testing and documenting the
work done in the lab in the previous years.
One senior student assumed the printed circuit board design task by using Eagle Light
layout design software. Another senior started working on the IR port since we have not
had that interface previously developed in the lab. Two seniors took over the
programming of the Building Blocks.
The underclassmen utilized the newly designed circuits and developed software in their
individually designed research projects.
Almost all previously designed projects relied on BASIC programming language in the
past. We decided to move to the C language. We ordered a C compiler for Microchips
PIC series microprocessors.
We ordered most of our generic electronic components, including special IR ICs, speech
recognition ICs, connectors, switches, sockets, relays, LEDs, LCDs, and radio kits early
on, in order to use them in our initial designs. We also left enough funding for the ideas
that would surface in the course of development. We searched for printed circuit board
(PCB) production companies and studied the PCB design process.
At the beginning we set up some of the previously designed projects on breadboards to
incorporate them into the Building Blocks. We set p speech and X10 units as individual
units and wrote C programs as libraries for future use. The LCD interface was also tested
on the proto-board with newly written C code. We procured a remote control IC and
implemented it in a remote control unit for a TV set, a VCR, and a cable box.
We reviewed the previously designed electronics projects that are stored in the Invention
Lab and discovered that the documentation was inadequate. During the first phase, we
had received a request from the spouse of a paralyzed person to design a one-button TV
remote control unit. We decided to synchronize the Building Blocks project with one of
Building Blocks 6
our ongoing projects and implemented some of the functions of this project to produce
solutions for the physically challenged. We designed, programmed, and delivered the
custom programmed one-button remote control to the person and it is in use since then.
Originally we were planning to send our PCB designs to professional PCB houses, but
decided to etch single sided PCBs in- house. Many functional circuit boards were
developed at this stage (Appendix A, C) This way we developed valuable experience in
PCB Design and prevented costly mistakes. We fixed the mistakes and design flaws in
our initial circuits and sent the files (Appendix B) for the final board to PCBExpress; a
supplier of prototype circuit boards.
SPIN-OFF PROJECTS:
Many of the electronics research projects were developed in sync with the Building
Blocks (Appendix E):
1. Serial Keys, an adaptive keyboard for the physically challenged ? is designed
around Microsofts implementation of Serial Keys protocol, which is built in all
Win32 systems. The unit reads an analog to digital converter (ADC) controlled by
a sliding potentiometer and sends serial mouse and keyboard information to the
operating system. It acts as a keyboard and mouse for people who have difficulty
controlling conventional keyboards and mice.
2. Universal Infrared Remote Control with Learning Ability ? a programmable
multipurpose remote controller for audiovisual equipment. Although such devices
exist in the market, we needed an IR controller for the Building Blocks with the
ability to control TV, VCR, etc. Even though we had an electronic solution from
Innotech Systems SP4001 IC we wanted to replace this chip with a firmware
solution.
3. Affordable Computer Controlled Braille Display ? a Braille solution that controls
pins attached to muscle wire.

Building Blocks 7
4. Voice Activated Life ? uses Microsofts Voice API to control X-10 networked
electrical appliances via simple voice commands.
5. Spectra Light ? generates a continuous spectrum of light by mixing red, green
and blue LEDs.
Most of these projects were presented in the Northern New Jersey Regional Science Fair
in March 2003 and all received multiple awards.
PROJECT RESULTS:
As was proposed, we implemented an interface for an LCD, a stepper motor control port,
a servo motor port, an X10 interface, an RS232 serial port, an IR communication port,
and on/off switches on our main printed circuit board. We sent the files of the final
design for production. We used Building Blocks in different projects and obtained
excellent results. Multiple C code libraries (LCD, X-10, RS232, IR, I2C) were written
and tested.
We also realized the need for external storage for the main board to store changing
parameters and added a serial EEPROM to the project. We built a voice feedback circuit
based on the ISD 2500 series integrated circuit and debugged the C program for it. We
experimented with the Sensory Voice Extreme voice recognition kit. We developed a
different PCB in each case. A generic digital input/output port on the main board was
left unconnected for future use.
FUTURE DEVELOPMENT:
We did not have enough time to implement an H-bridge for linear motor control and
voice circuits as separate modules as it had been originally proposed. Although we were
planning to experiment with different sensors, we ran out of time. We would like to
continue adding new functions to our main controller by incorporating new sensors. We
also would like to work on simple signal conditioning to better interpret the sensors.
Building Blocks 8
Our work revolved around three software products: Eagle printed circuit design software,
the PIC C compiler and MPLAB. These are specialized professional software products,
and it has taken more time than we anticipated to master them. Some of the sample
programs which came with the C compiler did not work, and we had to write byte level
code to remedy this. We also exceeded the limits of the shareware version of Eagle layout
software. We will continue to learn and utilize these tools more effectively.
We will write new software that will configure and monitor all the ports on our main
board and search for ways to modify the program running on the unit in the field.
CONCLUSION:
We have accomplished much this year. We now have our own design of a generic, multi-
purpose, programmable, flexible main controller that can be quickly tailored for any
invention project this lab supports. We are familiar with the hardware and the software of
the unit; it is well documented and it is available to anyone who needs it.
We have obtained all the design tools we need and mastered them all. We have also
ordered the recently released next generation microcontrollers.
Students were given the opportunity to push the boundaries of high school science
research, working in a team environment while gaining valuable experience designing
and developing their ideas.
ACKNOWLEDGEMENTS:
We would like to express our profound thanks to NSTA, Toyota TAPESTRY Program,
and Bergen County Academies for their generous and enthusiastic support of this project.
It is our intent to continue to develop inventions which stimulate our students,
imaginations and serve the community.
Building Blocks 9

APPENDIX A
Pictures

A1. First Circuit Boards Developed in the Invention Lab.
A2. Some of the Project Students Completed.
A3. Keyboard for the Physically Challenged




Building Blocks 10


A1. First Circuit Boards Developed in the Invention Lab.
Building Blocks 11


A2. Some of the Project Students Completed.
Building Blocks 12



A3. Keyboard for the Physically Challenged

Building Blocks 13

APPENDIX B
Final Board


B1. Schematic Diagram for the Double Sided Multi-purpose Board.
B2. Board Layout Diagram of the Double Sided Generic Board.
B3. Silk Screen for the Component Side (Gerber File).
B4. Gerber File for the Component Side.
B5. Gerber File for the Solder Side
B6. Solder Stop Gerber File for the Final Design (Component Side).
B7. Solder Stop Gerber File for the Final Design (Solder Side).
B8. Component Side of Final Board
B9. Solder Side of Final Board










Building Blocks 14


B1. Schematic Diagram for the Double Sided Multi-purpose Board.

Building Blocks 15




B2. Board Layout Diagram of the Double Sided Generic Board.



Building Blocks 16

B3. Silk Screen for the Component Side (Gerber File).
Building Blocks 17

B4. Gerber File for the Component Side.
Building Blocks 18

B5. Gerber File for the Solder Side.
Building Blocks 19

B6. Solder Stop Gerber File for the Final Design (Component Side).
Building Blocks 20

B7. Solder Stop Gerber File for the Final Design (Solder Side).
Building Blocks 21



B8. Component Side of Final Board







B9. Solder Side of Final Board


Building Blocks 22
APPENDIX C
Circuit Diagrams

C1. Schematic Diagram of the Single Sided Multi-purpose Circuit
C2. Layout Diagram for the Single Sided Generic Circuit
C3. Schematic Diagram of the Generic IR Controller
C4. Board Layout Diagram for the Generic IR Controller
C5. Schematic Diagram for IR Remote Controller
C6. Board Layout Diagram for the IR Remote Controller
C7. Schematic Diagram for the Stepper Controller.
C8. Board Layout of the Stepper Controller
C9. Schematic Diagram for the Voice Unit
C10. Board Layout Diagram of the Voice Unit
C11. Schematic Diagram of the X10 and Servo Motor Controller.
C12. Board Layout of the X10 and Servo Motor Controller



Building Blocks 23


C1. Schematic Diagram of the Single Sided Multi-purpose Circuit


Building Blocks 24





C2. Layout Diagram for the Single Sided Generic Circuit

Building Blocks 25


C3. Schematic Diagram of the Generic IR Controller
Building Blocks 26


C4. Board Layout Diagram for the Generic IR Controller
Building Blocks 27


C5. Schematic Diagram for IR Remote Controller
Building Blocks 28


C6. Board Layout Diagram for the IR Remote Controller
Building Blocks 29


C7. Schematic Diagram for the Stepper Controller.
Building Blocks 30


C8. Board Layout of the Stepper Controller.
Building Blocks 31


C9. Schematic Diagram for the Voice Unit
Building Blocks 32



C10. Board Layout Diagram of the Voice Unit

Building Blocks 33


C11. Schematic Diagram of the X10 and Servo Motor Controller.
Building Blocks 34


C12. Board Layout of the X10 and Servo Motor Controller
Building Blocks 35
APPENDIX D
C Programs

D1. Liquid Crystal Display C Program Listing
D2. Stepper Motor Controller C Program Listing
D3. Servo Motor Controller C Program Listing
D4. Timer with Interrupt C Program Listing
D5. I2C Library for 24LC32 SEEPROM
D6. RS232 Library for Serial Communication
D7. X10 Protocol Communication Library

Building Blocks 36

D1. Liquid Crystal Display C Program Listing
#include <pic.h>
void initLCD(void);
void enable(void);
void sendChar(char);

void enable(void) {
int i;

RD3 = 0;
for (i=0; i < 100; i++)
continue;
RD3 = 1;
for (i=0; i < 2000; i++)
continue;
}

void initLCD() {
int i;
TRISD = 0;
//RD3 = 1;

for (i=0;i < 10000; i++)
continue;
PORTD = 0b00111000;
enable(); // 1:
for (i=0;i < 20000;i++)
continue;
enable();
for (i=0;i < 20000;i++)
continue; // 2:
enable(); // 3:
PORTD = 0b00101000;
enable(); // 4:
PORTD = 0b00101000;
enable(); // 5:
PORTD = 0b11001000; //set for two lines ok
enable(); // 6:
PORTD = 0b00001000; // Display Off
enable(); // 7:
PORTD = 0b10001000;
enable(); // 8:
PORTD = 0b00001000; // Display On
enable(); // 9:
PORTD = 0b00011000;
Building Blocks 37
enable(); // 10:
PORTD = 0b00001000; // Entry Mode Set
enable(); // 11:
PORTD = 0b01101000;
enable(); // 12:
}

void sendChar(unsigned char data) {
unsigned char temp = data;
int i;
temp = temp&0xF0; // 240 = 0b11110000
temp = temp | 0b1110;
PORTD = temp;
enable();

temp = data;
temp = temp&15; // 15 = 0b00001111
temp = temp <<4;
temp = temp | 0b1110;
PORTD = temp;
enable();
}

void useLcd(void){
//Test Routine
int i;
for (i=0;i<10000;i++)
continue;

initLCD();

PORTD = 0b00001000;
enable();
PORTD = 0b00011000;
enable();


for (i=0;i<10000;i++)
continue;

for (;;) {

PORTD = 0b00001000;
enable();
PORTD = 0b00011000;
enable();
Building Blocks 38

//SEND DATA
sendChar('H');
sendChar('e');
sendChar('l');
sendChar('l');
sendChar('o');
sendChar(' ');
sendChar('W');
sendChar('o');
sendChar('r');
sendChar('l');
sendChar('d');

PORTD = 0b00001000;
enable();
PORTD = 0b11101000;
enable();

for (i = 0; i < 1000; i++) {
continue;
}
}
}
Building Blocks 39

D2. Stepper Motor Controller C Program Listing

/*Airpax 17V 7.5 degrees/step stepper motor is used
RB4 is connected to Yellow
RB3 is Black
RB2 is Orange
RB1 is Brown
for one direction and
RB4 Black
RB3 Yellow
RB2 Brown
RB1 Orange
for other
*/

#include <pic.h>
#define DELAY 4000
#define MAX 0xFFFF

void pause(unsigned int count){
unsigned int i;
for (i=0;i<count;i++)continue;
}

void pauseL(unsigned int count){
unsigned int i;
for (i=0;i<count;i++) pause(MAX);
}

void rotate (int n){
int i;
TRISA=255;
TRISB=0;

for(i=0;i<12*n;i++){
PORTB=0b10000000;
pause(DELAY);
PORTB=0b11000000;
pause(DELAY);
PORTB=0b01000000;
pause(DELAY);
PORTB=0b01100000;
pause(DELAY);
PORTB=0b00100000;
pause(DELAY);
Building Blocks 40
PORTB=0b00110000;
pause(DELAY);
PORTB=0b00010000;
pause(DELAY);
PORTB=0b10010000;
pause(DELAY);
}
}

void main(void){

while(1){
rotate(3);
PORTB=0;
pauseL(10);
}
}
Building Blocks 41


D3. Servo Motor Controller C Program Listing

#include <pic.h>

void pause8us(unsigned char delay){

//OPTION register
T0CS = 0; //TMR0 Clock source CLKOUT
//(internal instruction cycle clock Fosc/4)

PSA = 0; //prescalerAssignment to TMR0

PS2 = 0; //TMR0 Rate 1:8
PS1 = 1;
PS0 = 0;

// 4/4=1Mhz internal timer * 16 prescaler = 8us
// 8 * 125 (TIMER0) = 1000 us
// 8 * 222 (TIMER0) = 1776 us
// 8 * 256 (MAX) = 2048us
TMR0 = 0;
while (TMR0<delay);
}

void pause2ms(unsigned int delay){
unsigned int i;
for (i=0; i<delay; i++) pause8us(250);
}

void pausems(unsigned int delay){
unsigned int i;
for (i=0; i<delay; i++) pause8us(125);
}

void main (void){
unsigned int i;
TRISB2=0;
TRISB1=0;
TRISB0=0;

while(1){
for (i=0;i<125;i++){
RB2=1;
RB1=1;
Building Blocks 42
RB0=1;
pause8us(125+i);
RB2=0;
RB1=0;
RB0=0;
pausems(20);
}
for (i=125;i>0;i--){
RB2=1;
RB1=1;
RB0=1;
pause8us(125+i);
RB2=0;
RB1=0;
RB0=0;
pausems(20);
}

}
}
Building Blocks 43


D4. Timer with Interrupt C Program Listing

#include <pic.h>

void main(){
TRISB = 0;

//OPTION register
T0CS = 0; //TMR0 Clock source CLKOUT
//(internal instruction cycle clock Fosc/4)
PSA = 0; //prescalerAssignment to TMR0

PS2 = 0; //TMR0 Rate 1:2
PS1 = 0;
PS0 = 0;

// The program measures .52ms ON and .52ms OFF
// 4MHz clock; T = 1/4 = 0.25us

// 4/4=1Mhz internal timer * 2 prescaler =us
// 256*2 TIMER0 = 512 ms

//INTCON register

// INTE=0; //Disables the RB0/INT external interrupt
// EEIE=0; //EE Write complete

// T0IF=0;
T0IE=1; //Enables the TMR0 interrupt
GIE=1;
RB4=0;
TMR0 = 0;

while(1);
}

//Interrupts when overflow from FF to 0

void interrupt myint(){
// if (RB0==1) RB0=0; else RB0=1;
RB0=1^RB0;
T0IF = 0; //if you do not clear TOIF the moment it is done with the interrupt
//it will be interrupted again with 18us ON 22us OFF time
}
Building Blocks 44


D5. I2C Library for 24LC32 SEEPROM

//for 24LC32 SER EEPROM
//24LC32 is at the 0 th location A2,A1,A0=0
//can write 64 bytes at atime
//uses two address bytes
//block for 24LC16 is used for significant address byte
#include <pic1677.h>


#define SDA RC4
#define SDADIR TRISC4
#define SCL RC3
#define SCLDIR TRISC3
//The following are defined for unsigned char
#define ACK 1
#define NOACK 2
#define BUS_ERROR 3
//The following are defined for int
#define WRITE_ERROR -1
#define READ_ERROR -2
#define FORMAT_ERROR -3
#define FORMAT_ERROR_24LC16B -4

void pause(unsigned int count){
int i;
for(i=0; i<count;i++)continue;
return;
}

void scllow(){
SCL=0;
SCLDIR=0;
}

void sclin(){
SCLDIR=1;
}

void sdalow(){
SDA=0;
SDADIR=0;
}

Building Blocks 45
void sdain(){
SDADIR=1;
}

void release(void){
scllow();
sdain();
sclin();
}

void start(void){
/* high to low on SDA while SCL is high
*/
scllow();
sdain();
sclin();
pause(10);
sdalow();
pause(10);
scllow();
}

void stop(void){
/* LOW to HIGH on SDA while SCL is high*/
scllow();
pause(10);
sdalow();
pause(10);
sclin();
pause(10);
sdain();
pause(10);
}

void send(unsigned char addr){
signed char i;
scllow();
sdalow();
for (i=7; i>=0; i--){
if((addr>>i)&1) sdain();
else sdalow();
pause(30);
sclin();
pause(30);
scllow();
}
Building Blocks 46
}

void writeSel(unsigned char addr){
addr=addr & 0xFE;
send(addr);
}

void readSel(unsigned char addr){
addr=addr | 1;
send(addr);
}

unsigned char read(){
unsigned char i;
unsigned char byte = 0;
sdain();
for(i=0; i<8; i++){
scllow();
pause(30); /* min clock low period */
sclin();
if (SCL==0) pause (100);
if (SCL==0) return BUS_ERROR;
byte = byte << 1; /* read the next bit */
byte |= SDA;
}
scllow();
return byte;

}
unsigned char isAck(){
unsigned char temp;
scllow();
pause(10);
sdain();
sclin();
if (SCL==0) pause(10); //if SCL is kept by the slave
if (SCL==0) return BUS_ERROR;
pause(10);
temp=SDA;
scllow();
if (temp==0) return ACK;
return NOACK;
}

void ack(){

Building Blocks 47
scllow();
pause(10);
sdalow();
pause(10);
sclin();
pause(100);
scllow();
}

void noack(){
scllow();
pause(10);
sdain();
pause(10);
sclin();
pause(100);
scllow();
}

void flash(){
int i;
TRISB0=0;
for(i=1; i<10; i++){
RB0=1;
pause(10000);
RB0=0;
pause(5000);
}
}

int get(unsigned char block, unsigned char addr, unsigned char* data, unsigned char
count){
unsigned char i,flag;
start();
if (block>15) return FORMAT_ERROR;
//24LC32 is at the 0 th location A2,A1,A0=0
writeSel(0xA0|1);
flag=isAck();
if (flag==BUS_ERROR) return WRITE_ERROR;

send(block); //send high address
flag=isAck();
if (flag==BUS_ERROR) return WRITE_ERROR;

send(addr); //send low address
flag=isAck();
Building Blocks 48
if (flag==BUS_ERROR) return WRITE_ERROR;
stop();
start();

readSel(0xA0|1);
flag=isAck();
if (flag==BUS_ERROR) return READ_ERROR;

for (i=0; i<count-1;i++){

data[i]=read();
ack();
pause(100);
}
data[i]=read();
noack();
stop();
return count;
}

int put(unsigned char block, unsigned char addr, unsigned char* data, unsigned char
count){
unsigned char i;
unsigned char flag;
if (count>64) return FORMAT_ERROR_24LC16B;
release();
start();
if (block>15) return FORMAT_ERROR_24LC16B;
writeSel(0xA0|1);
flag=isAck();
if (flag==BUS_ERROR) return WRITE_ERROR;

send(block);
flag=isAck();
if (flag==BUS_ERROR) return WRITE_ERROR;

send(addr);
flag=isAck();
if (flag==BUS_ERROR) return WRITE_ERROR;

for (i=0; i<count;i++){
send(*(data+i));
flag=isAck();
if (flag==BUS_ERROR) return WRITE_ERROR;
}
stop();
Building Blocks 49
sclin();
while (SCL==0);
i=NOACK;
while(i==NOACK){
start();//Acknowledge Polling!
writeSel(0xA0|block<1);
i=isAck();
}

return count;
}
Building Blocks 50

D6. RS232 Library for Serial Communication

//BAUD 2400
//NO invertor

#include <pic.h>
#define tx RA3
#define rx RA4

void pause (unsigned int count){
unsigned int i,j;
for(i=0;i<count;i++)
for (j=0;j<0xffff;j++);
}

void initSer(void){
TRISA=0b11110111;
//OPTION register
T0CS = 0; //TMR0 Clock source CLKOUT
//(internal instruction cycle clock Fosc/4)
PSA = 0; //prescalerAssignment to TMR0

PS2 = 0; //TMR0 Rate 1:2
PS1 = 0;
PS0 = 0;
}

void putch(char c){
unsigned char i;
c=~c;
TMR0=0;
tx=1;
for(i=0;i<9;i++){

//300baud 1/300 = 3.33ms= 3333.33us
//2400 = 416us
while(TMR0<208);

tx=c&1;
TMR0=0;
c=(c>>1)|0x80;
}
tx=0;
while(TMR0<208);
c=0xaa;
Building Blocks 51
}

char getch(void){
unsigned char c;
unsigned char i;
c=0;
while(!rx);
for(i=0;i<25;i++);
TMR0=0;
for (i=0; i<8; i++){
while(TMR0<208);
TMR0=0;
c=c|(rx<<i);
}
while(TMR0<208);
return ~c;
}
Building Blocks 52
D7. X10 Protocol Communication Library

#include <pic.h>
//#include "x10lib.h"

#define zcross RB4
#define x10 RB3


#define NOZEROCROSSING 1

#define A 0b0110
#define B 0b1110
#define C 0b0010
#define D 0b1010
#define E 0b0001

#define one 0b01100
#define two 0b11100
#define three 0b00100
#define four 0b10100
#define five 0b00010
#define six 0b10010

#define ALLOFF 0b00001
#define ALLON 0b00011
#define ON 0b00101
#define OFF 0b00111


void x10full(unsigned char house, unsigned char unit, unsigned char command);
//void x10cmd(unsigned char house);
void pause2ms(unsigned int delay);

//PL513 pin 1 is connected to RB4 zcross
// pin 2&3 are ground pin4 is RB5 x10
//device=0bxxx1110hhhhddddd;
//device = 0b000 1110 0110 01100 //A1
//command1= 0b000 1110 0110 00101 //A ON
#define START 0b0001110
#define ms 125
#define ms17 222

void pause8us(unsigned char delay){
//OPTION register
T0CS = 0; //TMR0 Clock source CLKOUT
Building Blocks 53
//(internal instruction cycle clock Fosc/4)
PSA = 0; //prescalerAssignment to TMR0
PS2 = 0; //TMR0 Rate 1:8
PS1 = 1;
PS0 = 0;

// 4/4=1Mhz internal timer * 16 prescaler = 8us
// 8 * 125 (TIMER0) = 1000 us
// 8 * 222 (TIMER0) = 1776 us
// 8 * 256 (MAX) = 2048us
TMR0 = 0;
while (TMR0<delay);
}
void pausems(unsigned int delay){
unsigned int i;
for (i=0; i<delay; i++) pause8us(125);
}

void pause2ms(unsigned int delay){
unsigned int i;
for (i=0; i<delay; i++) pause8us(250);
}

void x10send(unsigned int string){
unsigned char x;
unsigned char i;
unsigned int state;
unsigned char j;

while(zcross); //do not start in the middle of the pulse
while(!zcross);
state=0;

//1 ms envelope need be applied to the inputs of PL513 to represent a one
//T= 1/60 = 16.67ms; T/2 = 8.33ms; T/2/3=2.78ms
//right after EVERY zero crossing of the local phase and estimated zero
//crossing of the two other phases, send the bits
//every bit in the stream is sent three times in one cycle then
//complement of the bit is sent three times (except start bits)
//then whole start header/house code/unit number or command word is
//sent again to have two words without any break


for (j=0; j<2 ;j++){
for (i=3; i<7;i++){
if ((string << i) & 0x8000) x=1;
Building Blocks 54
else x=0;
while(zcross==state);

x10=x;
pause8us(ms);
x10=0;

pause8us(17ms); //1.7ms for three phase distribution
x10=x; //if you do not have this only appliances on the
pause8us(ms); //same extention will communicate
x10=0;

pause8us(17ms);
x10=x;
pause8us(ms);
x10=0;

state=1 ^ state;
}
for (i=7;i<16;i++){
if ((string << i) & 0x8000) x=1;
else x=0;
while(zcross==state);

x10=x;
pause8us(ms);
x10=0;

pause8us(17ms);
x10=x;
pause8us(ms);
x10=0;

pause8us(17ms);
x10=x;
pause8us(ms);
x10=0;

state=1 ^ state;

if ((string<<i) & 0x8000) x=0;
else x=1;
while(zcross==state);

x10=x;
pause8us(ms);
Building Blocks 55
x10=0;

pause8us(17ms);
x10=x;
pause8us(ms);
x10=0;

pause8us(17ms);
x10=x;
pause8us(ms);
x10=0;

state=1 ^ state;

}
}

for (i=0;i<3;i++){
while(!zcross);
while(zcross);
}

}

void x10full(unsigned char house, unsigned char unit, unsigned char command){
int device;
int cmd;


device= (((START << 4) |(0xF & house) )<< 5) | (0x1F & unit);
cmd= (((START << 4) |(0xF & house))<< 5) | (0x1F & command);
x10send(device);
x10send(cmd);
}

/*
void main(void){
// unsigned char i;
TRISB4=1;
TRISB5=0;
//x10full(unsigned char house, unsigned char unit, unsigned char command)
while(1){
x10full(A,one,ON);
pause2ms(2000);
x10full(A,one,OFF);
pause2ms(2000);
Building Blocks 56
x10full(A,two,ON);
pause2ms(2000);
x10full(A,two,OFF);
pause2ms(2000);
}
}
*/

Building Blocks 57
APPENDIX E
Awards Won by some of the Students Working in the Toyota
TAPESTRY Project

North Jersey Regional Science Fair
Raritan Valley Community College
North Branch, New Jersey

March 14-15, 2003


Benjamin Nathaniel Herschenfeld

Affordable Computer Controlled Braille Display

ABSTRACT

During the last twenty years, technological progress in the fields of computers and
electronics have revolutionized communication and the transfer of information, especially
as the cost of computer controlled devices dropped into a range affordable to most
citizens of a developed country. However, during these last twenty years, the technology
that would allow blind people to benefit from these advances, computer controlled braille
displays, has stood still at piezo electric crystals which require thousands of volts and
remain prohibitively expensive, often causing devices to cost in the range of $10,000 to
$15,000. To remedy this, I designed and made prototypes for a workable computer
controlled braille display that uses simple, affordable, easily powered materials and
technologies so that braille displays might be available to all who could be helped by
them, and also so that they might be incorporated into more of the devices that have been
improving the lives of people with sight for twenty years already. All that was required
was muscle wire and pen components.

Awards:

First Place in Engineering Category
Stevens ECOES Summer Scholarship
Columbia Alumni Association Award ($50)
Princeton Plasma Physics Award
David S. Young Memorial Award ($200)
Army Outstanding Project Award, Sr. Division
Herbert Hoover Young Engineer Award, Sr. Division
Building Blocks 58
Dmitry Ryvkin

Computer Input for the Physically Challenged

ABSTRACT

The goal of my project is the design of a device that gives the physically challenged
control over a computer. Computer use grants innumerable opportunities to people with
physical disabilities. On standard keyboards, even the "hunt-and-peck" method requires
movement of the arm and wrist; the same thing holds for mice. My goal is to build an
input device to control any computer using a minimal physical range of motion. The
device consists of a slider and one or two buttons, requiring only two fingers to send both
mouse and keyboard input. Depending on the mode of the device, the button will either
send keyboard characters or mouse position information to the computer. In mouse input
mode, the slider will move the mouse cursor in a single dimension, either X or Y.
Although it is more time consuming than a regular keyboard and mouse, the device is
intended for individuals with limited manual dexterity, who would otherwise be unable to
use computers.

Awards
First Place in Mathematics and Computers Category
Special Computing Award, Grand Prize ($200, ACM membership)
Columbia Alumni Association Award
Army First Place Award
Herbert Hoover Young Engineer Award, Sr. Division
Intel Excellence in Computer Science Award, Sr. Division ($200)


Anton Ushakov

Universal Infrared Remote Control With Learning Ability

ABSTRACT

The goal of my project was to create a multipurpose, programmable remote control
module. I programmed a PIC16F877 processor to detect, analyze, and store infrared data
which is passed to it from a conventional remote. I constructed a fully functional remote
control which utilizes my program to learn and store 14 IR codes and to control various
devices such as TVs, VCRs, DVD players, and radios from most manufacturers.

Awards:
Second Place in Engineering Category
Special Computing Award, First Place ($100, ACM membership)
Scientific American Award International Society for Optical Engineering

Building Blocks 59
APPENDIX F
Expenses


Company Description Price
Altium CircuitMaker Upgrade $310.00
ThRobson Co., Inc Electronic Compass $76.00
Quantum Research Touch Sensor Ics $78.25
Sensory Voice Kit $375.00
Jameco Electronic Components $230.47
B7B Electronics Connectors $631.90
Hi-Tech Microchip PICmicro C-Compiler $570.00
Innotech Systems IR Remote Control Ics $425.00
AllElectronics Corp. Electronic Components $623.30
Digikey Microcontrollers, Kits,
Components
$2,371.19
Mouser Ics, tools, PCB material $2,036.22
Jameco Connectors, Ics, tools $663.57
CadSoft Eagle Layout Software $160.00
Innotech Systems IR Remote Ics $210.00
PCBexpress PCB Service $230.00
CSS Engineering Kit with Compiler $989.00
AllElectronics Corp. LEDs $22.50

Total: $10,002.40
Building Blocks 60
Dmi t r y Ryvk i n
I nvent i on Lab Ber gen Count y Ac ademy
Dr . Bahadi r Kar uv
May 2,2003
APPENDIX G
Senior experience report of one of the students who worked in Building Blocks Project
Building Blocks 61
Introduction
I am a senior in the Academy for the Advancement of Science and Technology,
and have had exposure to both science and technology, but little to engineering, a field I
am interested in studying. As a little boy, I would arrange for accidents to befall my
toys, just so I would have an excuse to take them apart. Few of the things I dismantled
worked properly when I put them back together, but I didnt mind; I was nourishing a
desire to learn how things worked, the hunger that drives my pursuit of engineering. I
love engineering because I can take all of the ideas I have and create tangible devices that
serve a useful purpose. Its the same feeling of making something out of nothing that
keeps writers and artists captivated, but instead of clay or words, I work with circuit-
boards and lines of code.
I have a weakness for good stories and endearing characters in books; my interest
in Science Fiction is partly responsible for my inclination towards engineering. I have
been fascinated by ideas like artificial intelligence since I first read 2001: A Space
Odyssey; perhaps engineering appeals to me because it allows me to make this world
more like the worlds of tomorrow I have read about.
I had done a research project with Dr. Karuv in my junior year and I had enjoyed
it. When Renee De Voursney told me that Dr. Karuv was looking for people to carry on
the work the current interns had started, I jumped at the opportunity. Not only would I get
to learn more about engineering and electronics, but I would be working on something
worthwhile, a continuation of a project intended to assist a physically challenged man
named Russell. Although I was already vaguely familiar with the RussAid, a project
made possible by a grant from the NSTA and Toyota TAPESTRY, I would become more
so as my internship in the Invention Lab started.

Organization Background
The Academy for the Advancement of Science and Technology accepted its first
class in the fall of 1992. Ever since, its mission has been to provide a technology- infused,
project-driven curriculum in a restructured learning environment. The seven schools that
became the Bergen County Academies are a public magnet high school serving Bergen
Building Blocks 62
County, New Jersey. Located in the central city of Hackensack, the Bergen County
Academies occupy the building previously held by Bergen Technical Schools.
Students attending AAST (and the six other schools it spawned) are presented
with opportunities for internship in their senior year, the idea being to gather valuable
workplace experience as well as to educate the student. The interns also provide a
valuable resource for external companies, as they can generate new and radical ideas and
have experience with many of the technologies used in todays business world.

Department Information
The Invention Lab is a unique research environment which, under the guidance of
Dr. Bahadir Karuv, is home to many projects developed by Academy students. Although
the first projects were centered around engineering and computer science, much of the
current research goes above and beyond these fields. Indeed, its alternative title of
Inventions Lab is more appropriate.
The projects performed in this laboratory are not limited to students of a certain
age or Academy, and often underclassmen are seen collaborating with upperclassmen in
their research. The Invention Lab is also host to an in-house senior internship, where
students can work on independent projects that will give them experience in electronics
research. Their work revolves around solving real- life problems using technology and
engineering. Many of the projects developed at the Invention Lab are entered into
competitions such as the North Jersey Regional Science Fair in an effort to show the
outside world what sort of work is being performed there, as well as to expand the
horizons of students to include areas of research outside their own.

My Role
My internship at the Invention Lab began with work on the RussAid, a project
that had been started the previous year by several students. The RussAid was a device
that allowed Russell, a severely physically challenged individual, to control the
electronics in his home, including, but not limited to, his television, bed, and several
lamps. Last years team had done an excellent job, and Russell had been happily using
the device for several months.
Building Blocks 63
My role in the internship became more defined as Dr. Karuv told us there was
another person in need of an Environmental Control Unit. Charles was also physically
challenged and his case was more urgent, as his condition seemed to be deteriorating.
Since Charles only required a handful of the features that were built into the
RussAid, I tried to use the configuration program developed by last years students for
this task, but it was error-prone and I was unable to create the configuration we needed.
By reverse-engineering the code that the configuration program generated, I wrote
another version of the program that met Charles requirements, television control.
I realized, however, that since Charles wanted (not unreasonably) to change the
channel as he watched TV and he had cable, the device would have to interface with the
cable box in his home. By virtue of having the same cable provider as Charles
(Cablevision), I was able to experiment on my own cable box with the hope that his was
identical. I modified the original RussAid code to control several infrared-controlled
devices, the case being both a television set and a cable box. (It is worth mentioning that
Anton was attempting to redesign the remote-chip we were using to output the infrared
signals, saving us nearly a quarter of the cost of building each device.)
Within two months of beginning our internship, we had created a new iteration of
the RussAid and had given it to Charles, whom we had met to install the device. It was
time to move on in our research.
I began to study the migration of the RussAid project from the expensive hobbyist
Basic STAMP II to the cheap and powerful PIC microprocessor. This would require the
transition from the Basic programming language to the more-powerful-but- more-difficult
C language, and I decided that rather than try to rewrite the RussAid code line by line, I
would recreate the functionality of the RussAid from scratch. (While last years team
accomplished an astounding feat in that they managed to complete their project starting
from nothing, their code was less than ideal and needed rewriting anyway.)
After some problems with the compiler for the PIC programming language were
ironed out (and Dr. Karuv played e- mail tag with their Australian development team), I
began to learn to program on the microprocessor. My first few projects were simple, just
experiments with what the hardware and software could do and nothing more than games
with light-emitting diodes. As I learned more, I began to look for a way to create a
Building Blocks 64
configurable menu system that would have an unlimited number of levels (well, limited
only by the memory available). This turned out to be a much more difficult proposition
than I had imagined, and it took me nearly a month to work out a system that worked
well. By the end of December, I had written the code that could be configured via this
system, but by then, our focus had begun to drift.
Dr. Karuv told us about the North Regional Science Fair, and all three of us
wanted to present projects there. Dr. Karuv had previously thought about Windows
support for keyboard and mouse input through a computers serial port, and this idea
became central to my project. If input could come from something that wasnt a
keyboard, it didnt have to have a traditional shape or form.
With that in mind, I set about designing a device that would allow the physically
challenged to use a computer. I had a good idea of what I wanted the interface to be like,
so most of the work came down to actually writing the program that would make it all
work. Dr. Karuv and I began to experiment with sending input to the serial port on a
computer, but we were delayed (as we would later figure out) because serial
communications on the computer I was working at did not work properly. We solved this
problem, but I was plagued by other problems completely outside my control (other
computers not working properly, etc.) until I moved my work over onto the laptop Dr.
Karuv had in the lab.
My work became more frantic as the deadline of the science fair loomed nearer.
In the final week, I scrambled to complete my work. Dr. Karuv had a dozen other
projects going to the science fair, and understandably he couldnt devote all his time to
mine, but he put in a lot of extra time and we stayed after school several times. My
project needed a liquid crystal display (LCD) so whoever was using it could know what
kind of input was going to be sent to the computer at any given time. (Upon later
reflection, more time should have been given to this, as without it the project wouldnt
have worked at all.) With some help from Dr. Karuv and a lot of panic about deadlines, I
managed to complete the code, and Dr. Karuv managed to complete the physical
construction of what I would take to the science fair as the SerialKeys project.
The science fair was a welcome respite from the furor of the previous few days,
although it was tiring to repeat the same spiel to the myriads of wandering judges (see the
Building Blocks 65
appendix for the abstract from my project). I was placed in the Mathematics and
Computer Science section, unlike Renee and Anton who were placed in Engineering. Im
still not sure why this decision was made. The science fair lasted two days, with an
awards ceremony at the end. I was quite pleasantly surprised to receive several first-place
awards, and it was nice to know that the judges who had smiled and nodded the days
before had actually been listening and evaluating me. All my effort had not been for
naught.
When the post-science fair exhaustion- induced euphoria wore off, I got back to
work at my internship, concentrating on the RussAid project that I had all-but-abandoned
for several months. Because I wanted this iteration of the RussAid to be easily
configurable, I set about writing a program in Visual Basic to do just this. Although I had
programmed in Visual Basic before, its graphical user interfaces were a welcome break
from the harsh, text-based world of C.
My time spent writing the RussAid Configuration Tool was more leisurely; my
new deadline was the end of the year. I went through several improvements, and I think I
ended up making something that both works and is visually satisfying.

Research Component
There are several commercially-available solutions similar to the RussAid device.
It is important to know the competition in a given market, what they can provide and how
much it will cost the end user.
Imperium 200H is produced by InterAct Plus, a division of Warning Systems Inc.
It functions, I was surprised to find, almost exactly as does our RussAid. The device is
based on a menu system, which is navigated by using two buttons. The menu is displayed
on a LCD (as opposed to our light-bar) which prints out each menu item as it is in turn
selected. The device also has verbal feedback, so visually impaired users could navigate
the menu without relying on the LCD (the RussAid 2 also had this feature).
The Imperium 200H has a fully featured, built- in, hands- free telephone. It
operates like a standard telephone with popular features, including call-waiting, 10-
number memory, redial, and volume control. In addition, the telephone can be set to tone
or pulse dialing, and prefixes can be included with phone number selection. Headphones
Building Blocks 66
let the user conduct a private conversation. A special noise filtering system allows normal
telephone conversation, even in a high- noise environment.
I was impressed by the Imperium 200H, as it had all of the features of the
RussAid and more. I couldnt find a price for the unit, but its safe to say that it probably
rises into the thousands of dollars.
The EZRA is an environmental control unit made by KY Enterprises. It outputs
its menu on a television, but otherwise runs similarly to the RussAid. The newest version
now controls a DSS satellite receiver, surround sound audio systems, and jukebox-type
CD players. The EZRA comes with universal remote, a wireless switch, X-10 appliance
modules, an interface to a wheelchair ECU unit, and an instructional video for setup and
operating the unit.
The basic EZRA system costs $750. Additional features include a speakerphone
for $200, a bed controller interface for $100, and a sip/puff switch for an additional $90.
The Solo Act environmental control unit is made by Taplink. The company was
founded in October of 1996.The Solo Act is versatile, partly because of an included A/D
converter port. It has most of the features of the RussAid and is able to control some
devices (like heating and air conditioning equipment) which the RussAid cannot.
A price for the Solo Act was not provided on the website, and in order to get an
estimate I would have had to contact them.
In general, what I found was that similar units to the RussAid were available, but
that they cost exorbitant amounts of money. The market that they cater to is very limited
physically challenged people who have the means to buy these products. The goal of
RussAid is not to create a device that does not exist in the marketplace, but to do so
cheaply and to create an affordable version which everyone in need could purchase.

Conclusion
Unlike other people I know, I enjoyed my internship and would readily repeat the
experience. Dr. Karuv is a good mentor in that he knows when to give help and when to
let you figure something out for yourself. I learned a lot about programming in the course
of this internship, especially the programming of microprocessors, which I had not been
Building Blocks 67
previously exposed to. Perhaps my only regret is that I didnt get more hands-on
electronics experience.
I would highly recommend this internship to juniors, but it requires an inquisitive
mentality and not everyone would be right for this sort of work. That said, I know several
students who would be perfect for it (and who it would be perfect for). I enjoyed working
with Dr. Karuv, Renee, and Anton during my internship and I learned a lot from them.



Appendix
Abstract:

Title: Computer Input for the Physically Challenged

The goal of my project is the design of a device that gives the physically
challenged control over a computer. Computer use grants innumerable opportunities to
people with physical disabilities. On standard keyboards, even the "hunt-and-peck"
method requires movement of the arm and wrist; the same thing holds for mice. My goal
is to build an input device to control any computer using a minimal physical range of
motion. The device consists of a slider and one or two buttons, requiring only two fingers
to send both mouse and keyboard input. Depending on the mode of the device, the button
will either send keyboard characters or mouse position information to the computer. In
mouse input mode, the slider will move the mouse cursor in a single dimension, either X
or Y. Although it is more time consuming than a regular keyboard and mouse, the device
is intended for individuals with limited manual dexterity, who would otherwise be unable
to use computers.
Outline
1. The Russ Aid Environmental Control Unit
a. Previous Work
b. What I Did
2. The SerialKeys Device
Building Blocks 68
a. The Problem
b. My Goals
c. Production
d. Final Product

Works Cited
http://www.interactplus.com Website for Imperium 200H, a product of InterAct
http://www.quadcontrol.com/ezra.htm - Information about the
http://www.taplink.net/ - TapLink manufactures assistive technology devices for the
disabled

You might also like