Water - PowerPoint PPT Presentation

About This Presentation
Title:

Water

Description:

PIC16F887 EEPROM: H EEPROM ( lactrically Erasable Programmable Read Only Memory) ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 19
Provided by: tei47
Category:
Tags: memory | power | water

less

Transcript and Presenter's Notes

Title: Water


1
????F??????? ??? PIC16F887
EEPROM H µ??µ? EEPROM (?lactrically Erasable
Programmable Read Only Memory) e??a? µ?a µ??µ? ?
?p??a e????feta? ??e?t???? ?a? d?at??e? ta
ded?µ??a t?? a??µa ?a? µet? t?? ap?µ?????s? t??
t??f?d?s?a?. ?p?p???? ? EEPROM µp??e? ?a
epa?e???afe? ????? ?a e??a? apa?a?t?t? ?a ???e?
p??ta ? d?a??af? t??. ?p??e? ?a ???s?µ?p????e?
se µ?a efa?µ??? ??a t?? ap????e?s? ??p????
??d???? ? ??p???? serial number s?s?e???. ?p?s??
e?e? µp????? ?a ap????e?t??? ???s?µa ded?µ??a ??a
µ?a efa?µ??? ? t? status ??p???? ?e?t??????? ?ste
se pe??pt?s? d?a??p?? t??f?d?s?a? ? µ????e?e??t??
µet? t?? epa?as??des? t?? ?a epa?af??e? t??
?at?stas? p?? ?p???e p??? t? d?a??p?.
2
????F??????? ??? PIC16F887
SPI Serial Peripheral Interface ?? SPI e??a?
??a se???a?? interface ep????????a? µe t? ?p???
ep?t??peta? ta?t?????a ? aµf?d??µ? (full duplex)
ep????????a a??µesa se µ?a master s?s?e?? ?a? se
µ?a ? pe??ss?te?e? slave s?s?e???. ??p?????a
3
????F??????? ??? PIC16F887 SPI
???s?µ?p??e? 3 ? 4 a???d??te? SLAVE MASTE
R SCK (RC3) serial clock (e?s?d??) SCK serial
clock (???d??) SDI (RC4) serial data in
(e?s?d??) SDI serial data in (e?s?d??) SDO
(RC5) serial data out (???d??) SDO serial data
out (???d??) SS (RA5) slave select (e?s?d??) ?
e?s?d?? SS e??a? p??a??et??? ?a? ???s?µ?p??e?ta?
?ta? ? master p??pe? ?a ep???????e? µe
pe??ss?te?e? ap? µ?a slave s?s?e??? ?a? st??
pe??pt?s? a?t? a???e? ? s?s?e?? ??a t?? ?p??a ?
master ????e? t? SS st? ?????? '0'. ? ep????????a
?e????e? ?ta? ? master ste??e? 8 pa?µ???
????????. ?e ???e pa?µ? st???eta? ?a? d?aß??eta?
??a bit ap? ???e s?s?e?? p?? µet??e? st??
ep????????a. ?ta? ??a µ?a s?s?e?? de? apa?te?ta?
?a ste??e? ded?µ??a t?te ap??? st???e? dummy
data. O? ?ata????t?? e?d???? ???s?? p??
???s?µ?p?????ta? ??a t? ???µ?s? t?? SPI e??a?
SSPSTAT, SSPCON.
4
????F??????? ??? PIC16F887
I2C Inter-Integrated Circuit To I2C e??a? ??a
interface ep????????a? µe t? ?p??? ep?t??peta?
aµf?d??µ? (half duplex) ep????????a a??µesa se
µ?a master ?a? µ?a slave s?s?e?? ?? ?p??e? e??a?
s??dedeµ??e? p??? st? bus. O? ?ata????t?? e?d????
???s?? p?? ???s?µ?p?????ta? ??a t? ???µ?s? t??
SPI e??a? SSPSTAT, SSPCON, SSPCON2. ??p?????a
5
????F??????? ??? PIC16F887 I2C
???s?µ?p??e? 2 a???d??te? SLAVE MASTER
SCL (RC3) serial clock (e?s?d??) SCK serial
clock (???d??) SDA (RC4) serial data
(e?s?d??/???d??) SD? serial

