adc not working on hardware but works on proteus – electroSome https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/feed/ Sat, 18 Mar 2023 04:12:49 +0000 https://bbpress.org/?v=2.6.9 en-US https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15789 <![CDATA[adc not working on hardware but works on proteus]]> https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15789 Thu, 20 Dec 2018 12:31:32 +0000 Linda11 I’m doing ADC with PIC 18F46K22, 16×2 lcd, LM3 temperature sensor, 20 MHz oscillator, MPLAB XC8 and PicKit3 programmer. I can do the generate the hex file and simulate it on Proteus and it works fine, but on hardware it doesn’t work. The LCD is switched on, but doesn’t display the analog value.

I wrote a small program to switch the led on off with delay and write something on the LCD on off with delay and this works on Proteus and hardware.

Please assist

]]>
https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15807 <![CDATA[Reply To: adc not working on hardware but works on proteus]]> https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15807 Fri, 21 Dec 2018 11:47:04 +0000 Ligo George It is very difficult to analyse the problem with above details. Kindly attach a photo of your LCD and the program you are using.

]]>
https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15850 <![CDATA[Reply To: adc not working on hardware but works on proteus]]> https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15850 Fri, 18 Jan 2019 11:29:24 +0000 Linda11 Find attached is my adc code and proteus simulation file.

]]>
https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15852 <![CDATA[Reply To: adc not working on hardware but works on proteus]]> https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15852 Fri, 18 Jan 2019 11:31:30 +0000 Linda11 I’m struggling to send the proteus file.

]]>
https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15888 <![CDATA[Reply To: adc not working on hardware but works on proteus]]> https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15888 Mon, 18 Feb 2019 17:33:40 +0000 BaseMell Hi..in my case I found that the microcontroller is powered by +5V. I had to change the Power Rail Voltage to +3.3V.
I changed the voltage from the “Design->Configure Power rails” menu entry. From the drop down list, I picked VCC/VDD and changed the voltage from 5 to 3.3. Now it works correctly.

]]>
https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15891 <![CDATA[Reply To: adc not working on hardware but works on proteus]]> https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15891 Fri, 29 Mar 2019 08:53:22 +0000 Linda11 Thank the hardware is working. I had to modify the codes.

]]>
https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15900 <![CDATA[Reply To: adc not working on hardware but works on proteus]]> https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15900 Thu, 13 Jun 2019 08:29:42 +0000 Omeken I am with LM35, LCD 16*2, and 16F877A. I want to use different value (read temperature and reference temperature) of the temperature to on or off the two LED. The code is only controlling one LED RD0.

// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections

unsigned int read_value=0, ref_value;
unsigned int value=0;
unsigned int temp;
char aux[7];

void main()
{
  RD0_bit = 0;
  RD1_bit =0;
  ADCON1 = 0x00; // All channels are config as analog I/p.

  ADC_Init();
  Lcd_Init(); // Initialize LCD
  Lcd_cmd(_lcd_clear);
  Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
  Lcd_out(1,3,"Temperature:");
  LCD_Out(2,1,"Eff:    Ref:");

  while(1)
  {
    read_value = Adc_Get_Sample(2)>>2;
    ref_value  = ADC_Get_Sample(4)>>2;

    if (read_value < ref_value)
    {
      PORTD.RD0 = 1;
      if (read_value > ref_value)
        PORTD.RD1 = 1;
      else
        PORTD.RD1 =  0;
      PORTD.RD0 = 0;
    }

    value = (unsigned int) read_value * (500./255); // Resolution for 5 volts, 8 bits
    ByteToStr(value,Ltrim(aux));
    LCD_Out(2,5, aux); //shows reading temperature

    value = (unsigned int) ref_value * (500./255);
    ByteToStr(value,Ltrim(aux));
    LCD_Out(2,13, aux); //shows reference temperature

    delay_ms(50);
  }
}
]]>
https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15908 <![CDATA[Reply To: adc not working on hardware but works on proteus]]> https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15908 Mon, 17 Jun 2019 10:51:15 +0000 Omeken I have rectified the problem, the design is now working . I changed to
RD0_bit = 0;
RD1_bit =0 ; to TRISD = 0;

]]>
https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15909 <![CDATA[Reply To: adc not working on hardware but works on proteus]]> https://electrosome.com/topic/adc-not-working-on-hardware-but-works-on-proteus/#post-15909 Mon, 17 Jun 2019 10:53:32 +0000 Omeken I mean changing RD1_bit = 0; to TRISD = ;

 

]]>