tukaj:
![](http://www.weebly.com/weebly/images/file_icons/rtf.png)
merilnik_slanosti_.docx | |
File Size: | 4245 kb |
File Type: | docx |
Koda za arduino, ki sem jo uporabil je tu spodaj:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// set up a constant for the tilt switchPin
const int switchPin = 6;
// a variable to choose which reply from the crystal ball
int reply;
int analogPin= 0;
int raw= 0;
int Vin= 5;
float Vout= 0;
float R1= 1000;
float R2= 0;
float buffer= 0;
float odstotek= 0;
void setup()
{
// set up the number of columns and rows on the LCD
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Pripravljen");
// set the cursor to column 0, line 1
// line 1 is the second row, since counting begins with 0
lcd.setCursor(0, 1);
// print to the second line
lcd.print("za meritve!");
Serial.begin(9600);
}
void loop()
{
raw= analogRead(analogPin);
if(raw)
{
buffer= raw * Vin;
Vout= (buffer)/1024.0;
buffer= (Vin/Vout) -1;
R2= R1 * buffer;
odstotek=pow((75/(R2-476)),(1/0.847));
Serial.print("Vout: ");
Serial.println(Vout);
Serial.print("R2: ");
Serial.println(R2);
Serial.print("odstotek soli: ");
Serial.println(odstotek);
lcd.clear();
// set the cursor to column 0, line 0
lcd.setCursor(0, 0);
// print some text
lcd.print("R: ");
lcd.print(R2);
// move the cursor to the second line
lcd.setCursor(0, 1);
lcd.print("Odstotek: ");
lcd.print(odstotek);
delay(3000);
}
}
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// set up a constant for the tilt switchPin
const int switchPin = 6;
// a variable to choose which reply from the crystal ball
int reply;
int analogPin= 0;
int raw= 0;
int Vin= 5;
float Vout= 0;
float R1= 1000;
float R2= 0;
float buffer= 0;
float odstotek= 0;
void setup()
{
// set up the number of columns and rows on the LCD
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Pripravljen");
// set the cursor to column 0, line 1
// line 1 is the second row, since counting begins with 0
lcd.setCursor(0, 1);
// print to the second line
lcd.print("za meritve!");
Serial.begin(9600);
}
void loop()
{
raw= analogRead(analogPin);
if(raw)
{
buffer= raw * Vin;
Vout= (buffer)/1024.0;
buffer= (Vin/Vout) -1;
R2= R1 * buffer;
odstotek=pow((75/(R2-476)),(1/0.847));
Serial.print("Vout: ");
Serial.println(Vout);
Serial.print("R2: ");
Serial.println(R2);
Serial.print("odstotek soli: ");
Serial.println(odstotek);
lcd.clear();
// set the cursor to column 0, line 0
lcd.setCursor(0, 0);
// print some text
lcd.print("R: ");
lcd.print(R2);
// move the cursor to the second line
lcd.setCursor(0, 1);
lcd.print("Odstotek: ");
lcd.print(odstotek);
delay(3000);
}
}
Tu pa je koda še obrazložena (najdete jo tudi v celotni raziskovalni nalogi v barvah):
lcd.clear(); // izbriše se vse kar je na ekranu, da se na njem lahko prikažejo novi podatki
lcd.setCursor(0, 0); // kurzor postavi v prvo vrstico
lcd.print("R: "); // na ekranu se izpiše R:
lcd.print(R2); // na ekranu se zapiše številka upornosti
raw= analogRead(analogPin); // raw - sveži, novi podatki so prebrani iz analognega pina
if(raw)
{
zacasno= raw * Vin; // vhod na pin A0 izračunamo v Voltih, da pomnožimo stopnje z napetostjo 5V in v nasledjem koraku spodaj delimo z maks. stopenj
Vout= (zacasno)/1024.0; // kot križni račun pri 5V je 1024 stopenj, koliko V je pri raw vhodnih stopnjah
zacasno= (Vin/Vout) -1; //del enačbe 2 razmerje napetosti minus 1, v naslednjem koraku pomnožimo z znanim uporom.
R2= R1 * zacasno;
odstotek=pow((75/(R2-476)),(1/0.847)); // matematična odvisnost, ki se lepo prilega na podatke.
Serial.print("Vout: "); // serial print pomeni, da se bodo podatki izpisali na pomožnem okencu na računalniku
Serial.println(Vout);
Serial.print("R2: ");
Serial.println(R2);
Serial.print("odstotek soli: ");
Serial.println(odstotek);
lcd.clear(); // izbriše se vse kar je na ekranu, da se na njem lahko prikažejo novi podatki
lcd.setCursor(0, 0); // kurzor postavi v prvo vrstico
lcd.print("R: "); // na ekranu se izpiše R:
lcd.print(R2); // na ekranu se zapiše številka upornosti
raw= analogRead(analogPin); // raw - sveži, novi podatki so prebrani iz analognega pina
if(raw)
{
zacasno= raw * Vin; // vhod na pin A0 izračunamo v Voltih, da pomnožimo stopnje z napetostjo 5V in v nasledjem koraku spodaj delimo z maks. stopenj
Vout= (zacasno)/1024.0; // kot križni račun pri 5V je 1024 stopenj, koliko V je pri raw vhodnih stopnjah
zacasno= (Vin/Vout) -1; //del enačbe 2 razmerje napetosti minus 1, v naslednjem koraku pomnožimo z znanim uporom.
R2= R1 * zacasno;
odstotek=pow((75/(R2-476)),(1/0.847)); // matematična odvisnost, ki se lepo prilega na podatke.
Serial.print("Vout: "); // serial print pomeni, da se bodo podatki izpisali na pomožnem okencu na računalniku
Serial.println(Vout);
Serial.print("R2: ");
Serial.println(R2);
Serial.print("odstotek soli: ");
Serial.println(odstotek);
Vprašanja lahko pustite tu: