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

    Smile Success - the wheels go round

    This PWM exercise is designed just for what I have done.

    http://www.melabs.com/resources/samples/pbp/hardpwm.bas

    After loading the .hex into the RC car (carrying my PICkit2), hooking up another battery and connecting CCP1 to the electronic speed control, The wheels spin!!

    Ain't technology grande!

    Ken

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


    Did you find this post helpful? Yes | No

    Default

    COOL!!!
    Another piece down!

    Did you get Walter's PWM reading code to work?
    If so then maybe now you can combine the two.

    If incoming PWM is X then wheels turn sort of thing?
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default How does PICkit 2 Logic Tool work?

    As I said, the wheels go round, but...

    The wheels are not going round and round in the pattern I expected. In particular they only go backwards. The code claims to sweep from 20% to 80% cuty cycle.

    SOOO, can I use my USB connection and PICkit 2 Logic and Analyze Tool to see what is actually happening?

    Ken

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    I believe you are using the PWM example here: http://www.melabs.com/resources/samples/pbp/hardpwm.bas

    This is a PWM that is not supposed to work with RC servo's. It's wave form is different. It is used to dim LED's etc. I am a little surprised that it can turn the wheels at all. I have a scope to help me view wave forms. I have tried for a few minutes to see what the pickit's logic tool can do, but I have not had any success. I am pretty sure it is just a problem with the operator (me).
    Last edited by ScaleRobotics; - 22nd January 2010 at 23:00.

  5. #5
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    This is what the program header says:
    Code:
    ' PicBasic Pro Program to demonstrate hardware PWM.
    ' Output is a 1Khz signal with duty cycle sweeping
    ' from 20% to 80% once per second
    Since the frequency is 1KHz, its period is 1mS. The duty cycle is sweeping from 20% to 80% therefore the pulse width is varying from 0.2mS to 0.8mS. There are 2 problems here. For R/C signals, the period should be 20mS or 50Hz. Second, the pulse width should be 1.5mS for neutral, 1.0mS for extreme left (or full reverse) and 2.0mS for extreme right (or full forward). So your car is responding to a very short pulse (even less than full reverse). You have to modify the values in the program to get it to do what you expect.

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


    Did you find this post helpful? Yes | No

    Default Thank you for your analysis

    Thanks gang.

    I came to much the same conclusion myself. I have been trying to figure out what exactly this PWM code does so that I can modify it meet the RC specs. The comments in the program are fairly clear. My first attempts have not worked but I am optimistic.

    Interesting how rusty my brain has become.

    Ken

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


    Did you find this post helpful? Yes | No

    Default All Right, I get it!

    Here is the code that makes the wheels spin.

    http://www.melabs.com/resources/samples/pbp/hardpwm.bas

    There are no PBP commands that overtly make pulses. They are created by appropriately loading CCP1CON and CCPR1L. I found CCP1CON easily enough. It is listed in the INDEX of the 16F887 Data Sheet. CCPRxL and CCPRxH are not in INDEX. They are quietly mentioned on page 127. But why is there no HPWM command per page 86 in the PBP manual?


    Although I see how this might be a low cpu overhead way to create PWM, I don't want to learn about this now. I want to use PBP and ASM commands to control my motor and servo. Maybe tomorrow all this will make sense.

    Ken

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


    Did you find this post helpful? Yes | No

    Default I need help

    The code in

    http://www.melabs.com/resources/samples/pbp/hardpwm.bas

    makes the wheels of my car go backwards in bursts. The bursts last, maybe 3/4 second then the wheels stop for a 1/4 second. I look at the code . I think that it is supposed to sweep through all pulse sizes in a second. I surmise the short ones are too short so the wheels don't move. As they get longer the come up near the low end of the electronic speed control spec. They start to move. Then the second is over.

    I would like to pump PWM pulses out CCP1 that have a frequency of one every 20 msec (50 per second) and a pulse width that I can (by changing the code) vary from 1 msec to 2 msec. Am I correct in guessing that the frequency of the pulses is dictated by the PAUSE command. One pulse per loop through mainloop:

    So far all my attempts have created no forward wheel motion at all! If one of you has the time please modify hardpwm.bas so that I understand it. Or, better yet, show me how to use PULSOUT. That does not work for me either.

    Ken

  9. #9
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    I gave you that info in post #44.

    Quote Originally Posted by rmteo View Post
    Since the frequency is 1KHz, its period is 1mS. The duty cycle is sweeping from 20% to 80% therefore the pulse width is varying from 0.2mS to 0.8mS. There are 2 problems here. For R/C signals, the period should be 20mS or 50Hz. Second, the pulse width should be 1.5mS for neutral, 1.0mS for extreme left (or full reverse) and 2.0mS for extreme right (or full forward). So your car is responding to a very short pulse (even less than full reverse). You have to modify the values in the program to get it to do what you expect.

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


    Did you find this post helpful? Yes | No

    Default Yes, we are all in agreement except..

    Thank you all for your help. I posted those quotes because they back up what you have been saying and what I thought I coded.

    Trouble is my PIC code only makes my car wheels go backwards and stop. I have not been able to create a PWM stream that drives the wheels forward. I know the ESC works because the wheels go fine under radio control.

    Oscilloscope, here I come.

    Ken

  11. #11
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Oscilloscope = Good!

    Quote Originally Posted by Kenjones1935 View Post
    Oscilloscope, here I come.
    Great idea Ken. I don't know how much you have modified hardpwm.bas, but here it is in it's native form. First pic is about 20 percent, and second pic is about 80 percent (of a 1ms pulse):





    You will notice that the min is about 0.2ms and max is 0.8ms.

    Your servo or speed controller requires a pulse width between 1.0ms and 2.0ms. It would probably like to see these pulses every 20ms or so, not every 1 ms (as seen here).

    And here is what you want it to look like (from my rc receiver):
    Attached Images Attached Images    
    Last edited by ScaleRobotics; - 26th January 2010 at 18:18.

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

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