This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/LMT01: Will not run code in Arduino Uno

Part Number: LMT01

Tool/software: TI C/C++ Compiler

Here is the code, it both compiled & uploaded appropriately.  The 1602A LCD display showed no sign of life.
I've not used it before so I don't know if it is even functional.
When it didn't work, I tried adding the line Serial.print(pulseCount); to check to see if the interrupt routine was working.  But to no avail, I got nothing.  Now I'll be satisfied to get it get it to print in the serial print register. 


The circuit is included (Apperantly not)  Also, I have a scope - the LMT01 put out 1.6 Volts/0.6 volts at 10 Usec and there were about the right no. of pulses for temp. @ 25 C  It's feeding into a 1.1V comparator..  The circuit is the standard one by Brandon Fisher.
---------------------------------------------------
#include <LiquidCrystal.h>
//Declare RS, E, D4, D5, D6, D7
LiquidCrystal lcd(3,5,6,9,10,11);

volatile int pulseCount = 0;
float temperature = 0;
int hold = 0; 

void setup() 
{
  //initialize 1602 LCD Display
  lcd.begin(16, 2);
  //Print Label for Pulse count
  lcd.setCursor(0,0);
  lcd.write("PULSES: ");
  //Print label for Temperature
  lcd.setCursor(0,1);
  lcd.write("TEMP(C): ");
  
  //Setup ACSR Register, to initlize the comparator

  /*         ACSR Bit Description
  *  
  ACD  - Clear ACD to enable Analog Comparator
  ACBG - Set ACBG to 1 to use internal 1.1V Reference
  ACO  - Clear ACIO (Will be ignored - read only)
  ACI  - Reset Analog Interrupt Flag by writing 1
  ACIE - Set ACIE to enable comparator interrupt
  ACIC - Clear ACIC, no connection to Timer/counter
  ACIS1 - Set ACIS1 to trigger interrupt on falling edge
  ACIS0 - Cleat ACIS0 to trigger interrupt on falling edge
  */
  ACSR = B01011010;    //Set according to above bit description
}

void loop() 
{
  //don't bother entering the loop again if no pulses have been counted yet. 
  if(pulseCount != 0)
  {
    //Wait for counting to be complete
    while(pulseCount != hold)
    {
      hold = pulseCount;
      delay(1);
    }
  
    //Print Pulse count to LCD
    lcd.setCursor(9,0);
    lcd.print(pulseCount);
     Serial.print(pulseCount);
     
    //Print Temperature to LCD
    temperature = 0.0625 * pulseCount - 50;
    lcd.setCursor(9,1);
    lcd.print(temperature);
   
    
    //reset pulseCount for next loop
    pulseCount = 0;
  }
  delay(2);
}


//Interrupt Service Routine, counts pulses
ISR(ANALOG_COMP_vect) 
{
  //Increment pulse count
  pulseCount += 1;
 
}
  • Donald,

    You tagged "TI C/C++ compiler" in the post. Did you use the Arduino IDE to compile?

    Please do a few sanity checks to see if your arduino works with the LCD. Download another simple working arduino example
    with the LCD and test to see if the LCD works as it should.

    To debug the comparator, remove all LDC code and use the serial terminal
    to debug. If the comparator interrupt doesn't seem to work find another arduino comparator example online and test that to see
    if you get a different response.

    Double check your circuit to match the LMT01 example circuit.

    The trick to debug is to isolate the problems into one problem at a time until you find the root cause.

    -Kelvin