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 Thank you!!

    The pictures you attached match my mental picture of what I have created. First I modified the .bas to make consistant 1.35ms pulses. The PAUSE command creates the spacing in time. This drove the car quite fast backwards with no hesitations. Next 1.5ms. The wheels stopped. From that point I increased (not automatically) the pulse width up past 2ms to no avail. I never got the car wheels to turn forward.

    Where can I find the assembly language code for the Basic commands?

    I gather from reading the manual that PAUSE is not a pure interrupt driven behavior. I can not use that command if it shuts down the PIC between pulses.

    I have two plans.

    1. Study Assembly Language programming. I do not see enough explanation in the PBP manual to feel confident in what Basic Pro is actually doing. I should be able to get the PIC to better communicate to me what it is doing via the LED's.

    2. Attach CCP1 to the servo that steers the car instead of the drive wheels. I know what a servo is and I know this one works.

    3. Make the effort to find an oscilloscope. My only access at this time is the CS department at Fitchburg State College. I would rather not use them. I do not really know them that well.

    Ken

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


    Did you find this post helpful? Yes | No

    Default

    First I modified the .bas to make consistant 1.35ms pulses. The PAUSE command creates the spacing in time.
    The "Pause 17" lets you adjust how fast it moves from 20% and 80%. However, it does not adjust the pulse width, which is what you need to be adjusting. I can't explain why it works at all though, but it might be so confused from receiving pulses every 1ms, instead of every 20ms.

    Where can I find the assembly language code for the Basic commands?
    I suppose MeLabs could have just given us all the assembly code, but that probably does not make good business sense for the company. You can TRY to read some of the assembled code after you compile, but it looks a little jiberish. It is nameofyourfile.lst . Some people have suggested getting a dis-assembler, and disassemble the hex file ... but then I think you loose syntax then.

    I gather from reading the manual that PAUSE is not a pure interrupt driven behavior. I can not use that command if it shuts down the PIC between pulses.
    In my mind, an interrupt is better, as it will not stall your processing. Pauses can work well with servo's. I have not tried them much with motor controllers. The fact that the pulse code you were using sort of worked is encouraging for simplifying code, and staying away from interrupts.

    I have two plans.

    1. Study Assembly Language programming. I do not see enough explanation in the PBP manual to feel confident in what Basic Pro is actually doing. I should be able to get the PIC to better communicate to me what it is doing via the LED's.

    2. Attach CCP1 to the servo that steers the car instead of the drive wheels. I know what a servo is and I know this one works.

    3. Make the effort to find an oscilloscope. My only access at this time is the CS department at Fitchburg State College. I would rather not use them. I do not really know them that well.
    I count three plans ..... here is my personal take on them which might be worth less than two cents...

    Your plan 1 is for someone that really wants to learn all about each register and each bit, and what they control. This will require reading a lot of the 375 page datasheet. Picbasic takes care of a lot of these details for you, making it easier for most people to create useful projects in a much smaller amount of time. Yes, it masks many of these processes from you, but to me, this is a very good thing!

    Plan 2, good idea. I still do not think you are really creating 1.5ms pulses. Why don't you PM me your code, or post it here, and I will PM you back, or post here what I see on my scope using your code.

    Plan 3 See above.

    Why don't you try this code, just don't use the analog. Change pos value to change servo, or motor controller. It will give you an idea if it only does servo's or if your motor controller will like it.

    EDIT:

    Ok this code http://www.melabs.com/resources/samp...bp/servox2.bas
    Last edited by ScaleRobotics; - 27th January 2010 at 04:27.

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


    Did you find this post helpful? Yes | No

    Default I think I should take a different tack

    I am realizing that using PAUSE can not work if my PIC is meant to do some thinking between pulses. I just discovered

    http://darreltaylor.com/DT_INTS-14/SPWM.html

    He is using interrupts. That is what I was hoping to do in the first place. I'll see if I can figure out what he is saying.

    Meanwhile, would you be willing to take pictures of the pulses that my code is making if I posted the code?

    Ken

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


    Did you find this post helpful? Yes | No

    Default

    Sure! Post what you have, and I will send you some oscilloscope shots.

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


    Did you find this post helpful? Yes | No

    Default This drives the wheels very fast backwards.

    Scalerobotics:

    This snippet has the capabiltiy to increment the pulse size a little bit at a time.

    With this code the car starts out driving very fast backwards, then after five to ten seconds it stops, but never starts up forward.

    My theory is that the (PAUSE 20) is what is causing the 50 pulses per second, Is that correct?


    Code:
    duty	VAR	WORD		' Duty cycle value (CCPR1L:CCP1CON<5:4>)
    range   VAR word
    segment   var word 
    		TRISC.2 = 0				' Set PORTC.2 (CCP1) to output
    		CCP1CON = %00001100		' Set CCP1 to PWM 
    		T2CON = %00000101		' Turn on Timer2, Prescale=4
    
    ' Use formula to determine PR2 value for a 1KHz signal, 
    ' 4MHz clock, and prescale=4. (4E6/(4*4*1E3))-1=249
    '		PR2 = 249				' Set PR2 to get 1KHz out
    '		PR2 = 499				' Set PR2 to get 2KHz out
    	
    ' Use formula to determine CCPR1L:CCP1CON<5:4> value for
    ' ends of range 20% to 80%.  (249+1)*4*0.2=200 (20% value)
    ' (249+1)*4*0.8=800 (80% value)
    '       duty = 200	' Set duty cycle to 20%
    
           range = 25
           duty = 1650	' Set duty cycle to 1.65msec      
           segment = 0
    
    mainloop:	CCP1CON.4 = duty.0		' Store duty to registers as
    		CCP1CON.5 = duty.1		' a 10-bit word
    		CCPR1L = DUTY >> 2
    		Pause 20				' Pause 1/50 of second
           duty = duty + 2    ' Increase duty cycle
    
    
    
    
    		IF (duty < (1650 + segment + range)) Then mainloop	' Do it again unless 2 msec
    
    		duty = duty + 2				' Reset to 20% duty cycle
    
    		segment = segment + range
            
            PAUSE 2000      'Pause 2 seconds				
            
           	GoTo mainloop				' Do it forever

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


    Did you find this post helpful? Yes | No

    Default

    Here is the result. It changes from off through the percentage points to all the way on, but the period remains constant at about 1.023ms. (I finally got my oscilloscope USB driver to work today!)

    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default PAUSE has no effect it would seem

    Thank you soooo much. What a great tool..

    Two things for me to consider.

    1. PAUSE seems to not have the affect I expected.
    2. The PR2 constant must mean something to PBP, but I can not figure out what.

    Lastly, which version of oscilloscope software do you use? Is it freeware or did it cost money. If so, how much?

    Ken

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


    Did you find this post helpful? Yes | No

    Default Success!!!

    The following code makes the car go full speed backwards, then stop, then full speed forwards, then stop etc. Using the RC system I can control the motor continuously though varying speed. I have not yet figured what HPWM parameters produce various speeds to the ESC. It may be that the over-specification fast pulse frequency is overriding that nuance.

    To really discover what this is doing I need to study and understand the ASM code. I think HPWM is interrupt driven. I am concerned because page 87 of the PBP Manual seems to say that the slowest pulse frequency is 245 hz. I want 50 hz.

    Code:
    '****************************************************************
    '*  Name    : HPWMcommand.BAS                                   *
    '*  Author  : Ken Jones                                         *
    '*  Notice  : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 1/27/2010                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : PBP has a HPWM command.  Let's try it.                                                  *
    '*          :                                                   *
    '****************************************************************
    ' Don't forget. The duty cycle is 0 to 256 resolution
    MAINLOOP:
      HPWM 1,110,50     ' Neutral discovered by experiment.
      PAUSE 5000
      HPWM 1,64,50      ' Full backwards
      PAUSE 2000
      HPWM 1,110,50
      PAUSE 5000
      HPWM 1,164,50     ' Full forward
      PAUSE 2000
     goto mainloop

    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