Show Posts
Pages: [1] 2
1  Forum 2005-2010 (read only) / Development / Re: ATTiny85 port (work in progress) on: May 28, 2010, 07:19:55 am
Nice! I am keeping my eye on this.
2  Forum 2005-2010 (read only) / Interfacing / Re: Using a 74HC153 to multiply external interrupts..? on: July 08, 2010, 07:27:46 pm
Can you post a sample of a polling technique that would work for this application?
3  Forum 2005-2010 (read only) / Interfacing / Re: Using a 74HC153 to multiply external interrupts..? on: July 08, 2010, 04:48:57 pm
The project is a PC Water Cooling Information and Control center. It reads temperature from 3 temperature sensors (10k thermistor based) Then after Displaying the temperature of each sensor for 10 seconds it will change screens and display The RPM of the 3 PC fans, this screen will also last for 10 seconds. Then it will display the pump RPM and Water flow rate for 10 seconds. After that it will start the loop over. With 3 fans, 2 pumps and 2 water flow meters to pull data from I was under the impressions I would need an external interrupt to be able to poll the PPM signal from each fan individually. I am also able to control the speed of the fans and pumps via PWM and a 12v transistor circuit that is separated from the arduino via an opto coupler.
4  Forum 2005-2010 (read only) / Interfacing / Re: Using a 74HC153 to multiply external interrupts..? on: July 08, 2010, 12:26:16 pm
Thanks Mike! I should have the Muxs I ordered in tomorrow or Monday.

Is there a chance I could get a snippet of sample code so I can understand how to code this.
5  Forum 2005-2010 (read only) / Interfacing / Using a 74HC153 to multiply external interrupts..? on: July 07, 2010, 08:09:25 pm
My current project requires me to read a ppm signal from 7 devices. The code I used to read the RPM of 1 fan uses an external interrupt. Since the ATMEGA 328 only has 2 external interrupts a friend of mine came up with the idea of using a MUX, specifically the 74HC153 to switch between devices. This would allow me to connect up to 8 devices on just 2 digital pins.

Multiplexers are completely new to me and I am just trying to wrap my head around how and if this will work. I am still waiting on the MUX to arrive from electronic goldmine so I can not breadboard it yet.
6  Forum 2005-2010 (read only) / Interfacing / Re: Loading Bar on an 16x2 parallel LCD? Help! on: June 11, 2010, 09:23:02 pm
Ok I created a custom character that fills the a whole column and got it to print a new one every .5 seconds for 8 seconds but it now stops my message on line 1 from scrolling. Can anyone tell me what I am doing wrong here?

Code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

byte block[8] =
{
  B11111,
  B11111,
  B11111,
  B11111,
  B11111,
  B11111,
  B11111,
  B11111
};

void setup() {
  // set up the LCD's number of rows and columns:
  lcd.begin(16, 2);
  //lcd.setCursor(0,7);
  // Print a message to the LCD.
  lcd.print("Satcomm Information Initializaion");
  delay(10);
  lcd.createChar(7,block);
  }

void loop() {
  // scroll 13 positions (string length) to the left
  // to move it offscreen left:
  {
  for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft();
    // wait a bit:
     delay(50);  
    lcd.setCursor(0,1);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
    delay(500);
    lcd.write(7);
      }

  
  }}
7  Forum 2005-2010 (read only) / Interfacing / Loading Bar on an 16x2 parallel LCD? Help! on: June 11, 2010, 08:12:27 pm
I am trying to create a faux loading bar on my LCD. I want to completely fill each column in the second row one at at time at .5 sec intervals until all 16 columns are filled.

The fill I am talking about is the second character on the second row in this pic.


I was thinking I could use the autoScroll function for this but am having trouble figuring out what the DEC code is for that character and how to put it all together. In the extended ASCII table that character shows up as 219 but on my LCD 219 shows up as a hollow box.
8  Forum 2005-2010 (read only) / Interfacing / Re: Help Printing data to LCD on: June 11, 2010, 06:46:11 pm
I had to modify the pin order in your revision but it works now. Thanks!!!!!!!!!!!!!!!!!!!!!!!!!

I also refined the code to have the data fit on my LCD and to include a second sensor. The only thing is that the LCD will not display a 0 if the second decimal point is a 0. It will instead drop that space and move the C into it. I also added the degree symbol for a more professional look.

Working Code
Code:
#include <LiquidCrystal.h>
#include <math.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);              
double Thermistor(int RawADC) {
  long Resistance;  
  double Temp;
  Resistance=((10240000/RawADC) - 10000);
  Temp = log(Resistance);
  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
  Temp = Temp - 273.15;
  return Temp;  
}

