Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC12F683 mikro c pro code ADC

Status
Not open for further replies.

imranahmed

Advanced Member level 3
Joined
Dec 4, 2011
Messages
817
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Karachi,Pakistan
Activity points
6,492
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.
 

Attachments

  • CodePICADC.txt
    189 bytes · Views: 154

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.
 
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.

8098063200_1353228818.png


Hope this helps.
Tahmid.
 
  • Like
Reactions: tpetar

    tpetar

    Points: 2
    Helpful Answer Positive Rating
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.
 

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.
 
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.
 

Attachments

  • pic.bmp
    2.3 MB · Views: 142

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.
 

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.
 

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

    V

    Points: 2
    Helpful Answer Positive Rating
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.
 
Its ok.PIC16F877A is a common PIC.I am newer in PIC and learning please do have any LCD code by using SPI.
 

MAX7219 is available here in Lahore for Rs.250, then why can't you find it in Karachi.
 
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?
 
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?
 

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?
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top