Home
Rengaslämpötilan mittausjärjestelmä
Contents
1. uint8 t twi transmit const uint8 t data uint8 t length uint8 ti Liite 6 13 48 ensure data will fit into buffer if TWI BUFFER LENGTH lt length f return 1 ensure we are currently a slave transmitter if TWI_STX twi_state return 2 set length and copy data into tx buffer twi_txBufferLength length for i 0 i lt length i twi txBuffer i data i return 0 Function twi attachSlaveRxEvent Desc sets function called before a slave read operation Input function callback function to use Output none void twi_attachSlaveRxEvent void function uint8 t int twi onSlaveReceive function Function twi attachSlaveTxEvent Desc sets function called before a slave write operation Input function callback function to use Output none void twi_attachSlaveTxEvent void function void twi_onSlaveTransmit function Function twi_reply Desc sends byte or readys receive line Input ack byte indicating to ack or to nack Output none void twi_reply uint8_t ack transmit master read ready signal with or without ack if ack TWCR _BV TWEN BV TWIE _BV TWINT BV TWEA Jelsef Function twi_stop Desc relinquishes bus master status TWCR _BV TWEN _BV TWIE BV TWINT Liite 6 14 48 Input none Output none 7 void twi stop void send stop condition TW
2. user_onReceive function sets function called on slave read void TwoWire onRequest void function void user_onRequest function 11 Preinstantiate Objects lIlhllllllllllllllllllllllllllllllilill TwoWire Wire TwoWire Liite 6 8 48 3 Wire keywords txt THHEHHBHBHHHEHHHHHHBHHHHHHHHHBHBHBHBHHHRHE Syntax Coloring Map For Wire THHEHHHHHHHHBHHHHHHBHHHHHHHHBHBHBHBHHHRHI THHEHHBHHHHHBHHHHHHBHHHHHHHHHBHBHBHBHHHRHE Datatypes KEYWORD1 THHEHHBHBHHHBHHHHHHBHHHHHHHHBHBHBHBHHHRHE THHEHHBHHHHHBHHHHHHBHHHHHHHHHBHBHBHBHHHRHE Methods and Functions KEYWORD2 THHEHHHHHHHHBHHHHHHBHHHHHHHHHBHBHBHBHHRHE begin KEYWORD2 beginTransmission KEYWORD2 endTransmission KEYWORD2 requestFrom KEYWORD2 send KEYWORD2 receive KEYWORD2 onReceive KEYWORD2 onRequest KEYWORD2 THHEHHHHHHHHBHHHBHHHBHHHHHHHHHBHBHBHHHHRHE Instances KEYWORD2 THHEHHHHHHHHBHBHHHHBHBHHHHHHHBHBHBHBHHHRHE Wire KEYWORD2 HUHUTTU Constants LITERAL1 Liite 6 9 48 4 Wire utility twi c twi c TWI I2C library for Wiring amp Arduino Copyright c 2006 Nicholas Zambetti All right reserved This library is free software you can redistribute it and or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation either version 2 1 of the License or at your option any later version
3. virtual size t write uint8 t 0 This is the write method used the Print library It allows printing characters to the display and new lines print println It will write the value to the display and increase the cursor param buffer in buffer to write to the current LCD write position param size in size of the buffer return None virtual void write uint8 t size t virtual size_t write const uint8_t buffer size_t size 0 Clear the display and the cursor to 0 0 void clear virtual void clear 0 Set the cursor to 0 0 void home Liite 6 25 48 virtual void home 0 Switch the display on This is the default state when the display is initialised See init method void on gi virtual void on 0 ES Switch the display off void off virtual void off 0 por Turn on the cursor void cursor_on virtual void cursor_on 0 JA Turn off the cursor This is the default state when the display is initialised void cursor off virtual void cursor_off 0 Activate cursor blink void blink_on virtual void blink_on 0 eee cursor blinking This is the default state when the display is initialised void blink_off virtual void blink_off 0 Set cursor following coordinates Line Col Initial value after initialization is 0 0 param Line in Line
4. Icd setCursor 1 0 Icd print Setup delay 5 if set4 true amp amp config true ChangeEmissivity dev10 emissivityLSB emissivityMSB ChangeEmissivity dev11 emissivityLSB emissivityMSB ChangeEmissivity dev12 emissivityLSB emissivityMSB Liite 5 5 10 delay 5 Icd init Icd setCursor 0 0 Icd print Temp Sensors 4 Icd setCursor 1 0 Icd print Setup Ready delay 5 digitalWrite gatePinSCL2 LOW digitalWrite gatePin4 LOW delay 100 void ChangeEmissivity int dev int lowbyte int hibyte Use this to Adjust Sensor Emissivity int tester hibyte lowbyte Serial begin 9600 Serial print Sensor Serial print dev gt gt 1 HEX Serial printin emissivity Serial print hibyte HEX Serial printin lowbyte HEX ReadEmis dev ZeroEmis dev ReadEmis dev ChangeEmis dev lowbyte hibyte while ReadEmis dev tester ZeroEmis dev ChangeEmis dev lowbyte hibyte digitalWrite MLXPower LOW MLX VDD must be cycled to OV after changing delay 10 emissivity values digitalWrite MLXPower HIGH word ZeroEmis int dev for int a 0 a 256 i2c_start_wait dev I2C WRITE send start condition and write bit i2c write 0x24 send command for device to return address i2c write 0x00 send low byte zero to erase i2c_write Ox00 send high byte zero to erase if i2c_write a
5. Liite 5 2 10 3 LF const boolean set3 false const int dev7 0x43 lt lt 1 const int dev8 0x44 lt lt 1 const int dev9 0x45 lt lt 1 set 4 RR const boolean set4 true const int dev10 0x48 lt lt 1 const int dev11 0x49 lt lt 1 const int dev12 0x50 lt lt 1 IISENSOR EMISSIVITY const boolean config true const float emissivityValue 0 95 Melexis IR Sensors Default Emissivity is OxFFFF HEX 65535 DEC long emissivity 65535 emissivityValue byte emissivityL SB emissivity amp OxFF byte emissivityMSB emissivity gt gt 8 amp OxFF double tempData 0x0000 Melexis IR Sensors correction factor for calibrating the sensors double adjustZero1 1 default 1 double adjustZero1offset 0 offset or calibration function default 0 double adjustZero2 1 double adjustZero2offset 0 double adjustZero3 1 double adjustZero3offset 0 double adjustZero4 1 double adjustZero4offset 0 double adjustZero5 1 double adjustZero5offset 0 double adjustZero6 1 double adjustZero6offset 0 double adjustZero7 1 double adjustZero7offset 0 double adjustZero8 1 double adjustZero8offset 0 double adjustZero9 1 double adjustZero9offset 0 double adjustZero10 1 double adjustZero10offset 0 double adjustZero11 1 double adjustZero1 1offset 0 double adjustZero12 1 double adjustZero1 2offset 0 void setup Ser
6. rxBufferlndex 0 Liite 6 4 48 rxBufferLength 0 txBufferlndex 0 txBufferLength 0 twi_init void TwoWire begin uint8_t address twi_setAddress address twi_attachSlaveTxEvent onRequestService twi_attachSlaveRxEvent onReceiveService begin void TwoWire begin int address begin uint8_t address uint8 t TwoWire requestFrom uint8_t address uint8 t quantity clamp to buffer length if guantity gt BUFFER LENGTH quantity BUFFER LENGTH perform blocking read into buffer uint8 t read twi readFrom address rxBuffer quantity set rx buffer iterator vars rxBufferlndex 0 rxBufferLength read return read uint8_t TwoWire requestFrom int address int quantity return requestFrom uint8_t address uint8 t quantity void TwoWire beginTransmission uint8 t address indicate that we are transmitting transmitting 1 set address of targeted slave txAddress address reset tx buffer iterator vars txBufferlndex 0 txBufferLength 0 void TwoWire beginTransmission int address beginTransmission uint8 t address uint8 t TwoWire endTransmission void transmit buffer blocking int8 t ret twi writeTo txAddress txBuffer txBufferLength 1 reset tx buffer iterator vars txBufferlndex 0 txBufferLength 0 indicate that we are done transmitting transmitting 0 return ret must
7. voidaan todeta ett koska vapausasteiden ollessa 988 saatu testisuureen arvo ylitt riskitason rajan arvon saadut mittaustulokset ovat tilastollisesti merkitsevi Milwaukee ilmoittaa Temp Gunin mittaustarkkuudeksi 1 5 mik merkitsee mittausalueella 0 100 C ep tarkimmillaan noin 1 5 C tarkkuutta Rengasl mp tilan mittausj rjestelm n mittaustulosten keskihajonta niiden lineaarisen regression suhteen mukaan 2 65 C kuvaa hyvin mittausj rjestelm n sis isen virheen maksimia N iden kahden j rjestelm n virheiden summa kuvaa hyvin mittausj rjestelm n mittaustarkkuutta joka on ep tarkimmillaan 4 1 C 4 3 Mittaustaajuus Rengasl mp tilan mittausjarjestelman mittaustaajuus riippuu k yt ss olevien anturisarjojen lukum r st Mittausj rjestelm n ohjelmasta voidaan delay komentojen perusteella laskea mittausj rjestelm n sis lt v n viivett noin 440 ms J rjestelm n mittaustaajuuden voidaan siis arvioida olevan 1 2 Hz 5 Yhteenveto Opinn ytety ss suunniteltiin v yl njakaja oppilasty n valmistettuun rengasl mp tilan mittausj rjestelm n Kyseinen j rjestelm k ytt infrapunas teily l mp tilan m ritt miseen Mittausj rjestelm n mittaustarkkuus gt m ritettiin vertaamalla sen tuottamia mittaustuloksia kaupalliseen infrapunal mp mittariin ja sen mittaustaajuudesta tehtiin arvio Rengasl mp tilan mittausjarjestelmalle asetettu tavoitet
8. Function twi_init Desc readys twi pins and sets twi bitrate nput none Output none ah void twi_init void initialize state twi state TWI READY activate internal pullups for twi digitalWrite SDA 1 digitalWrite SCL 1 initialize twi prescaler and bit rate cbi TWSR TWPSO cbi TWSR TWPS1 TWBR F CPU TWI FREQ 16 2 twi bit rate formula from atmega128 manual pg 204 SCL Frequency CPU Clock Frequency 16 2 TWBR note TWBR should be 10 or higher for master mode It is 72 for a 16mhz Wiring board with 100kHz TWI enable twi module acks and twi interrupt TWCR BV TWEN _BV TWIE BV TWEA Function twi_slavelnit Desc sets slave address and enables interrupt Input none Output none void twi setAddress uint8 t address set twi slave address skip over TWGCE bit TWAR address lt lt 1 Function twi readFrom Desc attempts to become twi bus master and read a series of bytes from device the bus Input address 7bit i2c device address data pointer to byte array length number of bytes to read into array Output number of bytes read uint8 t twi_readFrom uint8_t address uint8 t data uint8 t length uint8 ti ensure data will fit into buffer BUFFER LENGTH lt length return 0 Liite 6 11 48 wait until twi is ready become master receiver while TWI READY twi_
9. Liite 6 47 48 continue twst TW MT SLA return 1 break V i2c start wait ERR EAE ee ee tee IGNORE PICO NNN Issues a repeated start condition and sends address and transfer direction Input address and transfer direction of I2C device Return 0 device accessible 1 failed to access device ice pt eI ODIO Te CARA EOE eR KI ku eode m OE unsigned char i2c rep start unsigned char address return i2c_start address V i2c rep start NC eb ooo dex geo d ES Terminates the data transfer and releases the I2C bus MC D QU Uc pO e Oo void i2c_stop void send stop condition TWCR 1 lt lt TWINT 144 TWEN 144 TWSTO wait until stop condition is executed and bus released while TWCR amp 1 TWSTO V i2c stop JEEP EROR oko oi o EEE aN Send one byte to I2C device Input byte to be transfered Return 0 write successful 1 write failed ORIGEN joe AN EK QUON peo ones o eoim unsigned char 12 write unsigned char data uint8 t twst send data to the previously addressed device TWDR data TWCR 1 lt lt TWINT 144 TWEN wait until transmission completed while TWCR amp 1 lt lt TWINT check value of TWI Stat
10. lineaarisena Korjausfunktion kulmakerroin on mittausj rjestelm n mittaustulosten lineaarisen regression funktion kulmakertoimen k nteisluku tavoitteena on saada sovitettua lineaarisen regression kuvaaja kulkemaan yhdensuuntaisesti Temp Gunin mittaustulosten kuvaajan kanssa Kun Temp Gunin kuvaaja ja mittausj rjestelm n mittaustulosten lineaarisen regression funktion kuvaaja ovat yhdensuuntaiset sovitetaan lineaarisen regression kuvaaja kulkemaan kuvaajan origon kautta lis m ll kuvaajien yhdensuuntaistamisen tuottaman lukujoukon lineaarisen regression funktion vakion vastaluku korjausfunktion vakioksi kuva 6 Pintal mp tilamittaus 5 cm n et isyydelt korjausfunktiolla 65 f x 1x 0 60 0 98 55 50 45 40 35 30 m Temp Gun Mittausjarjestelma Lineaarinen regressio sarjalle Mittausj rjestelm 20 25 30 35 40 45 50 55 60 65 is Kuva 6 Pintal mp tilamittaus 5 cm n et isyydelt mittaustulokset sovitettu kuvaajaan korjausfunktion avulla 25 20 Mittaukset toistettiin my s niin ett Temp Gunilla mitattiin pintal mp tilaa 5 cm n et isyydell kun mittausj rjestelm n tunnistin siirrettiin 10 cm et isyydelle kohteesta kuva 7 Mittaustuloksista ja niiden lineaarisen regression funktiosta on havaittavissa ett mittaustulosten selitysaste huononee ja mitatut l mp tilat ovat systemaattisesti matalampia kuin lyhyemm n et isyyden p st saadut mittaustulokset
11. rity n tuloksena saatiin suunniteltua gt valmistuskustannuksiltaan gt edullinen rengasl mp tilan mittausj rjestelm jonka mittaustarkkuus tunnetaan ja jota voidaan k ytt Metropolia Ammattikorkeakoulun tulevissa projekteissa mittav lineen T m insin rity sis lt my s tarvittavan dokumentoinnin mittausj rjestelm n jatkokehitykselle Avainsanat infrapuna l mp tila mittaus rengas MUN Abstract Author s Antti Harhanen Title Tire Temperature Monitoring System Number of Pages 21 pages 7 appendices Date 4 May 2014 Degree Bachelor of Engineering Degree Programme Automotive and Transport Engineering Specialisation option Automotive Electronics Engineering Instructor s Vesa Linja aho Senior Lecturer in Automotive Electronics This thesis introduces an infra red tire temperature monitoring system designed as a part of Helsinki Metropolia University of Applied Sciences CDIO project The goal of this thesis was to fix the problems that occurred during the original tire temperature monitoring system project and to measure the accuracy of the system As a part of the thesis a smaller version of the system was designed for the use of the Automation Laboratories of Helsinki Metropolia University The thesis consists of three parts The first part introduces the I2C Bus technology and its terminology The second part displays the structure of the Tire Temperature Monitoring System and its main componen
12. TWI BUFFER LENGTH twi rxBuffer twi rxBufferlndex 0 sends ack and stops interface for clock stretching twi stop Liite 6 16 48 callback to user defined callback twi onSlaveReceive twi rxBuffer twi rxBufferlndex since we submit rx buffer to wire library we can reset it twi rxBufferlndex 0 ack future responses and leave slave receiver state twi releaseBus break case TW SR DATA NACK data received returned nack case TW SR GCALL DATA data received generally returned nack back at master twi reply 0 break Slave Transmitter case TW ST SLA ACK addressed returned ack case TW ST ARB LOST SLA arbitration lost returned ack enter slave transmitter mode twi state TWI STX ready the tx buffer index for iteration twi txBufferlndex 0 set tx buffer length to be zero to verify if user changes it twi txBufferLength 0 request for txBuffer to be filled and length to be set note user must call twi transmit bytes length to do this twi onSlaveTransmit if they didn t change buffer 8 length initialize it twi_txBufferLength twi_txBufferLength 1 twi txBuffer 0 0x00 transmit first byte from buffer fall case TW ST DATA ACK byte sent ack returned copy data to output register TWDR twi_txBuffer twi_txBufferlndex II if there is more to send ack otherwise nack if twi_txBufferlndex
13. This library is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU Lesser General Public License for more details You should have received a copy of the GNU Lesser General Public License along with this library if not write to the Free Software Foundation Inc 51 Franklin St Fifth Floor Boston MA 02110 1301 USA include lt math h gt include lt stdlib h gt include lt inttypes h gt include lt avr io h gt include lt avr interrupt h gt include lt compat twi h gt include Arduino h for digitalWrite ifndef define cbi sfr bit SFR BYTE sfr amp _BV bit endif ifndef sbi define sbi sfr bit SFR BYTE sfr BV bit endif include pins_arduino h include twi h static volatile uint8_t twi_state static uint8 t twi slarw static void twi onSlaveTransmit void static void twi onSlaveReceive uint8 t int static uint8 t twi masterBuffer TWI BUFFER LENGTH static volatile uint8 t twi masterBufferlndex static uint8 t twi masterBufferL static uint8 t twi txBuffer TWI BUFFER LENGTH static volatile uint8 t twi txBufferlndex static volatile uint8 t twi txBufferLength static uint8 t twi rxBuffer TWI BUFFER LENGTH static volatile uint8 t twi rxBufferlndex Liite 6 10 48 static volatile uint8 t twi error
14. ifdef DOXYGEN P defgroup pfleury ic2master I2C Master library code include lt i2cmaster h gt endcode brief I2C TWI Master Software Library Basic routines for communicating with I2C slave devices This single master implementation is limited to one bus master on the I2C bus This l2c library is implemented as a compact assembler software implementation of the I2C protocol which runs on any AVR i2cmaster S and as a TWI hardware interface for all AVR with built in TWI hardware twimaster c Since the API for these two implementations is exactly the same an application can be linked either against the software I2C implementation or the hardware 12 implementation Use 4 7k pull up resistor on the SDA and SCL pin Adapt the SCL and SDA port and pin definitions and eventually the delay routine in the module i2cmaster S to your target when using the software I2C implementation Adjust the CPU clock frequence CPU in twimaster c or in the when using the TWI hardware implementaion note The module i2cmaster S is based on the Atmel Application Note AVR300 corrected and adapted to GNU assembler and AVR GCC C call interface Replaced the incorrect quarter period delays found in AVR300 with half period delays author Peter Fleury pfleury gmx ch http jump to fleury par Usage Example The following code shows typical usage of this library see example test_i2cmaster c code include lt i2cmaster h
15. joka kuvaa aineen pinnan kyky luovuttaa vastaanottamaansa s teilyenergiaa Aineesta palaavan s teilyn intensiteetti verrataan teoreettisen tilanteeseen jossa aine ei s teile ollenkaan takaisin eli on t ysin musta 5 s 461 463 Aineiden kyky sitoa s teily vaihtelee suuresti niiden ominaisuuksien mukaan Tilanteessa jossa aineen sis inen l mp tila on ymp rist n vallitsevaa l mp tilaa korkeampi se s teilee enemm n kuin sitoo s teily My s s teilyn aallonpituudella on merkityst tutkittaessa emissiivisyytt sill aineen emissiivisyys muuttuu mitattavan s teilyn aallonpituuden mukaan T st syyst onkin aiheellista huomauttaa ett t ss opinn ytety ss emissiivisyydest puhuttaessa viitataan aineen emissiivisyyteen infrapuna aallonpituudella Tuntemattoman gt emissiivisyyden gt m ritt misess voidaan k ytt hy dyksi pinnoitusmateriaalia jonka emissiivisyys tunnetaan hyvin esimerkiksi maalarinteippi E 0 95 Riitt v n suuri alue mitattavasta kohteen pinnasta k sitell n tunnetun emissiivisyyden omaavalla aineella jolloin on mahdollista verrata kahden eri pinnan v list l mp tilaeroa Tunnetun emissiivisyyden omaavan pinnan l heisyydess voidaan k ytt mittaustarkkuuden parantamiseksi kontaktimittausta esimerkiksi l mp paria Mitataan mitattavan kappaleen pintal mp tiloja tunnetun emissiivisyyden alueelta ja pinnoittamattomalta alueelta Mitattujen l mp tilojen er
16. lt twi_txBufferLength twi reply 1 Jelsef twi reply 0 break case TW_ST_DATA_NACK received nack we are done case TW_ST_LAST_DATA received ack but we are done already ack future responses twi reply 1 leave slave receiver state twi state TWI READY break case TW_NO_INFO state information break case TW_BUS_ERROR bus error illegal stop start twi_error TW_BUS_ ERROR twi_stop break Liite 6 17 48 5 Wire utility twi h twi h TWI I2C library for Wiring amp Arduino Copyright c 2006 Nicholas Zambetti All right reserved This library is free software you can redistribute it and or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation either version 2 1 of the License or at your option any later version This library is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU Lesser General Public License for more details You should have received a copy of the GNU Lesser General Public License along with this library if not write to the Free Software Foundation Inc 51 Franklin St Fifth Floor Boston MA 02110 1301 USA zh Hifndef twi h define twi h include lt inttypes h gt ATMEGA8 Hifndef TWI FREQ define TWI FREQ 100000L endif ifndef TWI BUFFER
17. 1 58 3 47 5 33 6 314 26 3 28 4 50 2 43 8 50 9 42 8 35 9 36 44 1 40 8 48 39 9 58 5 47 1 34 1 31 8 26 6 28 7 50 4 44 1 51 1 42 8 36 3 36 44 3 40 8 48 5 40 3 58 7 473 34 1 32 27 2 29 3 50 8 43 4 51 2 43 36 2 35 9 44 3 41 1 49 40 4 59 3 46 9 34 7 32 5 27 6 29 3 51 43 8 51 5 43 35 5 35 7 44 7 41 49 2 40 5 59 4 47 2 35 32 3 27 8 29 4 51 4 44 1 51 5 43 4 36 1 35 4 44 8 40 8 49 8 40 5 59 4 473 35 2 32 8 28 1 29 6 51 5 44 6 51 6 43 3 36 1 35 4 45 2 41 2 48 6 417 59 5 47 1 35 9 33 3 28 1 29 9 52 1 45 514 43 6 35 5 352 45 3 412 48 8 41 9 58 1 36 2 33 5 28 3 30 52 7 45 1 51 2 43 4 35 4 35 45 5 41 1 49 1 417 59 473 36 5 33 6 28 9 30 2 53 45 2 52 5 43 6 34 8 34 7 45 9 41 5 49 3 41 9 59 3 477 37 34 29 6 30 6 53 4 45 1 52 6 43 6 34 7 34 8 46 414 48 8 42 5 59 8 47 6 37 2 34 2 29 9 30 4 53 8 45 5 52 7 43 8 35 4 34 6 46 2 41 9 49 6 42 3 60 2 47 5 37 8 34 6 30 30 8 54 45 6 52 7 43 8 35 4 34 3 46 2 42 50 2 42 5 60 1 477 38 3 35 30 4 30 8 54 1 45 8 52 7 44 2 34 4 34 2 46 3 41 9 50 6 42 6 60 47 5 38 7 35 2 30 7 30 8 54 4 45 6 53 44 1 34 4 34 2 46 6 41 8 51 42 8 60 1 47 6 39 2 35 7 31 31 1 54 7 46 1 52 4 43 9 34 1 34 46 7 42 51 1 43 60 6 47 5 39 8 36 1 31 2 31 5 54 9 46 53 2 44 1 34 33 9 46 8 42 2 51 4 43 2 61 47 6 40 2 36 5 314 31 5 55 2 46 6 53 3 44 3 33 8 34 47 424 51 6 43 5 61 2 47 8 40 5 36 8 31 7 31 6 55 3 46 2 53 1 44 3 34 8 33 7 47 2 41 9 52 9 43 6 61 3 47 9 41 1 37 31 9 31 8 55 5 46 6 53 1 44 2 25 8 27 1 47 4 42 1 52 8 43 6 61 2 477 41 5 37 3 32 3 32 1 55 8 46 9
18. 53 44 2 26 1 274 47 6 423 52 7 44 28 5 28 4 42 37 6 32 9 32 1 55 9 46 7 53 1 44 2 27 8 48 42 2 53 44 2 26 1 27 5 42 3 38 33 3 32 4 56 5 46 6 54 8 44 1 27 4 28 4 48 3 42 3 52 3 44 5 26 4 28 5 42 7 38 3 33 5 32 7 56 9 46 6 54 6 44 1 27 7 28 8 48 5 42 4 52 5 44 5 26 4 29 43 1 38 5 33 8 32 4 57 46 8 54 3 44 1 28 4 29 2 48 6 42 4 53 2 44 3 26 3 29 6 43 6 39 33 9 329 57 4 46 7 55 4 44 1 31 7 31 8 49 42 4 53 5 44 9 26 6 30 2 44 3 39 3 34 1 32 8 57 6 46 9 55 44 3 323 32 1 49 1 42 6 53 5 45 1 27 1 30 4 44 9 39 6 34 2 33 58 47 2 554 444 32 7 322 49 3 427 54 1 45 2 27 3 30 5 45 7 39 9 34 6 33 4 58 2 48 2 55 5 44 2 33 1 32 5 49 3 427 54 6 45 1 27 6 30 7 46 1 40 2 34 8 33 6 58 3 49 55 5 44 4 33 8 32 8 49 5 427 54 9 45 6 27 8 31 6 46 3 40 4 35 2 33 4 58 7 49 55 7 44 6 34 2 33 3 49 7 43 2 55 1 46 1 28 1 31 6 46 6 40 6 35 5 33 9 59 3 49 1 56 6 43 8 34 6 33 9 50 1 43 1 55 3 46 2 28 6 31 9 46 8 41 35 8 33 6 60 48 8 56 43 5 352 34 3 50 43 9 552 46 4 28 7 31 9 47 4 41 3 36 2 34 1 60 4 49 5 58 1 44 35 9 34 3 51 6 44 2 55 8 46 2 29 322 48 1 423 36 5 34 2 60 6 49 4 58 5 44 1 36 2 34 7 50 8 44 55 8 46 2 29 2 32 5 49 2 42 6 36 8 34 8 29 33 5 58 7 44 36 8 35 1 512 43 6 56 1 46 4 29 6 32 6 49 8 42 8 37 4 34 8 29 2 33 6 59 44 37 2 35 3 51 4 43 6 56 3 46 2 29 9 32 8 50 1 43 37 8 35 3 23 28 5 59 1 44 2 37 4 35 8 51 6 43 4 56 6 46 3 31 1 33 50 6 43 3 37 8 35 5 57 7 44 5 59 2 44 38 35 8 51 8 43 6 56 7 46 2 30 9 33 3 50 9 43 5 38 1 35 3 57 2 44 7 59 3 44 4 38 5 36 2 52 1 43 8 57 46
19. MR DATA data received ack sent put byte into buffer twi_masterBuffer twi_masterBufferlndex TWDR case TW_MR_SLA_ACK address sent ack received ack if more bytes are expected otherwise nack iftwi masterBufferlndex lt twi_masterBufferLength twi reply 1 jelse twi reply 0 break case TW MR DATA data received nack sent put final byte into buffer twi_masterBuffer twi_masterBufferlndex TWDR case TW_MR_SLA_NACK address sent nack received twi_stop break TW MR ARB LOST handled by TW MT ARB LOST case Slave Receiver case TW SR SLA ACK addressed returned ack case TW SR GCALL ACK addressed generally returned ack case TW SR ARB LOST SLA ACK lost arbitration returned ack case TW SR ARB LOST GCALL ACK lost arbitration returned ack enter slave receiver mode twi state TWI SRX indicate that rx buffer can be overwritten and ack twi rxBufferlndex 0 twi reply 1 break case TW SR DATA ACK data received returned ack case TW SR GCALL DATA ACK data received generally returned ack if there is still room in the rx buffer if twi rxBufferlndex lt TWI BUFFER LENGTH put byte in buffer and ack twi_rxBuffer twi_rxBufferlndex TWDR twi reply 1 jelse otherwise nack twi reply 0 break case TW_SR_STOP stop or repeated start condition received put a null char after data if there s room iftwi rxBufferlndex lt
20. be called in slave tx event callback or after beginTransmission address size t TwoWire write uint8 t data if transmitting in master transmitter mode don t bother if buffer is full if txBufferLength gt BUFFER_LENGTH setWriteError return O J put byte in tx buffer txBuffer txBufferlndex data txBufferlndex update amount in buffer txBufferLength txBufferlndex jelse in slave send mode reply to master twi transmit amp data 1 return 1 must be called in slave tx event callback or after beginTransmission address size t TwoWire write const uint8 t data size t quantity if transmitting in master transmitter mode for size_t i 0 i lt quantity i write data i else in slave send mode reply to master twi_transmit data quantity return quantity must be called in slave rx event callback or after requestFrom address numBytes int TwoWire available void return rxBufferLength rxBufferlndex Liite 6 5 48 Liite 6 6 48 must be called in slave rx event callback or after requestFrom address numBytes int TwoWire read void int value 1 get each successive byte on each call if rxBufferlndex lt rxBufferLength value rxBuffer rxBufferlndex rxBufferlndex return value must be called in slave rx event callback or after requestFro
21. command uint8_t value J Initialise the display Once created the object this is the next operation that has to be called to initialise the display into a known state It assumes that the I2C bus is not initialised and hence initialise the Wire interface Clear the display Set contrast levels Set the cursor at origens 0 0 Turn on the entire display void init void init Set a different delay to that in the library It may be needed to delay sending commands or characters one after the other param cmdDelayfin Delay after issuing a command param charDelay in Delay after issuing a character to the LCD return None void setDelay int int Liite 6 30 48 void setDelay int int This is the write method used the Print library It allows printing characters to the display and new lines print println It will write the value to the display and increase the cursor param value in character to write to the current LCD write position return None virtual void write uint8 t virtual size t write uint8 t This is the write method used by the Print library It allows printing characters to the display and new lines print println It will write the value to the display and increase the cursor param buffer in buffer to write to the current LCD write position param size in size of the buffer return None virtual void write uint8 t size t virtual size_t
22. gt Liite 6 41 48 define Dev24C02 OxA2 device address of EEPROM 24C02 see datasheet int main void unsigned char ret i2c_init initialize I2C library write 0x75 to EEPROM address 5 Byte Write i2c start wait Dev24C02 12C WRITE set device address and write mode i2c write 0x05 write address 5 i2c write 0x75 write value 0x75 to EEPROM i2c_stop set stop conditon release bus read previously written value back from EEPROM address 5 i2c start wait Dev24C02 12C WRITE set device address and write mode i2c write 0x05 write address 5 i2c rep start Dev24C02 12C READ set device address and read mode ret 2 readNak read one byte from EEPROM i2c stop for endcode WU endif DOXYGEN Hf GNUC 100 GNUC MINOR lt 304 terror This library requires AVR GCC 3 4 or later update to newer AVR GCC compiler endif include lt avr io h gt defines the data direction reading from I2C device i2c start i2c rep start define 12 READ 1 defines the data direction writing to 12C device in i2c start i2c rep start define I2C WRITE O E brief initialize the I2C master interace Need to be called only once param void return none extern void i2c init void Liite 6 42 48 brief Terminates the data transfer and releases the I2C bus param void return none ex
23. h gt include LCD h include ST7036 h Class private constants and definition constint CMD_DELAY 1 Command delay in miliseconds constint CHAR_DELAY 0 Delay between characters in miliseconds const int PIXEL ROWS PER CHAR 8 Number of pixel rows in the LCD character const int MAX_USER_CHARS 16 Maximun number of user defined characters LCD Command set Liite 6 34 48 const uint8 t DISP_CMD 0x0 Command for the display const uint8_t RAM_WRITE_CMD 0x40 Write to display RAM const uint8 t CLEAR_DISP_CMD 0x01 Clear display command const uint8 t HOME CMD 0x02 Set cursos at home 0 0 const uint8 t DISP ON Display on command const uint8 t DISP OFF CMD 0x08 Display off Command const uint8 t SET DDRAM CMD 0x80 Set DDRAM address command const uint8 t CONTRAST CMD 0x70 Set contrast LCD command const t FUNC SET TBLO 0x38 Function set 8 bit 2 line display 5x8 inst table 0 const t FUNC SET TBL1 0x39 Function set 8 bit 2 line display 5x8 inst table 1 LCD bitmap definition const t CURSOR ON 1 lt lt 1 Cursor selection bit in Display on cmd const uint8 t BLINK ON BIT 1 lt lt 0 Blink selection bit on Display on cmd Driver DDRAM addressing const uint8 t dram dispAddr 3 0x00 0x0
24. has been while l TWCR amp 1 lt lt TWINT check value of TWI Status Register Mask prescaler bits twst TW STATUS amp OxF8 if twst TW MT SLA amp amp twst TW MR SLA ACK return 0 o E EKIN IT SAIN An Ee gears ERATE Be Issues a start condition and sends address and transfer direction If device is busy use ack polling to wait until device is ready Input address and transfer direction of I2C device CONI IO RU AUGUE Ga eee Gone mT Nae I ITO OO E void i2c start wait unsigned char address uint8 t twst while 1 send START condition TWCR 1 lt lt TWINT 1 lt lt TWSTA 1 lt lt TWEN wait until transmission completed while l TWCR amp 1 lt lt TWINT check value of TWI Status Register Mask prescaler bits twst TW STATUS amp OxF8 if twst TW START 44 twst TW REP START continue send device address TWDR address TWCR 1 lt lt TWINT 1 lt lt TWEN wail until transmission completed while l TWCR amp 1 lt lt TWINT check value of TWI Status Register Mask prescaler bits twst TW STATUS amp OxF8 if twst TW_MT_SLA_NACK JI twst TW MR DATA NACK Wi device busy send stop condition to terminate write operation TWCR 1 lt lt TWINT 144 TWEN 144 TWSTO wait until stop condition is executed and bus released while TWCR amp 1 lt lt TWSTO
25. kaikkien mittausten ajan samana tulosten gt vertailtavuuden saavuttamiseksi T m on tarpeen koska anturin ollessa kiinnitettyn auton runkoon anturin ja renkaan kulutuspinnan v linen et isyys muuttuu jatkuvasti jousituksen sis n ja ulosjoustojen aikana Kuvassa 3 on esitetty trigonometriset perusteet kaavalle 13 jonka avulla on mahdollista renkaan py re n muodon vaikutus mittauset isyyteen kun mittausj rjestelm n tunnistimet pysyv t paikoillaan ja rengas liikkuu y akselin suuntaisesti joustojen mukana Kuva 3 Jouston pituuden vaikutus mittauset isyyteen trigonometriset perusteet Kuvan 3 perusteella voidaan todeta ett Ah sin a 8 8 mista seuraa Ah 9 r Saadun kulman a avulla on mahdollista maarittaa mittausetaisyyden muutos x cosa 10 mist ratkaistaan x r x r cosa 11 x r rcosa 12 Koska kulma a tunnetaan seuraa x r rcos arcsin 13 r Kaavaa 13 kayttaen on mahdollista todeta ett esimerkiksi 185 60R15 koon renkaan kohdalla t m merkitsee 12 5 cm n sis njoustossa 1 cm n muutosta mittauset isyydess mik li anturi on sijoitettu nollatilanteessa ajoneuvon akselin tasalle Kuvassa 4 on esitetty graafisesti t m jouston pituuden ja mittauset isyyden v linen riippuvuus kolmelle vuonna 2014 yleiselle rengaskoolle Kaavan 13 avulla 10 muodostettua kuvaajaa voidaan hy dynt tehokkaasti my s tilanteissa joissa mitta
26. m n j lkeen ohjelma sy tt halutun emissiivisyysarvon kaikille antureille yhden kerran aina ohjelman k ynnistyess Kalibraatioarvojen muokkaamiseksi vaaditaan tietokone johon on asennettu Arduino ohjelmisto 4 1 Mittausmenetelm Suoritetuissa mittauksissa k ytettiin mittausv linein rullamittanauhaa tarkkuus 0 1 mm ja Milwaukee Laser TEMP GUN M12 infrapunal mp mittaria Anturiasetelma kytkettiin statiiviin siten ett sen et isyytt mitattavaan kohteeseen voitiin muuttaa kuva 2 TEMP GUNia k ytt en pyrittiin m ritt m n mahdollisimman tarkasti renkaan pintal mp tila Infrapunas teily hy dynt v n l mp tilamittauksen mittaustarkkuus paranee mik li mitattavan kohteen l mp tila on nostettu ensin korkeammaksi kuin ymp rist n vallitseva l mp tila Lis ksi mittausten tarkkuuden parantamiseksi mitattavan kohteen t ss tapauksessa autonrenkaan pinta p llystettiin tunnetun emissiivisyyden omaavalla aineella eli maalarinteipill Kuva 2 Mittausj rjestelyt Rengasta l mmitettiin l mp l hteell renkaan sis puolelle puhaltamalla noin 60 C l mp tilaan saakka Renkaan l mmityksen aikana valokuvattiin mittausj rjestelm n ja TEMP GUNin n ytt m t l mp tilat ja ne kirjattiin n iden valokuvattujen tulosten perusteella yhden anturin osalta mittausp yt kirjaan liite 7 Mittaukset toistettiin 5 cm n 10 cm n ja 15 cm n et isyydelt niin ett TEMP GUNin et isyys pysyi
27. write const uint8_t buffer size_t size Clear the display and the cursor to 0 0 void clear void clear Set the cursor to 0 0 void home void home Switch the display on This is the default state when the display is initialised See init method void on void on Switch the display off void off virtual void off Turn on the cursor Liite 6 31 48 void cursor_on void cursor on Turn off the cursor This is the default state when the display is initialised void cursor_off void cursor_off Activate cursor blink void blink_on void blink_on NE cursor blinking This is the default state when the display is initialised void blink_off void blink_off Set cursor following coordinates Line Col Initial value after initialization is 0 0 param Line in Line where to put the cursor range 0 max display lines 1 This display only take 0 1 param Collin Colum where to put the cursor range 0 max width 1 return None void setCursor uint8_t Line uint8_t Col void setCursor uint8_t Line uint8_t Col EXPANDED FUNCTIONALITY METHODS ifdef_ LCDEXPANDED E Provides the state of the LCD This value is updated every command is sent to the LCD or a character or
28. 0 ichecks all possible PECS i2c_stop Release bus end transaction delay 100 Serial print Found correct CRC Serial println a HEX return a i2c_stop Release bus end transaction Serial printin Correct CRC not found return 1 Liite 5 6 10 word ChangeEmis int dev int NewELo int NewEHi for int a 0 a 256 i2c start wait dev I2C WRITE send start condition and write bit i2c write 0x24 send command for device to return address i2c write NewELo send new low byte i2c_write NewEHi send new high byte if i2c_write a 0 i2c_stop delay 100 Serial print Found correct CRC Serial println a HEX return a i2c_stop Release bus end transaction Serial printin Correct CRC not found return 1 int ReadEmis int dev int data_low 0 int data_high 0 int pec 0 i2c start wait dev 12C WRITE i2c write 0x24 read i2c_rep_start dev l2C_READ data_low i2c_readAck Read 1 byte and then send ack data_high i2c_readAck Read 1 byte and then send ack pec i2c readNak i2c_stop Serial begin 9600 Serial print Emissivity Serial printin dev gt gt 1 HEX Serial printIn data_high HEX Serial printIn data_low HEX return int data_low data_high delay 100 void datawriter int dataPin float average float averageout averageout map averag
29. 0 0x00 3 One line display address 0x00 0x40 0x00 3 Two line display address 0x00 0x10 0x20 Three line display address Static member variable definitions apa p NH a lc ST7036 ST7036 uint8 t num lines uint8 t num col uint8 t i2cAddr num lines num lines num col num col _i2cAddress i2cAddr gt gt 1 _cmdDelay CMD_DELAY _charDelay CHAR_DELAY _initialised false _backlightPin 1 ST7036 ST7036 uint8 t num lines uint8 t num col uint8 t i2cAddr int8 t backlightPin i num lines num lines num col col _i2cAddress i2cAddr gt gt 1 Liite 6 35 48 _cmdDelay CMD DELAY _charDelay CHAR DELAY _initialised false _backlightPin backlightPin If there is a pin assigned to the BL set it as an output if _backlightPin 0 pinMode backlightPin OUTPUT Functions modifiers set selectors get and class methods void ST7036 init size_t retVal Initialise the Wire library Wire begin Wire beginTransmission i2cAddress Wire write byte 0xO Send command to the display Wire write FUNC SET TBLO delay 10 Wire write FUNC SET TBL1 delay 10 Wire write Ox14 Set BIAS 1 5 Wire write Ox73 Set contrast low byte Wire write Ox5E ICON disp on Booster on Contrast high byte Wire write Ox6D Follower circuit internal a
30. 1 30 7 49 7 41 9 57 50 3 34 29 8 37 5 36 1 42 5 39 6 44 41 4 35 9 37 31 7 31 50 41 3 57 3 50 1 34 6 30 2 38 1 36 4 43 39 6 444 41 2 36 1 374 322 31 4 50 8 41 5 57 6 50 35 2 30 2 38 4 36 5 43 1 40 43 5 40 8 36 3 37 4 32 5 31 3 50 4 41 6 58 50 4 35 5 30 6 38 8 36 6 43 4 39 8 44 2 40 6 36 6 37 7 332 31 9 51 2 43 58 4 51 2 35 8 31 1 39 36 9 43 8 39 9 43 1 40 3 36 9 37 6 33 3 314 523 42 9 58 5 50 4 36 1 31 3 39 5 37 1 44 39 9 42 8 40 2 37 1 37 6 33 3 31 9 52 1 43 1 58 2 50 5 37 31 39 9 37 3 44 3 40 3 43 2 40 1 37 3 38 33 9 32 5 52 3 43 2 58 7 50 9 36 9 31 3 40 4 37 4 44 6 40 5 43 1 39 9 37 5 37 7 34 4 32 3 52 6 44 2 59 51 1 37 1 31 5 40 6 37 8 44 7 40 7 43 1 39 8 37 5 37 9 35 32 5 52 6 43 6 59 5 527 37 8 32 6 41 37 8 45 40 5 42 8 39 7 37 7 38 1 35 5 32 9 52 9 45 2 61 52 5 38 3 32 7 41 3 37 8 44 9 40 8 417 39 6 37 8 37 9 36 1 32 7 53 1 44 1 60 8 524 38 328 41 6 38 45 4 40 7 41 5 39 3 38 2 382 36 7 33 8 53 8 44 60 4 523 38 5 329 41 9 38 2 45 7 40 9 41 6 392 38 3 38 3 372 34 54 44 5 61 50 4 38 8 33 3 424 38 1 45 8 41 414 39 38 4 38 5 37 4 33 9 54 1 44 6 61 2 49 7 39 1 33 6 42 7 38 6 46 41 3 40 9 39 1 38 6 38 4 38 34 543 45 2 61 8 51 39 6 342 43 38 8 46 3 41 1 40 5 38 8 38 8 38 5 38 3 34 3 544 44 9 61 5 50 40 5 34 43 3 38 7 46 4 41 1 40 9 38 5 39 38 7 38 6 34 5 548 44 7 222 24 41 3 34 2 43 5 38 9 46 5 41 3 411 38 5 39 2 38 6 38 9 34 6 54 9 44 2 22 5 24 3 41 6 34 5 43 9 39 1 46 6 41 3 40 38 4 39 3 39 39 4 34 8 54 9 44 4 23 1 24 6 41 6 34 5 44 39 3 46 7 41 3 40 6 3
31. 1 30 8 33 3 51 43 8 38 2 35 6 51 6 44 7 38 7 35 8 522 45 1 39 2 36 51 2 43 9 38 5 35 5 51 9 45 39 1 35 6
32. 26 30 5 32 6 37 9 37 3 50 5 45 4 31 3 33 6 243 254 45 5 39 1 51 5 45 5 254 26 3 31 32 5 38 37 6 50 4 45 2 31 6 34 244 25 7 45 6 39 8 51 9 45 9 259 26 5 31 2 32 8 38 4 37 8 50 1 45 32 33 8 244 25 9 46 1 39 8 52 6 46 26 3 26 5 31 5 327 38 6 37 6 49 4 44 7 32 5 34 1 24 5 26 1 46 4 39 5 53 1 46 2 26 8 27 31 9 33 1 38 8 38 49 4 44 5 324 344 24 9 26 5 46 5 40 4 53 5 46 6 27 6 27 323 33 3 39 1 37 9 49 3 44 2 329 342 24 9 26 5 46 2 40 2 54 47 28 27 327 33 4 39 3 38 48 5 44 33 1 342 24 9 26 5 46 3 40 4 544 47 5 28 3 274 329 33 7 39 5 38 1 47 9 43 7 33 4 34 6 25 5 27 46 7 40 3 54 9 47 7 28 9 27 6 33 2 33 9 39 6 38 3 48 2 43 7 34 3 355 25 6 272 47 1 40 7 55 3 47 9 29 3 27 8 33 7 33 9 39 9 38 8 48 43 5 33 9 35 6 26 1 27 3 473 40 6 57 7 48 5 30 28 2 34 34 3 40 3 38 4 47 8 43 5 33 6 359 26 6 27 8 475 40 6 57 8 48 5 30 4 28 2 34 6 34 7 40 6 38 7 47 6 43 3 34 1 36 1 27 27 9 47 8 40 7 55 2 48 3 30 9 28 3 34 7 34 9 40 8 38 9 47 9 43 34 7 36 4 27 6 28 5 48 2 40 6 56 1 48 5 31 3 28 6 352 35 41 39 47 42 9 34 5 36 6 28 28 5 48 4 40 7 55 7 48 8 31 8 28 8 35 3 34 7 41 2 39 1 46 9 42 7 34 5 36 7 28 3 28 6 48 8 41 57 1 48 6 322 29 1 35 7 35 1 41 3 38 9 46 1 42 4 34 7 36 5 29 1 29 1 49 1 41 59 7 47 9 327 29 1 36 35 5 41 3 39 2 45 7 42 3 34 9 36 6 29 7 29 6 49 5 41 1 55 6 49 1 33 1 29 4 36 3 35 6 41 8 39 3 46 41 9 352 36 8 30 2 30 3 49 3 41 3 56 2 49 4 33 2 29 5 36 8 35 7 41 9 39 3 44 9 417 35 5 36 6 30 8 30 3 49 7 41 5 56 7 49 7 33 6 29 6 37 1 35 9 42 2 39 5 45 1 41 5 35 7 37 31
33. 2cmaster h gt define CPU frequency in Mhz here if not defined in Makefile ifndef F CPU define F CPU 16000000UL endif 2C clock in Hz define SCL_CLOCK 50000L AKIN RL EEN TUR OR Initialization of the I2C bus interface Need to be called only once RARER ERLE ARTA RO olio Ee Se Ree KEIN N EL EEN AEE void i2c_init void initialize TWI clock 100 kHz clock TWPS 0 gt prescaler 1 TWSR 0 no prescaler TWBR F CPU SCL CLOCK 16 2 must be gt 10 for stable operation 3 i2c init REE RES SEE EE Issues a start condition and sends address and transfer direction return 0 device accessible 1 failed to access device Te OR CERT TT Tee POTN unsigned char i2c_start unsigned char address uint8 t twst send START condition TWCR 1 lt lt TWINT 134 TWSTA 144 TWEN wait until transmission completed while TWCR amp 1 lt lt TWINT check value of TWI Status Register Mask prescaler bits twst TW STATUS amp OxF8 if twst TW START amp amp twst TW REP START return 1 received return 1 V i2c_start Liite 6 46 48 send device address TWDR address TWCR 1 lt lt TWINT 1 lt lt TWEN wail until transmission completed and ACK NACK
34. 4 29 76 Arduino Uno 1 27 58 Yhteens Total alv tax 24 487 85 Liite 3 1 6 Infrapunalampomittari jarjestelman pienoisversio ja sen kokoamisohjeet Infrapunalampomittari Metropolian automaatiotekniikan laboratorion opetusk ytt n suunniteltu yksinkertaistettu malli rengasl mp tilan mittausj rjestelm st sis lt l hes samat ominaisuudet kuin t ysikokoinen j rjestelm Malli on suunniteltu toimimaan osana opetusk ytt sulautettujen j rjestelmien havainnollistamisessa Oppilaat voivat koota j rjestelm n koekytkent levylle ja testata sen toimintaa k yt nn ss Ajatuksena on havainnollistaa my s v yl njakajan toimintaperiaatetta asettamalla infrapuna anturi ja Icd naytt6 samaan v yl osoitteeseen N iden ohjeiden perusteella on mahdollista rakentaa LCD n yt llinen l mp mittari joka hy dynt v yl tekniikkaa Vaadittavat komponentit 1 MCCOG21605C6W BNMLW LCD n ytt MLX90614ESF BAA Infrapunatunnistin 5kpl 4 7 vastuksia 2kpl 56kO vastuksia 2kpl 2n2222 transistoreja Arduino Uno Koekytkent levy NOAA amp R Johtimia Liite 3 2 6 SELO SDA O patePini 0 9 o 4 MLX996 4 A Sensor Kokoa jarjestelma kytkentakaavion mukaisesti Lataa liitteen oleva ohjelma mikrokontrolleriin Mik li saat virheilmoituksia varmista ett koneeseen on asennettu tarvittavat kirjastot ohjelman koodin kolme ensimm ist rivi sis lt v t niide
35. 8 1 39 6 39 1 39 6 34 9 54 8 44 5 23 7 25 41 8 35 1 44 2 40 47 6 41 5 39 6 38 1 39 8 39 3 40 1 35 5 54 8 44 6 24 1 25 2 41 6 35 7 44 3 41 47 4 42 39 5 38 2 39 9 39 2 40 4 35 7 55 2 44 3 24 6 255 422 35 4 45 2 41 4 46 41 8 39 3 37 9 40 1 39 4 41 1 35 9 54 9 44 7 25 26 2 42 8 35 3 45 7 40 9 47 4 41 3 39 3 38 40 2 39 4 41 3 36 2 55 4 44 1 256 26 6 43 1 35 3 45 8 41 2 46 4 42 3 38 9 37 6 40 6 39 3 41 4 36 3 55 3 44 3 26 2 26 9 43 8 35 4 45 9 41 8 45 8 42 3 38 6 37 6 40 6 39 4 41 8 36 2 55 8 43 2 27 1 27 3 23 4 25 4 46 4 41 4 47 5 41 9 38 6 37 4 40 7 39 3 42 4 36 6 56 1 42 8 27 6 27 8 23 6 254 46 8 41 8 48 3 422 38 4 37 3 41 2 39 6 42 5 36 9 56 2 427 28 5 28 2 23 7 25 2 47 2 41 7 48 8 41 9 38 6 372 41 2 39 5 43 37 2 55 7 43 9 28 9 28 5 23 5 25 4 47 7 42 2 49 42 38 9 37 41 8 39 8 43 7 37 7 55 9 43 6 29 6 28 7 23 7 25 5 47 8 42 48 7 42 38 36 8 41 9 39 6 44 1 37 5 56 2 43 6 30 1 29 2 23 6 26 48 2 42 2 49 2 42 4 38 1 36 8 42 2 39 8 44 5 38 2 56 4 43 7 30 7 29 5 23 7 26 2 48 5 42 3 49 4 42 3 38 2 36 5 42 3 40 45 38 6 56 7 43 2 31 3 30 24 26 6 48 8 42 7 49 8 42 6 37 4 36 4 42 5 40 1 45 4 38 6 56 7 43 3 31 7 30 2 24 5 27 2 49 42 4 49 7 42 5 37 6 36 4 42 9 40 5 45 5 38 4 56 8 43 2 31 9 30 2 25 1 27 9 49 7 43 50 1 42 8 37 2 36 3 43 2 40 7 46 1 38 8 56 9 43 6 32 4 30 7 25 3 27 9 49 7 43 3 50 1 42 3 36 9 36 1 43 5 40 6 46 3 38 8 57 5 44 3 32 5 31 1 256 28 2 50 1 43 6 50 6 42 8 36 1 35 8 43 9 40 8 47 392 574 44 9 33 31 1 259 28 5 50 43 6 50 8 42 8 35 8 36 44 40 8 47 3 39
36. 8 51 6 25 9 29 7 54 8 46 7 40 6 36 9 42 1 38 7 54 7 44 24 8 26 6 32 7 34 8 59 6 51 5 26 1 30 6 55 3 46 7 40 9 37 1 42 5 39 1 54 7 44 24 9 27 1 329 34 8 59 6 51 1 26 5 31 55 5 47 40 9 37 2 43 3 39 4 54 8 45 1 25 28 33 4 34 9 59 1 50 9 26 7 31 5 56 2 48 41 3 37 3 43 5 39 8 55 2 45 7 25 3 28 4 33 4 35 3 58 1 50 4 26 9 31 1 56 9 48 2 41 5 373 43 8 39 9 55 7 45 8 25 5 28 8 33 8 35 4 57 6 49 9 27 5 31 3 57 9 48 6 41 8 37 4 44 1 40 1 55 8 45 7 25 7 28 9 34 1 35 3 56 8 49 5 27 8 31 6 58 2 48 7 42 1 37 4 44 4 40 4 56 1 45 8 25 8 29 34 3 35 6 56 5 49 1 28 31 4 58 6 48 9 423 37 6 44 9 40 5 56 3 45 7 26 1 29 3 34 7 35 7 56 3 49 28 31 3 58 9 49 1 427 37 7 45 4 41 56 4 457 26 6 297 34 9 35 9 55 7 48 5 28 3 31 3 59 3 49 43 37 8 45 9 41 2 56 8 45 9 26 8 29 9 35 1 35 9 55 7 48 2 28 5 31 5 59 5 49 7 43 1 38 46 7 41 7 57 1 45 7 27 2 30 1 35 4 35 9 55 5 47 9 28 5 317 59 6 49 8 43 5 37 9 47 423 57 2 45 9 27 6 30 5 35 7 36 1 54 8 47 6 28 9 31 8 60 50 5 43 5 38 5 47 6 43 23 4 24 9 28 30 6 35 9 36 2 54 2 47 4 29 32 60 5 50 5 43 38 8 48 3 43 4 23 5 25 2 28 5 31 36 2 36 2 53 5 46 9 29 5 328 60 8 50 4 43 38 8 48 6 43 5 23 6 25 2 29 1 31 5 36 4 36 8 52 9 46 6 29 9 33 61 50 6 44 4 38 3 49 43 7 23 8 25 3 29 5 31 7 36 7 36 6 52 3 46 5 30 32 8 61 50 9 44 6 39 49 6 44 1 24 25 7 29 6 31 9 37 1 37 1 51 7 46 1 30 8 33 61 3 50 9 45 38 8 50 1 44 3 243 25 8 29 9 31 9 37 2 37 51 6 46 31 33 3 61 6 51 8 45 2 39 50 5 45 1 248 26 30 2 32 1 37 3 37 51 4 45 9 31 1 33 4 24 2 25 5 45 2 38 8 51 45 2 25
37. Antti Harhanen Rengaslampotilan mittausjarjestelma Mittausjarjestelma ja sen tarkkuuden maaritys N waia Metropolia Ammattikorkeakoulu Insin ri AMK Auto ja kuljetustekniikka Insin rity 4 5 2014 Ota Tiivistelm Tekij t Antti Harhanen Otsikko Rengasl mp tilan mittausj rjestelm Sivum r 21 sivua 7 liitett Aika 4 5 2014 Tutkinto Insin ri AMK Koulutusohjelma Auto ja kuljetustekniikka Suuntautumisvaihtoehto Autos hk tekniikka Ohjaaja t Autoelektroniikan lehtori Vesa Linja aho Insin rity ss esitell n oppilasty n valmistettu rengasl mp tilan mittausj rjestelm Insin rity n tavoitteena oli m ritt aiemmin oppilasty n valmistetun mittausj rjestelm n tarkkuus korjata sen toiminnassa ilmenneet puutteet sek suunnitella mittausj rjestelm st pienoisversio ohjelmineen Metropolia Ammattikorkeakoulun automaatiolaboratoriota varten Insin rity rakenteeltaan kolmiosainen Ensimm isess osassa gt esitell n insin rity n aihe ja l ht kohdat sek 12C v yl tekniikan perusteet sek k yd n l vitse aiheeseen liittyv gt termist Toisessa osassa esitell n rengasl mp tilan mittausj rjestelm n tekninen rakenne sen t rkeimpien kokonaisuuksien osalta Kolmannessa osassa tutkitaan rengasl mp tilan mittausj rjestelm n mittaustarkkuutta kaupallisen infrapunalampomittarin avulla Insin
38. CR _BV TWEN BV TWIE BV TWEA BV TWINT _BV TWSTO wait for stop condition to be exectued on bus TWINT is not set after a stop condition while TWCR amp BV TWSTO X continue update twi state twi state TWI READY Function twi releaseBus Desc releases bus control nput none Output none void twi releaseBus void release bus TWCR BV TWEN BV TWIE BV TWEA BV TWINT update twi state twi state TWI READY SIGNAL TWI vect switch TW STATUS Master case TW START sent start condition case TW REP START sent repeated start condition copy device address and r w bit to output register and ack TWDR twi slarw twi reply 1 break Master Transmitter case TW MT SLA ACK slave receiver acked address case TW MT DATA ACK slave receiver acked data if there is data to send send it otherwise stop if twi masterBufferlndex lt twi masterBufferLength copy data to output register and ack TWDR twi masterBuffer twi masterBufferlndex twi reply 1 jelse twi stop break case TW MT SLA NACK address sent nack received twi error TW MT SLA twi stop Liite 6 15 48 break case TW_MT_DATA_NACK data sent nack received twi_error TW_MT_DATA_NACK twi_stop break case TW_MT_ARB LOST lost bus arbitration twi error TW MT ARB LOST twi releaseBus break Master Receiver case TW
39. Kuva 9 Pintal mp tilamittaus tunnistin 10 cm n et isyydell Milwaukee 5 cm n et isyydell mittaustulokset sovitettu kuvaajaan korjausfunktion avulla 65 Verrattuna 5 cm n et isyydelt suoritettuihin mittauksiin selitysaste on laskenut 0 98 sta 0 95 teen ja lineaarisen regression kulmakerroin 0 7st 0 56 teen Voidaan siis todeta ett et isyyden kasvaessa mittausj rjestelm n havaitsemat l mp tilat laskevat ja niiden luotettavuus heikkenee Kun mittausetaisyys kasvaa 15 cm iin kuva 10 voidaan mittausj rjestelm n mittaamien l mp tilojen havaita olevan edelleen matalampia kuin esimerkiksi 10 cm n et isyydelt mitattaessa regressiosuoran kulmakerroin pysyy samana mutta sen vakio laskee arvosta 14 93 arvoon 13 94 Lis ksi mittaustulosten hajonta kasvaa erityisesti matalilla l mp tiloilla ja lineaarisen regression selitysaste laskee 0 95 st 0 94 n Pintalampotilamittaus tunnistin 15 cm n et isyydell Milwaukee 5 cm n et isyydell 65 f x 0 56x 13 94 60 R 0 94 55 50 45 V 40 35 30 m Temp Gun 25 Mittausj rjestelm Lineaarinen regressio 20 sarjalle Mittausj rjestelm 20 25 30 35 40 45 50 55 60 Kuva 10 Pintal mp tilamittaus tunnistin 15 cm n et isyydell Milwaukee 5 cm n et isyydell 15 65 Kuvassa 11 on esitettyn 15 cm st suoritetut mittaukset korjausfunktiolla sovitettuna 16 Pintal mp tilamittaus tu
40. LENGTH define TWI BUFFER LENGTH 32 endif define TWI_READY 0 define TWI MRX 1 define TWI MTX 2 define TWI SRX 3 define TWI STX 4 void twi init void void twi setAddress uint8 t uint8 t twi readFrom uint8 t uint8 t uint8 t uint8 ttwi writeTo uint8 t uint8 t uint8 t uint8 t uint8 ttwi transmit const uint8 t uint8 t void twi attachSlaveRxEvent void uint8 t int void twi attachSlaveTxEvent void void void twi reply uint8 t void twi stop void void twi releaseBus void endif Liite 6 18 48 6 LCD C0220BiZ LCD C0220BiZ h Created by Francisco Malpartida on 20 08 11 Copyright 2011 Under creative commons license 3 0 Attribution ShareAlike BY SA This software is furnished as is without technical support and with no warranty express or implied as to its usefulness for any purpose Thread Safe No Extendable No file LCD C0220BiZ h NHD C0220BiZ display class definition brief Based on the LCD 1 0 by dale wentztech com This library implements the driver to drive the Newhaven Display NHD C0220BiZ FSW FBW 3V3M The display is build around the ST7036 i2c LCD controller This is a 3 3V display I2C displays based on the 577632 should also be compatible Other compatible displays NHD C0220BiZ FSW FBW 3V3M NHD C0220BiZ FS RGB FBW 3VM Non tested but should be compatible with n
41. OQ 9 10 11 12 13 14 Wire keywords txt Wire utility twi c Wire utility twi h LCD_C0220BiZ LCD_C0220BiZ h LCD_C0220BiZ LCD_C0220BiZ cpp LCD_C0220BiZ keywords txt C0220BiZ lcd h LCD_C0220BiZ ST7036 h LCD_C0220BiZ ST7036 cpp I2Cmaster i2cmaster h I2Cmaster keywords txt I2Cmaster twimaster cpp Liite 7 Mittausp yt kirja M Lyhenteita ja kasitteita Lahetin Vastaanotin Isanta Orja Multi master Synkronisaatio Drain Arbitraatio laite joka lahettaa dataa vaylaan laite joka vastaanottaa dataa vaylalta tiedonsiirron aloittava laite luo kellosignaalit ja tekee tiedonsiirron lopetukset laite jonka kanssa isanta vaihtaa tietoja jarjestelma sallii useamman kuin yhden isannan i Iman ett siirrettava data korruptoituu tai vaylaviestinta muuten hairiintyy Arbitraatio varmistaa etta vain yksi is nt l hett kerralla v yl n kytkettyjen is ntien kellosignaalien tahdistaminen tarvitaan vain useampia is nti sis lt viss j rjestelmiss avoimen kollektorin piiri l hetysj rjestyksen m ritt minen is ntien keske n Koska 12C v yl on drain tyyppinen yhden laitteen kytkiess linjan maahan pysyy sen j nnite alhaalla riippumatta muista laitteista ykk st ja nollaa l hetett ess nollan ensin l hett nyt is nt voittaa arbitraation Tarvitaan vain useampia mastereita sis lt viss j rjestelmiss Voltage drain dra
42. T m voi osaltaan johtua my s MLX90614 infrapunatunnistimen mittausalueen leve st 90 keilasta kuva 8 13 Pintalampotilamittaus tunnistin 10 cm n et isyydell Milwaukee 5 cm n et isyydell 65 f x 0 56x 14 93 R 0 95 55 50 45 40 35 30 Temp Gun 25 Mittausj rjestelm Lineaarinen regressio 20 sarjalle Mittausj rjestelm 20 25 30 35 40 45 50 55 00 65 Kuva 7 Pintal mp tilamittaus tunnistin 10 cm et isyydell Milwaukee 5 cm et isyydell Temp Gunin infrapunatunnistimen kennon mittausalueen keila on huomattavasti MLX90614 n vastaavaa kapeampi mittausalueen keilan halkaisijan suhde mittauset isyyteen verrattuna on 1 40 Et isyyden vaikutus mittausalueen keilan halkaisijaan MLX90614 30 25 20 15 10 5 0 1234567 8 9 1011 12 13 14 15 16 17 18 19 20 Et isyys mittaus alueesta cm Keilan halkaisija cm Kuva 8 Mittauset isyyden vaikutus MLX90614 n mittausalueen keilan halkaisijaan 14 Kun 10 cm n et isyydelt otetut mittaustulokset sovitettiin aiemmin kuvatulla tavalla saatiin kuvan 9 mukainen kuvaaja Pintal mp tilamittaus tunnistin 10 cm n et isyydell Milwaukee 5 cm n et isyydell korjausfunktiolla 65 f x 1x 0 60 R 0 95 55 50 45 gt 40 35 i m Temp Gun 25 20 Mittausjarjestelma Lineaarinen regressio sarjalle Mittausjarjestelma 20 25 30 35 40 45 50 55 60
43. This is a 3 3V display I2C displays based on the 5770321 should also be compatible Other compatible displays NHD C0220BiZ FSW FBW 3V3M NHD C0220BiZ FS RGB FBW 3VM Non tested but should be compatible with no or little changes NHD C0216CiZ FSW FBW 3V3 NHD C0216CiZ FN FBW 3V author F Malpartida fmalpartida gmail com Hinclude LCD C0220BiZ h Class private constants and definition I const int NUM LINES 2 1 Number of lines in the display const int NUM COLUMNS 20 Number of columns in the display constint 12 ADDRS 0x78 I2C address of the display Static member variable definitions Static file scope variable definitions Private support functions CLASS METHODS Constructors LCD C0220BIZ LCD C0220BIZ ST7036 NUM LINES NUM COLUMNS I2C_ADDRS Liite 6 21 48 LCD_C0220BIZ LCD_C0220BIZ int8_t backlightPin ST7036 NUM LINES NUM COLUMNS 126 ADDRS bac
44. a Vain yksi laite kerrallaan voi l hettaa tietoa v yl ss ja v yl n kirjoittaminen tapahtuu muuttamalla SDA ja SCL linjojen j nnitett V yl n maksimikapasitanssin ei tulisi olla yli 400 pF jotta tiedonsiirto toimii normaalisti T m rajoittaa v yl n pituuden muutamaan metriin J rjestelm koottaessa todettiin t m n merkitsev n maksimissaan kahta kuuden metrin mittaista johdinta kolmen anturin anturisarjoilla 2 1 SDA SCL logiikkatasot Nollabitin ja bitin yksi tasot eiv t ole I2C v yl tekniikassa kiinte t vaan ne m ritetty Vdd n mukaan Nollabitiksi tulkitaan kaikki alle 30 Vdd st olevat signaalit kun taas bitiksi yksi kaikki yli 70 Vdd st olevat signaalit T h n on p dytty jotta v yl j rjestelm tukisi mahdollisimman moneen eri tekniikkaan CMOSiin NMOSiin ja bipolaariseen perustuvia laitteita O bitti on dominantti avoimen kollektorin rakenteen vuoksi On olemassa joitakin laitteita joille on m ritetty kinte t IL 1 5V ja lu 3 0V N m niin sanotut Legacy laitteet ovat kuitenkin poistumassa k yt st ja harvinaisia 2 2 Tiedonsiirto 2C v yl ss Kaikkien I2C vaylaan l hetett vien tavujen tulee olla 8 bittisi J rjestelm n kuitenkin mahdollista kytke my s muita esimerkiksi 4 ja 16 bittisi laitteita T ll in luettu ja kirjoitettu tieto tulee jakaa osiin ja tallentaa v limuistiin ennen datan varsinaista k sittely I2C hen pohjautuvi
45. a buffer is writen to the display return 0 OK 1 if data was too big to be transmitted 2 NACK on address transmission 3 NACK on data transmission 4 other error uint8 t status uint8_t status JE Liite 6 32 48 Load a custom character on the display After adding a new character to the character set the coordinates are set to 0 0 This method should be called during initialization param char num in Character to load onto the display this display supports upto 16 user defined characters param rows in Bitmap defining the character the display assumes an array of 8 bytes per character return None uint8 t load custom character uint8 t char num uint8 t rows void load_custom_character uint8_t char_num uint8_t rows NOT SUPPORTED uint8 t keypad xl uint8 t keypad void printstr const char Sets the backlight level If the backlight level is connected to PWM pin new val will set a light level range between 0 and 255 If it is connected to a normal GPIO from 0 to 127 it will be off and from 128 to 255 the backlight will be on Backlight pin allocation on constructor param new val in Backlight level of the display Full range will only be available on pins with PWM support return None uint8_t setBacklight void setBacklight uint8 t new val Sets the LCD contrast level param new val in The contrast range 0 to 255 has been mapp
46. akaja suunnitella uudelleen tai j rjestelm n rakennetta muokata siten ett tarve pitkille johtimille poistuu Yksi rengasl mp tilan mittausj rjestelm lle asetetuista vaatimuksista oli sen helppo siirrett vyys ajoneuvosta toiseen joten anturisarjojen johtimien pituuden optimointi tulee kysymykseen vain jos j rjestelm asennetaan kiinte sti johonkin ajoneuvoon Toisena ratkaisuna ongelmaan voidaan pit siirtymist langattomaan tiedonsiirtoon anturisarjojen ja ohjainyksik n v lill Itse ohjainyksik n kokoa voisi pienent huomattavasti suunnittelemalla mittausj rjestelm lle integroidun piirilevyn joka sis lt kaikki mittausj rjestelm n osat Siirtyminen yhteen suureen n ytt n v hent isi tarvittavien komponenttien lukum r mutta CDIO projektin alkuvaiheessa ei ollut saatavilla riitt v n suuria LCD n ytt j edulliseen hintaan joten p dyttiin k ytt m n nelj pienikokoista mutta edullista n ytt My s mittausj rjestelm n helppok ytt isyytt voisi parantaa Toistaiseksi mittaj rjestelm n parametrien muuttaminen vaatii sen kytkemist tietokoneyhteyteen Emissiivisyysarvon muuttaminen ilman tietokoneyhteytt on yksi t rkeimmist tulevaisuuden parannuksista Lis ksi laitteeseen kytkettyjen gt anturisarjojen automaattinen tunnistus olisi mahdollista toteuttaa pelk ll ohjelmistop ivityksell 21 Lahteet 1 Arduino Products and Reference Verkkodok
47. arkkuus 1 C oli jo l ht kohtaisesti ep realistinen otettaessa huomioon etta Milwaukee Laser TEMP GUN M12 n mittatarkkuus lampotila alueella 0 100 on 1 5 Mittausjarjestelman tuottamien mittaustuloksien lineaarisen regression todettiin 5 15 cm n et isyydell olevan selitysasteeltaan hyv ja saatujen mittaustulosten olevan tilastollisesti merkitsevi Nain ollen voidaan todeta rengasl mp tilan 20 mittausjarjestelman mittaustarkkuuden olevan vahintaan 4 1 C mittausalueella 0 65 C Teoreettiseksi mittaustaajuudeksi arvioidaan 1 2 Hz Insin rity t voidaan pit onnistuneena vaikka sen tuloksena valmistettu rengasl mp tilan mittausj rjestelm t ytti asetetut tavoitteet vain osittain Tavoitteena ollutta mittaustarkkuutta ei saavutettu Merkitt vin syy t h n oli valittujen tunnistimen mittausalueen keilan liian suuri leveys MLX90614xA kykenee valmistajan mukaan 1 mittaustarkkuuteen ymp rist n l mp tilan ollessa 0 50 C ja mitattavan kohteen l mp tilan ollessa 0 120 C Esimerkiksi saman valmistajan anturi MLX90614xCF n mittausalueen keilan kulma on 10 mik parantaa mittaustulosten luotettavuutta Lis ksi vertailumittauksissa olisi tullut k ytt tarkempaa mittav linett Mittausj rjestelm n mittaustaajuutta rajoittaa suurimmassa m rin v yl njakajassa k ytettyjen transistorien nopeus Mik li j rjestelm n nopeutta haluttaisiin parantaa tulisi v yl nj
48. bus end transaction Serial printin Correct CRC not found return 1 word ChangeEmis int dev int NewELo int NewEHi for int a 0 a 256 i2c start wait dev I2C WRITE send start condition and write bit i2c write 0x24 send command for device to return address i2c write NewELo send new low byte i2c write NewEHI send new high byte if iDc write a 0 i2c stop delay 100 Serial print Found correct CRC Serial println a HEX return a i2c_stop Release bus end transaction Liite 3 5 6 Serial printin Correct CRC not found return 1 int ReadEmis int dev int data_low 0 int data_high 0 int pec 0 i2c start wait dev 12C WRITE i2c write 0x24 read i2c_rep_start dev l2C_READ data_low i2c_readAck Read 1 byte and then send ack data_high i2c_readAck Read 1 byte and then send ack pec i2c_readNak i2c_stop Serial begin 9600 Serial print Emissivity Serial printin dev gt gt 1 HEX Serial printIn data_high HEX Serial printIn data_low HEX return int data_low data_high delay 100 float readtemp int dev float celcius int data_LSB 0 int data MSB 0 int pec 7 0 i2c start wait dev 12C WRITE i2c write 0x07 read temperature memory i2c rep start dev l2C READ data LSB 12 readAck Read 1 LSbyte and then send ack data MSB i2c readAc
49. ck or i2c_readNak Oparam ack 1 send ack request more data from device lt br gt 0 send nak read is followed by a stop condition return byte read from I2C device extern unsigned char i2c_read unsigned char ack define i2c_read ack ack i2c_readAck i2c_readNak Zendif Liite 6 44 48 13 I2Cmaster keywords txt FRA Syntax I2Cmaster THHHHHHHHHHHHHBHHHHHHBHHHBHHHHHHHHBHHHBHHBE THHHHHHHHHHHHBHHHHHHHHHHHHHHBHHHBHHHHHBHHBBE Datatypes KEYWORD1 FERRARA THHEHHBHHHHHEHHHHHHBHHHHHHHHHBHBHBHBHHHRHE Methods and Functions KEYWORD2 THHEHHBHHHHHEHHHHHHBHHHHHHHHBHBHBHHBHHHRHE i2c init KEYWORD2 i2c stop KEYWORD2 i2c start KEYWORD2 i2c rep start KEYWORD2 i2c start wait KEYWORD2 i2c write KEYWORD2 i2c readAck KEYWORD2 i2c readNak KEYWORD2 i2c read KEYWORD2 IHHHHBHHHHHHHHHHHHHHHHHHHHHBHHHHEHHHHRE Constants LITERAL1 HEAR Liite 6 45 48 14 I2Cmaster twimaster cpp Title 12 master library using hardware TWI interface Author Peter Fleury lt pfleury gmx ch gt http jump to fleury File twimaster c v 1 3 2005 07 02 11 14 21 Peter Exp Software AVR GCC 3 4 3 avr libc 1 2 3 Target any AVR device with hardware TWI Usage API compatible with I2C Software Library i2cmaster h ORO e oe ek oo include lt inttypes h gt include lt compat twi h gt include lt i
50. delay 5 Icd init Icd setCursor 0 0 Icd print Temp Sensors 1 Icd setCursor 1 0 Icd print Setup Ready delay 5 digitalWrite gatePin1 LOW digitalWrite gatePin2 HIGH delay 30 Icd init Icd setCursor 0 0 Liite 5 4 10 Icd print Temp Sensors 2 Icd setCursor 1 0 Icd print Setup delay 5 if set2 true amp amp config true ChangeEmissivity dev4 emissivityLSB emissivityMSB ChangeEmissivity dev5 emissivityLSB emissivityMSB ChangeEmissivity dev6 emissivityLSB emissivityMSB delay 5 Icd init Icd setCursor 0 0 Icd print Temp Sensors 2 Icd setCursor 1 0 Icd print Setup Ready delay 5 digitalWrite gatePinSCL LOW digitalWrite gatePin2 LOW digitalWrite gatePinSCL2 HIGH delay 5 digitalWrite gatePin3 HIGH delay 30 Icd init Icd setCursor 0 0 Icd print Temp Sensors 3 Icd setCursor 1 0 Icd print Setup delay 5 if set3 true amp amp config true ChangeEmissivity dev7 emissivityL SB emissivityMSB ChangeEmissivity dev8 emissivityL SB emissivityMSB ChangeEmissivity dev9 emissivityL SB emissivityMSB delay 5 Icd init Icd setCursor 0 0 Icd print Temp Sensors 3 Icd setCursor 1 0 Icd print Setup Ready delay 5 digitalWrite gatePin3 LOW digitalWrite gatePin4 HIGH delay 5 Icd init Icd setCursor 0 0 Icd print Temp Sensors 4
51. duinon digitaalisilta ulostuloilta Avaamalla ja sulkemalla transistoreja voidaan p tt mik nelj st v yl n osasta on k yt ss Transistorien k ytt kuitenkin rajoittaa j rjestelm n nopeutta koska 2n2222a n t ysi aukeaminen vaatii noin 24 ms 6 s 2 jolloin nelj n anturisarjan tietojen kirjoittaminen nelj lle erilliselle n yt lle noin 0 1 sekuntia T st syyst j rjestelm n p ivitystaajuus j korkeimmillaankin tasolle 10 n ytett sekunti Rengasl mp tilaa mitattaessa t m on kuitenkin riitt v n ytteenottotaajuus Transistorien k ytt v yl n jakamiseen ei ole ihanteellinen ratkaisu k ytett ess I2C v yl protokollaa V yl viestinn n rakenne perustuu SDA SCL signaalien tasomuutoksiin joten tilanne jossa molemmat v yl t siirtyv t yht aikaa 1 johtaa v yl viestinn n katkeamiseen T st johtuen v ylien fyysinen aktivointi tapahtuukin mittausj rjestelm ss nostamalla SCL signaali ennen SDA signaalia V yl viestinn ss t m vastaa STOP komentoa On my s otettava huomioon ett transistorien johtavaksi saattamisen vaatimat j nnitteenjakosillat laskevat v yl n l hetetyn signaalin j nnitetasoa noin 0 4 0 8 volttia 5 V n j nnitett k ytt v ss I2C vaylassa lu n j nnite saa vaihdella 3 5 5 V joten voidaan todeta ett vaimeneminen on hyv ksytt v ll tasolla 3 3 Virtapiiri 12C v yl tekniikan ansiosta j rjes
52. e 0 100 0 255 maps temperature 0 100C to PWM output range analogWrite dataPin averageout void writelcd boolean data int set match data and set e x set1 1 float celcius1 float celcius2 float celcius3 float average int PinSCL int Pin int dataPin int sens1 int sens2 int sens3 if data false if set 1 PinSCL gatePinSCL Pin gatePin1 if set 2 PinSCL gatePinSCL Pin gatePin2 if set 3 PinSCL gatePinSCL2 Pin gatePin3 if set 4 PinSCL gatePinSCL2 Pin gatePin4 digitalWrite PinSCL HIGH delay 30 digitalWrite Pin HIGH delay 30 Icd init Icd setCursor 0 0 Icd print Temp Sensors Icd setCursor 0 14 Icd print set Icd setCursor 1 0 Icd print NO DATA delay 5 digitalWrite PinSCL LOW digitalWrite Pin LOW Jelsef if data true if set 1 PinSCL gatePinSCL Pin gatePin1 dataPin dataPin1 sens1 dev1 sens2 dev2 sens3 dev3 if set 2 PinSCL gatePinSCL Liite 5 7 10 Liite 5 8 10 Pin gatePin2 dataPin dataPin2 sens1 dev4 sens2 dev5 sens3 dev6 if set 3 PinSCL gatePinSCL2 Pin gatePin3 dataPin dataPin3 1 dev7 sens2 dev8 sens3 dev9 if set 4 PinSCL gatePinSCL2 Pin gatePin4 dataPin dataPin4 sens1 dev10 sens2 dev11 sens3 dev12 digitalWrite PinSCL HIGH dela
53. e details You should have received a copy of the GNU Lesser General Public License along with this library if not write to the Free Software Foundation Inc 51 Franklin St Fifth Floor Boston MA 02110 1301 USA ifndef TwoWire_h define TwoWire_h include lt inttypes h gt include Stream h define BUFFER_LENGTH 32 class TwoWire public Stream private static uint8 t rxBuffer static uint8 t rxBufferlndex static uint8 t rxBufferLength static uint8 t txAddress static uint8 t txBuffer static uint8 t txBufferlndex static uint8 t txBufferLength static uint8 t transmitting static void user onRequest void static void user onReceive int static void onRequestService void static void onReceiveService uint8 t int public TwoWire void begin void begin uint8 t void begin int void beginTransmission uint8 t void beginTransmission int uint8 t endTransmission void uint8 t requestFrom uint8 t uint8 t Liite 6 2 48 uint8 t requestFrom int int virtual size t write uint8 t virtual size t write const uint8 size t virtual int available void virtual int read void virtual int peek void virtual void flush void void onReceive void int void onRequest void void using Print write extern TwoWire Wire endif Liite 6 3 48 2 Wire Wire cpp TwoWire cpp TWI I2C library for Wiring amp Arduino Copyrigh
54. ed to 16 contrast levels on the display return None uint8 t setContrast void setContrast uint8 t new val endif private uint8 t num lines uint8 t num col uint8 1 i2cAddress int _cmdDelay int charDelay Liite 6 33 48 bool _ initialised uint8_t_ status int8 t backlightPin endif 11 LCD C0220BiZ ST7036 cpp Created by Francisco Malpartida on 20 08 11 Copyright 2011 Under creative commons license 3 0 Attribution ShareAlike BY SA This software is furnished is without technical support and with no warranty express or implied as to its usefulness for any purpose Thread Safe No Extendable No file LCD C0220BiZ cpp Display class implementation of the LCD API 1 0 brief Based on the LCD API 1 0 by dale wentztech com This library implements the driver to any 12 display with the 517036 LCD controller I2C displays based on the 5770321 should also be compatible Other compatible displays NHD C0220BiZ FSW FBW 3V3M NHD C0220BiZ FS RGB FBW 3VM Non tested but should be compatible with or little changes NHD C0216CiZ FSW FBW 3V3 NHD C0216CiZ FN FBW 3V author F Malpartida fmalpartida gmail com include lt Arduino h gt things wiring arduino include lt Wire h gt include lt string h gt for strlen include lt inttypes
55. et a light level range between 0 and 255 If it is connected to a normal GPIO from 0 to 127 it will be off and from 128 to 255 the backlight will be on Backlight pin allocation on constructor param new vallin Backlight level of the display Full range will only be available on pins with PWM support return None uint8_t setBacklight virtual void setBacklight uint8 t new val 0 JE Liite 6 27 48 Sets the LCD contrast level param new val in The contrast range 0 to 255 has been mapped to 16 contrast levels on the display return None t setContrast virtual void setContrast uint8 t new val 0 endif private h endif Liite 6 28 48 10 LCD C0220BiZ ST7036 h Created by Francisco Malpartida on 20 08 11 Copyright 2011 Under creative commons license 3 0 Attribution ShareAlike BY SA This software is furnished as is without technical support and with no warranty express or implied as to its usefulness for any purpose Thread Safe No Extendable No 1 file ST7036 h NHD C0220BiZ display class definition brief Based on the LCD API 1 0 by dale wentztech com This library implements the driver to any 12 display with the ST7036 LCD controller I2C displays based on 577632 should also be compatible Other compatible displays NHD C0220BiZ FSW FBW 3V3M NHD C0220ST7036BiZ FS RGB FBW 3VM N
56. etup delay 5 digitalWrite gatePin1 HIGH digitalWrite gatePin2 LOW Open connection to MLX90614 ChangeEmissivity MLX emissivityLSB emissivityMSB digitalWrite gatePin1 LOW digitalWrite gatePin2 HIGH delay 30 Icd init Icd setCursor 0 0 Icd print Temp Sensor Icd setCursor 1 0 Icd print Setup Ready delay 100 digitalWrite gatePin1 LOW digitalWrite gatePin2 LOW Liite 3 4 6 void ChangeEmissivity int dev int lowbyte int hibyte Use this to Adjust Sensor Emissivity int tester hibyte lowbyte Serial begin 9600 Serial print Sensor Serial print dev gt gt 1 HEX Serial printin emissivity Serial print hibyte HEX Serial printin lowbyte HEX ReadEmis dev ZeroEmis dev ReadEmis dev ChangeEmis dev lowbyte hibyte while ReadEmis dev tester ZeroEmis dev ChangeEmis dev lowbyte hibyte delay 10 word ZeroEmis int dev for int a 0 a 256 i2c_start_wait dev I2C_WRITE send start condition and write bit i2c write 0x24 send command for device to return address i2c write 0x00 send low byte zero to erase i2c_write Ox00 send high byte zero to erase if i2c_write a 0 ichecks all possible PECS i2c_stop Release bus end transaction delay 100 Serial print Found correct CRC Serial printIn a HEX return a i2c_stop Release
57. evan lineaaristen mallien estimointimenetelm Mallin tarkkuutta arvioidaan regressiosuoran selitysasteen 2 luvun perusteella 3 s 291 Selitysaste havainnollistaa sit miten hyvin saadut mittaustulokset asettuvat regressiosuoran suhteen Selitysaste vaihtelee v lill 0 1 miss arvo 1 merkitsee tilannetta jossa kaikki mittaustulokset asettuvat regressiosuoralle Kuvassa 5 on graafisesti esitettyn mittausj rjestelm n yhden anturin mittaustulokset Temp Gunilla mitatut tulokset sovitettiin avulla kuvaajaan niin ett ne muodostavan suoran joka kulkee koordinaatiston origon kautta Mittauspisteist muodostetun regressiosuoran funktio on f x R arvosta voidaan p tell ett mittausj rjestelm n mittaustarkkuuden olevan hyv kun mittauset isyys on 5 cm Pintal mp tilamittaus 5 cm n et isyydelt 65 f x 0 7x 9 26 60 R 0 98 55 50 45 40 35 30 m Temp Gun 25 Mittausj rjestelm Lineaarinen regressio 20 sarjalle Mittausj rjestelm 20 25 30 35 40 45 50 55 00 65 Kuva 5 Pintalampotilamittaus 5 cm n et isyydelt Vaikka saatujen mittaustulosten lineaarinen riippuvuus on selitysasteen perusteella hyv pystyy mittaustulosten kuvaajasta p ttelem n ett rengasl mp tilan mittausj rjestelm n mittaamissa arvoissa on systemaattinen virhe T m n virheen 12 korjaaminen onnistuu ensimm isen asteen polynomifunktiolla mik li ilmi t voidaan pit
58. ial begin 9600 Removing slashes will enable Serial connection and disable independent mode Serial printin Setup Serial begin 9600 Serial printiIn emissivity check Liite 5 3 10 Serial printIn emissivityMSB HEX Serial print emissivityLSB HEX pinMode A4 INPUT SDA and SCL pins to analog input with pinMode A5 INPUT digitalWrite A4 LOW LOW internal pull ups turned off digitalWrite A5 LOW pinMode gatePin1 OUTPUT Pins to OUTPUT mode pinMode gatePin2 OUTPUT pinMode gatePin3 OUTPUT pinMode gatePin4 OUTPUT pinMode gatePinSCL OUTPUT pinMode gatePinSCL2 OUTPUT pinMode dataPin1 OUTPUT pinMode dataPin2 OUTPUT y pinMode dataPin3 OUTPUT pinMode dataPin4 OUTPUT pinMode MLXPower OUTPUT pinMode buttonPin INPUT set button as input delay 100 digitalWrite MLXPower HIGH digitalWrite gatePinSCL HIGH There must be a delay between opening SCL and SDA delay 5 SCL and SDA go from 0 to 1 at the same time it s digitalWrite gatePin1 HIGH not a command If SCL goes up first it s STOP delay 30 Icd init Icd setCursor 0 0 Icd print Temp Sensors 1 Icd setCursor 1 0 Icd print Setup delay 5 if set1 true amp amp config true ChangeEmissivity dev1 emissivityLSB emissivityMSB ChangeEmissivity dev2 emissivityLSB emissivityMSB ChangeEmissivity dev3 emissivityLSB emissivityMSB
59. in t ss yhteydess j rjestelm n k ytt j nnite Input Refence Low looginen nolla Input Reference High looginen yksi Signal Data datasignaali Signal Clock kellosignaali bin riluku O tai 1 kahdeksan bitin joukko Read Write eli luku kirjoitus bitti Acknowledge bitti seuraa jokaista l hetetty 8 bitin tavua Sen avulla orja ilmoittaa is nn lle olevansa valmis vapauttamaan v yl n uutta tiedonsiirtoa varten Is nt vapauttaa SDA v yl n jonka j lkeen orjan on mahdollista laskea SDA j nnite nollaksi T m 9 nen MUN kellosignaalipulssin aikana tapahtuva jannitteenmuutos IL n on ACK bitti NACK Not Acknowledge bitti syntyy kun SDA v yl n j nnite pysyy ylh ll 9 nen kellosignaalipulssin ajan Kertoo is nn lle ett 1 V yl ll ei ole laitetta kutsutussa osoitteessa 2 Vastaanotin ei kykene vastaanottamaan tai l hett m n johtuen siit ett se suorittaa teht v 3 Tiedonsiirron aikana l hetetty NACK vastaanotin vastaanottaa dataa tai komentoja joita se ei tunne tai ymm rr 4 Tiedonsiirron aikana l hetetty NACK vastaanotin ei kykene vastaanottamaan enemp tavuja dataa 5 lsannan on l hetett v tiedonsiirron p ttymist merkitsev signaali Nackin j lkeen is nt voi l hett joko Stop komennon tai Repeated Start komennon riippuen jatketaanko tiedonsiirtoa laitteiden v lill vai ei CRC Circular Redundancy Correction tarkistus
60. itration bus error uint8_t twi_writeTo uint8_t address uint8 t data uint8 t length uint8 t wait uint8 ti Liite 6 12 48 ensure data will fit into buffer if TWI BUFFER LENGTH lt length return 1 wait until twi is ready become master transmitter while TWI READY twi_state continue twi_state TWI_MTX reset error state OXFF no error occured twi_error OxFF initialize buffer iteration vars twi_masterBufferlndex 0 twi_masterBufferLength length copy data to twi buffer for i 0 i lt length twi masterBuffer i data i build sla w slave device address w bit twi slarw TW WRITE twi slarw address lt lt 1 send start condition TWCR _BV TWEN BV TWIE BV TWEA BV TWINT _BV TWSTA wait for write operation to complete while wait amp amp TWI MTX twi_state continue if twi error OxFF return 0 success else if twi error TW MT SLA NACK return 2 error address send nack received else if twi error TW MT DATA NACK return 3 error data send nack received else return 4 other twi error J JE Function twi_transmit Desc fills slave tx buffer with data if must be called in slave tx event callback Input data pointer to byte array length number of bytes array Output 1 length too long for buffer N 2 not slave transmitter
61. ittavan aineen l mp tila reilusti yli ymp rist ss vallitsevan l mp tilan AT gt 10 C 3 Mittaa tutkittavan aineen l mp tilaa infrapunal mp mittarilla teipatun alan kohdalta noin 5 cm et isyydelt tai kuten infrapunal mp mittarin valmistaja on mittauset isyyden m ritt nyt L mp parin ja infrapunal mp mittarin v lisest l mp tilaerosta on mahdollista todeta kuinka hyvin kontaktimittaus onnistuu Jos l mp tilaero on pienempi 0 1 mittarien n ytt m suurimman osan ajasta sama l mp tilan muutos n kyy toisessa mittarissa viiveell tutkittavan aineen j htyess voidaan kontaktimittauksen sovitusta pit riitt v n 4 L mmit kohde uudestaan Verrataan kontaktil mp mittauksen ja teippaamattoman pinnan l mp tilaeroa Mitattujen l mp tilojen erosta voi p tell mittaako tuntemattoman pinnan l mp tilaa liian suurella n ytt liian korkeita l mp tiloja vai liian pienell emissiivisyysarvolla mitatut l mp tilat liian alhaisia 5 S d mittalaitteen emissiivisyysarvoa saadun tiedon perusteella kunnes sen mittaustulokset ovat mahdollisimman l hell kontaktimittauksen l mp tila arvoja Parhaan tuloksen saa erilaisilla haarukoimismenetelmill Liite 5 1 10 Rengaslampotilan mittausjarjestelman koodi kommentteineen would like to thank following individuals and online communities for inspiration and advice control example Andy of workshop
62. k Read 1 MSbyte and then send ack pec i2c readNak i2c stop This converts high and low bytes together and processes temperature MSB is a error bit and is ignored for temperatures double tempFactor 0 02 0 02 degrees per LSB measurement resolution of the MLX90614 double tempData 0x0000 zero out the data int frac data past the decimal point Liite 3 6 6 This masks off the error bit of the high byte then moves it left 8 bits and adds the low byte tempData double data MSB amp 0x007F lt lt 8 data_LSB tempData tempData tempFactor 0 01 celcius tempData 273 15 Serial printin tempData 273 15 Serial print Celcius Serial printIn celcius Serial print Fahrenheit Serial printin celcius return celcius void loop float celcius1 digitalWrite gatePin1 HIGH digitalWrite gatePin2 LOW delay 30 celcius1 readtemp ML X digitalWrite gatePin1 LOW digitalWrite gatePin2 HIGH delay 30 Icd init Icd setCursor 0 0 Icd print Temperature y Icd setCursor 1 0 Icd print celcius1 1 delay 5 Liite 4 1 4 Kayttoohje rengaslampotilan mittausjarjestelmalle Rengaslampotilan mittausj rjestelm n k ytt ohje Rengasl mp tilan mittausj rjestelm koostuu kahdesta p komponentista anturisarjasta ja keskusyksik st Yksitt isen v yl johtimen p h n sijoitetut infrapunatunnistimet mu
63. kaja jotta kaikki mitta anturisarjat saataisiin toimimaan samanaikaisesti Opinn ytety n tavoitteena oli korjata n m mittausj rjestelm ss havaitut puutteet sek m ritt sen mittaustarkkuus Lis ksi opinn ytety ss suunniteltiin mittausj rjestelm st gt pienoisversio 3 Metropolia Ammattikorkeakoulun automaatiolaboratoriota varten T m n opinn ytety n teoriaosassa tarkastellaan 12C v yl tekniikkaa ja sen toiminnan perusteita Lis ksi esitell n Arduino Uno mikrokontrolleri Mittausj rjestelm n mittaustarkkuus on m ritetty vertaamalla sen mittaustuloksia teollisesti valmistetun infrapunal mp mittarin _ kanssa Mittausjarjestelman _ p ivitystaajuus arvioitiin laskennallisesti 2 Yleist I2C vaylatekniikasta I2C on yksi pienelektroniikassa yleisesti k yt ss olevista v yl tekniikoista 12C vaylan tiedonsiirtonopeus vaihtelee 100 kb s ja 5 Mb s v lill riippuen v yl n ohjainlaitteen kehitysasteesta I2C v yl on avoimen kollektorin rakenne eli se vaatii yl svetovastuksen j nnitteen vaihtelujen aikaansaamiseksi J rjestelm ss voi olla useita is nt laitteita ja orjalaitteita N iden m r rajaa vain osoitteiden 7 bittisyys mink vuoksi k ytett viss olevia v yl osoitteita on ainoastaan 127 kappaletta On olemassa my s 10 bittisi I2C laitteita mutta ne ovat toistaiseksi melko harvinaisia sill tarve niiden olemassaololle on syntynyt vasta viime vuosien kuluess
64. klightPin Liite 6 22 48 8 C0220BiZ keywords txt THHHHHHHHHHBHHHBHHHHHHBHHHBHHHHHHRHHBHHHBHBBE Syntax Coloring Map For Ultrasound THHHHHHHHHHBHHHHHHHHHBHHBHHHHHHHHHBHHHBHHBBE IHHHHBHHHHHHHHHHHBHHHHHHHHHBHHHHBHHHHRI Datatypes KEYWORD 1 EAE LCD_C0220BIZ KEYWORD1 THHHHHHHHHHHHBHHHHHHHHHHHHHHHBHHHHHHHBHBBE Methods and Functions KEYWORD2 FERRARA init KEYWORD2 setDelay KEYWORD2 command KEYWORD2 write KEYWORD2 clear KEYWORD2 home KEYWORD2 on KEYWORD2 off KEYWORD2 cursor on KEYWORD2 cursor off KEYWORD2 blink on KEYWORD2 blink off KEYWORD2 setCursor KEYWORD2 status KEYWORD2 load custom character KEYWORD2 keypad KEYWORD2 setBacklight KEYWORD2 setContrast KEYWORD2 IHHHHBHHHHHHHHHHHBHHHHHHHHHBHHHHBHHHHHI Constants LITERAL1 IHHHHBHHHHHHHHHHHBHHHHHHHHHBHHHHBHHHHHE Liite 6 23 48 9 LCD_C0220BiZ Icd h Created by Francisco Malpartida on 20 08 11 Copyright 2011 Under creative commons license 3 0 Attribution ShareAlike BY SA This software is furnished is without technical support and with no warranty express or implied as to its usefulness for any purpose Thread Safe No Extendable No file Icd h 1 LCD API 1 0 interface declaration class brief Based on the LCD API 1 0 by dale wentztech com This class implements the LCD API abstract library class from which all LCDs inherite author Mal
65. la m ritet n mittausj rjestelm lle korjausfunktio jonka mukaan korjattujen mittaustulosten regressiosuora on esitetty kuvassa 13 18 Pintal mp tilamittaukset koonti korjausfunktiolla P f x 1x 0 70 R 0 94 9 65 60 55 50 45 40 35 30 m Temp Gun Mittausjarjestelma Lineaarinen regressio sarjalle Mittausjarjestelma 20 25 30 35 40 45 50 55 60 65 Kuva 13 Pintal mp tilamittausten koonti korjatuilla mittaustuloksilla 25 20 Arvioitaessa PNS keinolla saatua mallia tulee tarkastella my s selitysasteen tilastollista merkitsevyytt Suoran tapauksessa malli selitt mittaustulosten vaihtelua merkitsev sti jos sen kulmakerroin poikkeaa riskitasolla 0 05 merkitsev sti nollasta 3 s 292 M ritet n lineaarisen regression to k ytt en kaavaa 7 3 s 292 b 7 miss b on suoran kulmakerroin ja On kulmakertoimen keskihajonnan estimaatti Mittaustuloksia arvioitiin taulukkolaskentaohjelman linest funktiota k ytt en taulukko 1 Taulukko 1 Linest funktion arvot mittaustuloksista bn 1 4 84 10 bra On 0 00807 0 356 On 1 r 0 939 2 649 Oy F 15342 942 988 df 19 SSreg 107686 797 6934 419 SSresid Taulukon perusteella laskien saadaan testisuureen arvoksi to 124 Verrattaessa saatua to arvoa taulukkoon t jakauman pisteit joille P T gt t p 3 s 303
66. lay _cmdDelay Set CGRAM position to write Wire write RAM WRITE CMD PIXEL ROWS PER CHAR char num status Wire endTransmission f we have changed the function table and configured the CGRAM position write the new character to the LCD s CGRAM if status 0 write rows PIXEL ROWS PER CHAR write the character to CGRAM Leave the LCD as it was function table 1 DDRAM and set the cursor position to 0 0 to start writing command FUNC SET TBL1 setCursor 0 0 void ST7036 setBacklight uint8 t new val Set analog write to the pin the routine already checks if it can set a PWM or not if _backlightPin 1 analogWrite backlightPin new val void ST7036 setContrast uint8 t new val Only allow 15 levels of contrast new val map new val 0 255 0 15 command CONTRAST CMD new val Liite 6 39 48 endif LCDEXPANDED Liite 6 40 48 12 12Cmaster i2cmaster h ifndef I2CMASTER H define I2CMASTER H 1 Title include file for the I2C master interface E i2cmaster S or twimaster c Author Peter Fleury pfleury gmx ch http jump to fleury File Id i2cmaster h v 1 10 2005 03 06 22 39 57 Peter Exp Software AVR GCC 3 4 3 avr libc 1 2 3 Target any AVR device Usage see Doxygen manual RON ICON ERR OCIO ene ocio e ooo f
67. m address numBytes int TwoWire peek void int value 1 if rxBufferlndex lt rxBufferLength value rxBuffer rxBufferlndex return value void TwoWire flush void XXX to be implemented behind the scenes function that is called when data is received void TwoWire onReceiveService uint8 t inBytes int numBytes don t bother if user hasn t registered a callback if luser onReceive f return don t bother if rx buffer is in use by a master requestFrom op i know this drops data but it allows for slight stupidity meaning they may not have read all the master requestFrom data yet if rxBufferlndex lt rxBufferLength return copy twi rx buffer into local read buffer this enables new reads to happen in parallel for uint8 t i 0 i lt numBytes i rxBuffer i inBytes i set rx iterator vars rxBufferlndex 0 rxBufferLength numBytes alert user program user onReceive numBytes Liite 6 T 48 behind the scenes function that is called when data is requested void TwoWire onRequestService void don t bother if user hasn t registered a callback if tuser_onRequest return reset tx buffer iterator vars this will kill any pending pre master sendTo activity txBufferlndex 0 txBufferLength 0 alert user program user_onRequest sets function called on slave write void TwoWire onReceive void function int
68. mp ratio 6 Wire write Display on Wire write 0x01 Clear display Wire write 0x06 Entry mode set increment status Wire endTransmission if status 0 initialised true void ST7036 setDelay int cmdDelay int charDelay _cmdDelay cmdDelay charDelay charDelay void ST7036 command uint8_t value If the LCD has been initialised correctly write to it if initialised Wire beginTransmission i2cAddress Wire write DISP CMD Wire write value status Wire endTransmission Liite 6 36 48 delay _cmdDelay size t ST7036 write uint8_t value If the LCD has been initialised correctly write to it if initialised If it is a new line set the cursor to the next 1 0 if value setCursor 1 0 else Wire beginTransmission i2cAddress Wire write RAM WRITE Wire write value status Wire endTransmission delay charDelay size_t ST7036 write const uint8_t buffer size_t size If the LCD has been initialised correctly write to it if _ initialised Wire beginTransmission i2cAddress Wire write RAM WRITE CMD Wire write uint8 t buffer size status Wire endTransmission delay charDelay void ST7036 clear command CLEAR DISP CMD void ST7036 home i command HOME CMD void ST7036 o
69. n command DISP ON CMD Liite 6 37 48 void ST7036 off command DISP OFF CMD void ST7036 cursor_on command DISP_ON_CMD CURSOR_ON_BIT void ST7036 cursor_off command DISP ON 8 CURSOR ON void ST7036 blink_on command DISP_ON_CMD BLINK ON void ST7036 blink_off command DISP ON amp BLINK_ON_BIT void ST7036 setCursor uint8_t line_num uint8_t x uint8_t base 0x00 If the LCD has been initialised correctly write to it if _ initialised set the baseline address with respect to the number of lines of the display base dram dispAddr num lines 1 line num base SET DDRAM base x command base Hitdef LCDEXPANDED uint8 t ST7036 status return status uint8 t ST7036 keypad NOT SUPPORTED return 0 void ST7036 load_custom_character uint8_t char_num uint8_t rows Liite 6 38 48 If the LCD has been initialised correctly start writing to it if _ initialised If itis a valid place holder for the character write it into the display s CGRAM if char num MAX USER CHARS Set up the display to write into CGRAM configure LCD to use func table Wire beginTransmission i2cAddress Wire write DISP CMD Wire write FUNC SET TBLO Function set 8 bit 2 line display 5x8 funct tab 0 de
70. n fahrenheits Serial printin tempData 273 15 corrFactor1 corrFactor2 Serial print Celcius Serial printIn celcius Serial print Fahrenheit Serial printIn celcius return celcius void Button pushbutton subprogram long time 0 while digitalRead buttonPin HIGH time delay 1 Serial begin 9600 Serial printin time if time gt 15 adjusting time sets the trigger for pushbutton if time gt 1000 digitalWrite MLXPower LOW RESET delay 100 digitalWrite MLXPower HIGH else O fflip 1 button 1 elsefflip 0 button 0 void loop writelcd set1 1 writelcd set2 2 Button writelcd set3 3 writelcd set4 4 Button delay 0 Liite 6 1 48 Tarvittavat Arduino IDE ohjelmakirjastot tiedostoineen 1 Wire Wire h TwoWire h TWI I2C library for Arduino amp Wiring Copyright c 2006 Nicholas Zambetti All right reserved This library is free software you can redistribute it and or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation either version 2 1 of the License or at your option any later version This library is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU Lesser General Public License for mor
71. n nimet Voit muuttaa anturin emissiivisyysarvoa sovittaaksesi sen mittaamaan eri materiaaleja mahdollisimman tarkasti include Wire h include ST7036 h include i2cmaster h ST7036 Icd 517036 2 16 Ox3E 1 16 characters and 2 line display 7 byte address IMODIFIABLE const int gatePin1 1 muxer control pins const int gatePin2 2 Liite 3 3 6 const float emissivityValue 0 95 Melexis IR Sensors Default Emissivity is OxFFFF HEX 65535 DEC const int MLX 0x00 universal address for all I2C devices IDON T TOUCH long emissivity 65535 emissivityValue byte emissivityL SB emissivity amp OxFF byte emissivityMSB emissivity gt gt 8 amp OxFF double tempData 0x0000 void setup Serial begin 9600 Removing slashes will enable Serial connection Serial printin Setup Serial begin 9600 Serial printin emissivity check Serial printIn emissivityMSB HEX Serial print emissivityLSB HEX pinMode A4 INPUT set SDA and SCL pins to analog input with pinMode A5 INPUT digitalWrite A4 LOW llif LOW internal pull ups turned off digitalWrite A5 LOW pinMode gatePin1 OUTPUT set Pins to OUTPUT mode pinMode gatePin2 OUTPUT delay 100 digitalWrite gatePin1 LOW digitalWrite gatePin2 HIGH Open connection to LCD delay 30 Icd init Icd setCursor 0 0 Icd print Temp Sensor Icd setCursor 1 0 Icd print S
72. n rakennetun regulaattorin ansiosta Mikrokontrollerin prosessorin kellotaajuus on 16 MHz ja siin on sis n rakennettuna 32 kB Flash muistia 2 kB SRAM muistia sek 1 kB EEPROM muistia Piirilevylt l ytyy 14 digitaalista I O pinni sek 6 analogista sis ntuloa Osan digitaalisista pinneist ulostulojannite on pulssileveysmoduloitua gt kanttiaaltoa Analogiset pinnit A4 ja A5 ovat I2C v yl n SDA SCL pinnit ja niiss on tiedonsiirron mahdollistamista varten sis n rakennetut yl svetovastukset jotka voi kytke p lle ja pois ohjelmallisesti Virran ulostuloja on kaksi 5 V ja 3 3 V Digitaalisten pinnien ulostulojannite on 5 V Arduino Unon ohjelmointia varten on mahdollista ladata ilmainen k ytt liittym Arduino IDE joka toimii yleisimmill k ytt j rjestelmill Linux Windows ja Ohjelmointikieli perustuu C aan 3 2 V yl njakaja Johtimien pituuden maksimoimiseksi ja nelj n saman kiinte n v yl osoitteen omaavan LCD n yt n k yt n mahdollistamiseksi tulee fyysinen v yl yhteys jakaa nelj n osaan T t tarkoitusta varten suunniteltiin erityinen v yl njakaja Renkaan l mp tilan mittausj rjestelm varten suunniteltiin kuuteen npn transistoriin perustuva v yl njakaja Transistoriksi valikoitui 2N2222a yleisyytens ja kest vyytens vuoksi V yl njakaja toimii seuraavasti transistorit avataan t ysin johtavaan tilaan johtamalla niiden kannalle 5 V n j nnite Ar
73. nnistin 15 cm n et isyydell Milwaukee 5 cm n et isyydell korjausfunktiolla 65 f x 1x 0 __ 2 0 94 55 50 45 V 40 35 30 m Temp Gun Mittausj rjestelm Linear Mittausjarjestelma 25 20 20 25 30 35 40 45 50 55 60 65 Kuva 11 Pintal mp tilamittaus tunnistin 15 cm n et isyydell Milwaukee 5 cm n et isyydell tulokset sovitettu korjausfunktion avulla Jouston aiheuttaman et isyyden muutoksen kaavasta voidaan todeta ett renkaan pinnan kaarevuuden aiheuttama mittaustuloksen muutos pysyy alle 10 55 yleisimmill rengaskoilla suurissakin 0 23 cm n joustoissa anturin ollessa sijoitettuna jouston liikeradan linjan kanssa kohtisuoralla linjalla py r nnavan korkeudella N in ollen voidaan todeta ett rengasl mp tilan mittausj rjestelm n mittaustarkkuus voidaan sovittaa et isyydelle 5 15 cm Kuvaan 12 on koottu kaikki rengasl mp tilan mittausj rjestelm n mittaustulokset j rjestelm n mittaustarkkuuden m rityst varten Regressiosuoran selitysaste on hyv 0 94 17 Pintalampotilamittaukset koonti 65 f x 0 6x 12 91 _ 22 0 94 55 50 45 V 40 35 30 m Temp Gun Mittausjarjestelma Lineaarinen regressio 20 sarjalle Mittausj rjestelm 20 25 30 35 40 45 50 55 60 65 25 Kuva 12 Koonti pintal mp tilamittauksista T m n mittaustulosten koonnin regressiosuoran funktion perusteel
74. o or little changes NHD C0216CiZ FSW FBW 3V3 NHD C0216CiZ FN FBW 3V author F Malpartida fmalpartida gmail com ifndef LCD C0220BIZ h define LCD C0220BIZ h define LCDEXPANDED If defined turn on advanced functions include lt Arduino h gt include ST7036 h LCD C0220BIZ VERSION 1 2 0 LCD API VERSION 1 0 class LCD C0220BIZ public ST7036 public Constructor for the display class return None LCD_C0220BIZ LCD C0220BIZ Liite 6 19 48 for the display class with backlight allowcation pin param backlightPin initiales the backlight pin return None LCD_C0220BIZ int8_t backlightPin LCD_C0220BIZ int8 t backlightPin endif Liite 6 20 48 7 ILCD C0220BiZ LCD C0220BiZ cpp Created by Francisco Malpartida on 20 08 11 Copyright 2011 Under creative commons license 3 0 Attribution ShareAlike BY SA This software is furnished as is without technical support and with no warranty express or implied as to its usefulness for any purpose Thread Safe No Extendable No file LCD C0220BiZ cpp Display class implementation of the LCD API 1 0 brief Based the LCD API 1 0 by dale wentztech com This library implements the driver to drive the Newhaven Display NHD C0220BiZ FSW FBW 3V3M The display is build around the ST7036 i2c LCD controller
75. odostavat anturisarjan Keskusyksikk koostuu v yl njakajasta ja Arduino Uno mikrokontrollerista Valmistelut Ohjelman lataaminen mikrokontrolleriin vaatii USB kaapelin ja tietokoneen johon on asennettu Arduino IDE k ytt liittym 1 Asenna koneeseen Arduino IDE ohjelmisto Rengasl mp tilan mittausj rjestelm vaatii Arduino IDE n kirjastop ivityksen toimiakseen Kirjastot kokonaisuudessaan ovat t m n ohjekirjan liittein N m kolmannen osapuolen ohjelmoimat kirjastot voivat olla saatavilla my s s hk isess muodossa 2 Lataa kirjastotiedostot seuraavat kirjastotiedostot Arduino IDE n libraries hakemistoon 1 Wire 2 LCD C0220BIZ 3 I2Cmaster Mik li kirjastoja ei ole saatavilla ne l ytyv t my s t m n dokumentin liittein Kukin liitteist sis lt tiedostonimen jolla luotu tiedosto tulee tallentaa Arduino IDE n libraries kansioon Ohjelman lataaminen mikrokontrolleriin 3 Valitse Arduino IDE n kuva 1 File liukuvalikosta Open ja avaa TireTemp ino Liite 4 2 4 TireTemp I would like to thant following individuals and online communities a LCD control example by Andy of workshopshed com http www workshopshed com 2012 07 Melexis IR Sensor Temperature reading example by bildr blog bildr community http bildr org 2011 02 mlx9061 Melexis IR Sensor Emissivity adjuster and I2C Slave address Changer example by arduino cc for
76. on tested but should be compatible with no or little changes NHD C0216CiZ FSW FBW 3V3 NHD C0216CiZ FN FBW 3V author F Malpartida fmalpartida gmail com Hifndef 577036 h ST7036_h define LCDEXPANDED If defined turn on advanced functions include lt Arduino h gt include lt inttypes h gt include lt Wire h gt include Print h include LCD h ST7036 VERSION 1 2 0 LCD API VERSION 1 0 class ST7036 public Print public Constructor for the display class param num lines in Number of lines in the display param num col in Number of columns in the display Liite 6 29 48 param i2cAddr in i2c address of the display return None ST7036 uint8 t num lines uint8 t num col uint8 t i2cAddr ri ST7036 uint8 t num lines uint8 t num col uint8 t i2cAddr JE Constructor for the display class with backlight allowcation pin param num lines in Number of lines in the display param num col in Number of columns in the display param i2cAddr in i2c address of the display param backlightPin initiales the backlight pin return None ST7036 uint8 t num lines uint8 t num col uint8 t i2cAddr ST7036 uint8 t num lines uint8 t num col uint8 t i2cAddr int8 t backlightPin Send a command to the display param value in Command to be sent to the display return None void command uint8_t value void
77. osta voi p tell mittaako tuntemattoman pinnan l mp tilaa liian suurella n ytt liian korkeita lampotiloja vai liian pienella emissiivisyysarvolla mitatut lampotilat lian alhaisia Parhaan tuloksen saa erilaisilla haarukoimismenetelmill Kun infrapunalla mitatun l mp tilan ja kontaktimittauksen l mp tilan ero on mahdollisimman pieni ollaan l hell aineen emissiivisyysarvoa Mitattavan aineen emissiivisyyden tarkkaa m rityst ei ollut mahdollista suorittaa osana t t opinn ytety t sen vaatimien erikoislaitteiden puuttumisesta johtuen 3 5 Melexis MLX 90614 infrapunatunnistin Opinn ytety ss k ytettiin MLX 90614 infrapunatunnistimia N m tunnistimet pystyv t l hett m n mittaamiaan l mp tiloja digitalisoituna tietona muun muassa 12 v lityksell Merkitt vin etu kyseisten infrapunatunnistimien k yt ss niiden edullisuuden lis ksi on se ett niiden v yl osoitteet ja emissiivisyysarvot ovat ohjelmallisesti muutettavissa MLX 90614 n kotelointi on tyyppi TO 39 eli ne ovat my s suhteellisen pienikokoisia Tunnistimen halkaisija on 12 mm 4 J rjestelm n mittaustarkkuuden m ritt minen ja kalibrointi Koska mittaj rjestelm n infrapuna anturit on mahdollista kalibroida eri materiaaleille ohjelmallisesti on t t ominaisuutta hy dynnetty osana mittaj rjestelm n ohjelmaa jolloin toiminto ei vaadi erillist ohjelmaa vaan ainoastaan yhden muuttujan muuttamisen T
78. ouble tempFactor 0 02 0 02 degrees per LSB measurement resolution of the MLX90614 double tempData 0x0000 zero out the data int frac data past the decimal point This masks off the error bit of the high byte then moves it left 8 bits and adds the low byte tempData double data_MSB amp 0x007F lt lt 8 data_LSB tempData tempData tempFactor 0 01 if dev dev1 corrFactor1 adjustZero1 corrFactor2 adjustZero1offset if dev dev2 corrFactor1 adjustZero2 corrFactor2 adjustZero2offset if dev dev3 corrFactor1 adjustZero3 corrFactor2 adjustZero3offset if dev dev4 corrFactor1 adjustZero4 corrFactor2 adjustZero4offset if dev dev5 corrFactor1 adjustZero5 corrFactor2 adjustZero5offset if dev dev6 corrFactor1 adjustZero6 corrFactor2 adjustZero6offset Liite 5 10 10 if dev dev7 corrFactor1 adjustZero7 corrFactor2 adjustZero7offset if dev dev8 corrFactor1 adjustZero8 corrFactor2 adjustZero8offset if dev dev9 corrFactor1 adjustZero9 corrFactor2 adjustZero9offset if dev devi0 corrFactor1 adjustZero10 corrFactor2 adjustZero10offset if dev devi1 corrFactor1 adjustZero11 corrFactor2 adjustZero1 1offset if dev dev12 fcorrFactorl adjustZero12 corrFactor2 adjustZero1 2offset celcius tempData 273 15 corrFactor1 corrFactor2 float celcius celcius 1 8 32 display i
79. partida fmalpartida gmail com ifndef LCD_h define LCD_h include Arduino h include Print h define LCDEXPANDED If defined turn on advanced functions LCD API VERSION 1 0 class LCD public Print public Send a command to the display param value in Command to be sent to the display return None void command uint8_t value virtual void command uint8_t value 0 Initialise the display Once created the object this is the next operation that has to be called to initialise the display into a known state It assumes that the I2C bus is not initialised and hence initialise the Wire interface Clear the display Liite 6 24 48 Set contrast levels Set the cursor at origens 0 0 Turn on the entire display void init virtual void init 0 Set a different delay to that in the library It may be needed to delay sending commands or characters one after the other param cmdDelayfin Delay after issuing a command param charDelay in Delay after issuing a character to the LCD return None void setDelay int int virtual void setDelay int int 0 JA This is the write method used by the Print library It allows printing characters to the display and new lines print println It will write the value to the display and increase the cursor param value in character to write to the current LCD write position return None virtual void write uint8 t
80. pinnin kautta j rjestelm sy tt ulos pulssileveysmoduloituna j rjestysnumeroltaan vastaavan anturisarjan keskil mp tilan set1 4 kertoo j rjestelm lle tietyn anturisarjan olevan k yt ss J rjestysnumero vastaa v yl njakajan SDa v yl ulostuloa dev1 12 m ritt mist v yl osoitteest tietty anturia kutsutaan config true false kertoo j rjestelm lle jos emissiivisyyden muutos on k yt ss emissivityValue emissiivisyysarvo joka tullaan sy tt m n antureihin 0 01 0 99 adjustZero1 12 anturikohtainen korjausfunktion kerroin adjustZero1offset 120ffset anturikohtainen korjausfunktion vakio adjustZero ja adjustZerooffset muodostavat yhdess korjausfunktion joka mahdollistaa lineaarisen virheen poistamisen Painonappi Keskusyksik n painonappi on kaksitoiminen Lyhyt painallus muuttaa keskusyksik n LCD n ytt jen n kym n yksitt isten anturien l mp tiloista anturisarjan mittaamaan keskil mp tilaan Pitk painallus katkaisee hetkellisesti j nnitteen VDD anturisarjoilta HUOMIO Mik li n ytt jen arvoissa on selke virhe voit k ytt pitk painallusta anturisarjojen v yl yhteyden korjaamiseksi Emissiivisyyden m ritys Liite 4 4 4 Ohjeet yhdelle infrapunamittarille ja l mp parille 1 Teippaa maalarinteipill 10cm x10cm alue tutkittavan aineen pinnasta mik li mahdollista Sijoita l mp pari t m n pinnan alle 2 L mmit tutk
81. shed com http www workshopshed com 2012 07 a little venture with electronics Icd html Melexis IR Sensor Temperature reading example bildr blog bildr community http bildr org 2011 02 mlx90614 arduino Melexis IR Sensor Emissivity adjuster and 2 Slave address Changer example arduino cc forum username paulrd http arduino cc forum index php topic 54170 0 Antti Harhanen include Wire h include ST7036 h include i2cmaster h ST7036 Icd ST7036 2 16 Ox3E lt lt 1 16 characters and 2 line display 7 byte address const int gatePin1 2 control pins const int gatePin2 4 const int gatePin3 7 const int gatePin4 8 const int gatePinSCL 10 const int gatePinSCL2 11 const int MLXPower 12 const int buttonPin 13 pushbutton pin number int button 0 Button subprogram variable int flip 0 const int dataPin1 3 const int dataPin2 5 pins for datalogger DP1 LF DP2 LR DP DP4 const int dataPin3 6 data is in 8 bit PWM const int dataPin4 9 Sensors I2C address 7Byte sensor arrays IIset 1 LF const boolean set1 false check true if a set is available const int dev1 0x39 lt lt 1 const int dev2 0x40 lt lt 1 const int dev3 0x41 lt lt 1 2 RF const boolean set2 false const int dev4 0x42 lt lt 1 const int dev5 0x46 lt lt 1 const int dev6 0x47 lt lt 1
82. ssa j rjestelmiss is nt aloittaa tiedonsiirron l hett m ll START komennon gt v yl n START komento suoritetaan muuttamalla SDA johtimen j nnitearvo I ksi SCL n ollessa Vastaavasti is nn n tiedonsiirron p tt v STOP komento suoritetaan muuttamalla SDA Ic sta I ksi SCL n ollessa lu ssa kuva 1 START komentoa seuraa kutsuttavan orjan osoite ja R W bitti riippuen siit odotetaanko kirjoitetaanko johonkin orjan sis isist osoitteista vai luetaanko jokin tietty orjan sis inen osoite e SNL LIN Ui L 4 START condition STOP condition 08 Fig 5 START and STOP conditions Kuva 1 2C v yl n Start ja Stop komennot 4 s 9 3 Rengasl mp tilan mittausjarjestelma Rengasl mp tilan mittausjarjestelma on suunniteltu toimimaan 12 MLX90614 l mp tilatunnistimella Tunnistimet on jaettu nelj n sarjaan niin ett kutakin ajoneuvon py r kohden on kolme tunnistinta Anturisarjat toimivat kukin omissa fyysisesti erillisiss v yliss n jotka luodaan vaylanjakajalla T m mahdollistaa pidempien johtimien k yt n Rengasl mp tilan mittausj rjestelm tulostaa kunkin anturisarjan keskim r isen l mp tilan Arduinon PWMOut pinneihin pulssileveysmoduloituna 5 V n datasignaalina 3 1 Mikrokontrolleri Arduino Uno mikrokontrolleri perustuu ATmega328 piirille ja sen k ytt j nnite on 5 V Mikrokontrollerin virtal hteen j nnite voi olla 6 20 V sen sis
83. state continue twi_state TWI_MRX reset error state OxFF no error occured twi_error OxFF initialize buffer iteration vars twi_masterBufferlndex 0 twi_masterBufferLength length 1 This is not intuitive read on On receive the previously configured ACK NACK setting is transmitted in response to the received byte before the interrupt is signalled Therefor we must actually set NACK when the next to last byte is received causing that NACK to be sent in response to receiving the last expected byte of data build sla w slave device address w bit twi slarw TW READ twi slarw address 1 send start condition TWCR _BV TWEN BV TWIE BV TWEA BV TWINT _BV TWSTA wait for read operation to complete while TWI_MRX twi state continue if twi_masterBufferlndex lt length length twi_masterBufferlndex copy twi buffer to data for i 0 i length i data i twi masterBufferT i return length J Function twi_writeTo Desc attempts to become twi bus master and write a series of bytes to a device on the bus Input address 7bit i2c device address data pointer to byte array length number of bytes in array wait boolean indicating to wait for write or not Output 0 success 1 length to long for buffer 2 address send NACK received 3 data send NACK received 4 other twi error lost bus arb
84. t c 2006 Nicholas Zambetti All right reserved This library is free software you can redistribute it and or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation either version 2 1 of the License or at your option any later version This library is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU Lesser General Public License for more details You should have received a copy of the GNU Lesser General Public License along with this library if not write to the Free Software Foundation Inc 51 Franklin St Fifth Floor Boston MA 02110 1301 USA ET extern C include lt stdlib h gt include lt string h gt include lt inttypes h gt include twi h include Wire h Initialize Class Variables uint8 t TwoWire rxBuffer BUFFER_LENGTH uint8 t TwoWire rxBufferlndex 0 uint8 t TwoWire rxBufferLength 0 uint8 t TwoWire txAddress 0 uint8 t TwoWire txBuffer BUFFER LENGTH uint8 t TwoWire txBufferlndex 0 uint8 t TwoWire txBufferLength 0 uint8 t TwoWire transmitting 0 void TwoWire user onRequest void void TwoWire user onReceive int Constructors MAI ll TT T T TwoWire TwoWire Public Methods void TwoWire begin void
85. tavu lasketaan viestin bittijonosta T m mahdollistaa viestien oikeellisuuden tarkistuksen Mik li orjalaitteen saaman viestin sis ll st laskema CRC bitti ei vastaa viestin osana vastaanotettua CRC bitti on vastaanotetussa viestiss virhe Lyhenteet ja k sitteet I2C vaylan spesifikaation ja k ytt ohjeen UM10204 n 2 s 6 32 mukaisesti MUN 1 Johdanto T m opinn ytety perustuu Metropolia Ammattikorkeakoulun CDIO projektin Conceive Design Implement Operate osana suunniteltuun rengasl mp tilan mittausj rjestelm n J rjestelm n tilasi Metropolian tuntiopettaja Pasi Oikarinen Toinen projektia ohjanneista oli autoelektroniikan lehtori Vesa Linja aho Projektin tavoitteena oli suunnitella ja valmistaa edullinen rengasl mp tilan mittausj rjestelm joka kykenee mittaamaan auton kaikkien renkaiden pintal mp tilan kolmesta pisteest 1 C n tarkkuudella Opinn ytety n tekij oli osana opiskelijaprojektia ohjelmoinut Arduino Uno mikrokontrollerin toimimaan infrapunatunnistimia k ytt v n gt mittausj rjestelm n ohjainlaitteena J rjestelm hy dynt 12C v yl tekniikkaa Rengasl mp tilan mittausj rjestelm n mittaustarkkuutta ei ollut m ritetty eik sit ollut kalibroitu Lis ksi mittausj rjestelm n virtapiiri ei kyennyt toimimaan suunnitelluilla nelj ll mitta anturisarjalla J rjestelm n oli n in ollen my s suunniteltava v yl nja
86. telm n vaatimien komponenttien lukum r melko pieni Rengasl mp tilan mittausj rjestelm n virtapiiri muodostuu v yl njakajasta LCD n ytt jen kirkkautta muuttavasta s t vastuksesta painonapin kytkenn st infrapuna anturien h iri npoistokondensaatoreista ja I2C vaylan vaatimista yl svetovastuksista Yl svetovastusten teht v on muodostaa I2C v yl n havaittavissa oleva j nnite Niiden mitoittamiseksi on v yl protokollassa 2 s 55 esitetty menetelm M ritet n j rjestelm n kapasitanssin aiheuttama viive j nnitteen noustessa arvosta Vit arvoon Vin 1 9 3 V pp 1 Vy 9 7 V pp 2 tiedetaan etta V t 0 3 V 1 7 3 Ratkaistaan t 0 3566749 RC 4 V t 0 7 V p 1 6 777 5 ratkaistaan tz t 1 2039729 RC 5 Tasta seuraa etta mittausjarjestelman aikavakio T t t 0 8473 RC 6 R max T 0 8473xC 7 missa R on yl svetovastuksen arvo ja C jarjestelman kokonaiskapasitanssi L mp tilan mittausj rjestelm ss k ytetty 12C v yl on Standard tasoa ja sen suurin sallittu aikavakio on 1000 ns N iden laskelmien ja protokollan Rpmax ja Rpmminx taulukoiden 2 s 55 perusteella yl svetovastuksiksi valikoituivat 4 7 vastukset koska j rjestelm n tarkkaa kapasitanssia ei tunneta mutta sen voidaan olettaa olevan suuri johtimien pituuden vuoksi 3 4 Emissiivisyys ja sen m ritt minen Emissiivisyys on suhdeluku
87. tern void i2c_stop void JE Obrief Issues a start condition and sends address and transfer direction Oparam addr address and transfer direction of I2C device Oretval O device accessible Oretval 1 failed to access device extern unsigned char i2c start unsigned char addr JE brief Issues a repeated start condition and sends address and transfer direction Oparam addr address and transfer direction of I2C device retval 0 device accessible retval 1 failed to access device extern unsigned char i2c_rep_start unsigned char addr brief Issues a start condition and sends address and transfer direction If device is busy use ack polling to wait until device ready Oparam addr address and transfer direction of I2C device return none extern void i2c_start_wait unsigned char addr brief Send one byte to I2C device param data byte to be transfered retval 0 write successful retval 1 write failed extern unsigned char i2c_write unsigned char data brief read one byte from 12 device request more data from device return byte read from I2C device extern unsigned char i2c_readAck void P brief read one byte from the I2C device read is followed by a stop condition return byte read from I2C device E Liite 6 43 48 extern unsigned char i2c_readNak void brief read one byte from the I2C device Implemented as a macro which calls either i2c readA
88. ts In the third part the accuracy of the system is tested As a result of this thesis an affordable tire temperature monitoring system was designed for the use of Helsinki Metropolia University The system can be used in future projects and has potential for further development This thesis includes also the full documentation of the Tire Temperature Monitoring System Keywords infra red temperature measuring tire EE M Sisallys Lyhenteita ja kasitteita 1 Johdanto 2 Yleist 2C v yl tekniikasta 2 1 SDA SCL logiikkatasot 2 2 Tiedonsiirto I2C vaylassa 3 Rengasl mp tilan mittausj rjestelm 3 1 Mikrokontrolleri 3 2 V yl njakaja 3 3 Virtapiiri 3 4 Emissiivisyys ja sen m ritt minen 3 5 Melexis MLX 90614 infrapunatunnistin 4 J rjestelm n mittaustarkkuuden m ritt minen ja kalibrointi 4 1 Mittausmenetelm 4 2 Mittaustulokset 4 3 Mittaustaajuus 5 Yhteenveto L hteet Liitteet Liite 1 Rengasl mp tilan mittausj rjestelm n kytkent kaavio Liite 2 Rengasl mp tilan mittausj rjestelm n komponenttien kustannukset 11 18 18 20 Liite 3 Infrapunal mp mittari j rjestelm n pienoisversio ja sen kokoamisohjeet Liite 4 K ytt ohje rengasl mp tilan mittausj rjestelm lle Liite 5 Rengasl mp tilan mittausj rjestelm n koodi kommentteineen Liite 6 Tarvittavat Arduino IDE ohjelmakirjastot tiedostoineen 1 Wire Wire h 2 Wire Wire cpp MUN po AO
89. um username paulrd http arduino cc forum ind Antti Harhanen amp include lcd h include Wire h include ST7036 h include LCD CO220BiZ h include i2cmaster h 577036 lcd 577036 2 16 Ox3E lt lt 1 16 characters and 2 line d const int oatePinl 2 muxer control pins 4 5 Arduino Uno Kuva 14 Arduino IDE k ytt liittym Tee tarvittavat muutokset yksitt isten anturien osoitteet anturisarjojen j rjestys ja lukum r emissiivisyyss t 4 Lataa ohjelma mikrokontrolleriin valitsemalla File valikosta Upload tai pikan pp imell Ctrl U Ohjelman muokkaaminen J rjestelm n ohjelmaa ei ole suojattu mitenk n ja kaikkia sen osia voi muokata K yt n kannalta oleellisimmat muokattavat ohjelman osat ovat anturisarjojen lukum r niiss olevat anturit v yl osoitteineen ja anturien emissiivisyys Liite 4 3 4 K ytett vyyden kannalta t rkeimm t muokattavat osat on sijoitettu koodin alkuun muuttujiksi Muuttujat Seuraavassa kappaleessa on esitelty ohjelman t rkeimm t muuttujat ja niiden k ytt tarkoitus gatePin1 4 sy tetty arvo kertoo ohjelmalle mihin mikrokontrollerin digital out pinniin muuttujalla viitataan N ill hallitaan SDa signaalin kulkua v yl njakajan l vitse gatePinSCL 2 kuten edell mutta SCI signaalin osalta buttonPin m ritt mihin digital out pinniin painonappi on kytketty dataPin1 4 m ritt mink
90. umentti Arduino lt www arduino cc gt Luettu 1 1 2013 2 12C bus specification and user manual UM10204 5 9 2012 Verkkodokumentti NXP lt www nxp com gt Luettu 1 3 2013 3 Laininen Pertti 1998 Todenn k isyys ja sen tilastollinen soveltaminen Helsinki Otatieto 4 Melexis MLX90614 family Single and Dual Zone Infra Red Thermometer in TO 39 datasheet Datalehti Melexis Suvanto Kari 2010 Tekniikan fysiikka 1 Helsinki Edita Publishing 6 2N2222A datasheet Datalehti Microsemi Liite 1 1 1 Rengaslampotilan mittausjarjestelman kytkentakaavio File lampotunnistus sch Date 3 may 2014 KiCad eeschema 2011 05 25 stable _ Liite 2 141 Rengasl mp tilan mittausj rjestelm n komponenttien kustannukset Osa Part Lkm Amount X Yht Total MCCOG21605C6W BNMLW LCD n ytt 4 62 25 MLX90614ESF BAA Infrapunatunnistin IR Sensor 2 39 43 MLX90614ESF BAA Infrapunatunnistin IR Sensor 11 186 87 100nF kalvokondensaattori condensator 11 4 09 2n2222a transistori transistor 4 3 22 4 7Kohm vastus resistor 10 1 70 SN74CBT3253D multiplexer 2 2 08 3ETL9 15 0 katkaisin switch 2 5 93 91A1A B28 D15Lpotentiometer 10K 1 6 50 CABLE 4 CORE 0 22MM 25M 440V 1A Re 1 56 35 VEROBOARD PCB 121 92MM X 101 6MM Boar 1 11 63 MCCOG21605C6W BNMLW LCD n ytt 2 31 12 PLUG PANEL 4WAY Connector Type Circul 4 19 34 SOCKET 4WAY FREE Connector Type Circu
91. us Register Mask prescaler bits twst TW STATUS amp OxF8 if twst TW MT DATA return 1 return 0 Liite 6 48 48 V i2c write a ATENE EEEE ICI OR ION KAKE Read one byte from the I2C device request more data from device Return byte read from I2C device Pe See OR RR eese RO ee unsigned char 12 readAck void i TWCR 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWEA while TWCR amp 1 lt lt TWINT return TWDR i2c readAck Read one byte from the I2C device read is followed by a stop condition Return byte read from I2C device EASA pi KIAN TKKK KAA TAKKAA Ree optato ore sup TAKAA unsigned char 2 readNak void TWCR 1 lt lt TWINT 1 lt lt TWEN while l TWCR amp 1 lt lt TWINT return TWDR i2c readNak Liite 7 10 Mittauspoytakirja milwaukee sensori milwaukee sensori milwaukee sensori milwaukee sensori milwaukee sensori milwaukee sensori milwaukee sensori milwaukee sensori 61 1 54 5 23 8 28 7 52 5 45 4 39 3 36 5 39 36 9 524 43 5 57 3 46 312 33 5 60 4 544 244 28 8 52 9 45 7 39 4 36 4 39 8 37 3 52 8 43 7 57 4 46 1 31 4 33 9 62 7 54 245 294 52 9 46 3 39 8 36 5 40 2 37 7 52 9 43 7 57 7 45 9 31 7 33 8 61 5 53 4 24 9 29 8 53 3 46 7 40 1 36 7 40 8 38 1 53 6 43 6 58 2 45 7 31 9 34 1 61 5 53 3 25 1 294 54 3 46 5 40 6 36 8 41 5 38 3 54 43 8 58 2 45 4 32 5 34 3 59
92. uspiste ei ole py r n navan tasolla T m onnistuu siirt m ll y akselia oikealle jolloin jouston pituuden aiheuttama muutos mittauset isyyteen on sis njoustossa suurempi kuin ulosjoustossa Kuvaajasta voidaan my s todeta ett mit l hemm s py r nnavan tasoa anturisarja on sijoitettavissa sit v hemm n mittauset isyyden muutos vaikuttaa mittaustuloksiin 20 185 60R15 18 205 60R16 215 45R17 Jouston vaikutus mittaus etais yyteen cm 12345 6 7 8 9 1011 1213 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Jouston pituus cm Kuva 4 Jouston pituuden vaikutus mittauset isyyteen Mik li mitta anturien sijoitus renkaan navan tasolle jousituksen ollessa perusasennossa on mahdotonta pystyy kuvaajasta p ttelem n my s jouston vaikutuksen t ss tapauksessa Koska anturien sijoittelumahdollisuudet vaihtelevat ajoneuvoittain kuten my s jouston liikerata on todettava ettei kyseinen riippuvuuslaskelma ole suoraan sovellettavissa kaikkiin tapauksiin Esimerkiksi yhdysheilurijousituksella varustetun ajoneuvon jouston liikerata on ympyr m inen suhteessa kiinte sti sijoitettuun mitta anturiin kun taas erillisjousitetussa ajoneuvossa yl ja alatuennan rakenne m rittelee suoraviivaisen liikkeen kulman suhteessa ajoradan pintaan 11 4 2 Mittaustulokset Mittaustulosten laadun m ritt misess k ytettiin hy dyksi PNS eli pienimm n neli summan keinoa PNS keino on yleisesti k yt ss ol
93. where to put the cursor range 0 max display lines 1 This display only take 0 1 param Collin Colum where to put the cursor range 0 max width 1 return None void setCursor uint8_t Line uint8_t Col virtual void setCursor uint8_t Line uint8_t Col 0 Liite 6 26 48 EXPANDED FUNCTIONALITY METHODS Hitdef LCDEXPANDED pz Provides the state of the LCD This value is updated every command is sent to the LCD or a character or a buffer is writen to the display return 0 OK 1 if data was too big to be transmitted 2 NACK on address transmission 3 NACK on data transmission 4 other error uint8_t status virtual uint8 t status 0 jer Load a custom character on the display After adding a new character to the character set the coordinates are set to 0 0 This method should be called during initialization param char Character to load onto the display this display supports upto 16 user defined characters param rows in Bitmap defining the character the display assumes an array of 8 bytes per character return None uint8 tload custom character uint8 t char num uint8 t rows virtual void load custom character uint8 t char num uint8 t rows 0 SUPPORTED uint8 t keypad virtual uint8 t keypad 0 void printstr const char Sets the backlight level If the backlight level is connected to PWM pin new val will s
94. y 5 digitalWrite Pin HIGH delay 30 celcius1 readtemp sens1 celcius2 readtemp sens2 celcius3 readtemp sens3 average celcius1 celcius2 celcius3 3 datawriter dataPin average if button 0 Icd init Icd setCursor 0 0 Icd print Out Mid Ins Icd setCursor 1 0 Icd print celcius1 1 Icd setCursor 1 6 Icd print celcius2 1 Icd setCursor 1 12 Icd print celcius3 1 delay 5 digitalWrite gatePinSCL LOW digitalWrite Pin LOW Jelsef Icd init Icd setCursor 0 0 Icd print Average Ay Icd setCursor 1 0 Icd print average 1 delay 5 Liite 5 9 10 digitalWrite PinSCL LOW digitalWrite Pin LOW jelse Icd init Icd setCursor 0 0 Icd print Parameter Icd setCursor 1 0 Icd print Error delay 5 digitalWrite PinSCL LOW digitalWrite Pin LOW float readtemp int dev float celcius int data_LSB 0 int data_MSB 0 int pec 0 double corrFactor1 0 correction factor of each separate sensor double corrFactor2 0 i2c start wait dev 12C WRITE i2c write 0x07 read temperature memory i2c rep start dev l2C READ data LSB i2c_readAck Read 1 LSbyte and then send ack data MSB i2c readAck Read 1 MSbyte and then send ack pec i2c readNak i2c stop This converts high and low bytes together and processes temperature MSB is a error bit and is ignored for temperatures d
Download Pdf Manuals
Related Search
Related Contents
Manuel de l`éditeur Software und Zubehör für die Polycom MX1, MX1HS, MX1EC Model RW1K77X2 OWNER`S MANUAL High Speed Counter Module Type A1SD61 User`s Manual Maxtor 4 Channel Stand-alone DVMR User's Manual Revell 23518 Bedienungsanleitung de Operating instructions en Samsung SyncMaster Copyright © All rights reserved.
Failed to retrieve file