symmetric source code pic 16f877a


Closed Thread
Results 1 to 5 of 5
  1. #1

    Default symmetric source code pic 16f877a

    Best regards friends from Medellin Colombia


    I have developed the following code in pic basic pro in the trial version, I used in pic 16f877a, but I would like to change this pic for 16f887 to use the internal crystal, but I do not know how to change it in the code so that the program works with the pic 16f887.


    also on the lcd 20x4 blinks a lot the positive and negative voltage, I would like it to remain fixed on the lcd.
    It is very university project for digital electronics class, the compiler is very good to work microchip pics


    I hope and can help me friends and thanks

    code:

    include "fp2032.bas" ' Include file for 14-bit core with RAM at $20 (32-bit)


    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTE
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTE
    DEFINE LCD_EBIT 1
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2


    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_ SAMPLEUS 50




    LED VAR PORTB.6
    TXD VAR PORTC.6
    B1 VAR WORD
    B2 VAR WORD
    VALOR1 VAR BYTE
    VALOR2 VAR BYTE
    fpplaces var byte ' Used to define number of decimal places in fpdisplay,fpdisplayr
    ahold var word ' Required by fpdisplay
    bhold var word ' Required by fpdisplay




    STAR:
    TRISC.6 = 0
    TRISC.7 = 1
    TRISA = 255
    ADCON1 = %11000010
    TRISB.6 = 0


    LCDOUT $FE,2," SYMMETRY SOURCE "
    LCDOUT $FE,$C0," JOSE LUIS "
    LCDOUT $FE,$94,"VOLT.NEGATIVE:-"
    LCDOUT $FE,$D4,"VOLT.POSITIVE:+"
    STAR:
    ADCIN 1, B1
    ADCIN 2, B2


    SEROUT2 TXD,188,["$", "$", DEC4 B1,"$", "$",DEC4 B2,10,13]

    aint = B1
    gosub itofa
    bint = 2000
    gosub itofb
    gosub fpmul
    bint = 52224
    gosub itofb
    GOSUB fpdiv
    LCDOUT $FE,$A3," "
    LCDOUT $FE,$A3
    fpplaces = 2 : Gosub fpdisplayr ' Call display routine

    aint = B2
    gosub itofa
    bint = 35
    gosub itofb
    gosub fpmul 'ADCres * 35
    bint = 1024
    gosub itofb
    GOSUB fpdiv '(ADCres * 35)/1024
    LCDOUT $FE,$E3," "
    LCDOUT $FE,$E3
    fpplaces = 2 : Gosub fpdisplayr ' Call display routine
    HIGH LED
    GOTO STAR

    ' The fpdisplayr routine checks for number of places, then adds the appropriate
    ' value to achieve rounding. To save RAM space, the values are hard coded
    ' in floating point format.


    fpdisplayr: If fpplaces=0 Then ' Set floating point barg to 0.5
    bexp = $7E
    bargb0 = $00
    bargb1 = $00
    bargb2 = $01
    Endif
    If fpplaces=1 Then ' Set floating point barg to 0.05
    bexp = $7A
    bargb0 = $4C
    bargb1 = $CC
    bargb2 = $CD
    Endif
    If fpplaces=2 Then ' Set floating point barg to 0.005
    bexp = $77
    bargb0 = $23
    bargb1 = $D7
    bargb2 = $0B
    Endif
    If fpplaces=3 Then ' Set floating point barg to 0.0005
    bexp = $74
    bargb0 = $03
    bargb1 = $12
    bargb2 = $6F
    Endif
    If fpplaces=4 Then ' Set floating point barg to 0.00005
    bexp = $70
    bargb0 = $51
    bargb1 = $B7
    bargb2 = $17
    Endif


    Gosub fpadd ' add barg to aarg






    ' The fpdisplay routine outputs the signed value of aarg in decimal floating point format. It
    ' can display a positive value of 65535, and decimals to 4 places. The number of decimal
    ' places should be stored in fpplaces before calling the routine. The routine reads the
    ' floating point value of aarg. This value should NOT be converted to an integer before
    ' calling fpdisplay. The integer conversion will be perfomed as part of this routine, and
    ' aint will be returned to the calling program just as from the itofa routine.


    fpdisplay: bexp = aexp ' Store the FP value of aarg to the barg variables
    bargb0 = aargb0
    bargb1 = aargb1
    bargb2 = aargb2


    Gosub ftoia ' Convert aarg to integer
    ahold = aint ' Save this value for the final display

    Gosub itofa ' Convert integer back to float


    Swap aexp,bexp ' Swap the FP values of aarg and barg before subtraction
    Swap aargb0,bargb0
    Swap aargb1,bargb1
    Swap aargb2,bargb2


    Gosub fpsub ' Subtract the integer portion from the full number




    bint = 10 ' Make bint = 10 E fpplaces
    If fpplaces=2 Then
    bint = 100
    Endif
    If fpplaces=3 Then
    bint = 1000
    Endif
    If fpplaces=4 Then
    bint = 10000
    Endif


    bhold = bint ' Save the integer value of bint for zeros loop


    Gosub itofb ' Convert bint to integer prior to FP multiply
    Gosub fpmul ' Multiply the decimal portion x 10 E fpplaces


    Gosub ftoia ' Convert result to aint integer




    Lcdout dec ahold ' Display integer portion


    If fpplaces > 0 Then
    Lcdout "." ' Display decimal point


    zeros: bhold = bhold / 10 ' Set bhold to be next place to right
    If (aint < bhold) AND (bhold > 1) Then ' Check for leading zero in decimal
    Lcdout "0" ' Display leading zero
    Goto zeros ' loop to check for another zero
    Endif

    Lcdout dec aint ' Display the rest of the decimal portion


    Endif


    aint = ahold ' Restore the original value of aint


    Return

    :confuso:

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: symmetric source code pic 16f877a

    help dear friends with code with pic 16f887 please

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: symmetric source code pic 16f877a

    help dear friends with code for pic 16f887

  4. #4


    Did you find this post helpful? Yes | No

    Unhappy Re: symmetric source code pic 16f877a

    help dear friends with code for pic 16f887

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: symmetric source code pic 16f877a

    help dear friends with code pic 16f877a, replace the pic 16f877a with the pic16f887

    thank you jose

Similar Threads

  1. Help needed with source code
    By orangekitty in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th October 2010, 11:06
  2. need help in assembling a source code
    By mellifluous in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th September 2008, 07:56
  3. Please help ? RF Remote Source code
    By sorasit46 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2007, 15:40
  4. code source
    By meyou in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th August 2004, 22:01
  5. accessing source code
    By mle in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st July 2003, 15:25

Members who have read this thread : 1

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