Pulsin within subroutine


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Oversight or typo?

    Although I didn't try to completely understand the routine, I did notice something off...
    You have RETURN at the end of the start loop but don't see where it was GOSUB'd from. Is it suppose to be GOTO?
    Code:
    start:
    pulsin PORTB.1,1,widthx
    IF widthx >= 50 && widthx < 70 Then run_motor1 
    IF widthx >70 && widthx <90 Then Goto run_motor2
    IF widthx >90 Then
    Goto run_motor3
    Else
    Goto brake
    Endif
    Return
    Just a thought and not sure if it would even make a difference.
    Louie

  2. #2
    Join Date
    Jan 2009
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    I removed the return command, but I still can't get it to read the pulsin variable within the subroutine. It it impossible? What should I do?

    start:
    pulsin PORTB.1,1,widthx
    IF widthx >= 50 && widthx < 70 Then run_motor1
    IF widthx >70 && widthx <90 Then Goto run_motor2
    IF widthx >90 Then
    Goto run_motor3
    Else
    Goto brake
    Endif

    run_motor1:
    Low Brake1
    motor_dir = CW
    motor_speed = 50
    Gosub pwm_periods
    While (widthx >= 50 && widthx < 70)
    Gosub pwm_pulse
    Wend
    Goto start

  3. #3
    Join Date
    Jan 2009
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Charles you were right. I've always had issues with the PWM command, but following your comment I re-wrote the program using PWM, and now I have no problem. Thanks!

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 02:17
  2. Better understanding PULSIN
    By Wirecut in forum mel PIC BASIC
    Replies: 12
    Last Post: - 29th June 2008, 10:17
  3. Funny PULSIN values: what is going on???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th April 2008, 08:02
  4. Pulsin 16F819 problem
    By rekcahlaer in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th April 2007, 13:52
  5. PULSIN and RCTIME
    By Dwayne in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th November 2004, 14:45

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