Pic16f690 ADC with LM35 temperature sensor

Discussion in 'Embedded Systems and Microcontrollers' started by Krentin018, Sep 14, 2016.

  1. Krentin018

    Thread Starter New Member

    Mar 27, 2016
    4
    0
    Hi, I am making a thermometer using the LM35 interfaced to the pic16f690 for a school project using the assembly language. The temperature in degrees Celsius needs to be displayed on two multiplexed seven segment displays.

    I am using MPLABX with the PicKit 3 to program the MCU and simulator to debug. I am having trouble with the ADC of the LM35, the result stored in ADRESL and ADRESH stays at 0 and does not change. In the simulator ADRESL and ADRESH does not update with changing voltage from the LM35, but I have noticed that it only changes the moment the simulation is paused, when resumed thereafter the registers do not update until the simulator is paused again.

    Apart from the ADC issue the rest of the code has been tested and verified working.

    I am using AN0 as the analogue input, VDD for reference voltage, PortC to display on the SSD's, RB4 and RB5 to multiplex and Fosc/4.

    Thanks in advance:)
     
  2. Krentin018

    Thread Starter New Member

    Mar 27, 2016
    4
    0
    Sorry, I forgot to mention that I attached the Assembly code below
     
  3. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,645
    759
    For your particular micro, check if ADC is actually simulated. In fact, for any new micro always check what MPSIM does not simulate.
     
    Last edited: Sep 14, 2016
  4. AlbertHall

    Well-Known Member

    Jun 4, 2014
    1,886
    375
    You must set up a stimulus file for the ADC input.
    For a quick testing method you could add code after the ADC 'measurement' is complete to write your desired values to ADRESL and ADRESH.
     
  5. Krentin018

    Thread Starter New Member

    Mar 27, 2016
    4
    0
    I am new to Pic programming so i'm not so sure how to do that but it does accept the analogue input correctly but just not during its runtime or on the chip.

    I have tested with some values of ADRESL and ADRESH (on chip as well) and the rest of the code does what it should be doing, the problem is with the actual conversion.
     
  6. AlbertHall

    Well-Known Member

    Jun 4, 2014
    1,886
    375
    Have you set up a stimulus file for the ADC?
     
  7. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,645
    759
    I always went that way. Or, adding a break point to poke the test values.
     
  8. Krentin018

    Thread Starter New Member

    Mar 27, 2016
    4
    0
    Yes, I made one with synchronous input and I can clearly see from the IO Pin window that the value on the AN0 pin is changing but it doesn't seem to affect any registers
     
Loading...