PBP projects for R/C models


Closed Thread
Results 1 to 40 of 772

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Ioannis,

    I let PBP and MPLAB install to their default directories, but my actual code and related project files are kept here.
    C:\MAC\My Dropbox\PIC PROGS\"project name here"
    Cad/CNC files and such are in a sub directory of the above.

    Another benefit from having an off site backup... My CNC machine's PC is also DropBoxed so the machine always has the latest files automatically.

    No problems with the path, the path name is still under the length limit this way.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    OK, Thanks Dave.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Red face Calling all Geeks......

    Ladies and gentlemen - I am bamboozled. My 1/10 toy level car seems to be a bit confused also. Garbage in. Garbage out. The old give-no-quarter rule of programming. Is the issue response time? Is the issue inconsistent friction? Is the issue - no it couldn't be - my PBP code? I believe the electronics are consistent and the hookup wires are stable ( I used Silicone household sealant)

    In the video I say, "As soon as it starts to turn right, it's in trouble." That now seems not to be the problem. After it successfully negotiates a corner-caused left turn and it is too close to the new wall, it turns left to get out to desiredtrack, but never straightens out.

    The code is at: http://www.employees.org/~kjones/ToyCarKickTurn4.htm



    Any insight would be greatly appreciated.
    Ken

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default my $.02

    Its really cool!! It has come a long way, in a very positive way.

    When its stuck, I see 2 distinct possibilities. the first time when the car was perpendiculer to the wall, my guess was it was too close, therefore the front sensor missed the echo. the second and third times, when it was trying to go forward into the wall, my guess is the angle was just right so as the reflection of the sonar bounced off the wall and kept going forward so the car thought it was all clear ahead.

    One time towards the beginning it ran head on into the wall. it went straight back, I am not sure if it bounced or if the car said reverse.

    Overall it seems like response time may be the issue. are you able to slow the car when the front is blocked and needs to turn? If so, maybe cut the speed to half when the front is blocked. then on the all clear go back to full ahead. I don't think the car is able to make the turn, check the front, check the side and continue forward.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Smile You might be absolutely correct.

    I suppose an echo has a significant energy distribution pattern which is a function of the angle on incidence. I do not know the physics but it certainly seems reasonable.

    Thank you!

    Ken

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    I don't know about all that, but if you stand at 1 focal point of a room made in an ellipse shape and wisper, someone standing at the other focal point can hear you clearly. Sonar is just sound, so it stands to reason it has to reflect like a pool ball.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    BATS
    Bat navigation....
    you are building a bat-car.
    Dave
    Always wear safety glasses while programming.

  8. #8
    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

    Hello Ken,

    Were you able to get your serial link going?

    Walter

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


    Did you find this post helpful? Yes | No

    Default

    You got it Ken. Your ICSP pins are RB7 and RB6. I think I have the definitions right for you. So you should be able to get it to talk pretty easy.
    Attached Images Attached Images  
    Last edited by ScaleRobotics; - 31st January 2011 at 01:54.

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Friction is sure a problem with your car along with others...

    Try to increase the friction with this simple idea.

    Cut from a kitchen glove the fingers and place the cut parts on your wheels. I think these will last for a test run, at least.

    With the increased friction you will get over the overturning of the car.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Smile Two steps forward....

    1. I cobbled together the working parts of two DELL 8600 lap tops and created one that works!! I installed the PBP tools and have a strong new battery. I will be able to modify my code in the building - sans electricity and heat - where I test.

    2. I found that putting a cardboard right up to the front SONAR makes it behave as if there is nothing within range. Sooo up real close is far away as far as it is concerned.

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


    Did you find this post helpful? Yes | No

    Talking Science, Technology, Engineering - not so much math

    Got a new video to show you all. The code is much the same as the last time. I included it below.

    The video speaks for itself. Would this be a good context for a public school engineering project? It certainly shows the real world as I know it. The kids could see whether they can make the car go around the room staying outside traffic cones which define the inside of the course.




    Code:
    '*************************************************  ***************
    SYMBOL trigright = PORTB.0 ' Define output pin for Trigger pulse
    SYMBOL trigfront = PORTB.1 ' Define output pin for Trigger pulse
    SYMBOL trigleft  = PORTB.3 ' Define output pin for TRigger pulse
    SYMBOL echoright = PORTC.6 ' Define input pin for Echo pulse
    SYMBOL echofront = PORTC.5 ' Define input pin for Echo pulse
    SYMBOL echoleft  = PORTC.7 ' Define input pin for Echo pulse
    SYMBOL radiotransmitterON = PORTC.4 ' Define input pin for Signal 
          'inside radio receiver indicatin that the transmitter has 
          'been turn on. Used to stop the car by turning ON the xmitter.
    TRISC = %11110000
    DATA $1C,$B5'This version's checksum goes here.
    ' Speed of sound echo is about 2mS per foot distance.
    ' define pulsin_max 2800 '28mS  SF05 spec says it drops at 30mS.  
    ' don't forget channel 3 every 20mS or 50Hz.
    '-------------------- 
    
    frontdanger CON 180 'about 12 inches. Was 450 about 30 inches 
    stopreversing CON 390' about 26 inches
    frontfree CON 1080 'about 72 inches.  Was 800 about 53 inches.
    desiredtrack CON 540 'about 36 inches. Now only one line. 
    'outertrack con 450 'about 30 inches. Was 360 about 24 inches
    
    SYMBOL turnon = PORTC.3 ' the signal that if HIGH makes the car steer straight
    SYMBOL steerto = PORTC.2 ' the signal that if on turning is on, then decides 
       'the direction
    SYMBOL stopgo =PORTC.1 ' the signal that if HIGH makes the car go
    SYMBOL forrev =PORTC.0 ' the signal that if on and is not on stop makes 
       'the car reverse
    
    '---------------------------
    rangeleft VAR WORD  'experimental timing.
    rangeright VAR WORD
    rangefront VAR WORD
    oldrangeright VAR WORD
    oldrangefront VAR WORD
    CNTR VAR WORD
    CNTR = 0
    CNTL VAR WORD
    CNTL = 0
    steeringstate VAR WORD
    steeringstate = 0 ' 0=straight,1=left,2=right,3=skid left,4=rightback,
    
    '--------------
    'Looks like I need to kick the steering back into straight.
    LOW stopgo 'stop
    HIGH turnon
    'pause 2000 'Wait so I can put the car down and get out of the way.
    
    main:
    GOSUB triggers 
    
    CheckIfInDanger:
    IF (rangefront < frontdanger) AND (steeringstate <> 3) THEN
     HIGH stopgo  'go
     LOW forrev 'back
     LOW turnon  'steer
     LOW steerto 'right
     steeringstate = 4
     GOTO reverseoutoftrouble
    ' loop till this is secured
    ENDIF 
    
    tryleftturn:
    IF rangefront < frontfree THEN
    'something ahead - turn hard left.
     'gosub leftforward
      IF (steeringstate <> 3) THEN
        HIGH stopgo    'go
        LOW forrev    'reverse
        LOW turnon    'steer
        HIGH steerto  'left
        steeringstate = 3 'skid left 
        PAUSE 150
       ENDIF
      HIGH steerto  'left 
      HIGH stopgo   'go
      HIGH forrev   'forward
      GOTO main 'Loop until secured
    ENDIF
     
    goingforward:                          
    keepgoingforward:
    
    IF (rangeright < desiredtrack) THEN
    'steer left
      CNTL = (CNTL+1)
      IF CNTL = 2 THEN
        LOW turnon   'steer
        HIGH steerto 'left
        steeringstate = 1
        HIGH stopgo   'go
        HIGH forrev   'forward
        CNTL = 0
      ENDIF
      PAUSE 150
    ENDIF
    
    IF (rangeright > desiredtrack)THEN 
    'steer right
      CNTR = (CNTR+1) 
      IF CNTR = 2 THEN
        LOW turnon   'steer
        LOW steerto  'right
        steeringstate = 2
        HIGH stopgo   'go
        HIGH forrev   'forward
        CNTR = 0
      ENDIF 
      PAUSE 150
    ENDIF
    
    IF steeringstate = 1 THEN 'left
      LOW steerto 'right
      PAUSE 100
    ENDIF
    IF steeringstate = 2 THEN  'right   
      HIGH steerto  'left
      PAUSE 60
    ENDIF  
    HIGH turnon
    steeringstate = 0
    GOTO main
    
    '-------------------------
     reverseoutoftrouble:
    ' below seems reduncant except for the pause.
    LOW turnon   'steer
    LOW steerto  'right
    steeringstate = 4 'new steeringstate
    HIGH stopgo  'go
    LOW forrev   'back
    PAUSE 200 'added to do some reversing. We have a problem of bumping
    'against the wall and not backing up.  This pause should fix that.
    
    keepreversing:
    WHILE (rangefront < stopreversing) OR ((oldrangefront = rangefront) AND (oldrangeright = rangeright))
    ' We have not reversed far enough
      HIGH stopgo  'go
      LOW forrev   'back
      PAUSE 250    'maybe this will get car to back off wall
      GOSUB triggers
    WEND
    
    '------------------------------------
    'done reversing.  Go straight or turn left depending on right 
    'ping. If > outertrack then out in the middle.  If < desiredtrack 
    'then stuck on wall. This did not work.  See TOY_CAR_KICK_TURN_3.wmv
    'Try no IF statement.
    'if rangeright > desiredtrack then 
    'steer left
      LOW turnon   'steer
      HIGH steerto  'left
      steeringstate = 1
      HIGH stopgo   'go
      HIGH forrev   'forward
      PAUSE 250
    'hpwm 2,Forward,50  --Already going Forward
    'endif
    GOTO main
    '--------------------------
    
    triggers:  ' Check two sonars and xmitter ON signal. 
    oldrangeright = rangeright
    ' produce 10uS trigger pulse (must be minimum of 10uS)
    LOW trigright
    HIGH trigright
    HIGH trigright
    HIGH trigright
    LOW trigright
    'zero could be legal below
    PULSIN echoright,1,rangeright 'measures the range in 10uS steps
    PAUSE 10 'Wait for ringing to stop - read SF05 spec.
    
    'pulsin echoleft,1,rangeleft  'see if this slows the triggers to one 
    'per second.  That it did, but it crashed straight into the wall.
    
    pulsf: 
    oldrangefront = rangefront 
    LOW trigfront
    HIGH trigfront
    HIGH trigfront
    HIGH trigfront
    LOW trigfront
    PULSIN echofront,1,rangefront ' measures the range in 10uS steps
    PAUSE 10 
     
    radioON:
    ' make ON = LOW for 1/10 toy car to radiotransmitter
    do WHILE radiotransmitterON = 0
    LOW stopgo
    loop
    HIGH stopgo 'get going again 
    RETURN  
          
    END

  13. #13
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Since you will have a Laptop with you, how about getting telemetry data from your car to analyze them? Like echo, steering acceleration/braking.

    Ioannis

  14. #14
    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

    Maybe the folks on the MPLAB C32 Compiler forum can help: http://www.microchip.com/forums/f204.aspx

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


    Did you find this post helpful? Yes | No

    Smile Hello everybody, I'm back

    I got the PICket 3 to program both my 16F887 and my 32MX460. That's fine, but I am not doing well with C. I have not programmed in C since 1992. In those days I was part of a large corporation that had a support staff.

    rich, you mention rd0 - rd4 on the PIC32. I was hoping to see reference of that kind of hardware detail in the PIC32C User's Manual. Nope. No mention of a MACRO either. I have to read the PIC32 Data Sheet? Oh dear....

    I am inclined to return to this forum and PICBASIC PRO and 16F887. To work with higher speeds my car needs to know better where it is and what it is doing. It needs some rate of approach calculations and a bit of trigonometry. It needs to increase the number of SONAR triggers per second and their attendant drive wheel and steering adjustments.

    I have not pushed the limits of the 16F887. I am not sure how to find them.

    Ken

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


    Did you find this post helpful? Yes | No

    Default

    Hi Ioannis,

    Yes, it takes TTL True, so Ken can do debug something like this for his setup:

    Code:
    DEFINE DEBUG_REG PORTB      'This is set to match the ICSP pins
    DEFINE DEBUG_BIT 7          'PIC sends data to the PC on this pin
    DEFINE DEBUGIN_BIT 6        'Can be used to receive data from the PC
    DEFINE DEBUG_BAUD 38400     'This is the highest baud rate Pickit2 can handle
                                'It seems to work ok with my 8 mhz stuff and higher
    DEFINE DEBUG_MODE 0         'Sets debug to True levels (1 for inverted)
    Last edited by ScaleRobotics; - 30th January 2011 at 22:08. Reason: Edited for Ken's hardware

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


    Did you find this post helpful? Yes | No

    Default The pin assignments

    My PICkit2 communicates with my PIC on its pins 4 and 5 already. Are you saying that after it is downloaded and running, my code can use the same USB wire to talk back to the PC? And I can display what it says using the DEBUG tool.

    Ken

  18. #18
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    As Walter stated, exactly that Ken!

    So, this is a great tool. I wonder why Pickit3 does not support this handy idea.... Mysterious way Microchip works...

    Ioannis

  19. #19
    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

    Here are some of the ones I know about. However, nothing is quite like the real thing. Especially when timing is important.

    See the bottom of the page.

    http://www.picbasic.co.uk/forum/cont...ctronics-links

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


    Did you find this post helpful? Yes | No

    Question How do PIC 16F887, PICBASIC PRO and Arduino relate?

    Looks interesting, but I do not understand..... VBB says it is Arduino oriented.

    "http://www.picbasic.co.uk/forum/content.php?r=95-Some-electronics-links" contains:

    "http://www.virtualbreadboard.com free, nice graphics, some bugs, and some rebooting reported
    Might work better with XP than newer Windows OS's."

    Ken

  21. #21
    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

    It's in there ... about 1/4 the way through.
    Code:
    ;****************************************************************
    ;* HPWM       : Output a pulse width modulated wave in hardware *
    ;*                                                              *
    ;* Input      : W = channel 1 - 5                               *
    ;*            : R1 = frequency                                  *
    ;*            : R4 = duty cycle                                 *
    ;* Output     : None                                            *
    ;*                                                              *
    ;* Notes      :                                                 *
    ;****************************************************************

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


    Did you find this post helpful? Yes | No

    Smile You're correct. It is there!

    I must have spelled HPWM wrong.

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


    Did you find this post helpful? Yes | No

    Default Simulation??

    PICs are often used for controls. Do you all know of any available simulation packages?

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