external instance not working

Hi,

I am declaring instance of my own Traces class like that :

/*
   Traces.cpp for traces output.

   Copyright (c) Nicolas VALENTIN 2010
   12 Oct 2010  - First Version
   2010 nov. 20 Adding Special Features Writing Direction
   */

#include "WProgram.h"
#include "Traces.h"
#include "Time.h"
#include <Wire.h>
#include <Utils.h>
#include <DS1307.h>
#include <LiquidCrystal.h>

//=============================================================================
//=============================================================================

Traces Tracer = Traces();
/* set fdm=marker */
/*
  traces.h - low level traces functions
*/

#ifndef _Traces_h
#define _Traces_h

#include "WProgram.h"
#include <inttypes.h>
#include <LiquidCrystal.h>
#include "Time.h"
// #include <QueueList.h>


class Traces
{
  public:
//=============================================================================
  private:
//=============================================================================
//=============================================================================
//=============================================================================
};
/* set fdm=marker */

extern Traces Tracer;
#endif /* _Traces_h */

and in my setup I pass it to others classes :

/*
   CoreSystem

   Manage Main Loop to control some electrical feature
   */

#include <inttypes.h>

#include <Time.h>

// niva add features
#include <Traces.h>
#include <Utils.h>


#include <PinManager.h>
#include <FunctionalTasks.h>

#include <FunctionalWrapper.h>
#include <LcdMenu.h>

#include <Alarm.h>
#include <AlarmsManager.h>

#include <Wire.h>
#include <LiquidCrystal.h>
#include <DS1307.h> // written by  mattt on the Arduino forum and modified by D. Sjunnesson
#include <SRF02.h>
#include <UltrasonCmd.h>
#include <MemoryFree.h>
#include <QueueList.h>


/* Arduino          Lcd 2x16
 *
 * VSS              Pin 1
 * VDD              Pin 2
 * VSS              Pin 3
 * Pin 7            Pin 4
 * VSS              Pin 5
 * Pin 8            Pin 6
 * NA                  Pin 7
 * NA                  Pin 8
 * NA                  Pin 9
 * NA                  Pin 10
 * Pin 9            Pin 11
 * Pin 10           Pin 12
 * Pin 11           Pin 13
 * Pin 12           Pin 14
 * VDD              Pin 15
 * VSS              Pin 16
 *
 *
 */
LiquidCrystal     lcd(7, 8, 9, 10, 11, 12) ;
SRF02 sonicsensor = SRF02(0x70, SRF02_CENTIMETERS);
FunctionalTasks   FuncTask                 ;

// ENTREES 

//
//  SETUP
//

void setup()  { 

      // SERIAL
      Serial.begin(9600); 


      // LCD
      lcd.begin(16, 2);
      lcd.setCursor(0, 0);
      lcd.clear();
      delay(2000);


      PinMng.setTracer(&Tracer);

      // pass lcd to tracer and tracer to all others objects
      Tracer.setLcd(&lcd);
      delay(200);
      // FuncTask.setSonicSensor(&sonicsensor);
      
      // UltraSonic Sensor
      UltraCmd.setSonicSensor(&sonicsensor);
      UltraCmd.setDistToOnRelays(180);
      UltraCmd.setTracer(&Tracer);


      // FunctionalTask
      FuncTask.setTracer(&Tracer);
      FuncTask.setPinManager(&PinMng);

      // FuncTask.setRealTimeClock();   //!!! only if date is out of date

      // Bind the wrapper to FunctionalTasks p and call procedure
      FunctionalWrapper::setObj(FuncTask);

      //
      Tracer.LcdDelayPrintTopLineFromLeft("Ecran.........OK");

      // CONFIGURATION
      FuncTask.ConfigPinsRelays();

      Tracer.LcdDelayPrintBottomLineFromLeft("Config Pins...OK");
      delay(300);
      FuncTask.displayRelayConfig();

      // AUTOTEST RELAIS
      // FuncTask.Autotests();

      // TESTS SECTION OF ALARM {{{1

void PinManager::setTracer(Traces *TracerPtr) {

      if (  TracerPtr != NULL )
      {
            _Tracer = TracerPtr;
      }
}
class PinManager
{
  public:
    PinManager();

      void setTracer(Traces *TracerPtr);

And in all of class the setter is like that :

I would like to know if there is a mismatch cause my lcd screen display bad unknown characters.

Nobody can help ?

My guess is that your Sketch uses too much SRAM.

I have used free memory function to know how many bytes are free and it displays 160 bytes.

How can I correct this problem ? (for the moment I cannot add ram to the mountage)

I have used free memory function to know how many bytes are free and it displays 160 bytes.

Then my guess was likely wrong.

How can I correct this problem ?

Sorry, I don't have another guess.

I have used free memory function to know how many bytes are free and it displays 160 bytes.

At what point? Free memory is not static. As function calls are made, it goes down. As objects are constructed, it goes down.

Your advice could be go to this link:
http://www.arduino.cc/en/Reference/PROGMEM

Sorry I have used a function that allocate memory and display how many free memory in bytes is still available.

I have not used function to free memory.

I am surprised that managing a RTC DS1307, the 2009 arduino board, a LCD and an Ultrasonic sensor causes your guess.

That I am using too much SRAM

If it isn't a shortage of RAM, it is probably a rogue pointer.
Sorry, you're the one with the means to debug this one.

Can I had if( myPtr != NULL on all my pointers ??

Can I had if( myPtr != NULL on all my pointers ??

Yes, but that would only show (global) pointers that had never been initialised, not pointers that had been "re-used" and were pointing at invalid areas of memory.