data(e?s?d??/???d??) ? ep????????a ?e????e? ?a?
staµat?e? µe s???e???µ??a s?µß??ta (events) ta
?p??a p??pe? a?a????????ta? ap? t?? s?µßat?? µe
t? I2C s?s?e???. S Start To Start ? a?????
Start bit ??e? µ??e??? 1 bit ?a? ?a?????e? t??
??a??? µ?a? I2C ep????????a?. O? start bit
a?a??????eta? e?e??? t? bit ?at? t? ?p???
pa?at??e?ta? ?ate???µe?? µ?t?p? st? s?µa SDA e??
t? SCL ß??s?eta? se ?????? '1'. P Stop To Stop
? a????? Stop bit ??e? µ??e??? 1 bit ?a?
?a?????e? t?? te?µat?sµ? µ?a? I2C ep????????a?.
O? stop bit a?a??????eta? e?e??? t? bit ?at? t?
?p??? pa?at??e?ta? a?e???µe?? µ?t?p? st? s?µa SDA
e?? t? SCL ß??s?eta? se ?????? '1'.
6
????F??????? ??? PIC16F887 I2C
R Repeated Start To Repeated Start ??e? µ??e???
1 bit ?a? ?a?????e? t?? ??a??? µ?a? I2C
ep????????a?. O? Repeated start bit a?a??????eta?
e?e??? t? bit ?at? t? ?p??? pa?at??e?ta?
?ate???µe?? µ?t?p? st? s?µa SDA e?? t? SCL
ß??s?eta? se ?????? '1'. ? d?af??? µe t? S bit
e??a? ?t? µe R bit a????e? µ?a ??a ep????????a
????? ?a ??e? te?µat?ste? µe P bit ?
p??????µe??. ?a ded?µ??a st? SDA a??????? p??t?te
?at? t? ??????? st??µ? p?? t? SCL ß??s?eta? st?
?????? '0'. ??a t?p??? ep????????a µe I2C ???eta?
µe t?? e??? d?ad??as?a 1. Start bit 2. Ap?st???
e??? byte (7-bit d?e????s? ?a? t? 8? bit R/W) 3.
?pe?e?????s? t?? SDA ??a acknowleadgement (??????
'0' ap? t? d??t? s?µa??e? ep?ßeßa??s?) 4.
?p?st??? byte ded?µ???? 5. ?pe?e?????s? t?? SDA
??a acknowleadgement (?????? '0' ap? t? d??t?
s?µa??e? ep?ßeßa??s?) (?a ß?µata 3 ?a? 4
epa?a?aµß????ta? ??a ?se? f???? ??e???eta?) 6. ?
bit
7
???G????? ?????S??? ???????O???S I2Ca. Slave
reception, ß. Slave transmission, ?. Master
reception, d. Master transmission
a
ß
?
d
8
????F??????? ??? PIC16F887
USART Universal Synchronous Asynchronous
Receiver Transmitter ? USART ap?te?e? ??a
se???a?? interface ep????????a? µe t? ?p???
µp????µe ?a ????µe e?te s??????? ep????????a
a??µesa se µ?a master s?s?e?? ?a? se µ?a slave ?
as??????? ep????????a a??µesa se d?? s?s?e???. ??
?ata????t?? e?d???? ???s?? p?? ???s?µ?p?????ta?
??a t? ???µ?s? t?? USART e??a? ?? TXSTA, RCSTA,
BAUDCTL, SPBRG, SPBRGH, TXREG ?a? RCREG. S???????
ep????????a ???s?µ?p?????ta? d?? a???d??te? µe
t? s?s?e?? master ?a e????e? t? ????? CK e?? ?
a???d??t?? ded?µ???? e??a? ? a???d??t??
DT. ?s??????? ep????????a ?? s???e???µ???
?????µa ???s?µ?p??e?ta? ?????? ??a as???????
ep????????a ?a? s?????? ??a ep????????a µe t??
UART t?? ?p?????st?? µe t? ???s? t?? interface
RS232. ??p?????a
9
????F??????? ??? PIC16F887 USART
???s?µ?p?????ta? 2 a???d??te? ?? (transmit) ?a?
RX (receive). ??a t?p??? ep????????a µe I2C
???eta? µe t?? e??? d?ad??as?a 1. Start bit
(?????? '0') 2. ?p?st??? e??? byte st?????ta?
p??ta t? LSB 3. ?p?st??? 1 ? 2 Stop bit (??????
'1')
St? d?p?a?? d????aµµa pa???s???eta? ? ap?st???
t?? byte h'55' (85). ?p?s?? ??a t? d?as??des? st?
se???a?? ???a t?? ?p?????st? apa?te?ta?
µetat??p?a? ??a t? µetat??p? t?? TTL ???????
sta?µ?? se RS232 ?a? t? a?t?st??f? ?p?? t? MAX232.
10
PWM (Pulse Width Modulation) ??aµ??f?s? e?????
pa?µ??
??a PWM ??µat?µ??f? st?? p?a?µat???t?ta ap?te?e?
µ?a pe???d??? ??µat?µ??f? ? ?p??a ??e? d??
tµ?µata. ?? tµ?µa ?? st? ?p??? ? ??µat?µ??f? ??e?
t?? µ???st? t?µ? t?? ?a? t? tµ?µa OFF st? ?p???
??e? t?? t?µ? µ?d??. To ?? tµ?µa ???µ??eta? Duty
Cycle ?a? µet???ta? e?te se µ???de? ?????? (ms,
us ??p) e?te se p?s?st? () ep? t??
pe???d??. ?fa?µ????ta? µ?a PWM ??µat?µ??f? st??
t??f?d?s?a e??? f??t??? ep?t???????µe ?a
e??????µe t?? t? p?s?st? t?? ?s???? p?? p?fte?
p??? st? f??t??. G?a t?? pe??pt?s? p?? t? f??t??
e??a? ??a? ????t??a? a?t? s??ep??eta? ??e????
st??f?? t?? ????t??a.
11
????F??????? ??? PIC16F887 PWM
CCP Capture/Compare/PWM ?ta? t? CCP ?e?t????e?
se PWM mode t?te pa???e? µ?a PWM ??µat?µ??f? se
??p???? a???d??t? t?? µ????e?e??t?. ?? PWM
??µat?µ??f?? ???s?µ?p?????ta? ?d?a?te?a st??
t??ep????????e? a??? ?a? st?? ?d???s? ????t????.
12
????F??????? ??? PIC16F887 CCP
CCP Capture/Compare/PWM O PIC16F887 d?a??te? ??a
ße?t??µ??? PWM module (?CCP Enhanced CCP) µe t?
?p??? ?p???e? ? d??at?t?ta ?a pa?µ?d?t?????
MOSFET se s??desµ?????a ?µ???f??a? (half bridge)
? p?????? ??f??a? (full bridge) ?p?? fa??eta? st?
pa?a??t? s??µa. O? ?ata????t?? p??
???s?µ?p?????ta? ??a t? ???µ?s? t?? CCP e??a?
CCPxCON, CCPRxL, PR2, T2CON, x1 ? 2.
13
???G???????S??S/CONFIGURATION BITS
O PIC16F887 p????aµµat??eta? µe t? ???s? t??
pa?a??t? a???de?t?? MCLR (Master Clear)
????d??t?? st?? ?p??? efa?µ????ta? ?? ??????
(12V) t?se?? p????aµµat?sµ??. RB7 Data RB6
Clock ? p????aµµat?sµ?? ep?s?? pe???aµß??e? t?
???µ?s? t?? configuration bits. ??t? e??a?
?pe????a ??a t?? ep????? t?? ta?a?t?t? ?????sµ??,
??a t?? e?e???p???s?/ape?e???p???s? ??p????
?????st?? (WDT, Power up Timer), ??a t??
p??stas?a t?? ??d??a ??p.
14
CONFIGURATION BITS
a) Oscillator ?a????sµ?? ta?a?t?t? ?????sµ?? t?? µ????e?e??t?. External RC Clockout ?p????? ta?a?t?t? ?????sµ?? ßas?sµ???? se e??te???? d??t?? RC ?? ????? e??a? d?a??s?µ? e??te???? st?? a???d??t? 14 t?? PIC16F887. External RC No Clockout ?p????? ta?a?t?t? ?????sµ?? ßas?sµ???? se e??te???? d??t?? RC. ?? ????? e??a? de? d?a??s?µ? e??te???? t?? µ????e?e??t?. Internal RC Clockout ?p????? ta?a?t?t? ?????sµ?? ßas?sµ???? st?? es?te???? ta?a?t?t? t?? µ????e?e??t?. ?? ????? e??a? d?a??s?µ? e??te???? st?? a???d??t? 14 t?? PIC16F887. Internal RC ?? Clockout ?p????? ta?a?t?t? ?????sµ?? ßas?sµ???? st?? es?te???? ta?a?t?t? t?? µ????e?e??t?. ?? ????? e??a? de? d?a??s?µ? e??te???? st? µ????e?e??t?. EC ?p????? ta?a?t?t? ?????sµ?? ap? e??te???? ????? (External Clock) HS ?p????? ???sta????? ta?a?t?t? ?????? ta??t?ta? (High Speed) gt 8??z ?? ?p????? ???sta????? ta?a?t?t? s????t?ta? lt 8MHz LP ?p????? ?e?aµ???? ta?a?t?t? ?aµ???? ?s???? (Low Power) ß) WatchDog Timer ? WatchDog timer ap?te?e? ??a ?????µa ?????sµ?? ep?t???s??. Se ???e ?pe??e???s? p???a?e? RESET ?a? ???s?µ?p??e?ta? ??a ap?f??? ?????µ?t?? t?? p?????µµat?? t?? µ????e?e??t?. On ??e???p???s? Off ?pe?e???p???s? ?) Power Up Timer ? Power Up Timer ap?te?e? ??a ?????µa p?? d?at??e? se RESET t? µ????e?e??t? ??a µe???? msec ?at? t?? efa?µ??? t?? t??f?d?s?a? µ???? ?a sta?e??p????e?. On ??e???p???s? Off ?pe?e???p???s? d) Master Clear Enable ?a????sµ?? t?? a???d??t? 1 t?? PIC16F887 (MCLR) ?? Master Clear ? ?? ??f?a?? e?s?d??. RE3 is digital input ? a???d??t?? 1 t?? PIC16F887 ap?te?e? ??f?a?? e?s?d? Master Clear is external ? a???d??t?? 1 t?? PIC16F887 ap?te?e? t? Master Clear. e) Code Protect ?e t? bit a?t? ?a?????eta? a? ?a ?p???e? p??stas?a t?? µ??µ?? p?????µµat?? ap? a?????s?. Off ?e? ?p???e? p??stas?a ap? a?????s? On ?p???e? p??stas?a ap? a?????s? st) Data EE Read Protect ?e t? bit a?t? ?a?????eta? a? ?a ?p???e? p??stas?a t?? µ??µ?? ded?µ???? EEPROM ap? a?????s?. Off ?e? ?p???e? p??stas?a ap? a?????s? On ?p???e? p??stas?a ap? a?????s? ?) Brown Out Detect ?e t? ?a?a?t???st??? Brown out Detect p???a?e?ta? RESET st? µ????e?e??t? ?ta? ? t??f?d?s?a p?se? ??t? ap? ??p??a t?s? a?af????. ?e t?? pa?ap??? ep????? ?a?????eta? ? e?e???p???s?/ape?e???p???s? a?t?? t?? ?a?a?t???st???? t?? PIC16F887 BOD and SBOREN disabled ?pe?e???p???s? SBOREN controls BOR function ?? bit SBOREN t?? ?ata????t? PCON e????e? t?? e?e???p???s?/ape?e???p???s? BOD enabled in run, disabled in sleep, SBOREN disabled ?d? t? ?a?a?t???st??? a?t? e??a? e?e???p???µ??? ?at? t?? ?a?????? ?e?t?????a ?a? ape?e???p???µ??? ?at? t? ?e?t?????a ?aµ???? ?ata????s?? ?s???? BOD enabled, SBOREN disabled ??e???p???s? ?) Internal External Switch Over Mode ?e t? bit a?t? ? e?e???p??e?ta?/ ape?e???p??e?ta? ? a??a?? t?? ta?a?t?t? ?????sµ?? ap? t?? es?te???? se e??te???? ?a? t? a?t?st??f?. Enabled ??e???p???s? Disabled ?pe?e???p???s? ?) Monitor Clock fail-safe ?e t? bit a?t? e?e???p??e?ta?/ape?e???p??e?ta? t? ?a?a?t???st??? t?? µ????e?e??t? ?a µp??e? ?a µetaße? st?? es?te???? ta?a?t?t? ?????sµ?? se pe??pt?s? ap?t???a? t?? e??te????? ta?a?t?t?. Enabled ??e???p???s? Disabled ?pe?e???p???s? ?) Low Voltage Program ?e t? bit a?t? e?e???p??e?ta?/ape?e???p??e?ta? ? d??at?t?ta ??a p????aµµat?sµ? e?t?? t?? ?????µat?? µe ?aµ??? t?s?. ?ta? e??a? e?e???p???µ??? ? d??at?t?ta a?t? t?te ? a???d??t?? RB3/PGMpa?e? ?a e??a? d?a??s?µ?? st?? p????aµµat?st? ?a? ???s?µ?p??e?ta? µ??? ??a t?? p????aµµat?sµ? t?? µ????e?e??t?. Enabled ??e???p???s? Disabled ?pe?e???p???s? ?a) Brown Out Reset Sel Bit ?e t? bit s?t? ep????eta? ? t?s? a?af???? ??a t? Brown-out Reset. Brown out at 2.1V Ta p?a?µat?p????e? RESET ?ta? ? t?s? ???e? 2.1V. Brown out at 4.0V Ta p?a?µat?p????e? RESET ?ta? ? t?s? ???e? 4.0V. ?ß) Self Write Enable ?e t?? ep????? a?t? ?a???????µe a? ? µ??µ? p?????µµat?? ?a ??e? p??stas?a e???af?? ap? t? firmware t? µ????e?e??t?. 0000-0fff prot. ???stas?a e???af?? st?? d?e????se?? µ??µ?? ap? h0000 ??? h0FFF. 0000-7fff prot. ???stas?a e???af?? st?? d?e????se?? µ??µ?? ap? h0000 ??? h7FFF. 0000-00ff prot. ???stas?a e???af?? st?? d?e????se?? µ??µ?? ap? h0000 ??? h00FF. No protection. ???stas?a e???af?? ape?e???p???µ???.
15
?ata????t?? ?2CON (Bank0) ?ata????t?? ?2CON (Bank0)
bit 7 ?e? e??a? ???p???µ???
bit 6-3 TOUTPSlt30gt Bit ep?????? ???µa?a? ep?µe??? ßa?µ?da? µ?t??s?? (Postscaler) 0000 11 Postscaler 0001 12 Postscaler 0010 13 Postscaler 0011 14 Postscaler 0100 15 Postscaler 0101 16 Postscaler 0110 17 Postscaler 0111 18 Postscaler 1000 19 Postscaler 1001 110 Postscaler 1010 111 Postscaler 1011 112 Postscaler 1100 113 Postscaler 1101 114 Postscaler 1110 115 Postscaler 1111 116 Postscaler
bit 2 TMR2ON Bit e?e???p???s?? Timer2 1 E?e???p???s? Timer2 0 ?pe?e???p???s? Timer2
bit 1-0 T2CKPSlt10gt Bit ep?????? ???µa?a? p??????µe??? ßa?µ?da? µ?t??s?? (Prescaler) 00 11 Prescaler 01 14 Prescaler 1x 116 Prescaler
16
?ata????t?? CCP1CON (Bank0) ?ata????t?? CCP1CON (Bank0)
bit 7-6 P1Mlt10gt Bit ???µ?se?? t?? PWM e??d?? ??? CCP1Mlt32gt 00, 01, 10 xx ? a???d??t?? P1A ????eta? ?? e?s?d?? Capture/Compare. ?? a???d??te? P1B, P1C ?a? P1D ??????ta? ?? e?s?d??/???d?? t?? ????? st?? ?p??e? a?????? ??? CCP1Mlt32gt 11 00 ? a???d??t?? P1A ????eta? ?? ap?? ???d?? PWM. ?? a???d??te? P1B, P1C ?a? P1D ??????ta? ?? e?s?d??/???d?? t?? ????? st?? ?p??e? a?????? 01 ?d???s? eµp??s??a? ?ate????s?? ????t??a s??desµ?????a? p?????? ??f??a?. ???d?? P1D d?aµ??f?µ??? ?at? e????. ???d?? P1A e?e????. ???d?? P1B a?e?e????. ???d?? P1C a?e?e???? 10 ?d???s? ????t??a s??desµ?????a? µ?s?? ??f??a?. ???d?? P1A ?a? P1B d?aµ??f?µ???? ?at? e????. ???d?? P1C ?a? P1D ??????ta? ?? e?s?d??/???d?? t?? ????? st?? ?p??e? a?????? 11 ?d???s? a?t?st??f?? ?ate????s?? ????t??a s??desµ?????a? p?????? ??f??a?. ???d?? P1? d?aµ??f?µ??? ?at? e????. ???d?? P1C e?e????. ???d?? P1A a?e?e????. ???d?? P1D a?e?e????
bit 5-4 DC1Blt10gt ?a ????te?? s?µa?t??? bit t?? Duty Cycle t?? PWM ??µat?µ??f?? Capture mode ?e? ???s?µ?p??e?ta? se a?t? t? mode ?e?t?????a? Compare mode ?e? ???s?µ?p??e?ta? se a?t? t? mode ?e?t?????a? PWM mode ?a d?? ????te?? s?µa?t??? bits t?? Duty Cycle t?? PWM ??µat?µ??f??
bit 3-0 CCP1Mlt30gt Bit ep?????? mode ?e?t?????a? 0000 ?pe?e???p???s? µ???da? CCP 0001 ?e ???s?µ?p??e?ta? (desµe?µ???) 0010 Compare mode, a?t?st??f? e??d?? se ???e ta?t?s? 0011 ?e ???s?µ?p??e?ta? (desµe?µ???) 0100 Capture mode, s?????? se ???e ?ate???µe?? µ?t?p? 0101 Capture mode, s?????? se ???e a?e???µe?? µ?t?p? 0110 Capture mode, s?????? se ???e 4? a?e???µe?? µ?t?p? 0111 Capture mode, s?????? se ???e 16? a?e???µe?? µ?t?p? 1000 Compare mode, ???d?? st? ?????? 1 se ???e ta?t?s? 1001 Compare mode, ???d?? st? ?????? 0 se ???e ta?t?s? 1010 Compare mode, ???d?? a?ep???ast?, s?µat?d?t?s? d?a??p?? se ???e ta?t?s? 1011 Compare mode, s?a?da??sµ?? e?d???? s?µß??t?? p???a???ta? RESET st?? Timer1 ?a? ?????ta? e?????s? µ?a? A/D µetat??p?? 1100 PWM mode, ??a ta P1A, P1C ? e?e???? ?at?stas? pe?????feta? µe ????? ep?ped?, ??a ta P1?, P1D ? e?e???? ?at?stas? pe?????feta? µe ????? ep?ped?. 1101 PWM mode, ??a ta P1A, P1C ? e?e???? ?at?stas? pe?????feta? µe ????? ep?ped?, ??a ta P1?, P1D ? e?e???? ?at?stas? pe?????feta? µe ?aµ??? ep?ped?. 1110 PWM mode, ??a ta P1A, P1C ? e?e???? ?at?stas? pe?????feta? µe ?aµ??? ep?ped?, ??a ta P1?, P1D ? e?e???? ?at?stas? pe?????feta? µe ????? ep?ped?. 1101 PWM mode,??a ta P1A, P1C ? e?e???? ?at?stas? pe?????feta? µe ?aµ??? ep?ped?, ??a ta P1?, P1D ? e?e???? ?at?stas? pe?????feta? µe ?aµ??? ep?ped?.
17
???????G?? ???S?S PWM
include ltp16f887.incgt org h'0000' bsf
STATUS,RP0 Bank1 bcf TRISC,2 ?? RC2
?a?????eta? ?? ???d?? movlw d'20' movwf PR2
F??t?s? st?? PR2 t? 20 bcf STATUS,RP0
Bank0 bsf T2CON,TMR2ON ??e???p???s? Timer2
movlw d'10' movwf CCPR1L ?a????sµ?? t??
Duty Cycle st? RC2 movlw b'00001100' movwf
CCP1CON ???µ?s? CCP1 ??a PWM goto end
18
?????S ??G???? ???????
Write a Comment
User Comments (0)
About PowerShow.com