Problem with Div32


Results 1 to 6 of 6

Threaded View

  1. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    hi,

    all my variables are word variables: here is the full program, except for the overhead:

    '///////////////////////////////////////////////
    '// Variable Declaration and initialization //
    '///////////////////////////////////////////////

    oldcounter var word
    counter var word
    gauss var word
    gauss1 var word
    dummy var word
    test11 var word
    test22 var word
    test3 var word
    difference var word

    counter = 0
    oldcounter =0
    gauss1 =0

    '//////////////////////////
    '// Program starts here //
    '//////////////////////////

    loop:

    ADCON0.2 = 1 'Start A/D Conversion
    oldcounter = counter

    ADCIN 0, counter 'Read channel PORTA.0
    pause 30

    'Reducing the varying output (average)
    counter = (counter + oldcounter) / 2

    '************** Condition 1 ***********************
    if counter == 126 then
    lcdout $FE,1, " Neutral ",dec counter
    lcdout $FE,$C0, "Gauss: ", dec gauss1
    endif

    '************** Condition 2 ***********************
    if counter > 126 then 'GOOD CALCULATION
    dummy=(counter *10000)
    test11= div32 506

    dummy =0

    dummy=(126 * 10000)
    test22=div32 506

    test3=test11-test22

    gauss= test3 / 25
    gauss1= test3 // 25

    lcdout $FE,1, "1:",dec test11," 2:", dec test22," 3:", dec test3
    lcdout $FE,$C0, "C:", dec counter, "G:", dec dummy

    'lcdout $FE,1, " Negative S: ",dec counter
    'lcdout $FE,$C0, "Gauss: -", dec gauss,".", dec gauss1
    endif
    Last edited by Darrel Taylor; - 22nd April 2008 at 02:31. Reason: Highlight

Similar Threads

  1. RPM - DIV32 Problem
    By davewanna in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 11th April 2008, 04:33
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  3. 32-bit Variables and DIV32, Hourmeter 99999.9
    By Darrel Taylor in forum Code Examples
    Replies: 9
    Last Post: - 23rd November 2006, 07:23
  4. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59
  5. Retrieving Div32 Remainder
    By Darrel Taylor in forum Code Examples
    Replies: 4
    Last Post: - 20th August 2003, 03:53

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