Problems with 16F684


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Problems with 16F684

    Simple schematic, simple code, WITHOUT DS18B20 ...Still no result !!! I am ...
    Code:
    @ DEVICE pic16F684, intrc_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_ON
    define osc 4
    
    TRISA= %00000000                           
    TRISC= %00001000
                    
    CMCON0  = %00000111      'Disable analog comparators.     
    
    DEFINE ADC_BITS 10       ' 10 bit A/D Conversion
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50   ' 50 uS A/D sample time
    
    VRCON  = %00000000       ' Disable Comparator Voltage Reference
    ANSEL  = %10000000       ' Set pin (AN7) to analog input, the rest to digital
    ADCON0 = %10011101       ' Set up A/D converter - Right Just., VDD REF., CH 7, ON
    ADCON1 = %00110000       ' Set up A/D Converter clock source to internal RC
    
    ;----[ Change these to match your LCD ]--------------------------------------- 
    LCD_DB4    VAR PORTA.2 
    LCD_DB5    VAR PORTC.0 
    LCD_DB6    VAR PORTC.1 
    LCD_DB7    VAR PORTC.2 
    LCD_RS     VAR PORTA.0 
    LCD_E      VAR PORTA.1 
    LCD_Lines  CON 1     ' # of Lines on LCD, 1 or 2 (Note: use 2 for 4 lines) 
    LCD_DATAUS CON 50     ' Data delay time in us 
    LCD_COMMANDUS CON 2000     ' Command delay time in us 
    
    INCLUDE "LCD_AnyPin.pbp" 
    
    Vfs             con     20480           '20,480v 
    K16             con     61441           'coefficiente filtro 15/16
    Vbatt           var     word            'Vbatt filtrato
    TmpW            var     word
    Acc_Vbatt       var     word            'accumulatore Vbatt filtrato * 16
    
    
    Pause 500
    LCDOUT $FE, 1, $FE, $0C                 ' Clear display, cursor off
    Pause 500
    
    Main :
            ADCON0.1 = 1                          'start A/D
            while ADCON0.1 = 1          
            wend
            TmpW.byte1 = ADRESH                        'get A/D value
            TmpW.byte0 = ADRESL
            Acc_Vbatt = Acc_Vbatt ** K16 + TmpW      'filtro 15/16
            Vbatt = Acc_Vbatt / 16                  ' / 16 valore normalizzato       
            Acc_Vbatt = TmpW * 16                 'filter preload  Vbatt * 16
            TmpW = Vbatt * Vfs                    ' AD * 20480
            TmpW = Div32 1024                     '(AD * 20480) / 1024
    LcdOut $FE, $c0, dec TmpW dig 4,dec TmpW dig 3,",",dec TmpW dig 2
    Goto Main    
    return
    Name:  error2.jpg
Views: 2736
Size:  462.2 KB

  2. #2
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Problems with 16F684

    Same weird behavior using JUST code for thermometer ...
    Code:
    Main :
     OWOut DQ1, 1, [$CC, $44] 
     OWOut DQ1, 1, [$CC, $BE]
     OWIn DQ1, 2, [temperature1.byte0, temperature1.byte1]  
        
    If Temperature1.15 then       
      Temperature1= ~Temperature1 +1
      Twist1 = 1
    Endif
     
    Dummy1 = 625 * Temperature1
    TempC1 = DIV32 10 
    TempC1 = (Temperature1 & $7FF) >> 4
    Float1 = ((Temperature1.Lowbyte & $0F ) * 25 )>>2
    Temperature1 = TempC1*100 + Float1
    
    If Twist1 then
      V1= 10000 - Temperature1                 
      Twist1 = 0
     else
      V1= 10000 + Temperature1
    EndIf
    
    If V1 >= 10000 then                           
      Temperature1=V1-10000                   
     else                                   
      Temperature1=10000-V1                    
    EndIf
    '===================================================================================================================
    GoSub SelectSign
    if (temperature1/100) =>10 then
    LcdOut $FE, $80, "I:", Sign1, DEC (Temperature1 / 100), ".", DEC Temperature1 dig 1, 223 
    else
    LcdOut $FE, $80, "I:", Sign1, $14, DEC (Temperature1 / 100), ".", DEC Temperature1 dig 1, 223 
    endif
    
    Goto Main                                                                    
    '==========================================================================================================================
    SelectSign:
    If v1 = 10000 then                      
      Sign1=" "                          
     else 
      If v1 < 10000 then                     
       Sign1="-"                             
      else
       Sign1="+"                          
      EndIf
    EndIf
    Return

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Problems with 16F684

    Sorry for pollute this great forum ... I think it's a PROTEUS error ; with the code posted by Mr.Darrel I have the same messages .Name:  code_Mr_Darell.jpg
Views: 2671
Size:  583.4 KB

  4. #4
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Problems with 16F684

    Bad news, for me ... The hardware DON'T WORK ! Just some stranges characters appears on display, not stable-fast changing ...cannot post pictures... I try even code of Mr.Darrel (posted above). I think it's a "incompatibility" between THIS PIC and "LCD_AnyPin" ?!?
    What else I cand do (outside of using "clasic" configuration of LCD-PIC pins) ?

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Problems with 16F684

    Please, can someone to compile this file for me ? Maybe it's something wrong with my PBP or WinXp or...I dont know....
    Thanks in advance !
    Attached Files Attached Files

  6. #6
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Re: Problems with 16F684

    Quote Originally Posted by fratello View Post
    Please, can someone to compile this file for me ? Maybe it's something wrong with my PBP or WinXp or...I dont know....
    Thanks in advance !
    I would be willing to compile your code with my PBP v. 2.6 compiler, and I tried to do so. But it won't compile without the include file "LCD_AnyPin.pbp" . If you can post the code to this include file I will give it a go for you.
    Regards, jellis00

  7. #7
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Problems with 16F684

    Thank You for help ! Mr.Darrel code can be found there : http://www.picbasic.co.uk/forum/cont...CD-on-any-pins

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