版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
IntroductoryMicrocontrollerTheoryandApplicationsChapter9InterfacingtheMCS-51toMechanicalandOpticalDevicesInterfacingtoExternalDevices8051A-DconverterExternalMemory7-segmentdisplayKeypadLCDdisplayD-AconverterSteppermotoriButtonKeypads按键andKeyboards键盘Interfaceto3x4KeypadINT0P1.2P1.0P1.1P0.0P0.3+5VPull-upresistorsRow0Row1Row2Row301Col2Interfaceto3x4KeypadINT0P1.2P1.0P1.1P0.0P0.3+5VPull-upresistors11110000111I/PO/P01Col2Row0Row1Row2Row3Interfaceto3x4KeypadINT0P1.2P1.0P1.1P0.0P0.3+5VPull-upresistors11110000111I/PO/P01Col200InterruptRow0Row1Row2Row3Switchclosed0Interfaceto3x4KeypadINT0P1.2P1.0P1.1P0.0P0.3+5VPull-upresistors000011I/PO/P01Col20Column=1Row0Row1Row2Row3Whichcolumn?Interfaceto3x4KeypadINT0P1.2P1.0P1.1P0.0P0.3+5VPull-upresistors011111I/PO/P01Col21NotRow0Row0Row1Row2Row3Whichrow?Interfaceto3x4KeypadINT0P1.2P1.0P1.1P0.0P0.3+5VPull-upresistors101111I/PO/P01Col21NotRow1Row0Row1Row2Row3Whichrow?Interfaceto3x4KeypadINT0P1.2P1.0P1.1P0.0P0.3+5VPull-upresistors110111I/PO/P01Col20Row2Row0Row1Row2Row3Whichrow?Interfaceto3x4KeypadINT0P1.2P1.0P1.1P0.0P0.3+5VPull-upresistors111011I/PO/P01Col21NotRow3Row0Row1Row2Row3Interfaceto3x4KeypadINT0P1.2P1.0P1.1P0.0P0.3+5VPull-upresistors01Col2Row0Row1Row2Row3 POLLINGTOFINDSWITCHMakeP0outputandP1inputMakeP0=00hWaitforinterruptISRreadsP1.FindwhichcolumnMakeRow0low.IfP1not111bthenRow0MakeRow1low.IfP1not111bthenRow17.MakeRow2low.IfP1not111bthenRow28.MakeRow3low.IfP1not111bthenRow39.2.4Debouncing防抖动ofKeypads080511P1.09.2.4Debouncing防抖动ofKeypads080511P1.09.2.4Debouncing防抖动ofKeypads0805111010P1.0ISR_KEY: MOV R0,#20hLOOP1: MOV R1,#FFh DJNZ R1,$ DJNZ R0,LOOP1 ;RemainderofISR9.2.4Debouncing防抖动ofKeypadsPleasetry…. Question9.6.2 Question9.6.3 (4)Question9.6.2ACBMGHINROPDJKLEFVUTSXQW10portpins9.6.37-SegmentDisplays七段码显示Connectionof7-segmentdisplaysto8051s7-SegmentDisplaycabdefgP-typeGaAssemiconductorN-typesemiconductorN-型半导体LightEmittingDiode(LED)LightGalliumArsenide砷化镓GND+CommonAnodeConnection共阳极Anodes阳极+abcdefgGND+CommonCathodeConnection共阴极Cathodes阴极GNDabcdefgPortCurrentCapability8051P1.48051P1.4LEDLEDGND+5V60mA2mASETBP1.4CLRP1.4107-SegmentDisplays七段码显示7-Segmenttodisplay1780P1.0P1.3P0.0P0.7ConnectiontoanodesP1.0P1.3P0.0P0.7Connectiontoanodes100010011117-Segmenttodisplay1780P1.0P1.3P0.0P0.7Connectiontoanodes010000011117-Segmenttodisplay1780P1.0P1.3P0.0P0.7Connectiontoanodes001000000007-Segmenttodisplay1780P1.0P1.3P0.0P0.7Connectiontoanodes000100000017-Segmenttodisplay1780P1.0P1.3P0.0P0.7ConnectiontoanodesDisplay3Display2Display1Display07-Segmenttodisplay1780
ZERO EQU 10000001b ONE EQU 11001111b TWO EQU10010010b THREE EQU10000110b FOUR EQU11001100b FIVE EQU10100100b SIX EQU10100000b SEVEN EQU10001111b EIGHT EQU10000000b NINE EQU10001100bREPEAT: CLR P1 SETB P1.0 ;SelectDisplay0 MOV P0,#ONE ACALL DELAY7-Segmenttodisplay1780
CLR P1.0 SETB P1.1 ;SelectDisplay1 MOV P0,#SEVEN ACALL DELAY CLR P1.1 SETB P1.2 ;SelectDisplay2 MOV P0,#EIGHT ACALL DELAY CLR P1.2 SETB P1.3 ;SelectDisplay3 MOV P0,#ZERO ACALL DELAY SJMP REPEAT7-Segmenttodisplay1780UseofaDecoderchip译码器芯片B7447decoderCADabcgdfe7-SegmentDisplayDecoderP1.0P1.2P0.0P0.37447decoderPleasetry….Question9.6.10 (Page204)Question9.6.10P1.0P1.2P0.0P0.37447decoderInput=0110Output=?abcdefgOutput=01000007447decoderControlling7-segmentsfromtheSerialPort1.Usethe8051serialport2.UseSerialMode03.ConnectaShiftRegister移位寄存器 toeach7-segmentdisplayUses7pinsonthe80516.2.5UsingMode0onthe8051serialportModeSM0SM1DescriptionBaudrate000ShiftregisterOsc/121018-bitUARTVariable2109-bitUARTOsc/64Osc/323119-bitUARTVariable80516.2.5UsingMode0onthe8051serialport01110011TXDfosc/121machinecycleRXDSBUF80516.2.5UsingMode0onthe8051serialport01110011RXDTXDSBUFfosc/1280516.2.5UsingMode0onthe8051serialport01110011RXDTXDSBUFfosc/1280516.2.5UsingMode0onthe8051serialport01110011RXDTXDSBUFfosc/1280516.2.5UsingMode0onthe8051serialport01110011RXDTXDSBUFfosc/1280516.2.5UsingMode0onthe8051serialport01110011RXDTXDSBUFfosc/1280516.2.5UsingMode0onthe8051serialport01110011RXDTXDSBUFfosc/1280516.2.5UsingMode0onthe8051serialport01110011RXDTXDSBUFfosc/1280516.2.5UsingMode0onthe8051serialport01110011RXDTXDSBUFfosc/121TIShiftRegister移位寄存器for7-segment74LS164ShiftRegister(MasterReset)8051ShiftRegister移位寄存器for7-segmentQ0ABCKRXDTXDSBUFACC+5V60hLSBMSBLSBMSBSerialMode0ag74LS1648051ShiftRegister移位寄存器for7-segmentQ0ABCKRXDTXDSBUF1000001ACC+5V060hag8051ShiftRegister移位寄存器for7-segmentQ0ABCKRXDTXDSBUF0100001ACC+5V060hag8051ShiftRegister移位寄存器for7-segmentQ0ABCKRXDTXDSBUF011000ACC+5V0060hag8051ShiftRegister移位寄存器for7-segmentQ0ABCKRXDTXDSBUF00110ACC+5V00060hag8051ShiftRegister移位寄存器for7-segmentQ0ABCKRXDTXDSBUF0011ACC+5V000060hag8051ShiftRegister移位寄存器for7-segmentQ0ABCKRXDTXDSBUF001ACC+5V0000160hag8051ShiftRegister移位寄存器for7-segmentQ0ABCKRXDTXDSBUF00ACC+5V00001160hag8051ShiftRegister移位寄存器for7-segmentQ0ABCKRXDTXDSBUF0ACC0+5V00001160hag8051ShiftRegister移位寄存器for7-segmentQ0ABCKRXDTXDSBUFACC0+5V000011060hagShiftRegister移位寄存器for7-segment8051RXDTXD74164ABQ1Q7CKCK74164+5VHowmanymachinecycles?32Todisplay1234(Page194)8051RXDTXD74164ABQ1Q7CKCK74164+5Vag
ZERO EQU10000001b ONE EQU11001111b
TWO EQU10010010b THREE EQU10000110b FOUR EQU11001100b FIVE EQU10100100b SIX EQU10100000b SEVEN EQU10001111b EIGHT EQU10000000b NINE EQU10001100bMAIN: CLR SM1 CLR SM0 ;Serialmode0 CLR TITodisplay1234(Page194)REPEAT: MOV SBUF,#FOUR JNB TI,$ ;8machinecycles CLR TI MOV SBUF,#THREE JNB T1,$ CLR TI MOV SBUF,#TWO JNB TI,$
CLR TI MOV SBUF,#ONE JNB TI,$ CLR TI ACALL DELAY
SJMP REPEAT32+32ms500msPleasetry….Question9.6.11 (Page204)REPEAT: MOV SBUF,#FOUR JNB TI,$ CLR TI MOV SBUF,#THREE JNB T1,$ CLR TI MOV SBUF,#TWO JNB TI,$
CLR TI MOV SBUF,#ONE JNB TI,$ CLR TI ACALL DELAY
SJMP REPEATQuestion9.6.11(Page204)Modifythisprogramsothatdisplayshows0000 MOV R7,#04h;UseR7tocountLOOP: MOV SBUF,#ZERO JNB TI,$ ;Waitforshift CLR TI DJNZ R7,LOOP;NextdigitQuestion9.6.11(Page204)Modifytheprogramtodisplay0000LiquidCrystalDisplays(LCDs)Alphanumeric字母数字=A…Z,1…0,#,$,%...WhatisLight?Anelectromagneticwave电磁波=ElectricWave+MagneticWaveElectricWave(Vertical)
distance
ElectricfieldE
MagneticWave(Horizontal)
distance
MagneticfieldHElectric
Field
Magnetic
Field
ElectricField
Magnetic
Field
+-+-EHS
ElectromagneticWave电磁波
Polarisationdirection极化方向S=ExH矢量叉乘EHPolariser极化Polarisationdirection极化方向AlllightreflectedisbackConductors
导体EHPolariser极化Polarisationdirection极化方向AlllightistransmittedLiquidCrystalDisplays(LCDs)液晶显示器Polarisationoflight极化方向LiquidcrystalelectricalpropertiesLiquidcrystaltwistLighttransmissionWhatisaLiquidCrystal液晶?晶体液晶液体FixedFreeFlexibleCrystalLiquidLiquidcrystalMolecule分子Nematic向列态liquidcrystalsVNematicliquidcrystaltwistTwistangleVoltage旋转LiquidCrystalDisplays(LCDs)液晶显示器Polarisationoflight极化方向LiquidcrystalelectricalpropertiesLiquidcrystaltwist旋转LighttransmissionMolecule分子Groovedglass
有槽的玻璃LiquidCrystalDisplays(LCDs)液晶显示器Polarisationoflight极化方向LiquidcrystalelectricalpropertiesLiquidcrystaltwistLighttransmission光传播LCDconstructionGroovedglassandconductorPolariserat0oLightPolariserat90oLightLiquidcrystalLCDconstructionLightLightLightNolightLighttransmission光传播VoltageLight%LCDconstructionMirror镜子Liquidcrystal液晶Polariser极化Polariser极化Transparentconductor透明导体Electricalconnections电气连接LightLCDDisplayModuleHitachiHD44780UController控制器RSRWEDataLCDControllinesHD44780UcontrollerLCDDisplay显示RSRWEDataI/OpinsDB0-DB7LCDRSRWEDataI/OpinsDB0-DB7LCDRegisterSelect0=Instructions1=DataRead/WriteEnablepulseValueInstruction38hFunction:8-bitinterface,2lines,5*7pixels30hFunction:8-bitinterface,1line,5*7pixels28hFunction:4-bitinterface,2lines,5*7pixels20hFunction:4-bitinterface,1lines,5*7pixelsInstructionSet指令集forHD44780ULiquidCrystalDisplays(LCDs)Cursor光标Pixel象素5x7pixelsValueInstruction1EhScrollright18hScrollleft02hHome10hCursorleft14hCursorright0EhUnderlineValueInstruction0FhBlinkcursor0ChHidecursor08hBlank0ChRestore01hClearscreen80h+addrSetcursorInstructionSetforHD44780U8051mC=Microcontroller单片机DB0DB7RSRWEP1.0P1.2P0.0P0.701RSInstructionDataRWWriteReadELowHighLCD8051mC=Microcontroller单片机DB0DB7RSRWEP1.0P1.2P0.0P0.701RSInstructionDataRWWriteReadELowHighSETB RS;RS=1
CLR RW;RW=0MOV P0,#58h;“X”CLR E ;EnableSETB ECLR E Slow8051mC=Microcontroller单片机DB0DB7RSRWEP1.0P1.2P0.0P0.701RSInstructionDataRWWriteReadELowHighXSETB RS;RS=1
CLR RW;RW=0MOV P0,#58h;“X”CLR E ;EnableSETB ECLR E Handshaking握手信号Doyouwantsomebananas?PleasesendHandshaking握手信号Doyouwantsomemore?Don’tsendHandshaking握手信号Pleasesend8051mC=Microcontroller单片机DB0DB7RSRWEP1.0P1.2P0.0P0.7BusyflagX001Character“X”8051mC=Microcontroller单片机DB0DB7RSRWEP1.0P1.2P0.0P0.7BusyflagX001 MOV P0,#0FFh ;SetPort1forinput SETB RW ;SelectreadoperationEPULSE: SETB E ;Starttheenablepulse MOV ACC,P0 ;ReadtheBusyFlag CLR E ;Endenablepulse JB ACC.7,EPULSE;Loopwhilebusy8051mC=Microcontroller单片机DB0DB7RSRWEP1.0P1.2P0.0P0.7BusyflagX MOV P0,#0FFh ;SetPort1forinput SETB RW ;SelectreadoperationEPULSE: SETB E ;Starttheenablepulse MOV ACC,P0 ;ReadtheBusyFlag CLR E ;Endenablepulse JB ACC.7,EPULSE;LoopwhilebusyWAIT_BUSY: MOV P0,#0FFh ;SetPort1forinput SETB RW ;SelectreadoperationEPULSE: SETB E ;Starttheenablepulse MOV ACC,P0 ;ReadtheBusyFlag CLR E ;Endenablepulse JB ACC.7,EPULSE;Loopwhilebusy
RETWRITE_CHAR:;Write“X”tocurrentcursorposition SETB RS ;RS=1
Selectdata CLR RW ;RW=0
Selectwrite MOV P0,#58h ;Send“X”toLCD CLR E ;SendEnablepulse SETB E CLR E ACALL WAIT_BUSYSubroutineENABLE_PULSE:WRITE_CHAR:;Write“X”tocurrentcursorposition SETB RS ;RS=1
Selectdata CLR RW ;RW=0
Selectwrite MOV P0,#58h ;Send“X”toLCD ACALL ENABLE_PULSE ;SendEnable ACALL WAIT_BUSYWRITE_CHAR:;Write“X”tocurrentcursorposition
SETB RS ;RS=1
Selectdata CLR RW ;RW=0
Selectwrite MOV P0,#58h ;Send“X”toLCD ACALL ENABLE_PULSE ;SendEnable ACALL WAIT_BUSYCOMMAND:;Sendinstruction14htoLCD
CLR RS;RS=0Selectinstructions
CLR RW;RW=0Selectwrite
MOV P0,#14h ACALL ENABLE_PULSE ;SendEnable ACALL WAIT_BUSY Pleasetry….Question9.6.16 (Page205)UseTable9.3onPage198WRITE_CHAR:;Write“X”tocurrentcursorposition
SETB RS ;RS=1
Selectdata CLR RW ;RW=0
Selectwrite MOV P0,#58h ;Send“X”toLCD ACALL ENABLE_PULSE ;SendEnable ACALL WAIT_BUSYCOMMAND:;Sendinstruction14htoLCD
CLR RS;RS=0Selectinstructions
CLR RW ;RW=0Selectwrite
MOV P0,#14h ACALL ENABLE_PULSE ;SendEnable ACALL WAIT_BUSY 01RSInstrDataRWWriteRead CLR RS ;Selectinstructions
CLR RW ;Selectwriteoperation MOV P0,#38h ;8-bit,2lines,5*7pixels ACALL ENABLE_PULSE
ACALL WAIT_BUSY CLR RS ;Selectinstructions
CLR RW ;Selectwriteoperation MOV P0,#02h ;Cursortotop-left ACALL ENABLE_PULSE
ACALL WAIT_BUSY CLR RS ;Selectinstructions
CLR RW ;Selectwriteoperation MOV P0,#0Ch ACALL ENABLE_PULSE
ACALL WAIT_BUSY MOV DPTR,#DATA_ADDRESS MOV R7,#08hLOOP: SETB RS ;Selectdata
CLR RW ;Selectwrite
CLR A MOVC A,@A+DPTR MOV P0,A ;SendchartoLCD ACALL ENABLE_PULSE
ACALL WAIT_BUSY INC DPTR DJNZ R7,LOOP SJMP $DATA_ADDRESS: DB “SHANDONG” StepperMotors步进电机DCMotor直流电
StepperMotor步进电机ContinuousrotationTwowiresHighspeedSteppedrotationPrecisepositionLowspeedSNNMagnetCoilsStepperMotor12341234SNNStepperMotor12341234SNNNStepperMotor12341234SNNStepperMotor12341234SNNNStepperMotor12341234SNNStepperMotor12341234SNNStepangle=45oSN12341234Howcanwereducethestepangle?ToothedRotor有牙的转头O4coils25teethWhatisthestepangle?4coils25teeth4coils25teethTwocoilsenergisedwillproducea“half-step”Angle=1.8o8051P0.0P0.1P0.2P0.3GND60mAmaximum8051P0.0P0.1P0.2P0.3GNDInterface8051interfacetoStepperMotorCoilDarlingtontransistor达灵顿晶体管8051interfacetoStepperMotor8051interfacetoStepperMotor8051interfacetoStepperMotor8051interfacetoStepperMotorProtectiondiodes保护二极管+5VGNDviHighpositivevoltage-+-+8051interfacetoStepperMotorHighpositivevol
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 《烃和卤代烃 》课件
- 《现代软件工程》课件
- 《投资工具基础知识》课件
- 《热熔胶的保养》课件
- 《接触式IC卡》课件
- 《新消费者心理学》课件
- 普通高中地理课程标准解读
- 《文化生活知识结构》课件
- 正确认识挫折战胜挫折大学生挫折教育
- 教育技术水平中级考试复习指导浦东
- 2026年贵阳市公共交通有限公司第二批驾驶员招聘笔试参考题库及答案详解
- 2026年成人高考专升本政治真题试卷及完整答案解析(官方标准)
- 有机废气活性炭吸附处理安装工程竣工验收报告
- 新版2026秋统编版(新版)小学道德与法治五年级上册(全册)知识点清单梳理
- 2026年卫生高级职称面审答辩(社区护理)副高面审经典试题及答案
- 《井下作业事故处理》课件-第六章 油水井维修及事故处理
- 汽车散热器制造工艺流程
- 2025-2026学年人教版(2024)数学七年级上册期中测试卷
- 《光伏发电技术》课件(共七章)
- T/CAPE 10108-2024设备设施报废管理指南
- 《诗经》诗经全文
评论
0/150
提交评论