PBP projects for R/C models


Closed Thread
Results 1 to 40 of 772

Hybrid View

  1. #1
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kenjones1935 View Post
    First, my oscillator. I have been using the 16F887's internal oscillator. I think if I do nothing my prescaler is set at 4:1. The PIC has an 8mhz internal oscillator. Figure 4-1 on Page 61 of DS41291F (the x887 gospel) indicates that by setting OSCCON = %01110111 I can get the internal 8mhz oscillator and the prescaler of 1:1. Does this seem correct to you all? I will try this evening.

    Ken
    The oscillator (whether internal or external) frequency is always divided by 4 in these PIC's to get the instruction clock - it does not have anything to do with pre-scalers. Also, OSCCON.3:1 is read only.

  2. #2
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Yep, you got it. But no point in setting bits 1&2... they're read only.
    This is what I use to set the 16F887 to 8MHz.:
    OSCCON = %01110001 'Set Osc to 8MHz.

    And don't forget to add to your define list: DEFINE OSC 8


    For external xtal you will need a 20MHz crystal connected to OSC1 & OSC2 (RA7, RA6) and a small capacitor from each pin to ground. The recommended capacitor size will be in the xtal data sheet, but is typically a couple dozen pF or less.

    steve
    Last edited by Byte_Butcher; - 4th April 2010 at 02:45. Reason: don't forget to add DEFINE OSC 8

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


    Did you find this post helpful? Yes | No

    Default

    When bumping up to 8MHz try
    Code:
    pulsout trigfront,1
    That should give you 5uS trigger. I was doing 4.

    For external OSC I like ceramic resonators, good and bad to everything but with these you do not have to mess with capacitors, that is why I like them.
    http://www.allelectronics.com/make-a...ATORS/-/1.html
    The two outside pins will go to RA6 and RA7, the center to the zero rail (ground).
    The problem with the 44 pin demo board is Micro Chip did not "ground" the via between RA6 and RA7, so you will have to run a jumper if you go this route.
    Attached Images Attached Images  
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default It surely did change the behavior.

    Bed time here on the east coast.

    I tried both
    OSCCON = %01110111
    and
    OSCCON = %01110001

    I got the PIC to read the PWM signal from the radio channel 3 by doubling the threshold for differentiation. I can toggle between PIC and radio control.

    But I have not been able to get the HPWM to behave. I tried using the original duty cycle. This made the wheels go backwards very fast no matter what was in the HPWM command. I tried doubling the duty cycle (to account for cutting in half the clock rate and the wheels did not turn at all. The Electronic Speed Control wants this PWM signal to arrive at 50 hz. In fact it is probably at 489Hz (according to page 87 of MicroEngineering Labs' PICBASIC PRO book). I'll put a 'scope on it tomorrow.

    I think the book says that HPWM channel, 127, 50 will be a square wave of 489Hz. Does that agree with you guys' thinking?

    I also have not gotten the PING echos to mean anything. The little red lights on the SRF05s are blinking. But my code is not making sense of the echo responses. I thought that all I would need to do was to double the expected echo pulse duration numbers.
    Ken

  5. #5
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kenjones1935 View Post
    Bed time here on the east coast.

    I tried both
    OSCCON = %01110111
    and
    OSCCON = %01110001

    I got the PIC to read the PWM signal from the radio channel 3 by doubling the threshold for differentiation. I can toggle between PIC and radio control.

    But I have not been able to get the HPWM to behave. I tried using the original duty cycle. This made the wheels go backwards very fast no matter what was in the HPWM command.
    did you add :

    DEFINE OSC 8

    to your code somewhere near the top?
    Otherwise the PIC thinks you're still running at the default 4MHz.


    steve

  6. #6
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kenjones1935 View Post
    The Electronic Speed Control wants this PWM signal to arrive at 50 hz.

    Ken
    No matter how you cut it, to get 50Hz (20mS period) using hardware PWM, the maximum clock frequency you can use is 0.819MHz (819KHz)
    Attached Images Attached Images  
    Last edited by rmteo; - 4th April 2010 at 04:55. Reason: - typo in numbers.

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


    Did you find this post helpful? Yes | No

    Default

    Darn,
    I thought the SRF05 was the same thing as the PING. Now I see that the SRF05 takes a different trigger pulse.

    So it looks like I just wasted your time on that part.

    I guess on the good side rmteo noticed another possible problem.

    I wonder if a While/Wend loop using PWM would be the answer?
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default PWM per Electronic Speed Control specs.

    Originally Posted by Kenjones1935 View Post
    The Electronic Speed Control wants this PWM signal to arrive at 50 hz.

    I was not clear in my last posting. The Electronic Speed Control PWM specification is for a single positive pulse no less than 1ms and no more than 2ms once per 20 ms, ie 50 pulses per second. The one to two millisecond pulse width is divided into 256 parts. 1.5 ms corresponds to 128 which corresponds to neutral in a servo.

    Neutral is steering straight on a steering servo. Neutral is stopped on a wheel driving servo.

    I discovered that using HPWM with the 4mhz default oscillator a pulse width of 100 to 110 gets the behavior of 'neutral' on my car. For example "HPWM 1, 100, 50" turns the front wheels of my car to straight. See the attached picture. Channel 2 is the HPWM version of neutral. Channel 3 is what the radio receiver sends.

    Ken
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Talking Progress - er, at least using my head.

    I have found a way to make short, 10 to 80 usec pulses while using the 4mhz oscillator. The SRF05 proximity detector wants at least 10 usec. If I give it super long pulses catching the following echo measurement can be a problem for PULSIN.

    Sooo the following makes an 80 usec positive pulse.

    SYMBOL trigright = PORTB.0
    LOW trigright
    HIGH trigright
    HIGH trigright
    HIGH trigright
    LOW trigright.

    One thing at a time.

    Ken

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