Help for my project(16f877,2x16LCD,)


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Try this...don't know if it'll work or not, but it should put a value on your LCD that matches the A/D result register, assuming you have something wired to PortA.0, like the wiper of a pot, with +5v on one side and ground on the other...
    Code:
    @ DEVICE pic16F877 
    @ DEVICE pic16F877, WDT_on 
    @ DEVICE pic16F877, PWRT_ON 
    @ DEVICE pic16F877, PROTECT_OFF 
    @ DEVICE pic16F877, HS_OSC 
    DEFINE LCD_DREG PORTB 
    DEFINE LCD_DBIT 0 
    DEFINE LCD_RSREG PORTE 
    DEFINE LCD_RSBIT 1 
    DEFINE LCD_EREG PORTE 
    DEFINE LCD_EBIT 0 
    DEFINE LCD_RWREG PORTE 
    DEFINE LCD_RWBIT 2 
    DEFINE LCD_BITS 8 
    DEFINE LCD_LINES 2 
    DEFINE LCD_COMMANDUS 1000 
    DEFINE LCD_DATAUS 225 
    raw var word : trisa=1 : trisb=0 : trise=0 : adcon0 = $c1 : adcon1 = $ce
    main:     adcon0.2 = 1   'start A/D conversion
    wait_for_it:     if adcon0.2 = 1 then wait_for_it     'wait for A/D to finish
    raw.highbyte = adresh : raw.lowbyte = adresl
    lcdout $fe , 1 , DEC4 raw : goto main
    END

  2. #2
    Join Date
    Mar 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Try this...don't know if it'll work or not, but it should put a value on your LCD that matches the A/D result register, assuming you have something wired to PortA.0, like the wiper of a pot, with +5v on one side and ground on the other...
    Code:
    @ DEVICE pic16F877 
    @ DEVICE pic16F877, WDT_on 
    @ DEVICE pic16F877, PWRT_ON 
    @ DEVICE pic16F877, PROTECT_OFF 
    @ DEVICE pic16F877, HS_OSC 
    DEFINE LCD_DREG PORTB 
    DEFINE LCD_DBIT 0 
    DEFINE LCD_RSREG PORTE 
    DEFINE LCD_RSBIT 1 
    DEFINE LCD_EREG PORTE 
    DEFINE LCD_EBIT 0 
    DEFINE LCD_RWREG PORTE 
    DEFINE LCD_RWBIT 2 
    DEFINE LCD_BITS 8 
    DEFINE LCD_LINES 2 
    DEFINE LCD_COMMANDUS 1000 
    DEFINE LCD_DATAUS 225 
    raw var word : trisa=1 : trisb=0 : trise=0 : adcon0 = $c1 : adcon1 = $ce
    main:     adcon0.2 = 1   'start A/D conversion
    wait_for_it:     if adcon0.2 = 1 then wait_for_it     'wait for A/D to finish
    raw.highbyte = adresh : raw.lowbyte = adresl
    lcdout $fe , 1 , DEC4 raw : goto main
    END
    There is no activity on the screen

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by karamastik View Post
    There is no activity on the screen
    change lcdout $fe,1,.........
    to
    lcdout $fe , $80

    Hook up a potentiometer connected as I described earlier and try that....

    SMALL STEPS!!!!

  4. #4
    Join Date
    Mar 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    ADC works .
    I connected the Vcc of pic to the portA.0 and it shows 1023 .
    After that ; i tried
    Code:
    ; Initialize your hardware and LCD first.
    
    DEFINE ADC_BITS 8 ' Number of bits in ADCIN result
    ADCON1.7 = 1 ' Right Justify AD result
    
    INCLUDE "LCDbar_INC.bas" ' Include the BARgraph routines
    
    Value VAR WORD ' Must be a WORD even though AD is 8bit
    
    LCDOUT $FE, 1 ' Clear Screen
    
    Loop1:
    ADCIN 0, Value
    LCDOUT $FE,2,"Value = ",DEC Value," "
    ; syntax- BARgraph Value, Row, Col, Width, Range, Style
    @ BARgraph _Value, 2, 0, 16, 255, lines
    GOTO Loop1
    The bars are ok , don't flickr
    but the word "value" always flickering , why ?
    And whene there is no input to the portA.0 , the value becomes 276 and there are still full bars ? (I know there are too many questions , but i want to learn )

    It seems , the problem is my circuit output
    By the way , as i said before , whene there is 5V , i don't want any bars , there must be full bars at 3.9V
    How can i change this code to run like for my project or there must be a different code ?
    Code:
    Loop1:
        ADCIN  0, ham
        LCDOUT $FE,2,"Value = ",DEC ham,"   "
        ; syntax- BARgraph   Value, Row, Col, Width, Range, Style
        @         BARgraph  _ham,   2,   0,    16,   255,  lines
        
    Goto Loop1
    Thank you very much again.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    but the word "value" always flickering , why ?
    Probably because something is overwriting it or clearing the screen, then you re-print the VALUE on the LCD...

    as i said before , whene there is 5V , i don't want any bars , there must be full bars at 3.9V
    Simple math
    Minimum = 5V (1023 ADC counts)
    Maximum = 3.9V (798 ADC counts)
    Spread = 1.1V (225 counts)
    raw = 1024 - raw 'flips the value upside-down
    raw = raw / 14 '14 counts per box, assuming 16 boxes
    Surely you can do something with that...

  6. #6
    Join Date
    Mar 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Okey my friend , thank you for your patience and for your helps
    Today is enough for me ;
    i'm working about this project from 9 o'clock to now.
    I think , it's time to make my brain free.
    And one last question ; i don't know that you are interested in integrated circuits; if you are ; i want to ask something.
    I have 2 op-amps LM358 and i learned that , the maximum supply current for LM358 is 600mA . I have a power supply with 6-9-12-15 adjustable ; and it says , it can give a current of 2.5A
    So, if i connect it to my op-amps , do they blow out ?
    Thank you .

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    The op amps will be fine. The PS rating is the maximum it can handle, the op amps will only draw what they need.

    As for the flicker, you need a pause of maybe 100 in the loop.
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts