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


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Sorry for the flood , but i must ;
    i changed the ADC codes , but volt variable does not accept floating numbers :

    START:

    ADCIN 0,RAW
    LOOK : IF ADCON0.2=1 THEN LOOK
    Volt=(0,0048828125*RAW)*1000
    MVolt=Volt//10 ' Mvolt = Volt mod 10
    LCDOUT $FE,2,"VOLT=",#VOLT,",",#Mvolt
    PAUSE 500
    GOTO START
    Last edited by karamastik; - 20th March 2008 at 01:54.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by karamastik View Post
    i changed the ADC codes , but volt variable does not accept floating numbers :
    Neither does anything else in PBP...

    PORTA=1 : RAW var word : volt var long
    START: ADCIN 0,RAW : IF ADCON0.2=1 THEN START
    Volt = Raw * 4882813 'round up
    LCDOUT $FE , 2 , "V=" , DEC ( volt dig 9 ) , "." , DEC ( volt dig 8 ) , DEC ( volt dig 7 )
    LCDOUT DEC ( volt dig 6 ) , DEC ( volt dig 5 ) , DEC ( volt dig 4 ) , DEC ( volt dig 3 )
    LCDOUT DEC ( volt dig 2 ) , DEC ( volt dig 1 ) , DEC ( volt dig 0 ) 'get all them digits in there
    PAUSE 500
    GOTO START

  3. #3
    Join Date
    Mar 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    I was at school ,sorry for the delay.
    Thanks for the help but in pbp , i saw that there is no " long " .
    It gives error.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by karamastik View Post
    I was at school ,sorry for the delay.
    Thanks for the help but in pbp , i saw that there is no " long " .
    It gives error.
    There is if you upgrade to PBP 2.50a.

  5. #5
    Join Date
    Mar 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Hello again !
    I changed my code like that :
    (Arkadaşlar yok mu yardımcı olacak ? )

    @ DEVICE pic16F877
    @ DEVICE pic16F877, WDT_on
    @ DEVICE pic16F877, PWRT_ON
    @ DEVICE pic16F877, PROTECT_OFF
    @ DEVICE pic16F877, HS_OSC

    TRISA=%00000001
    TRISB=0
    TRISE=0


    LCDOUT $FE, $40, $00, $1F, $1F, $1F, $1F, $1F, $1F, $00

    bar var byte
    raw var word
    I var byte


    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
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 2
    DEFINE ADC_SAMPLEUS 100

    ADCON1=%10001110
    LOW PORTE.2

    LCDOUT $FE,1
    PAUSE 200


    ADCIN 0,raw
    bar=(1023-raw)/64
    lcdout $fe,2
    for I=1 to bar
    lcdout ,255
    next

    END
    Is the idea correct , isn't it ?
    But it does not work
    Last edited by karamastik; - 21st March 2008 at 12:12.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Are you using a 16F877 or 16F877A?
    Probably doesn't matter much, but, put the config registers first, then your define's, then you variables, then your code.
    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 
    DEFINE ADC_BITS 10 
    DEFINE ADC_CLOCK 2 
    DEFINE ADC_SAMPLEUS 100 
    bar var byte:raw var word:I var byte
    trisa=1:trisb=0:trise=0:lcdout $FE,$40,0,$1F,$1F,$1F,$1F,$1F,$1F,0,$fe,1
    ADCON1=$8e:PAUSE 200:ADCIN 0,raw:bar=(1023-raw)/64:lcdout $fe,2:for I=1 to bar
    lcdout ,255:next I
    END
    Looks like something might be missing from that lcdout command...(and the next I shouldn't matter, but it might).
    How do you know you ADCIN is actually reading something?
    Have you tried just reading the RAW value and displaying it in a loop?
    lcdout DEC3 RAW

  7. #7
    Join Date
    Mar 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Hello
    I'm using 16f877;
    i changed the lcdout command like yours and
    here , i checked for the ADC reading:
    @ 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
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 2
    DEFINE ADC_SAMPLEUS 100

    bar var byte
    raw var word
    I var byte

    trisa=1
    trisb=0
    trise=0

    lcdout $FE,$40,0,$1F,$1F,$1F,$1F,$1F,$1F,0,$fe,1
    ADCON1=$8e
    PAUSE 200
    ADCIN 0,raw
    bar=(1023-raw)/64
    for I=1 to bar
    lcdout dec3 raw
    next I
    END
    there is a 16 digit number : 2732732732732732 and does not change;
    if i reset the pic , there is another number 2742742742742742 , so goes on ...
    I think i it couldn't read raw.
    And the number does not change;maybe my loop is wrong

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