Operator problem


Results 1 to 16 of 16

Threaded View

  1. #1
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Operator problem

    Hi ;

    I'm having an interesting problem with the following programme block ..

    Just to note that , The program works as written and compiled with it's current form below . I'm getting RB0 interrupts on every falling edge of PORTB.0 and when the programme goes to interrupt block it just clears the TMR1 register and RB0 int. flag and waits for the next RB0 interrupt by reading the INTF(RB0 int flag) continuously . . And when the INTF goes high (RB0 interrupt occurs) thus it leaves the while wend cycles and gets the variable in the TMR1 so that I can measure a period .. As I said , I can measure and display the period with this method ... But when It comes to calculating the revolutions per minute (RPM) with the ( * ) operator in the bold written code it just goes mad and misdisplays the RPM value on the screen ..

    What I wanna know is : Why the ( * ) multiplication operator doesn't work in the code below and how come the ( */ ) operator gives me the right result ??

    I mean let's say , time and rpm are word variables and time=19827 (us) , you know that 1 minute equals to 60 * 10^6 (us) = which is written in the form of 6000 * 10000 (just to state them both in word format)

    So : When we take ( */ ) operator the result is supposed to be

    6000*/ 10000 = 234375 (since the */ gives me the middle 16 bit of the result , as if we divide the result by 256)
    rpm=div32 19827
    result ===> rpm=11.82 thus "11"

    Both the project on breadboard and PROTEUS give me the correct result ( 3026 )

    How is that possible ? and why ( * ) operand doesn't work while it is supposed to work ?

    Thanks in advance !

    Code:
    '------
    DISABLE
    
    
    intblock:
    
    
    TMR1=0   
    INTF=0     'RB0/INT FLG
    
    
    WHile INTF=0
    @ NOP
    wend
    
    
    time=TMR1
    rpm=6000*/10000
    rpm=div32 time
    
    
    INTF=0'FLG
    
    
    resume
    
    
    enable
    '------
    Last edited by gunayburak; - 1st April 2014 at 18:08.

Similar Threads

  1. Can someone please explain the operator */
    By triton99 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th November 2011, 14:16
  2. // Division Operator
    By Dick Ivers in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th September 2011, 14:27
  3. Exponential Operator
    By andrewroz in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 31st October 2007, 08:00
  4. '*/' operator
    By jblackann in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th January 2007, 20:00
  5. math operator LOG
    By Eyal in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd July 2004, 23:45

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