Bit conversion


Results 1 to 12 of 12

Thread: Bit conversion

Threaded View

  1. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Hi lerameur,

    In your code piece here, first you are missing ENDIF. For now say it is there, then;

    Your variables are all decimal already.


    Also, say that Right = 5 and Left = 2.

    Then,

    IF Right > Left statement will be executed; then

    Temp = Right - Left
    (Temp = 3)
    Temp = Temp/Right
    (Temp = 3/5)
    (Temp = 0)
    Temp = Temp*254
    (Temp = 0)


    In this case, you will get TEMP as zero, because you will always be dividing a small number by a bigger number.


    Also, if you run your code alone, it will not give you any errors.

    Code:
    IF Right > Left THEN 'left and right are from sensor reading
        Temp =Right-Left
        Temp= Temp/Right
        Temp= Temp * 254
        HPWM 1,255-temp,1000
        HPWM 2,255,1000 
    ENDIF
    
    'No errors !!


    Thus, you should check the rest of your code. It seems that you have no problem with your IF statement.

    -------------------------------
    Last edited by sayzer; - 4th November 2006 at 16:22.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Doubt with interrupt on change
    By lugo.p in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th March 2010, 15:22
  3. Sleep Mode
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th March 2008, 10:31
  4. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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