PBP projects for R/C models


Closed Thread
Results 1 to 40 of 772

Hybrid View

  1. #1
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483


    Did you find this post helpful? Yes | No

    Default PULSIN sets the register to zero!

    I wrote a snippet of code that:

    1. set the 'range' registers, rangeright and rangefront, each to 1
    2. gosub blinkloop01 if the 'range' registers are both 1
    3. do the pulsout, pulsin exercise
    4. gosub blinkloop45 and blinkloop67 if the range registers are 0

    I ran the code. The LED's told me that pulsin is loading the range registers with 0. Why??

    ---------start code-----------
    symbol trigright = PORTB.0 ' Define output pin for Trigger pulse
    symbol trigfront = PORTB.1 ' Define output pin for Trigger pulse

    symbol echoright = PORTB.2 ' Define input pin for Echo pulse
    symbol echofront = PORTB.3 ' Define input pin for Echo pulse

    rangeright var word
    rangefront var word
    rangeright = 1
    rangefront = 1

    if rangeright = 1 and rangefront = 1 then
    gosub blinkloop01
    endif

    main:

    DEFINE PULSIN_MAX 65535
    pulsout trigright,2
    pulsin echoright,1,rangeright

    pulsout trigfront,2
    pulsin echofront,1,rangefront
    pause 10 ' recharge period after ranging completes

    '*****test for zeros******
    IF rangeright = 0 then
    gosub blinkloop45
    endif
    if rangefront = 0 then
    gosub blinkloop67
    endif
    goto main:

    ------------end code----------

  2. #2
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483


    Did you find this post helpful? Yes | No

    Default Is there a robotics good forum?

    Maybe a PICBASIC robotics forum would know what is wrong with my PULSIN. They are always dealing with sensors.

    Suggestions?

    Ken

  3. #3
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483


    Did you find this post helpful? Yes | No

    Default Last picture for tonight

    Channel 2 is PULSOUT.
    Channel 3 is the corresponding PULSIN.

    PULSOUT is waaayyy to long. It is supposed to be 20 microseconds since I am using the 4meg oscillator and my command is

    PULSOUT trigfront 2

    PULSOUT is about 14 millisec according to the LOGIC TOOL. See picture. Oops. The forum won't honor my request to upload the picture. You'll have to take my word for it.

    Any ideas?

  4. #4
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483


    Did you find this post helpful? Yes | No

    Default Could it be as simple as the choice of input pin??

    I chose, by flipping a coin, to have my PULSIN inputs on pins PORTB.2 and PORTB.3.

    Is it possible that these pins can not accept pulses for width measurement? I read a two year old posting that seemed to say by changing his PULSIN pins from PORTA to PORTC everything suddenly worked. He was having the same problem as I. The pulse is on the pin, but the PIC does not act upon it.

    KEn

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Ken, Are you still using 16F887. If so PortB is lousy with analog functions, just waiting to be disabled.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483


    Did you find this post helpful? Yes | No

    Default I don't understand

    Joe,

    Are you saying that all I need to do to use PORTB is figure out how to appropriately configure it?

    If so, please give me a hint? I am soooo close.

    Ken

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kenjones1935 View Post
    Joe,

    Are you saying that all I need to do to use PORTB is figure out how to appropriately configure it?

    If so, please give me a hint? I am soooo close.

    Ken
    Ken,
    I am not an expert on pulseout or pulsein, and I have not read the manual lately, but I believe they are digital commands, which by default should require you to disable the analog functions on the pin you are using.
    On this chip you have,
    ADCON0
    ADCON1
    ANSEL
    ANSELH
    CMCON0
    CCP1CON
    CCP2CON
    CM1CON0
    CM2CON0
    CM2CON1 and a couple more which all have effect on the I/O. Get into the data sheet and read about them, they are all listed in the index of the data sheet, and see how to set them up. Remember if a bit is SET it is a 1 if cleared it is a 0.
    When you come out of the data sheet you will be a much more "Savy" programmer.
    Last edited by Archangel; - 2nd March 2010 at 15:26.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. PBP Extensions, What are they?
    By PJALM in forum PBP Extensions
    Replies: 9
    Last Post: - 28th September 2021, 11:26
  3. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 19:01
  4. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th December 2005, 23:30
  5. Making PBP code more modular
    By forgie in forum General
    Replies: 30
    Last Post: - 25th October 2005, 16:24

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