Show Posts
|
|
Pages: 1 ... 3 4 [5] 6 7
|
|
61
|
Using Arduino / Programming Questions / Re: Slow response - how to improve . . ?
|
on: January 21, 2013, 02:12:51 am
|
Hello to all, I would like to state that im still a noob and trying to learn as much as it needs to continue my progress with the Arduino. Thanks for your prompt reply, i appreciate all your comments, that make me more motivated to go on further to improve my code and learn more and more. Thanks again. .  You could read the switch state after each call to SoilMoistureN().
Im i correct, if in the void loop, i place the SwapMenu() after each MoistureN = SoilMoistureN(); ? I.e using in all 4 SwapMenu(); ?? Why do you need 4 nearly identical functions. One would do, if the pin numbers were passed in. Then, you could call the one function in a for loop, testing the switch state after each iteration.
Im actually testing the soil moisture percentage for 4 different variety of plants, i shall conclude if they consume almost the same amount of water per day. According to what you said about passing the pin numbers and calling a for loop, can you kindly please explain a little more so that i can grasp the max and try to implement it. The SwapMenu() code is ridiculous. Testing to see what value lcdMode has before incrementing it is silly. Just increment is, whatever value it has. Then, test to see if it is out of range. Fix it, it if is.
I shall try to perform this increment algorithm, will keep thing posted to see if im on the right track. Also the use of arrays can simplify the code as you have four times the same measurements.
int SoilMoisture(int i) is a function that needs to be rewritten to but with the above + the info about arrays in the tutorial section you should be able to figure it out.
I Shall consult the array tutorial and come back here for clarifications if needed, and im sure i will need those. Well your lux calculation is wrong, for a start.
You need to re-read the description of how the light-sensitive device works, and how it is approximately linear on a log-log scale. It's the last bit of that sentence, I think you didn't understand.
It seems i did not much understand the linear on a log-log scale, but i presumed it was for data logging, and i wrong, can you please guide me on this issue. Thanks
|
|
|
|
|
62
|
Using Arduino / Programming Questions / Slow response - how to improve . . ?
|
on: January 19, 2013, 04:22:47 pm
|
Hello to all, i have been writing some codes about a greenhouse project and testing them in parallel part by part. The level i reached is : Im using 4 soil moisture probe connected to 2 DO doing the alternate current thing and 4 AI to get the reading in percentage. I get an LDR, with some code writing, to display light in LUX (not accurate) Push Button to swap menu on LCD for the displaying of the above readings of soil moisture and Lux reading. Later i shall interpret Output status when i will be connecting and doing the part for the output. I like to share my code in the forum here as well as getting an idea where i stand . .  Actually when i press my button to swap menu on the lcd, it takes me about almost 5 seconds to be holding the button for the 1 Menu to change. Is there any way to adapt a faster response without adding another push button becoz im out of inputs, as i have to cater for outputs to connected Pump and Ventillation Fan. Here is the code : due to exceeding max number of characters, i cut some part of my code, the function block int SoilMoisture () is repeated 4 times due to the presence of 4 soilmoisture probe. hope it is still comprehensive  /* Soil Mositure probe Callibrated at 100% with water (H20) /* Declaration of I/Os */
#define moisture_input 1 // Analog Input pin 1 connected to collect Soil Moisture reading. #define LDR_input 2 // Analog Input pin 2 connected to read Light Intensity from Ambient environment. #define Moisture_Input1 3 // Analog Input pin 3 connected to Collect Soil Moisture reading #define Moisture_Input2 4 // Analog Input pin 4 connected to Collect Soil Moisture reading #define Moisture_Input3 5 // Analog Input pin 5 connected to Collect Soil Moisture reading #define SwapButton 4 // Digital pin 4 Push Button connected - Purpose : To sawp menu on LCD screen. #define dcSource_top 13 // Power source 5V top connected to digitsl pin 13 #define dcSource_bottom 12 // Power Source 5V bottom connected to digital pin 12 #define Pump 3 // Irrigation Pump connected to digital pin 3
/* Library Code to be included */
#include <LiquidCrystal.h> // include the library code:
/* Declaration Of Variables */
int moisture; // Analogical value obtained from the experiment S.probe 1 int Moisture1; // Analogical value obtained from the experiment S.probe 1 int Moisture2; // Analogical value obtained from the experiment S.probe 1 int Moisture3; // Analogical value obtained from the experiment S.probe 1 int val; // Variable for reading the pin status to compare with buttonState int val2; // Variable to read the debounced status int buttonState; // Variable to hold the last button state int lcdMode = 0; // Variable to store different Modes to swap between LCD menu. int Lux; // int Luminosity; float RLDR; float Vout; double PercentMoisture; // Varible to store % Percentage Soil Moisture Value double PercentMoisture1; double PercentMoisture2; double PercentMoisture3;
LiquidCrystal lcd(11, 10, 9, 8, 7, 6, 5); // Initialize the library with the numbers of the interface pins
void setup (void) { Serial.begin(9600); // Set up Serial Communication at 9600 bps. pinMode(Pump,OUTPUT); // Define Digital Pin as output pinMode(SwapButton,INPUT); // Define Digital Pin as Input buttonState = digitalRead(SwapButton); // Read the initial state and save into buttonState.
lcd.begin(16,2); // Rows, columns. use 16,2 for a 16x2 LCD. lcd.clear(); // Start with a blank screen lcd.setCursor(0,0); // Set cursor to column 0, row 0 }
int SoilMoisture(){ // Variable to hold value from Moisture input. int reading; // Set driver pins to outputs pinMode(dcSource_top,OUTPUT); pinMode(dcSource_bottom,OUTPUT);
// Drive a current through the divider in one direction digitalWrite(dcSource_top,LOW); digitalWrite(dcSource_bottom,HIGH);
// Wait a moment for capacitance effects to settle delay(1000);
// Take readings reading = analogRead(moisture_input);
// Reverse the current digitalWrite(dcSource_top,HIGH); digitalWrite(dcSource_bottom,LOW);
// Give as much time in 'reverse' as in 'forward' delay(1000);
// stop the current digitalWrite(dcSource_top,LOW);
return reading;
}
void LCDprintMenu (void) { lcd.clear(); lcd.print("Tazlim -- GrnHse"); lcd.setCursor(0,1); lcd.print(" EngineerinG"); }
void LCDprintSoilMoist(void) {
lcd.clear(); lcd.print("SoilMoisture"); lcd.setCursor(0,1); lcd.print("Percentge:"); lcd.print(PercentMoisture); lcd.print("%"); }
void LCDprintSoilMoist1(void) {
lcd.clear(); lcd.print("SoilMoisture 1"); lcd.setCursor(0,1); lcd.print("Percentge:"); lcd.print(PercentMoisture1); lcd.print("%"); }
void LCDprintSoilMoist2(void) {
lcd.clear(); lcd.print("SoilMoisture 2"); lcd.setCursor(0,1); lcd.print("Percentge:"); lcd.print(PercentMoisture2); lcd.print("%"); }
void LCDprintSoilMoist3(void) {
lcd.clear(); lcd.print("SoilMoisture 3"); lcd.setCursor(0,1); lcd.print("Percentge:"); lcd.print(PercentMoisture3); lcd.print("%"); }
void LCDprintLux (void){ lcd.clear(); lcd.print("Light Intensity"); lcd.setCursor(0,1); lcd.print(" : "); lcd.print (Luminosity); lcd.print ("LUX"); } void PumpControl (){ if (PercentMoisture <= 60.00) {digitalWrite (Pump,HIGH);} else { if (PercentMoisture >= 90.00) {digitalWrite (Pump,LOW);} } }
void SwapMenu (void){ // Push Button connected to PIN 4 by Pull up resistor Circuit for swapping Menu on LCD val = digitalRead(SwapButton); // Read Input value and store in val. delay(10); val2 = digitalRead(SwapButton); // Read Input again to check for bounces if (val == val2){ if(val != buttonState){ if (val == LOW){ if (lcdMode == 0) {lcdMode = 1;} // Execute LCDprintSoilMoist(). else{ if (lcdMode == 1) {lcdMode = 2;} // Execute LCDprintMenu(). else { if (lcdMode == 2) {lcdMode = 3;} else { if (lcdMode == 3) {lcdMode = 4;} else { if (lcdMode == 4) {lcdMode = 5;} else { if (lcdMode == 5) {lcdMode = 0;} } } } } } } buttonState = val; // Save the new state in the Variable for monitoring further button press (Continuous program loop). } } if (lcdMode == 0) {LCDprintMenu();} // Display Intro Display on the LCD. if (lcdMode == 1) {LCDprintSoilMoist();} // Display SoilMoist Reading in % if (lcdMode == 2) {LCDprintSoilMoist1();} if (lcdMode == 3) {LCDprintSoilMoist2();} if (lcdMode == 4) {LCDprintSoilMoist3();} if (lcdMode == 5) {LCDprintLux();} //Display Light Intensity in LUX }
int LightSensorLDR (void){ int ADC;
ADC = analogRead (LDR_input); Vout = (ADC * 0.0048828125); // Vout = Output voltage from potential Divider. [Vout = ADC * (Vin / 1024)]
RLDR = (10.0 * (5 - Vout))/Vout; // Equation to calculate Resistance of LDR, [R-LDR =(R1 (Vin - Vout))/ Vout] // R1 = 10,000 Ohms , Vin = 5.0 Vdc. Lux = (500 / RLDR); return Lux; } void loop (void) { SwapMenu(); Luminosity = LightSensorLDR(); moisture=SoilMoisture(); // assign the result of SoilMoisture() to the global variable 'moisture' Moisture1=SoilMoisture1(); // assign the result of SoilMoisture 1() to the global variable 'Moisture1' Moisture2=SoilMoisture2(); // assign the result of SoilMoisture 2() to the global variable 'Moisture2' Moisture3=SoilMoisture3(); // assign the result of SoilMoisture 3() to the global variable 'Moisture3' PercentMoisture = ((moisture/950.00)*100.00); // Derivation of Soil Moisture in % PercentMoisture1 = ((Moisture1/950.00)*100.00); PercentMoisture2 = ((Moisture2/950.00)*100.00); PercentMoisture3 = ((Moisture3/950.00)*100.00); }
[\code]
Thanks
taz
|
|
|
|
|
64
|
Using Arduino / Programming Questions / Re: LDR reading to lux conversion.
|
on: January 10, 2013, 01:39:08 pm
|
Is there any look up table, already up for the lux values .. ??  Callibration is quite tough to be doing.. as its difficult to get a lux meter.. Back to the above equation ... if i need some greater values for the Vout at night, i.e. a bigger range than 0.31, should i render my circuit more sensitive,do i need to change the fix resistor to 100 k ohms or less ?? any clarification please .. ? \thanks taz...
|
|
|
|
|
65
|
Using Arduino / Programming Questions / Re: LDR reading to lux conversion.
|
on: January 10, 2013, 01:15:02 am
|
Hello, The link to the sensor is quite nice, but i shall stick to the simple LDR, cause i shall be doing some switching only for some LIghts when sunset occurs. Moreover i want to display this value on an LCD, like i displayed % soil moisture and now some light reading. Why are you converting to lux. In fact why convert anything when you can use the sensor value directly.
I think it is more appropriate to display Lux reading on an LCD instead of ADC value to the people around . .  Thanks taz ..
|
|
|
|
|
66
|
Using Arduino / Programming Questions / Re: LDR reading to lux conversion.
|
on: January 10, 2013, 01:01:55 am
|
Hello, Regards ADC = analogRead (LDR_input); RLDR = (10000.0 * (5 - Vout))/Vout; // Equation to calculate Resistance of LDR, [R-LDR =(R1 (Vin - Vout))/ Vout] // R1 = 10,000 Ohms , Vin = 5.0 Vdc. Vout = (ADC * 0.0048828125); // Vout = Output voltage from potential Divider. [Vout = ADC * (Vin / 1024)]
I will try to swap the lines, i.e make the Arduino calculate the Vout first and then RLDR, this quite make some sense, but sometimes we do not see it when we are just coding.  Have you got something against compact code? int ADC = analogRead (LDR_input);  .. i will try to stick to compact mode now . .  RLDR = (10000.0 * (5 - Vout))/Vout; // Equation to calculate Resistance of LDR, [R-LDR =(R1 (Vin - Vout))/ Vout]
And what value does Vout have? Dividing by 0 is not generally a good practice. At night in the room with light on, i could get only 0.31 Volts reading from serial monitor as well as from voltmeter. Do i need to adjust the fixed resistor so as to get more coherent values for the Vout and less trouble for the Arduino to compute ?? Actually im using a 10 K ohms resistor with the potential divider circuit . . Any views ? Thanks
|
|
|
|
|
67
|
Using Arduino / Programming Questions / LDR reading to lux conversion.
|
on: January 09, 2013, 02:10:49 pm
|
Hello to all, I just been wondering what can be wrong with my program code, as my result is returning to zero though all my other variables are giving correct values. See parts of my code : Connect LDR with a 10 Kohms resistor as shown:
Vin: 5V---* | \ 0 LDR(16K - 2M Ohms) / | | analog 2----* | / \ / R1 (10K ohms) \ | *----> Ground */
int moisture; // Analogical value obtained from the experiment double PercentMoisture; // Varible to store % Percentage Soil Moisture Value int val; // Variable for reading the pin status to compare with buttonState int val2; // Variable to read the debounced status int buttonState; // Variable to hold the last button state int lcdMode = 0; // Variable to swap between LCD menu. float RLDR; // Resistance calculation of potential divider with LDR float Vout; // voltage ouput from potential divider to Anolg input
float Lux; int Luminosity;
float LightSensorLDR (){
int ADC; ADC = analogRead (LDR_input); RLDR = (10000.0 * (5 - Vout))/Vout; // Equation to calculate Resistance of LDR, [R-LDR =(R1 (Vin - Vout))/ Vout] // R1 = 10,000 Ohms , Vin = 5.0 Vdc. Vout = (ADC * 0.0048828125); // Vout = Output voltage from potential Divider. [Vout = ADC * (Vin / 1024)]
Lux = (500 / RLDR); return Lux; }
[code\]
These are some results im getting from serial monitor (Room with light ON at Night) : LUX = 0 ADC = 63 Res LDR 0.00 Vout0.31 LUX = 0 ADC = 63 Res LDR 152539.68 Vout0.31 LUX = 0 ADC = 64 Res LDR 152539.68 Vout0.31 LUX = 0 ADC = 63 Res LDR 150000.00 Vout0.31 LUX = 0 ADC = 63 Res LDR 152539.68 Vout0.31 LUX = 0 ADC = 63 Res LDR 152539.68 Vout0.31 LUX = 0 ADC = 63 Res LDR 152539.68 Vout0.31 LUX = 0 ADC = 64 Res LDR 152539.68 Vout0.31 LUX = 0 ADC = 64 Res LDR 150000.00 Vout0.31 LUX = 0 ADC = 63 Res LDR 150000.00 Vout0.31 LUX = 0 ADC = 62 Res LDR 152539.68 Vout0.30
Any comments will be welcome if some kind of improvements can be achieved in terms of a more precise equation in converting to Lux.
Thanks
Regards
taz ..
|
|
|
|
|
70
|
Using Arduino / Programming Questions / LCD do not update information.
|
on: January 04, 2013, 09:11:42 am
|
|
Hello to all,
I just modified some codes concerning soil moisture measurement, i already implement the hardware part as well and incorporate an LCD screen display 16 x 2, to print the soil moisture in percentage. I added a push button in my sketch to enable myself to swap menu on the LCD display. For the time being it displays the soil moisture % and the other menu display hello world, later on i shall make it display some reading for light intensity.
My issue is before i implemented this swap menu function the reading of % moisture would display correctly and the value will be updated after a delay of 1000.
Later when i add this menu swap function my value of percentage do not update until i swap menu to 'Hello World" and back to soilMoist % reading.
Any comments please. My apologies for the code format as i am encountering an error while copying for forum.
The code is as follows: ------------------------------------------------------------------------------------------------------------ [ code ] /* Soil Moisture measurement v0.1 Alternate DC current circuit Callibrated at 100% with water (H20) Started by Mike Rice, October 14, 2009 Modified by M.A. de Pablo, October 17, 2009 Modified and new adaptation by Tazlim Goolap, January 1, 2013 Circuit: To connect two Copper Wire and a 100 KOhms resistor as shown: digital 13---* | \ / \ R1(100K Ohms) / | | analog 1----* | | *----> nail 1 *----> nail 2 | | R2 (100 Ohms) | digital 12---* */
/*--------------------------------------------------------------------*/
/* Declaration of I/Os */
#define moisture_input 1 // Analog Input pin 1 connected to collect Moisture reading. #define dcSource_top 13 // Power source 5V top connected to digitsl pin 13 #define dcSource_bottom 12 // Power Source 5V bottom connected to digital pin 12 #define SwapButton 4 // Push Button connected to digital pin 4. Purpose : To sawp menu on LCD screen.
/*--------------------------------------------------------------------*/
/* Library Code to be included */
#include <LiquidCrystal.h> // include the library code:
/*--------------------------------------------------------------------*/
/* Declaration Of Variables */
int moisture; // Analogical value obtained from the experiment double PercentMoisture; // Varible to store % Percentage Soil Moisture Value int val; // Variable for reading the pin status to compare with buttonState int val2; // Variable to read the debounced status int buttonState; // Variable to hold the last button state int lcdMode = 0; // Variable to swap between LCD menu.
/*--------------------------------------------------------------------*/
/* LCD Connections: rs (LCD pin 4) to Arduino pin 11 rw (LCD pin 5) to Arduino pin 10 enable (LCD pin 6) to Arduino pin 9 LCD pin 15 to Arduino pin 4 LCD pins d4, d5, d6, d7 to Arduino pins 8, 7, 6, 5 */
LiquidCrystal lcd(11, 10, 9, 8, 7, 6, 5); // Initialize the library with the numbers of the interface pins
void setup (void) { Serial.begin(115200); // Set up Serial Communication at 9600 bps. pinMode(SwapButton,INPUT); // Define Digital Pin as Input buttonState = digitalRead(SwapButton); // Read the initial state and save into buttonState.
lcd.begin(16,2); // Rows, columns. use 16,2 for a 16x2 LCD. lcd.clear(); // Start with a blank screen lcd.setCursor(0,0); // Set cursor to column 0, row 0 }
int SoilMoisture(){ int reading; // Variable to hold value from Moisture input. // Set driver pins to outputs pinMode(dcSource_top,OUTPUT); pinMode(dcSource_bottom,OUTPUT);
// Drive a current through the divider in one direction digitalWrite(dcSource_top,LOW); digitalWrite(dcSource_bottom,HIGH);
// Wait a moment for capacitance effects to settle delay(1000);
// Take a reading reading=analogRead(moisture_input);
// Reverse the current digitalWrite(dcSource_top,HIGH); digitalWrite(dcSource_bottom,LOW);
// Give as much time in 'reverse' as in 'forward' delay(1000);
// stop the current digitalWrite(dcSource_top,LOW);
return reading; }
void LCDprintSoilMoist(void) {
//lcd.clear(); lcd.print("SoilMoisture:"); lcd.setCursor(0,1); lcd.print("Percentge:"); lcd.print(PercentMoisture); lcd.setCursor(16,1); lcd.print("%"); }
void LCDprintMenu (void) { lcd.clear(); lcd.setCursor (0,0); lcd.print("Hello World"); }
/* int SwapMenu (){ // Push Button connected to PIN 4 by Pull up resistor Circuit for swapping Menu on LCD } */
void loop (void) { val = digitalRead(SwapButton); // Read Input value and store in val. delay(10); val2 = digitalRead(SwapButton); // Read Input again to check for bounces if (val == val2){ if(val != buttonState){ if (val == LOW){ if (lcdMode == 0){ lcdMode = 1; LCDprintMenu(); } else{ lcdMode = 0; LCDprintSoilMoist(); } } } buttonState = val; // Save the new state in the Variable for monitoring further button press (Continuous program loop). } delay (1000); moisture=SoilMoisture(); // assign the result of SoilMoisture() to the global variable 'moisture' Serial.print("Soil moisture: "); Serial.print(moisture); // print the analogical measurement of the experiment PercentMoisture = ((moisture/950.00)*100.00); // Derivation of Soil Moisture in % Serial.print(" Percentage Soil Moisture = "); Serial.print(PercentMoisture); Serial.println(); delay(1000);
Serial.print ("buttonState"); Serial.println (buttonState); }
[ /code ]
__________________________________________________________________________________
|
|
|
|
|
71
|
Using Arduino / General Electronics / Re: Innacuracy in converting thermistor resistance to temperature.
|
on: December 12, 2012, 12:49:35 am
|
I would take what dc42 said seriously about making sure you have a correct temp standard to calibrate against..I have been playing around with thermocouples for quite some time and have found that the difference in readings from one to another can vary quite a bit more than specs. If I want to do a calibration, I use a very accurate mercury thermometer. I usually take an ice point ( 0c) and a boiling point ( which will vary with external pressure but can be calculated) and they do not drift or pick up noise like some of the electronic devices I have tried.
So taking both the reply posted by dc42 and RPCoyle: I should take callibration point with Ice point and Boiling point and try to adjust the nominal resistance till i get the correct value, is that correct?? You can do the calibration in software. Typically when calibrating a "straight line", there is an offset adjustment at zero (or at the bottom of your range). The offset is a constant correction-value added/subtracted from each reading. In other words, the offset adjustmet shifts the curve (or line) up or down without affecting the slope.
Then the top of the range there is usually calibrated with a gain adjustment. i.e. A constant correction-value multiplied by each reading. In other words, the gain adjustment adjusts the slope of the curve/line.
If you want the most accuracy at room temperature (or somewhere in the middle of the range), you may want to make that one of your calibration-points, instead of using the high-low end-points.
Sometimes, there are different corrections (calibrations) for different segments of the curve/line. But, you have to be careful not to introduce a discontinuity, where your correction value suddenly jumps and the reading could jump down, when the temperature goes up, etc.
That seems quite interesting, introducing a gain value and calculating the offset directly from the software. To DVDdoug: Can you please kindly guide me where to start, atleast with an equation and how will i be able to calculate the offset and find the proper gain value. Where do i need to integrate the gain value in my actual equation? Thanks Taz ...
|
|
|
|
|
72
|
Using Arduino / General Electronics / Innacuracy in converting thermistor resistance to temperature.
|
on: December 11, 2012, 07:47:03 am
|
Hello to all, I just build a potential divider circuit using a thermistor, i have read several tutorials whereby they are using a 10 K thermistor ana a 10 K resistor in series. I purchased the Ultimate microcontroller pack, havinf 2 qty of thermistor written 503 on that, with a range of 20k ohm - 1M ohm with power of 50mW and having its beta value 4300. Through much research i could deduce that it was a 50 K thermistor due to the 503 code. When i measured the resitance through a meter at room temperature which at that time was approx. 26 to 27, i could get around 35.2 K ohms. My first puzzle, i should have a reading near 50 K right ?? I combine 2 100K resistors in parallel, to be used in the divider circuit, where the actual reading was 46 K ohm. I used an external power supply, providing with 4.98 V as input on the UNO board R3. Using the equation : R(therm) = R(Series)/((1023/ADC) - 1); and V(out) = ( R(therm)/R(series) + R(therm) ) *V(in) My resistance values were coherent, almost the same reading through measurement and calculation as well as from the program code on the arduino giving therm resistance. However, when i convert the resistance reading through stainhart-hart equation, my values are innacurate on my UNO, above +2.8 C when compared to digital thermometer used to measure the ambient temperature. At the time of measurement RT = 27 C with digital thermometer and arduino temperature display showing 31.58 C. See the code i used: Please note the stainhart equation used was for the beta value only. // which analog pin to connect #define THERMISTORPIN A0 // resistance at 25 degrees C #define THERMISTORNOMINAL 50000 // temp. for nominal resistance (almost always 25 C) #define TEMPERATURENOMINAL 25 // how many samples to take and average, more takes longer // but is more 'smooth' #define NUMSAMPLES 5 // The beta coefficient of the thermistor (usually 3000-4000) #define BCOEFFICIENT 4300 // the value of the 'other' resistor #define SERIESRESISTOR 46000 int samples[NUMSAMPLES]; void setup(void) { Serial.begin(9600); //analogReference(EXTERNAL); } void loop(void) { uint8_t i; float average; // take N samples in a row, with a slight delay for (i=0; i< NUMSAMPLES; i++) { samples = analogRead(THERMISTORPIN); delay(10); } // average all the samples out average = 0; for (i=0; i< NUMSAMPLES; i++) { average += samples; } average /= NUMSAMPLES; Serial.print("Average analog reading "); Serial.println(average); // convert the value to resistance average = 1023 / average - 1; average = SERIESRESISTOR / average; Serial.print("Thermistor resistance "); Serial.println(average); float steinhart; steinhart = average / THERMISTORNOMINAL; // (R/Ro) steinhart = log(steinhart); // ln(R/Ro) steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro) steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To) steinhart = 1.0 / steinhart; // Invert steinhart -= 273.15; // convert to C Serial.print("Temperature "); Serial.print(steinhart); Serial.println(" *C"); delay(1000); }
I tried to work with the full stainhart equation, using the a,b,c values constant to see if things get better, i tried the code below: Note that the a,b,c values are constant for a 10K thermistor, i used values for a 50K therm i.e. a = 9.657154 e -4 , b= 2.106840 e -4 , c= 8.585481 e -8, but unfortunately my temperature reading was above 300 C instead of near room temperature. So i stick the same values in the program code. #include < LiquidCrystal.h> #include <math.h> LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); int backLight = 13; // pin 13 will control the backlightvoid setup( void) { pinMode(backLight, OUTPUT); digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.lcd. begin(16,2); // rows, columns. use 16,2 for a 16x2 LCD, etc.lcd. clear(); // start with a blank screenlcd. setCursor(0,0); // set cursor to column 0, row 0} double Thermister( int RawADC) { double Temp; Temp = log(((10230000/RawADC) - 10000)); Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp)); Temp = Temp - 273.15; // Convert Kelvin to Celciusreturn Temp; } void printTemp( void) { double fTemp; double temp = Thermister( analogRead(0)); // Read sensorlcd. clear(); lcd. setCursor(0,0); lcd. print( "Temperature is:"); lcd. setCursor(0,1); lcd. print(temp); lcd. print( " C / "); fTemp = (temp * 1.  + 32.0; // Convert to USAlcd. print(fTemp); lcd. print( " F"); //if (fTemp > 68 && fTemp < 78) {//lcd.setCursor(0,3);//lcd.print("Very comfortable");//}} void loop( void) { printTemp(); delay(1000); Again i had a drift of temperature reading, LCD displaying 32.20 C while digi thermometer showing 30.6 C Any suggestion please. Thanks Taz . . .
|
|
|
|
|
74
|
Using Arduino / General Electronics / Re: MOSFET use for driving larger current devices
|
on: October 17, 2012, 01:04:10 pm
|
Basically yes - be sure it's a logic-level MOSFET (that can be switched with 5V logic - most require 10V). The 5V fan might run a bit fast on 9V - so you are adding a resistor to drop the voltage a bit? You would normally do that on the high side, and switch with a n-channel MOSFET or NPN transistor on the low side.
Is the fan a brushless motor BTW?
I need to check if the MOSFET is a 5 level logic - i got the tech spec for the mosfet bt got to read it ..  but im pretty sure its a 10 V logic. . Yes wanna use the resistor to drop the voltage a bit. about the circuit it seems i will need an NPN transistor ? What if . . Can i achieve the same with an SSR?? And i already have that at hand, with 5 volt logic and switch up to 250 vac . . can i run the FAN without the need to get an external 5V power supply for the FAN, can i use the 9 Vdc . . Concerning the FAN, i got them from the real china market, no specs at all, with brand name RUNDA without model no :-( i need the cfm as well for some sizing work bt . .  But still i will like to control these through pwm with my arduino without hurting my pins, . . . ------
|
|
|
|
|
75
|
Using Arduino / General Electronics / MOSFET use for driving larger current devices
|
on: October 17, 2012, 12:19:02 am
|
|
Dear all,
I would like to raise one confusion upon the connection of a MOSFET to my arduino UNO board.
This confusion aroused after reading some Arduino materials.
My concern:
I have a fan with operating voltage 5Vdc but alas with current consumption 0.16 Amps.
In regards to an output Pin on the Arduino, we can draw up to 20 mA per pin and a total of 200mA in total. correct if im wrong.
Can i supply my Arduino Board with my external Power supply 9 Vdc, and take my supply from Vin of my board, pass through coresponding resistances through my MOSFET and up to my FAN without hurting my Arduino ?? Please note that i will like to control my FAN with PWM in relation to a thermistor.
thanks
Regards taz -----------------
|
|
|
|
|