Professional Documents
Culture Documents
KeithDronson SamSubbarao
DepartmentofElectricalEngineering ColumbiaUniversity
TableofContents
1. 2. 3. 4. 5. 6. 7.
AppendixASoftwareCode
I.ExecutiveSummary Thegoalofourprojectwastodesignandbuildaportableelectronicnotepad.Thenotepadwould haveatouchscreenforwritingonandmemorytostoreyourdrawingsandnotesin.Atyourconvenience youshouldbeabletotransferthedatatoacomputerwhereasoftwareprogramcanreaditandthen displayitonthescreenforyoutosee.Thenotepadshouldhaveafastsamplingrateandhighaccuracy soyourimageswillappearasyoudrewthem. ThisisachievedbyusingamicrocontrollertoreadXandYcoordinatesoffofaresistive touchscreen.TheseX,Ycoordinatescorrespondtothepointthatyouarepokingthescreen.Thesevalues arethenstoredlocallyona*SDcard.Whenyouflipaswitchthemicrocontrollertransfersthedatafrom theSDcardtothecomputerviaaserialconnection.Thisdataisreadinonthecomputerandthen displayedusingsoftwarethatisprovidedwiththenotepad. *AtthispointtheSDcardinterfaceisonlyimplementedinhardware.ThesoftwareinterfacetotheSD cardisstillunderdevelopment.
II.BlockDiagram,DesignTargetsandSpecifications
III.IndividualBlockDescriptions (a)PIC16F877AMicrocontroller TheMCUprovidesaninterfacetothetouchscreen,LCD,SDcardandserialcommunicationtoa computer.TheMCUisabletocreateaconductivepathtogroundinboththeXandYplanesofthe touchscreenbydrivingtwoofthefourpinsconnectedtotheresistivetouchscreenhighandpullingthe othertwotoground.ThevoltagelevelsarethensampledandtheXandYcoordinatesaredetermined fromthesemeasurements. (b)Resistivetouchscreen ThetouchscreenusesafivewireinterfacefordeterminingXandYcoordinates.Fourofthefive wirescorrespondtothefourcornersofthescreen.Thefifthwireprovidesthevoltagelevelatthepoint ofcontact.BysettingthetwotopcornerpointstoVddandthebottomtwotogroundcurrentwillflow fromtoptobottom.Pressingapointonthescreenwillconnectthetopconductiveplaneofthe touchscreenwiththebottomlayeratthatpoint.Bymeasuringthevoltageatthisbottomlayerwecan determinetheYcoordinate.TheXcoordinateisdeterminedthesamewayexceptthetwoleftmost pointsaresettoVddandthetworightmostpointstoground.ByswitchingbackandforthbetweenX andYitispossibletorecreateimagesthataretracedonthescreen. (c)TouchscreenPowerCircuit ThePIC16F877Aisnotabletosupplythecurrentneededforthetouchscreen.Thereforepower opampsareusedtobuffertheoutputoftheMCUandsupplythepowertothetouchscreen. (d)VoltageRescalerCircuit Thevoltagerescalercircuitisrequiredinordertorealizethefull10bitrangeoftheA/D.Without thiscircuitthevoltagemeasuredfromthescreenisbetween~14V.Thisreducesourresolutionbyalmost abit.Inordertofixthistherescalercircuitsubtractsoffavoltageinordertozerothelowerpartofthe range.Thentheresultingvoltageisgainedupinordertospreadtheresolutionfrom0to5Vthusgiving usthefull10bitsofresolution. (e)LCD TheLCDisusedtodisplaydatatotheuser.TheLCDhasa2x8characterdisplayandcanbe programmedtodisplayalmostanykindofdatatotheuser.CurrentlytheXandYcoordinatesmeasured aredisplayedinrealtimetotheuser.
(f)EEPROMSDcard TheSDcardisusedtostorepagesofdatabeforetransferringthemtoacomputer.Currentlythis isonlyimplementedinhardware.HoweverthealgorithmforstoringdatatotheSDcardhasbeen determinedandanappropriatefilesystemdeveloped.TheSDcardisblockaddressedwitheachblock containing512bytesofdata.DuetomemorylimitationsofthePIConlythefirst100bytesofeachblock willcontaindataforaspecificpage.Fora1megapixelresolutionthiswillrequirethat1250blocksbe usedforeachpage.Howeverusingthismethodallowsustooverlappagesbyaddinganoffsetof100 bytestoeachconsecutivepage.Thiswayupto5pagescanbestoresineach1250blocksofdata.When theMCUreadsaX,YpairfromthetouchscreenthePICwilldeterminewhichblockthepointisin.After whichthe100byteswillbereadinfromtheSDcardandthepixelcorrespondingtotheX,Ycoordinate willbesettoa1. (g)SerialCommunicationtoComputer ThePICissetuptotransferdatatothecomputerthroughtheserialportwhenaswitchisflipped. Thedataissentatarateof9600baudusingtheRS232protocol.
IV.IndividualBillofMaterials
PART PIC16F877A LF411OPAMP MCP601OPAMP CPDR07086DualpowerOPAMP 20MHzOscillator SDCardSlot SDCard 5VRegulator 3.3VRegulator LCDScreen Touchscreen PCBboard TotalCost
MANUFACTURER MicrochipTechnology NationalSemiconductor MicrochipTechnology ONSemiconductor Abracon 3M Transcend STMicroelectronics STMicroelectronics CrystalFontz Bergquist SunstoneCircuits
# 1 4 1 2 1 1 1 1 1 1 1 1
COST 8.5 1.63 .65 1.25 1.30 1.33 12.25 1.35 .68 15.70 55.00 50.00 149.64
V.Health,SafetyandEnvironmentalIssues a.ProductDangers Thisproductdoesnotposeanydangerwhenusedproperly. b.HealthHazards Therearenoknownhealthhazardsassociatedwiththisproduct. c.EnvironmentalHazards i.ThisproductcomplieswithallFCCstandards. ii.TheACadaptershouldnotbedisassembledortamperedwith.Theoperatingvoltage for thisdeviceis12Vwhichdoesnotposeanyriskofelectricshock,
VI.FinalGanttChart Week Week Week Week Week Week Week Week Week Week Week Week 1 2 3 4 5 6 7 8 9 10 11 12 Project Brainstorming PaperDesign Touchscreen Controller RescalerCircuit SDCard Interface SerialInterface Display Software BoardDesign FinalPackaging K/ S K/ S K S K S K/ S S K/ S
AppendixA DisplaySoftware
importjava.awt.*; importjavax.swing.JButton; importjavax.swing.JComboBox; importjavax.swing.JFrame; importjavax.swing.JTextField; importjavax.swing.JLabel; importjava.io.*; importjavax.swing.*; importjava.awt.event.*; importjavax.swing.event.*; publicclassImageConverter{ publicstaticStringfileName; publicstaticJTextFieldjtf;
BufferedReaderdataReader=newBufferedReader(newInputStreamReader(in)); StringdataLine; String[]coordinate=newString[DIM]; intx,y; g.setColor(newColor(0,0,0)); while((dataLine=dataReader.readLine())!=null) { coordinate=dataLine.split("",DIM); x=1000Integer.parseInt(coordinate[0]); y=Integer.parseInt(coordinate[1]); g.fillRect(2*x/3,2*y/3,PIXELWIDTH,PIXELWIDTH); System.out.println("Xcoordinate:"+x+"Ycoordinate:"+y); }
} catch(Exceptione) { System.err.println("Error:"+e.getMessage()); } } /***Makessurethat *thewindowdrawingareaendsupbeingthe *rightsize.Youdon'tneedtochangethis. */ publicDimensiongetPreferredSize(){ returnnewDimension(WIDTH,HEIGHT); } //Thesesetthesizeofthedrawingarea. //Changethesizestosuitwhatyouneed. privateintWIDTH=1000; privateintHEIGHT=1000;
publicstaticvoidaddComponentsToPane(Containerpane){ pane.setLayout(newGridBagLayout());
}); } }
MCUFirmware '**************************************************************** '*Name:Pad.bas* '*Author:Keith* '*Notice:Copyright(c)2008[selectVIEW...EDITOROPTIONS]* '*:AllRightsReserved* '*Date:1/24/2008* '*Version:1.0* '*Notes:* '*:* '**************************************************************** Include"modedefs.bas" DEFINEOSC20'Define20MHZclockfrequency DEFINELCD_DREGPORTD'SetLCDdataporttoportD DEFINELCD_DBIT4'Setstartingdatabiton4 DefineLCD_RSREGPORTE'SetRegisterselectporttoE DEFINELCD_RSBIT0'Setstartingdatabiton0 DefineLCD_EREGPORTE'SetEnableport DEFINELCD_EBIT1'Setenablebiton1 DEFINELCD_BITS4 DEFINELCD_LINES2 DEFINeADC_BITS10'SetnumberofbitsinA/Dconversion DEFINEADC_SAMPLEUS50'SetsampletimeinuS TRISA=%11111111'SetPortAtoallinput TRISC.0=0 TRISC.1=1 CMCON=7 ADCON1=%10000100'AN3andAN2areVref+andVrefrespectively ADCON0=%01000001 TRISA.0=1 TRISD=0 TRISB=0 TRISE.0=0
TRISE.1=0 Result_XVarWORD Result_YVarWord Last_XVARWORD Last_YVarWORD CNTVARBYTE TSTARTVARPORTC.1 Up_LeftVArPORTB.0'UpperLeftofscreen Up_RightVarPORTB.1'UpperRight Lo_RightVARPORTB.2'LowerRight Lo_LeftVarPORTB.3'LowerLeft AD_ONVARADCON0.0 AD_STARTVARADCON0.2 SDOVARPORTD.0 SCLVARPORTD.1 modevarword mode=%0101000000111100 PAUSE500'WaitforLCDtosetup CNT=0 PORTC.0=1 Last_X=0 Last_Y=0 main: GosubAD_X pauseUS10 GOSUBAD_Y ifcnt=10THEN LCDOUT$FE,1 LCDOUT$FE,$80,"X:",DECResult_X LCDOUT$FE,$C0,"Y:",DECResult_Y CNT=0 ENDIF CNT=CNT+1 ifTSTART=1THEN IFResult_X!=Last_X||Result_Y!=Last_YThen
seroutSDO,N9600,[#Result_X,"",#Result_Y,13] Last_X=Result_X Last_Y=Result_Y ENDIF endif Gotomain AD_Y:'MeasureX Up_Left=1 Up_Right=1 Lo_Right=0 Lo_Left=0 Result_Y=0 pauseus500'PAUSE5 AD_START=1 WhileAD_START=1 WEND PAUSEUS50 Result_Y.HighByte=ADRESH Result_Y.LowByte=ADRESL Up_left=0 Up_Right=0 RETURN AD_X:'MeasureY Up_Right=1 Lo_Right=1 Up_Left=0 Lo_Left=0 Result_X=0 pauseus500 AD_START=1 WhileAD_START=1 WEND PAUSEUS50 Result_X.HighByte=ADRESH Result_X.LowByte=ADRESL Up_Right=0 Lo_Right=0 Return