How to generate 40MHz pulse with PWM command for my ultrasonic transmitter..please


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Let the weeding begin...
    It will be great when Bruce finishes his book. I will be doing some weeding then too
    Dave
    Always wear safety glasses while programming.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    It will be great when Bruce finishes his book. I will be doing some weeding then too
    $20 says that even when Bruce does finish the book, we'll still be answering the same questions over and over and over...and not because of a lack of information from the book.
    Maybe Bruce can include a couple of hands with each book.. ya know, for the user to hold while messing around with the PICs.

  3. #3
    Join Date
    Aug 2008
    Posts
    42


    Did you find this post helpful? Yes | No

    Default My tests

    I am working with the following code using the lcd to display distance with the Ping sensor.
    I am using the QL200 development board, so my DEFINE statements may be different or un-needed for you. My problem is that the ping sensor works,( I can see it on my oscilloscope),
    but I cannot get a reading on my lcd. Only 0.
    Any help would be appreciated!.

    ' File......sonar1.pbp
    ' Microcontroller used: Microchip Technology 16F887
    '--------Program Desciption--------
    ' Using the ping ultrasonic range finder,
    ' the distance from the range finder to an object
    ' is displayed on an LCD screen in inches.
    ' rb0 is signal in/out
    define osc 4
    adcon1 = %00000000
    define lcd_dreg portd
    define lcd_dbit 4
    define lcd_ereg porta
    define lcd_ebit 3
    dist var byte
    range var word
    inches CON 15 'Assigns the value 15 conversion
    pause 2000

    sonar 'Pulse Width
    pulsout 0,20
    pauseus 100
    pulsin 0,10,range
    dist = range/inches 'Converts raw sonar reading to inches
    LCDOUT $FE,1,"Distance"
    LCDOUT $FE,$14,#range
    PAUSE 2000
    GOTO sonar
    END

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,144


    Did you find this post helpful? Yes | No

    Default

    Try the DEIFINE's in capital.

    Ioannis

  5. #5
    Join Date
    Aug 2008
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    Tried capitalizing Define's but to no avail, you're right though they are supposed to be in capitol. Any other ideas??
    Last edited by Picstar; - 22nd September 2008 at 14:25.

  6. #6
    Join Date
    Aug 2008
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    You're right missing : in sonar label. According to the specs on the ping unit, there is a 750us pause called a "holdoff?". At any rate, I have tried it without a pause and have changed timing in the pulsin and pulsout commands, but still no luck. Using PBP 2.50b. heres the latest code:


    ' File......sonar1.pbp
    ' Microcontroller used: Microchip Technology 16F887
    '--------Program Desciption--------
    ' Using the ping ultrasonic range finder,
    ' the distance from the range finder to an object
    ' is displayed on an LCD screen in inches.
    ' rb0 is signal in/out
    adcon1 = %00000000
    define LCD_DREG PORTD
    define LCD_DBIT 4
    define LCD_EREG PORTA
    define LCD_EBIT 3
    dist var byte
    range var byte
    inches CON 15 'Assigns the value 15 conversion
    pause 2000

    sonar: 'Pulse Width
    pulsout portb.0,20
    pulsin portb.0,100,range
    'dist = range/inches 'Converts raw sonar reading to inches
    LCDOUT $FE,1,"Distance"
    LCDOUT $FE,$14,#range
    PAUSE 2000
    GOTO sonar
    END
    Last edited by Picstar; - 22nd September 2008 at 14:28.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Re-read the manual on the use of the pulsin statement.

    You say the unit has a 'holdoff' of 750us, and yet you originally used a pauseus of 100. What's up with that?

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    The define, in this case, won't make any difference since it's define osc 4, which is PBP default...

    Code:
    sonar   'Pulse Width
    How does that work? Is it a label? Is it a command? Is it a comment?

    Code:
    pulsout 0,20
    pauseus 100
    pulsin 0,10,range
    You wait for 100us instead of going straight to looking for a return pulse? How does THAT work? Shouldn't you jump directly to looking for the return pulse?
    Which version of PBP are you using?

Similar Threads

  1. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  2. PWM Pulse Amplitude on 16F877
    By jrudd in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th June 2009, 07:24
  3. Pulsin within subroutine
    By Wesley in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 10th January 2009, 23:05
  4. Replies: 3
    Last Post: - 13th September 2008, 17:40
  5. How to generate sine PWM using 16f877
    By kvrajasekar in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th September 2008, 08:40

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