#samplingtime
Explore tagged Tumblr posts
Video
instagram
#samplingtime #samplingtechniques #elektron #octatrack #ipadmusic #ipadmusicians #dedalusapp #audiobus3 #idmmusic #glitchmusic #downtempo (presso XONAR Records & Studios) https://www.instagram.com/p/CNxBfDXoeJi/?utm_medium=tumblr
#samplingtime#samplingtechniques#elektron#octatrack#ipadmusic#ipadmusicians#dedalusapp#audiobus3#idmmusic#glitchmusic#downtempo
0 notes
Photo


One of many arduino projects.
air pollution counter with two sensors (2015)
// 24-12-2014 Nikos Siolios //==================display 16x2 #include <Wire.h> #include <LCD.h> #include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27 // <<----- Add your address here. Find it from I2C Scanner #define BACKLIGHT_PIN 3 #define En_pin 2 #define Rw_pin 1 #define Rs_pin 0 #define D4_pin 4 #define D5_pin 5 #define D6_pin 6 #define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
//==========variables for SY int pinSY = 8; unsigned long duration; unsigned long starttime; unsigned long endtime; unsigned long sampletime_ms = 3000; unsigned long lowpulseoccupancy = 0; float ratio = 0; float concentration = 0; float myConceSY; //===========variables for SHARP int measurePinSHARP = 0; //Connect dust sensor to Arduino A0 pin int ledPowerSHARP = 2; //Connect 3 led driver pins of dust sensor to Arduino D2
int samplingTime = 280; int deltaTime = 40; int sleepTime = 9680;
float voMeasured = 0; float calcVoltage = 0; float dustDensity = 0; float dustmgSH; //=========================== int count=0; float meanVsy=0; float meanVsh=0; unsigned long stabilizationTime=60000; //60 sec . // all this time the data are not counted in the mean values // just displays the values // there are no reliable values for the first 1 min
unsigned long timeStab; //variable for stabilization time boolean warming=true;
// variables for mean of the last 20 (meanPlyth) values #define numberofMeans 20 const int meanPlyth=numberofMeans; // meanPlyth x sampletime_ms =20 x3000ms= 1min float lastValueSY[numberofMeans]; //including zero from 0 to 19 float lastValueSH[numberofMeans]; float meanV5sy; float meanV5sh;
void setup() { lcd.begin (16,2); // <<----- My LCD was 16x2 lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE); // Switch on the backlight lcd.setBacklight(LOW); //off lcd.home (); // go home //----------------------- Serial.begin(115200); pinMode(pinSY,INPUT); pinMode(ledPowerSHARP,OUTPUT);
lcd.setCursor (5,0); // go to 1st line lcd.print("warming up"); lcd.setCursor (5,1); // go to 2nd line lcd.print("sensors....");
starttime = millis(); timeStab=starttime; }
void loop() { //============= read SY ============= duration = pulseIn(pinSY, LOW); /*reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds. Gives up and returns 0 if no pulse starts within a specified time out. */ lowpulseoccupancy = lowpulseoccupancy+duration; //microsec420*6
Serial.println(duration); //lcd.setBacklight(LOW); // Backlight off
endtime = millis(); if ((endtime-starttime) > sampletime_ms) //every 3sec find the value { ratio = (lowpulseoccupancy)/((endtime-starttime)*10.0); // Integer percentage 0=>100 concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve //the above equation Concentration in particles (pcs/283ml=0.01cf) Particle Size :over 1µm Serial.print("lowpulseocc:"); Serial.print(lowpulseoccupancy); Serial.print(" - ratio:"); Serial.print(ratio); Serial.print(" - consentr:"); Serial.print(concentration); myConceSY=(ratio+0.16)/9.6; //this equation gives mg/m3 it is from dust sensor DSM501 spec sheet /* if you need the concentration in mg/m3 instead of concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; just use concentration =(ratio+0.16)/9.6; //it gives mg/m3 . (not ug/m3) it is a simplyfied equation because the sensor has no so much accuracy */
if (lowpulseoccupancy==0) myConceSY=0; Serial.print(" - myco mg/m3:"); Serial.println(myConceSY);
lowpulseoccupancy = 0;
//=============== read the SHARP NOW ============ digitalWrite(ledPowerSHARP,LOW); // power on the LED delayMicroseconds(samplingTime); voMeasured = analogRead(measurePinSHARP); // read the dust value delayMicroseconds(deltaTime); digitalWrite(ledPowerSHARP,HIGH); // turn the LED off delayMicroseconds(sleepTime); // 0 - 5V mapped to 0 - 1023 integer values calcVoltage = voMeasured * (5.0 / 1024.0); dustDensity = 0.17 * calcVoltage - 0.1; Serial.print("signal (0-1023): "); Serial.print(voMeasured); Serial.print(" - V=: "); Serial.print(calcVoltage); Serial.print(" - Dust="); dustmgSH= constrain(dustDensity,0,2000);// used only in order to cut negative values Serial.print(dustmgSH); // unit: mg/m3 Serial.print("mg/m3"); int ug=dustDensity*1000; Serial.print(" = "); Serial.print(ug); // unit: ug/m3 Serial.println("ug/m3"); // unit: ug/m3 //=============Write ============================ // lcd.setBacklight(HIGH); // Backlight on. don't light because there is voltage drop in the sensor SY. so wrong values lcd.setCursor (0,0); // go to start of 2nd line lcd.print(myConceSY); lcd.setCursor (0,1); // go to start of 2nd line lcd.print(dustmgSH); //========mean values if not warming up if (warming==true) { if ((millis() - timeStab)> stabilizationTime) //if warming time is gone clear screen message "warming up sensors" { warming=false; lcd.setCursor (5,0); // go to start of 2nd line lcd.print(" "); // clean screen lcd.setCursor (5,1); // go to start of 2nd line lcd.print(" "); } } if (warming==false) { meanVsy=(meanVsy*count+myConceSY)/(count+1); //mean of all the values meanVsh=(meanVsh*count+dustmgSH)/(count+1); count+=1; if (count<=meanPlyth) //if there are less than 20 values fill the array { lastValueSY[count-1] = myConceSY; // gemisma tou pinaka twn teleytaiwn deka timwn lastValueSH[count-1] = dustmgSH; } else { //-----------------mean of the last meanPlyth+1 values meanV5sy=0; meanV5sh=0 ; for(int i=0; i<=meanPlyth-2; i++) { // shift data in the array lastValueSY[i] = lastValueSY[i+1]; lastValueSH[i] = lastValueSH[i+1]; meanV5sy+=lastValueSY[i]; meanV5sh+=lastValueSH[i] ; } lastValueSY[meanPlyth-1] = myConceSY; lastValueSH[meanPlyth-1] = dustmgSH;
meanV5sy+=lastValueSY[meanPlyth-1]; meanV5sh+=lastValueSH[meanPlyth-1] ;
meanV5sy/=meanPlyth; //3000ms x20 =3x20 =6- sec=1min meanV5sh/=meanPlyth ;
lcd.setCursor (5,0); //the mean of the last 1 min lcd.print(meanV5sy); lcd.setCursor (5,1); lcd.print(meanV5sh); } //--------------------------- lcd.setCursor (10,0); lcd.print(meanVsy); lcd.setCursor (10,1); lcd.print(meanVsh); Serial.print("count="); Serial.println(count); } //======================= starttime = millis(); }
}
0 notes