+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 20 of 29
  1. #1
    Advanced Member level 1
    Points: 2,327, Level: 11
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    444
    Helped
    2 / 2
    Points
    2,327
    Level
    11

    PIC12F683 mikro c pro code ADC

    Please let me know that I wrotw this attached code for ADC 10 bit but its not working another question is that how to implement Frc bit of ANSEL register.
    IMRAN

    •   Alt17th November 2012, 22:43

      advertising

        
       

  2. #2
    Banned
    Points: 6,265, Level: 18

    Join Date
    Jul 2012
    Posts
    1,192
    Helped
    169 / 169
    Points
    6,265
    Level
    18

    Re: PIC12F683 mikro c pro code ADC

    How can you assign a integer value ( of 10-bit ADC value) to an o/p pin which is a bit. will a bit o/p a integer value?

    your code
    Code:
     unsigned int temp_res;
    
    void main() {
      ADCON0=0x83;
      ANSEL  = 0x01;
      TRISIO  = 0x09;
      CMCON0=0x00;
      do {
        temp_res = ADC_Read(0);
        GPIO.GP1 = temp_res;
      } while(1);
    }
    Code:
     GPIO.GP1 = temp_res;
    is wrong. Try to display the value of temp_res by using lcd or some other thing.


    1 members found this post helpful.

  3. #3
    Advanced Member level 5
    Points: 39,725, Level: 48
    Tahmid's Avatar
    Join Date
    Jun 2008
    Location
    Cornell University, Ithaca, New York, USA (from Dhaka, Bangladesh)
    Posts
    4,734
    Helped
    1675 / 1675
    Points
    39,725
    Level
    48
    Blog Entries
    19

    Re: PIC12F683 mikro c pro code ADC

    What are you trying to do?

    Here's your code:
    Code:
    unsigned int temp_res;
    
    void main() {
      ADCON0=0x83;
      ANSEL  = 0x01;
      TRISIO  = 0x09;
      CMCON0=0x00;
      do {
        temp_res = ADC_Read(0);
        GPIO.GP1 = temp_res;
      } while(1);
    }
    Whatever settings you have in ADCON0 will be overwritten by the ADC_Read() function. So, setting ADCON0 doesn't really do anything.

    temp_res gets the ADC reading value. But what are you trying to do with it? You can't just send it to a single output pin.

    Here's the ANSEL register:

    As you can see, to set FRC, you have to use 011 or 111 for ADCS2:ADCS0 (ADCS[2:0]). I think mikroC automatically initializes the ADC to use FRC.



    Hope this helps.
    Tahmid.


    1 members found this post helpful.

  4. #4
    Advanced Member level 1
    Points: 2,327, Level: 11
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    444
    Helped
    2 / 2
    Points
    2,327
    Level
    11

    Re: PIC12F683 mikro c pro code ADC

    So,what should I will do for displaying AN0 input analog value on any single port like GP1-GP5.

    - - - Updated - - -

    I want to show analog input value in any port GP1-GP5 except GP3.
    IMRAN



  5. #5
    Advanced Member level 5
    Points: 39,725, Level: 48
    Tahmid's Avatar
    Join Date
    Jun 2008
    Location
    Cornell University, Ithaca, New York, USA (from Dhaka, Bangladesh)
    Posts
    4,734
    Helped
    1675 / 1675
    Points
    39,725
    Level
    48
    Blog Entries
    19

    Re: PIC12F683 mikro c pro code ADC

    So, you want the output to be 4-bit and displayed on GP5, GP4, GP2, GP1.

    The ADC result is a 10-bit value. You need to turn it into 4-bit.

    So, try this:
    Code:
    unsigned int temp_res;
    unsigned char tres;
    
    void main() {
      ANSEL  = 0x01;
      TRISIO  = 0x09;
      CMCON0=0x00;
      do {
        temp_res = ADC_Read(0) >> 6;
        tres = temp_res;
        GP5_bit = tres >> 3;
        GP4_bit = (tres & 0x04) >> 2;
        GP2_bit = (tres & 0x02) >> 1;
        GP1_bit = tres & 0x01;
        delay_ms(100);
      } while(1);
    }
    Hope this helps.
    Tahmid.


    1 members found this post helpful.

  6. #6
    Advanced Member level 1
    Points: 2,327, Level: 11
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    444
    Helped
    2 / 2
    Points
    2,327
    Level
    11

    Re: PIC12F683 mikro c pro code ADC

    Its a conversion of 10-bit to 4-bit but i saw PIC12f683 based voltmeter, in that circuit the 10-bit values transmit serially by single bit.So how he implement transmission data on single bit.
    IMRAN



  7. #7
    Banned
    Points: 6,265, Level: 18

    Join Date
    Jul 2012
    Posts
    1,192
    Helped
    169 / 169
    Points
    6,265
    Level
    18

    Re: PIC12F683 mikro c pro code ADC

    See this link, there is some code http://www.electronics-lab.com/proje...015/index.html

    Are you using Internal Oscillator? if yes, what is the frequency of clock and have you set to use internal osc function and IO function on GPIO4 and GPIO5?
    Last edited by internetuser2k12; 19th November 2012 at 03:09.



  8. #8
    Advanced Member level 5
    Points: 39,725, Level: 48
    Tahmid's Avatar
    Join Date
    Jun 2008
    Location
    Cornell University, Ithaca, New York, USA (from Dhaka, Bangladesh)
    Posts
    4,734
    Helped
    1675 / 1675
    Points
    39,725
    Level
    48
    Blog Entries
    19

    Re: PIC12F683 mikro c pro code ADC

    Notice that there is an additional chip used - 74HC595. It is a serial shift register. Go through the datasheet: www.nxp.com/documents/data_sheet/74HC_HCT595.pdf


    1 members found this post helpful.

  9. #9
    Advanced Member level 1
    Points: 2,327, Level: 11
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    444
    Helped
    2 / 2
    Points
    2,327
    Level
    11

    Re: PIC12F683 mikro c pro code ADC

    Yes i m using internal oscillator at 4Mhz (INOSCIO) .
    Do you have any knowledge about automotive electronics like Engine Control Unit (ECU) data transmission .

    - - - Updated - - -

    ooh yes its ok.Do you have know any IC for converting serial data into 7-segment display.
    I know one IC but its available in market
    IC number is MAX7219.
    IMRAN



  10. #10
    Advanced Member level 5
    Points: 39,725, Level: 48
    Tahmid's Avatar
    Join Date
    Jun 2008
    Location
    Cornell University, Ithaca, New York, USA (from Dhaka, Bangladesh)
    Posts
    4,734
    Helped
    1675 / 1675
    Points
    39,725
    Level
    48
    Blog Entries
    19

    Re: PIC12F683 mikro c pro code ADC

    ooh yes its ok.Do you have know any IC for converting serial data into 7-segment display.
    I know one IC but its available in market
    IC number is MAX7219.
    Do you actually mean that the IC is not available in the market? If it is available in the market, you should use it. It's a nice chip and you can easily interface it with the 12F683 using SPI.



    •   Alt19th November 2012, 14:28

      advertising

        
       

  11. #11
    Advanced Member level 1
    Points: 2,327, Level: 11
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    444
    Helped
    2 / 2
    Points
    2,327
    Level
    11

    Re: PIC12F683 mikro c pro code ADC

    Yes its not available in the market sorry for mistake.
    IMRAN



  12. #12
    Advanced Member level 1
    Points: 2,327, Level: 11
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    444
    Helped
    2 / 2
    Points
    2,327
    Level
    11

    Re: PIC12F683 mikro c pro code ADC

    If I want to purchase MAX7219 in Bangladesh by internet what would I do?
    IMRAN


    1 members found this post helpful.

  13. #13
    Advanced Member level 5
    Points: 39,725, Level: 48
    Tahmid's Avatar
    Join Date
    Jun 2008
    Location
    Cornell University, Ithaca, New York, USA (from Dhaka, Bangladesh)
    Posts
    4,734
    Helped
    1675 / 1675
    Points
    39,725
    Level
    48
    Blog Entries
    19

    Re: PIC12F683 mikro c pro code ADC

    Why do you want to purchase it from Bangladesh? Can't you get it at all from Karachi?

    If availability is such a big issue, don't use MAX7219. Instead use a larger PIC, where you'll have enough pins to drive the 7 Segment directly from the PIC. PIC16F877A is a common PIC that I'm sure you can get hold of.


    1 members found this post helpful.

  14. #14
    Advanced Member level 1
    Points: 2,327, Level: 11
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    444
    Helped
    2 / 2
    Points
    2,327
    Level
    11

    Re: PIC12F683 mikro c pro code ADC

    Its ok.PIC16F877A is a common PIC.I am newer in PIC and learning please do have any LCD code by using SPI.
    IMRAN



  15. #15
    Advanced Member level 4
    Points: 11,647, Level: 25
    ALERTLINKS's Avatar
    Join Date
    Dec 2003
    Location
    Pakistan
    Posts
    1,162
    Helped
    349 / 349
    Points
    11,647
    Level
    25

    Re: PIC12F683 mikro c pro code ADC

    MAX7219 is available here in Lahore for Rs.250, then why can't you find it in Karachi.


    1 members found this post helpful.

  16. #16
    Advanced Member level 5
    Points: 39,725, Level: 48
    Tahmid's Avatar
    Join Date
    Jun 2008
    Location
    Cornell University, Ithaca, New York, USA (from Dhaka, Bangladesh)
    Posts
    4,734
    Helped
    1675 / 1675
    Points
    39,725
    Level
    48
    Blog Entries
    19

    Re: PIC12F683 mikro c pro code ADC

    Quote Originally Posted by imranahmed View Post
    Its ok.PIC16F877A is a common PIC.I am newer in PIC and learning please do have any LCD code by using SPI.
    You can connect the LCD directly to PIC, without the need to use SPI. The PIC16F877A has enough pins. Is there any specific reason you want to use SPI for LCD?


    1 members found this post helpful.

  17. #17
    Advanced Member level 1
    Points: 2,327, Level: 11
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    444
    Helped
    2 / 2
    Points
    2,327
    Level
    11

    Re: PIC12F683 mikro c pro code ADC

    In electronic market, the price of MAX7219 is 550 rupees is much more price and according to you in its price is only 250Rs.
    Can I buy this IC in 550Rs.????

    - - - Updated - - -

    I want that the any received data by serially is display on LCD.What can i do?
    IMRAN



  18. #18
    Advanced Member level 5
    Points: 39,725, Level: 48
    Tahmid's Avatar
    Join Date
    Jun 2008
    Location
    Cornell University, Ithaca, New York, USA (from Dhaka, Bangladesh)
    Posts
    4,734
    Helped
    1675 / 1675
    Points
    39,725
    Level
    48
    Blog Entries
    19

    Re: PIC12F683 mikro c pro code ADC

    Quote Originally Posted by imranahmed View Post

    I want that the any received data by serially is display on LCD.What can i do?
    Do you mean you want to display data that is received by serial communication, eg SPI or UART, on the LCD?


    1 members found this post helpful.

  19. #19
    Banned
    Points: 6,265, Level: 18

    Join Date
    Jul 2012
    Posts
    1,192
    Helped
    169 / 169
    Points
    6,265
    Level
    18

    Re: PIC12F683 mikro c pro code ADC



    1 members found this post helpful.

  20. #20
    Advanced Member level 1
    Points: 2,327, Level: 11
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    444
    Helped
    2 / 2
    Points
    2,327
    Level
    11

    Re: PIC12F683 mikro c pro code ADC

    Yes exactly.
    IMRAN



+ Post New Thread
Please login
Page 1 of 2 12 LastLast