void printDouble(double val, byte precision) {

  lcd.print (int(val));
  if( precision > 0) {
    lcd.print(".");
    unsigned long frac, mult = 1;
    byte padding = precision -1;
    while(precision--) mult *=10;
    if(val >= 0) frac = (val - int(val)) * mult;
    else frac = (int(val) - val) * mult;
    unsigned long frac1 = frac;
    while(frac1 /= 10) padding--;
    while(padding--) Serial.print("0");
    lcd.print(frac,DEC) ;
  }
}

void setup() {
  Serial.begin(115200);
  lcd.begin(16, 2);
}

#define ThermistorPIN 0  
#define Thermistor2PIN 1
double temp;
void loop() {
  lcd.setCursor(0, 0);
  temp=Thermistor(analogRead(ThermistorPIN));        
  lcd.print("Sensor 1 ");
  printDouble(temp,2);
  lcd.print((char)223);  
  lcd.print("C");
  lcd.print((char)223);
  lcd.setCursor(0, 1);
  temp=Thermistor(analogRead(Thermistor2PIN));
  lcd.print("Sensor 2 ");
  printDouble(temp,2);
  lcd.print((char)223);  
  lcd.print("C");
  lcd.print((char)223);
  //uncomment the next 4 lines for temp display in F
  //temp = (temp * 9.0)/ 5.0 + 32.0;      
  //lcd.print("");  
  //printDouble(temp,3);
  //lcd.println("f");                                  
  delay(500);

}




Thanks Again for all the help!!!!!!!!!!!!!!! smiley smiley smiley smiley smiley
9  Forum 2005-2010 (read only) / Interfacing / Re: Help Printing data to LCD on: June 11, 2010, 02:14:03 pm
I apologize for leaving out those details.  

The LCD is a standard 16x2 parallel LCD. I did not include any LCD code in the above code because all of my attempts failed. Every time I tried to output the data to the LCD weird things would happen that led me to believe that the math.h and LiquidCrystal.h libraries were not playing well together. I have attached a photo of the output problems at the bottom of this post.

First I tried using lcd.write to print the serial data to the LCD but realized the completed project will have more serial data than just the temperature info.

So I tried lcd.print(); printdouble(temp,2); and that failed to work also.

I am using pins 7, 8, 9, 10, 11, 12 for the LCD.

10  Forum 2005-2010 (read only) / Interfacing / Help Printing data to LCD on: June 11, 2010, 01:21:56 am
I am having a bit of trouble printing the Temp Data to the LCD. Can anyone help me out. LCD is hooked up correctly and thermistor is reading correctly. Serial output is within .01 deg C of my laser thermometer.

The code below is the code I am using to output the data to the serial console.
Code:
#include <math.h>
                          
double Thermistor(int RawADC) {
 // Inputs ADC Value from Thermistor and outputs Temperature in Celsius
 //  requires: include <math.h>
 // Utilizes the Steinhart-Hart Thermistor Equation:
 //    Temperature in Kelvin = 1 / {A + B[ln(R)] + C[ln(R)]^3}
 //    where A = 0.001129148, B = 0.000234125 and C = 8.76741E-08
 long Resistance;  double Temp;  // Dual-Purpose variable to save space.
 Resistance=((10240000/RawADC) - 10000);  // Assuming a 10k Thermistor.  Calculation is actually: Resistance = (1024 * BalanceResistor/ADC) - BalanceResistor
 Temp = log(Resistance); // Saving the Log(resistance) so not to calculate it 4 times later. // "Temp" means "Temporary" on this line.
 Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));   // Now it means both "Temporary" and "Temperature"
 Temp = Temp - 273.15;  // Convert Kelvin to Celsius                                         // Now it only means "Temperature"
 return Temp;  // Return the Temperature
}

void printDouble(double val, byte precision) {
  // prints val with number of decimal places determine by precision
  // precision is a number from 0 to 6 indicating the desired decimal places
  // example: printDouble(3.1415, 2); // prints 3.14 (two decimal places)
  Serial.print (int(val));  //prints the int part
  if( precision > 0) {
    Serial.print("."); // print the decimal point
    unsigned long frac, mult = 1;
    byte padding = precision -1;
    while(precision--) mult *=10;
    if(val >= 0) frac = (val - int(val)) * mult; else frac = (int(val) - val) * mult;
    unsigned long frac1 = frac;
    while(frac1 /= 10) padding--;
    while(padding--) Serial.print("0");
    Serial.print(frac,DEC) ;
  }
}

void setup() {
 Serial.begin(115200);

}

