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 Thanks, you got me started

    I have not been planning on adding sensors. I might change the SONAR for IR. I know nothing about the details.

    For speed I was planning on dividing distance traveled by time between measurements. For angles, I agree, the SONAR's have a vague and varying pattern. Hence the 'speed' calculations may be inconsistent.

    With the hobby level car I have complete proportional control of both steering and wheel power. If I could get a PWM system that is truly 50htz (my present system is not. It was calibrated by trial and error) then I would have a great deal of flexibility - the better to speed up the car. Then a parameter passing GOSUB would be very convenient.

    Ken

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kenjones1935 View Post
    I have not been planning on adding sensors.
    Then it sounds like PBP should be plenty powerful for your application. Only, I don't think you will be able to get into mapping, as there is no reference to where the car currently is. You could count turns, but once you miss or rather add a turn, then you are off. The only angle you could calculate, is the angle between the front location sensed, and the side position sensed in reference to being parallel with the car. You would not know whether this angle is being measured on a corner, or a straight away.

    If you want to use accurate servo, you could use some of the code already pointed out to you.

    (Ok, this one is kind of new, so no one suggested it yet)
    http://www.picbasic.co.uk/forum/cont...th-2-I-O-lines

    Back on post #336 of this thread:
    http://www.picbasic.co.uk/forum/show...1961#post91961

    Somewhere way back on this thread:
    http://www.picbasic.co.uk/forum/cont...e-Servo-Driver

    And suggested back on post #80 of this thread (though these later examples a lot better)
    http://www.picbasic.co.uk/forum/cont...-encode-decode
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default Re: PBP projects for R/C models

    Hi Ken,

    HPWM is hardware based, so it keeps going while other things happen.

    Check out the manual:
    It can run continuously in the background
    while the program is executing other instructions.

    You might try trouble shooting your output signal, to see what is happening.

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


    Did you find this post helpful? Yes | No

    Unhappy Yes, but................

    HPWM is a hardware command. It runs while PAUSE is pausing except (it appears) when it is the first "active" command in the code. Really. Truly. The only difference between those two snippets of code is the WHILE statement at the beginning of the one that works.

    Note: These few lines of code precede the 'main:' label. All I am trying to do is to demonstrate that the wheel controls are working before experimenting with racing. Once the program counter gets past 'main:' both versions run identically.

    Ken

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


    Did you find this post helpful? Yes | No

    Smile Telling time...

    I would like to read a TIMER immediately after sending a trigger pulse to my SONARS. Then immediately reset it for the next cycle. (Which TIMER am I not using with PAUSE or HPWM.) Anybody?

    I want to calculate velocity. I plan to subtract two SONAR distance readings and divide by the time elapse between triggers. Units of distance sound travels in a millisecond (13.2 inches) divided by the number of milliseconds. (Could do no translation: Use the distance sound travels in a 4Mhz tick divided by the number of those ticks between SONAR triggers.) Could I explain that to middle school students?

    I have not been translating SONAR echo pulses to inches. Instead I learned how to translate inches into SONAR echo times. That is how I set up my distance parameters. At 1100 feet per second that is 13.2 inches per millisecond. (When measuring distance the PIC must divide by two. It is measuring time for an echo response.)

    Any simple code snippets you know of?

    Ken
    Last edited by Kenjones1935; - 21st January 2011 at 21:52. Reason: error in calculation

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


    Did you find this post helpful? Yes | No

    Smile What I am trying to write is...

    I would like to use the 4 Meg counter to measure time in seconds and the SONAR responses to measure distance in inches.

    I could then set up CONstants that would be recognizable
    and measurable by middle school students with a yardstick and a watch with a second hand.

    How?

    Ken

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


    Did you find this post helpful? Yes | No

    Default

    This displays the sonar distance in inches. Using the "ping" module from Parallex.

    Code:
    '  18F6680
        DEFINE OSC 20
        @ __CONFIG    _CONFIG1H, _OSC_HS_1H
        @ __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
        @ __CONFIG    _CONFIG4L, _LVP_OFF_4L
        INCLUDE "modedefs.bas"
        DEFINE LCD_DREG     PORTG
        define LCD_DBIT     0
        DEFINE LCD_RSREG    PORTE
        DEFINE LCD_RSBIT    0
        DEFINE LCD_EREG     PORTE
        DEFINE LCD_EBIT     1
        DEFINE LCD_BITS     4
        DEFINE LCD_LINES    4
        DEFINE LCD_COMMANDUS    3000
        DEFINE LCD_DATAUS   150
        PAUSE 500
        PAUSE 1000
        
        INCONSTANT  CON 890
        INDISTANCE  VAR WORD
        TIME        VAR WORD
        
        START:
        HIGH PORTB.3
        PULSOUT PORTB.3,2
        PULSIN  PORTB.3,1,TIME
        INDISTANCE = INCONSTANT ** TIME
        LCDOUT $FE,1,DEC3 INDISTANCE," INCHES" 
        PAUSE 100
        GOTO START
    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

    Red face How do I make hex memory look digital?

    My robocars have no LEDs. They have no debugger and no break points. Using PICkit 2 I can read EEPROM. My code can write in that area using the WRITE command.

    When I have my car on blocks connected via the PICkit2 USB cable, I would like to do a READ and see in the EEPROM section some words that the code placed there while it ran represented as decimal numbers.

    hex includes the digits 0-9. Is there a library routine or a command to which I can give a WORD containing a positive hexadecimal number (for example the response from a SONAR) and it will return that number in decimal format represented with the digits 0-9 in least significant (as read by PICkit2) to the right?

    Ken

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


    Did you find this post helpful? Yes | No

    Default Re: PBP projects for R/C models

    Yes, but how are you checking to see that hpwm is not working, sometimes. Are you really observing the signal itself, or just the reaction it is "supposed" to cause? You have the tools to look at the source .... why not use them?

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


    Did you find this post helpful? Yes | No

    Unhappy I compile and run....

    I compile the code with the WHILE command. During the first three seconds after powering up the wheels steer and roll as expected. I then comment out the WHILE, recompile and program. For the first three seconds the car does nothing. The PAUSEs work but the HWPM commands do not.

    After the initial three seconds both programs work identically.

    Ken

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


    Did you find this post helpful? Yes | No

    Default Re: I compile and run....

    Quote Originally Posted by Kenjones1935 View Post
    The PAUSEs work but the HWPM commands do not.
    You really need to test the signal Ken. Without observing the signals, you really can't say HPWM doesn't work. How about getting your Pickit2 out and using the logic probe again?

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


    Did you find this post helpful? Yes | No

    Red face As usual good thinking.....

    Scalerobotics:

    I used the oscilloscope you gave me way back when. You are correct. The PWM signals appear to be there from the get go, but the wheels neither rotated nor steered until the program counter got past 'main:'.

    The pulse traces on the scope are stable and easily readable.

    All my fault - nothing new there - just between us programmers. I thought I had set PORTC.0 low with a TRISC = %11110000 when in fact I had set it to be an output. This is the pin that drives the DPDT switch that selects between PIC control and radio receiver control. Once I activated the LOW portc.0 located just before the HPWM commands. Lo and behold!

    Thank you for your patience and smarts.

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