16LF1824 strange problem


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: 16LF1824 strange problem

    Its very strange! If I use the same variable in init and in main(another loop), no work properly. If I use different variables, work great. Totally mistake!

    Code:

    varb var byte
    vara var byte
    x var byte
    divf var byte
    divf = 0
    varb = 0
    vara = 0
    x = 0
    pause 200

    init:
    pulsin portc.2 , 1, vara
    if vara < 140 or vara > 160 then init
    pause 100
    pulsin portc.2 , 1, vara
    if vara < 140 or vara > 160 then init
    if vara > 140 and vara < 160 then goto beep
    goto init

    beep:
    hpwm 1 , 10, 3000
    high front
    pause 80
    low front
    pause 200
    hpwm 1 , 5, 1200
    high front
    pause 80
    low front
    pause 200
    hpwm 1 , 10, 3000
    high front
    pause 80
    low front

    main:
    pulsin portc.2 , 1, varb

    hpwm 1 , x, 1954

    '========================miss signal===========================
    if varb < 50 then
    varb = 150
    x=0
    low front
    endif
    '================================================= =============

    if varb> 160 then
    high front
    divf=255*(varb-160)/30
    if varb > 190 then varb = 190
    if x > 255 then x = 255
    if divf > x then x=x+2
    if divf < x then x=x-6
    if x < 15 then x=15
    endif

    if varb < 160 and varb > 140 then
    low front
    x = 0
    endif
    goto main
    end
    Last edited by midali; - 20th August 2014 at 10:18.

Similar Threads

  1. A strange problem
    By mombasa in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 25th January 2012, 21:08
  2. Very strange problem...
    By alanmcf in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th May 2011, 06:28
  3. strange serout2 problem
    By KaanInal in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th January 2010, 09:33
  4. Strange problem with PBP 2.50
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th October 2007, 20:45
  5. strange problem 12f675
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th July 2007, 13:47

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