Crystal 16MHZ Temp

How can I stabilize the Crystal?

I have noticed that the change in temperature of the crystal can have an effect on the read out off the chip.

Hi,
How is it effecting the readout of the chip?
What model arduino?
Clone or OEM?

Tom... :slight_smile:

englewood:
How can I stabilize the Crystal?

I have noticed that the change in temperature of the crystal can have an effect on the read out off the chip.

Most Arduino boards nowadays create their frequency not from a "crystal oscillator", but from a "ceramic resonator", which is MUCH more inaccurate than a crystal.

If you need an accurate 16 MHz clock for your Arduino, AVOID boards that create the Atmega clock from ceramic resonator and select a board which creates the clock frequency from a crystal.

For example, the last Atmega328 based board with a crystal was the "UNO Duemilanove". All UNO boards in "R3 design" just have an inaccurate ceramic resonator for clocking.

I'm not using the actual board.

I have set-up the Audunio on veraboard.

Could it be the tollarance of the 2 capacitors going to the Crystal

No, not really. But a crystal is pretty accurate. Yes it changes a bit under temperature (but so does it under rotation). But what are you trying to do that you think is so time critical?

I have made a digital flow meter.

I have a inline non-digital flow meter connected the digital flow meter and when I was testing yesterday - I had read outs of 6L on the non-digital flow meter and digital flow meter.

When I turned it on this morning I had 6L on the non-digital flow meter and 8L on the digital flow meter - this was first thing when the temperature is low.

I applied some heat to the area of the crystal and the chip and the flow the corrected itself to 6L

Okay, what's the output of the digital flow meter (pulses, data?)? And what's the output of the analog flow meter (voltage?)? Are they both connected to an Arduino?

Because, yeay, there is a difference with temperature but the application sounds simple enough to me to not bother with that...

There is not electronics on the non-digital flow meter, its just a plastic cylinder with a boing showing the flow rate at a certain level.

The flow rate on this flow meter was saying 6L

Then the digital flow was saying 8L

Hi,
8L per what ever to 6L per whatever, please can you use proper units.
Thats 25% change.
Crystals do not have that much temperature drift.
Can you post a picture of your project and also what value and type of capacitors do you have around the crystal?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Tom..... :slight_smile:

I will update tomorrow with PICS and PDF.

Was Litres Per Min

0.22pf caps on the crystal

Hi,
Don't you mean 22pF?

Tom..... :slight_smile:

Yeah I did :slight_smile:

I have tested the Crystal with a Oscilloscope and the reading is 15.90-16.10hz

This is what I followed to make the board but migrated the Arduino chip to Veroboard

englewood:
I have tested the Crystal with a Oscilloscope and the reading is 15.90-16.10hz

Don't you mean Mhz? Don't measure it that way. Load the blink without delay sketch and compare it with a clock. The placement of the crystal on the Veroboard looks suspicious. Are you sure it's connected to the right pins? How about a picture of the back of the board?

You may have a loose or improper clock connection that causes it to improperly oscillate or "free run" on parasitic impedances.

But it's far more likely that you have a software bug.

Yeah I meant Mhz >:(
I have the Crystal on PIN 9-10.

My Code

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 6);

volatile int FlowPulse; //measuring the rising edges of the signal
int Calc;                               
int flowsensor = 2;    //The pin location of the sensor


void setup() {
     
   pinMode(flowsensor, INPUT); //initializes digital pin 2 as an input
   Serial.begin(9600);         //This is the setup function where the serial port is initialised,
   attachInterrupt(0, rpm, RISING); //and the interrupt is attached
   
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 6);
  // Print a message to the LCD.
  lcd.setCursor(1,0);
  lcd.print("Flow Rate Meter");
  
  delay(1000);// wait 500ms                                      // Delay to read text
 lcd.clear(); // clear LCD display

}

void loop() {
     
 FlowPulse = 0;      //Set NbTops to 0 ready for calculations
 sei();            //Enables interrupts
 delay (1000);      //Wait 1 second
 cli();            //Disable interrupts
 Calc = (FlowPulse * 1.75/ 7.5 ); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour 
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/Minn"); //Prints "L/hour" and returns a  new line
  
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.begin(16,6);
  lcd.setCursor(1, 0);
  lcd.print(Calc, DEC);   // print the Flow Rate
  lcd.print("    L/Min");
}

void rpm ()     //This is the function that the interupt calls 
{ 
  FlowPulse++;  //This function measures the rising and falling edge of the hall effect sensors signal
} ]

The leads on the crystal must be pretty scrunched together. Are you sure that they aren't shorted or open as a result?

The wires on the front of your board are not insulated. Are you sure they are not shorting out on the bus bars (PCB traces)?

there is no shorts on the board, checked all of that.

Nope all seem fine.

Could it be errors in the code.

The calculated flow rate is proportional to the number of rising edges detected by your interrupt routine. There's no way that has anything to do with the 0.001% frequency drift that your crystal will experience with minor temperature changes.

You're probably just getting a noisy signal for some reason. Can you look at it with an oscilloscope? Warming up the "area of the crystal and the chip" doesn't isolate the problem to the crystal. Even if you didn't have the capacitors on board the crystal would probably still oscillate very close to 16MHz.

You should add 0.1uF capacitors between Vcc-ground and AVcc-ground. That could cause you problems, if not now then later.

I will add some caps to the two reference points you just stated.

I can have a look at the circuit with an Oscilloscope but what are my reference points, I know the crystal is ok.

 Calc = (FlowPulse * 1.75/ 7.5 ); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour

You previously declared FlowPulse and Calc as int types. Then you do decimal calculations using them.