Konstrukcijski zadatak V0
Ovaj termometar baziran je na mbed mikroupravljaču LPC1768 koji na 16x2 LCD-u prikazuje temperaturu koju mjeri na svom analognom ulazu preračunavajući izmjerenu vrijednost napona u temperaturu. Zamišljeno je da se kao senzor koristi LM35P koji ima mogućnost svoj temperaturni raspon (-50 do 150 stupnjeva C) prikazati kao napon reda veličine 0V do Vcc (napona napajanja senzora). Za demonstraciju korišten je potenciometar kako bi se simulirala promjena temperature i prikazala funkcionalnost sklopa. Osim trenutne izmjerene temperature, na ekranu se prikazuju najmanja izmjerena i najveća izmjerena temperatura. Tipkalo služi za resetiranje tih vrijednosti čime se one postavljaju na vrijednost trenutno očitane temperature u trenutku pritiska na tipkalo.
Shema spajanja
main.cpp@1:dd6a9b9f2504, 2019-11-16 (annotated)
- Committer:
- thabazin
- Date:
- Sat Nov 16 08:07:05 2019 +0000
- Revision:
- 1:dd6a9b9f2504
- Parent:
- 0:aec63b445200
Promjena furmule za temp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thabazin | 0:aec63b445200 | 1 | #include "mbed.h" |
thabazin | 0:aec63b445200 | 2 | #include "thermistor.h" |
thabazin | 0:aec63b445200 | 3 | #include "TextLCD.h" |
thabazin | 0:aec63b445200 | 4 | |
thabazin | 0:aec63b445200 | 5 | TextLCD lcd(p19, p20, p21, p22, p23, p24); |
thabazin | 0:aec63b445200 | 6 | Temperature senzor1 (p17); |
thabazin | 0:aec63b445200 | 7 | InterruptIn button(p26); |
thabazin | 0:aec63b445200 | 8 | float temp, mini, maxi; |
thabazin | 0:aec63b445200 | 9 | Ticker tik1; |
thabazin | 0:aec63b445200 | 10 | DigitalOut ledica (LED2); |
thabazin | 0:aec63b445200 | 11 | |
thabazin | 0:aec63b445200 | 12 | |
thabazin | 0:aec63b445200 | 13 | void reset() { |
thabazin | 0:aec63b445200 | 14 | mini=temp; |
thabazin | 0:aec63b445200 | 15 | maxi=temp; |
thabazin | 0:aec63b445200 | 16 | } |
thabazin | 0:aec63b445200 | 17 | |
thabazin | 0:aec63b445200 | 18 | void ispis(float temp, float min, float max) { |
thabazin | 0:aec63b445200 | 19 | lcd.locate(0,0); |
thabazin | 0:aec63b445200 | 20 | lcd.printf("temp=%.1f",temp); |
thabazin | 0:aec63b445200 | 21 | lcd.locate(0,1); |
thabazin | 0:aec63b445200 | 22 | lcd.printf("MIN=%.0f",mini); |
thabazin | 0:aec63b445200 | 23 | lcd.locate(8,1); |
thabazin | 0:aec63b445200 | 24 | lcd.printf("MAX=%.0f",maxi); |
thabazin | 0:aec63b445200 | 25 | |
thabazin | 0:aec63b445200 | 26 | } |
thabazin | 0:aec63b445200 | 27 | |
thabazin | 0:aec63b445200 | 28 | void tiker1(){ |
thabazin | 0:aec63b445200 | 29 | ledica=!ledica; |
thabazin | 0:aec63b445200 | 30 | lcd.cls(); |
thabazin | 0:aec63b445200 | 31 | ispis(temp, mini, maxi); |
thabazin | 0:aec63b445200 | 32 | } |
thabazin | 0:aec63b445200 | 33 | |
thabazin | 0:aec63b445200 | 34 | int main() { |
thabazin | 0:aec63b445200 | 35 | temp=senzor1.get_temperature(); |
thabazin | 0:aec63b445200 | 36 | mini=temp; |
thabazin | 0:aec63b445200 | 37 | maxi=temp; |
thabazin | 0:aec63b445200 | 38 | tik1.attach(&tiker1, 0.15); |
thabazin | 0:aec63b445200 | 39 | while(1) { |
thabazin | 0:aec63b445200 | 40 | button.fall(&reset); |
thabazin | 0:aec63b445200 | 41 | temp=senzor1.get_temperature(); |
thabazin | 0:aec63b445200 | 42 | if(temp<mini) |
thabazin | 0:aec63b445200 | 43 | mini=temp; |
thabazin | 0:aec63b445200 | 44 | if(temp>maxi) |
thabazin | 0:aec63b445200 | 45 | maxi=temp; |
thabazin | 0:aec63b445200 | 46 | |
thabazin | 0:aec63b445200 | 47 | } |
thabazin | 0:aec63b445200 | 48 | } |