16LF1824 strange problem


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: 16LF1824 strange problem

    Quote Originally Posted by midali View Post
    I tried your code...the same. But is something what I don't understand ... I used 2 different variables and work great . It don't work if I use the same variable ! Today I'll try initialisation from Alain's code. In this moment my code work good, but I want to understand whats happen inside.

    Code:
    varb var byte
    vara var byte
    varb = 0
    vara = 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:
    pulsin portc.2 , 1, varb
    ....code....
    goto beep
    1000 x THX
    Are you saying the init routine works but beep does not work if vara is used but does work if varb is used?
    If so I am puzzled.
    Can you post the code in beep?

  2. #2
    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 : 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