#define ThermistorPIN 0   // Analog Pin 0
double temp;
void loop() {
 temp=Thermistor(analogRead(ThermistorPIN));           // read ADC and convert it to Celsius
 Serial.print("Sen.1 "); printDouble(temp,2);   // display Celsius
 Serial.print("c ");
 temp = (temp * 9.0)/ 5.0 + 32.0;                      // converts to Fahrenheit
 Serial.print(""); printDouble(temp,2);  // display Fahrenheit
 Serial.println("f");                                   // End of Line
 delay(1000);                                     // Delay a bit... for fun, and to not Serial.print faster than the serial connection can output
 //lcd.clear();

}
11  Forum 2005-2010 (read only) / Interfacing / Re: reading rpm signal from cpu fan on: June 05, 2010, 05:33:08 am
Ok I finally got this working with the help of a friend. I have posted it on my site http://themakersworkbench.com/?q=node/350

Code:
//Code by Crenn from thebestcasescenario.com

//Varibles used for calculations
int NbTopsFan;
int Calc;
char counter;
char flag;
unsigned long time[2];

//The pin location of the sensor
int hallsensor = 2;

//Defines the structure for multiple fans and their dividers
typedef struct{
  char fantype;
  unsigned int fandiv;
}fanspec;

//Definitions of the fans
fanspec fanspace[3]={{0,1},{1,2},{2,8}};

char fan = 0;   //This is the variable used to select the fan and it's divider, set 1 for unipolar hall effect sensor
               //and 2 for bipolar hall effect sensor


//This is the function that the interupt calls
void rpm()
{
   if (counter == 0)
      time[0]=millis();
   if (counter == 100){
      time[1]=millis();
      flag=1;
      cli();            //Disable interrupts
   }
}

//This is the setup function where the serial port is initialised,
//and the interrupt is attached
void setup()
{
 pinMode(hallsensor, INPUT);
 Serial.begin(9600);
 attachInterrupt(0, rpm, RISING);
}
void loop ()
{
   NbTopsFan = 0;      //Set NbTops to 0 ready for calculations
   sei();            //Enables interrupts
   while(flag==0);
   flag=0;
   counter=0;
   Calc = (((60*100)/(time[1]-time[0]))/fanspace[fan].fandiv);
   Serial.print (Calc, DEC); //Prints the number calculated above
   Serial.print (" rpm\r\n"); //Prints " rpm" and a new line
}
12  Forum 2005-2010 (read only) / Interfacing / Re: reading rpm signal from cpu fan on: June 02, 2010, 05:07:05 pm
Ok I connected the fans ground to one of the arduinos ground pins and I am still getting noting but random rmp numbers. Did I connect the resistor wrong? Does the sketch look right?

This is how I have it wired currently.


and the code
Code:
volatile byte NbTopsFan;
int hallsensor = 2;

void rpm()
{
 NbTopsFan++;
}


/***************************************/
void setup()
{
// pinMode(hallsensor, INPUT);
 Serial.begin(9600);
 attachInterrupt(0, rpm, RISING);
};

void loop ()
{
   NbTopsFan = 0;
  
   delay (1000);
   NbTopsFan = NbTopsFan * 30;
   Serial.print ("     ");
   Serial.print (NbTopsFan, DEC);
   Serial.print (" rpm");

  
};
13  Forum 2005-2010 (read only) / Interfacing / Re: reading rpm signal from cpu fan on: June 01, 2010, 08:27:20 pm
Thanks for the help!
14  Forum 2005-2010 (read only) / Interfacing / Re: reading rpm signal from cpu fan on: June 01, 2010, 07:54:23 pm
So I need to wire the ground wire from the fan to the arduino ground? Damn how did I not see that.
15  Forum 2005-2010 (read only) / Interfacing / Re: reading rpm signal from cpu fan on: June 01, 2010, 06:41:45 pm
I can not get this to work.  I have tried 4 different fans including a CPU fan I know has a working RPM sensor.  As it is right now the arduino is just printing random RPM numbers out to the serial console. I can stop the fan with my fingers and nothing changes. Disconnecting the fan all together from the arduino makes no change in the serial output.

Here is how I have tings wired up.


And this is the sketch I am using. (found on page 1 of this thread)

Code:
volatile byte NbTopsFan;
int hallsensor = 2;

void rpm()
{
 NbTopsFan++;
}


/***************************************/
void setup()
{
// pinMode(hallsensor, INPUT);
 Serial.begin(9600);
 attachInterrupt(0, rpm, RISING);
};

void loop ()
{
   NbTopsFan = 0;
  
   delay (1000);
   NbTopsFan = NbTopsFan * 30;
   Serial.print ("     ");
   Serial.print (NbTopsFan, DEC);
   Serial.print (" rpm");

  
};
Pages: [1] 2