Serial voltmeter with Pic16f84a

Discussion in 'Embedded Systems and Microcontrollers' started by ssiko, Jan 10, 2010.

  1. ssiko

    Thread Starter New Member

    Jan 10, 2010
    2
    0
    Hello everyone ,
    i'll say it out loud....from the start that i am relatively new to working with microcontrollers, so here's my project and here's my problem:
    1st. My project :
    i intended to build a serial voltmeter to check the voltage on a battery that is charged by solar energy . the initial project was intended with a pic16c711 so i bought this microcontroller and wanted to use the code that was given to program it. since i wasn't verry careful one of the pins broke and i can't use it anymore(in my area to get a pic16c711 the waitingtime is about 1 week)
    so i decided to use a pic16f84a since the pins are similar.
    2nd my problem
    so i want to program a pic16f84a to have the RA0pin as input and the RB0 pin as digital output
    so here id the code in mikrobasic that i have gotten so far , please help me add that else is needed and correct what's wrong.

    main:
    ANSEL = 0x17 ' Configure AN0 pin as analog
    TRISA = 0xFF ' PORTA is input
    ANSELH = 0 ' Configure other AN pins as digital I/O
    TRISB = 0 ' PORTB is output

    while (TRUE)
    adc_rd = ADC_Read(0) ' get ADC value from 2nd channel
    PORTB = adc_rd ' display adc_rd[7..0]
    wend
    end.
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Pic16F84A doesen't have any analog input pins. You might have to wait until you get your new chip.
    There are some methods for measuring analog voltages with digital pins but it probably isn't worth it. A quick google search should find some methods and there are some app notes on the microchip site about it.
     
  3. ssiko

    Thread Starter New Member

    Jan 10, 2010
    2
    0
    hey thank you for your answer , i was so obsessed with finding a quick replacement that i overlooked the fact that pic16f84 didn't have an adc converter .
    i might just use a simple adc converter by microchip , i think that might do it.
    thx again :)
     
Loading...