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've got me started.

    There are plenty of machine cycles to do the math work and the control decisions. I think the 5 millisec interrupt timing should give me accurate timing for the PWM signals. I have no idea how much noise there is in the SONAR responses. I want to space them further apart in time so the trends are clear. Four triggers for each SONAR per second is my first guess.

    Now to bed. Thanks.

    Ken

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


    Did you find this post helpful? Yes | No

    Default I need more reference information

    Folks, I have been PBPing on a wing and a prayer (to quote an old WWII song). I need more
    reference material. I compiled Mackrackit's code and got the following error. I do not know
    where to go to chase it down.

    Error 118 c:/~~~.asm 67: Overwriting previous address contents(2007)

    Here's from the .asm file:
    66 ASM?
    67 __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
    68
    69 ENDASM?

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


    Did you find this post helpful? Yes | No

    Default

    Remove this line
    Code:
    @ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
    The above sets the configs in code space. You must be setting them in the *.inc file. Either way is good.

    To read more about it
    http://www.picbasic.co.uk/forum/cont...o-your-Program
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kenjones1935 View Post
    There are plenty of machine cycles to do the math work and the control decisions. I think the 5 millisec interrupt timing should give me accurate timing for the PWM signals. I have no idea how much noise there is in the SONAR responses. I want to space them further apart in time so the trends are clear. Four triggers for each SONAR per second is my first guess.

    Now to bed. Thanks.

    Ken
    Ken, I have been thinking about this, and IMHO the cleanest way may be to use 2 counters, one for the math/pwm, and 1 for the sonars
    -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

    Default It's working....

    The PWM development works. Clearly LED #7 grows in magnitude through eight counts of #4.

    The PWM is controlling the frequency of that signal's pulse. I do not unerstand
    how the prescaler and the 8Mhz clock create the slowly blinking LED4.

    KEn

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kenjones1935 View Post
    There are plenty of machine cycles to do the math work and the control decisions. I think the 5 millisec interrupt timing should give me accurate timing for the PWM signals. I have no idea how much noise there is in the SONAR responses. I want to space them further apart in time so the trends are clear. Four triggers for each SONAR per second is my first guess.

    Now to bed. Thanks.

    Ken
    I think once you have the PWM stuff sorted in your head, I feel like you may need to address this not knowing part. If your car is going a mere 10 mph, that's approx 14 feet per sec. If you only check each direction (front and side) four times a sec, your car will have traveled 3.5 feet!!! Ok maybe you are not going 10, but how bout 2 mph? That will still be 7.5 inches. At that rate, you will be correcting for things long past.
    Last edited by cncmachineguy; - 18th November 2010 at 18:09. Reason: Misread post, corrected math
    -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 2009
    Location
    Fitchburg, Mass
    Posts
    483


    Did you find this post helpful? Yes | No

    Default OMG you are correct.

    I have been forgetting that this car is capable of mph. Not just 10, but over 20. I am pushing some boundaries. I know nothing theoretical about control math. My gut tells me that knowing rate (ie trend) is of great importance -- somehow.....

    Ken

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


    Did you find this post helpful? Yes | No

    Smile Here's the spec WEB page.

    Here's the WEB page for my SONAR SF05.

    http://www.robot-electronics.co.uk/htm/srf05tech.htm

    It says:
    -10microsec trigger pulse
    -produces an 8 cycle burst of 40khz sound (total duration 5millisec)
    -can be triggered every 50millisec (20 per second)
    -the beam pattern is conical.

    Details! Details! Ain't technology grande!
    Ken

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


    Did you find this post helpful? Yes | No

    Default That's kinda what I do...

    cncmachineguy,

    I sort of tried to do what you say:
    goingforward:
    HPWM 1,Straight,50
    HPWM 2,Forward,50
    '-------------------
    keepgoingforward: '----Compare to right wall
    IF rangeright > outertrack THEN
    HPWM 1,QuarterRight,50
    ENDIF

    IF rangeright < desiredtrack AND oldrangeright < rangeright THEN
    HPWM 1,Straight,50
    ENDIF

    IF rangeright > desiredtrack AND oldrangeright > rangeright THEN
    HPWM 1,Straight,50
    ENDIF

    IF rangeright > desiredtrack AND oldrangeright < rangeright THEN
    HPWM 1,QuarterRight,50
    ENDIF

    IF rangeright < desiredtrack AND oldrangeright >= rangeright THEN
    HPWM 1,QuarterLeft,50
    ENDIF

    GOTO main
    I have three degrees of turning in each direction. My "oldrangeright" WORD is the previous reading of that SONAR. What I had not done was make this state machine "math" actually proportional. My present thinking is that with finer control I would get smaller oscillations.

    Ken

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


    Did you find this post helpful? Yes | No

    Smile Here's a big issue with the 16F887 and PBP

    I have avoided translating to digital any of my measurements. I have used > and <, but no actual arithmetic. To go proportional per the PID, requires that I do arithmetic. HEX or digital, that is the question. I'd like to think in digital, may I?

    I'm going to reveal my age. I wrote in machine language on the IBM 370 back in the last century. Well back in the last century. Since then it has been C, C++, shell, tcl. I am used to having a large library backup and writing in a modular fashion. Now it is PBP. I think I need to know more about ASM coding and the architecture of the PICs. What is the easiest (best) way to learn?

    Ken

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


    Did you find this post helpful? Yes | No

    Default I like the TIMER1 interrupt idea

    cncmachineguy, TIMER1 interrupt with a carefully chosen pre-set sounds good to me. I am not succeeding in figuring out how to do it. Page 32 in the 887 spec talks about PIE1. Page 70 talks about T1CON. I do not know where to look for an example.

    Is there a collection of PBP and ASM code samples? If so, where?

    Ken

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


    Did you find this post helpful? Yes | No

    Default

    Ken, the one I suggested earlier http://www.acroname.com/robotics/parts/gp2y0a21yk_e.pdf... well, I just read the timing chart on page 4, and believe it or not, this infra red sensor is slower than your sonar! But, the good part is, you wouldn't have to wait for one to finish, before sensing the other. It would be nice to find a faster response sensor, if possible though, to allow your car to measure under 20 ms (at least for the side).

    Here's a little bit about how they work http://www.societyofrobots.com/robot...p?topic=7991.0
    Last edited by ScaleRobotics; - 24th November 2010 at 05:40.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    Ken, can you give us a bigger snippet?
    Last edited by ScaleRobotics; - 23rd November 2010 at 03:13.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Smile Seems litte different than the HPWM technique

    I took my interrupt driven car to the gym this morning. It behaved about the same as my old HPWM design. When going slowly it just barely made the left turns at the corners. It did seem to go straight with less wiggle, but it still hit the wall occasionally.

    It appears that the problem is reaction time. My delving into an interrupt driven system was motivated by the guess that randomly (in time) changing the HPWM command might be confusing the electronic speed control. On this account I detect little difference.

    Another reason for regularly timed SONAR triggers was to take advantage of PID control. I have not coded that experiment. I am not convinced quicker reaction time will result.

    I partially solved the TOGGLE problem by inserting the following code right after 'main:'. This system does not toggle control between PIC and RC, but it does stop (Brake) the car when the radio transmitter is turned ON. It is not a nice picture - a 75 year old man running around a gymnasium trying to tackle an out-of-control RC car.

    The code samples channel3. This is the steering PWM signal from the car's radio receiver. There are pulses on that line as soon as the transmitter is activated.

    main:
    switchtoPIC = 2
    WHILE switchtoPIC >= 2
    COUNT channel3, 65, switchtoPIC
    WHEELS = Brake
    WEND

    I am not sure what to do now. The reaction time seems quick enough on the bench.

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


    Did you find this post helpful? Yes | No

    Default Serious problem...

    In order to make sense of interrupt driven controls I need to know which PBP commands are 'blocking'. Why? During the blocking time no PWM pulses and no SONAR triggers are being emitted.

    Ken

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


    Did you find this post helpful? Yes | No

    Default Infrared distance detector?

    Back a couple weeks one of you mentioned using infrared distance detector instead of a sonar detector. How do I find that posting? What was he product's name? How does it work? Or am I mistaken.

    Ken

  17. #17
    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
    In order to make sense of interrupt driven controls I need to know which PBP commands are 'blocking'. Why? During the blocking time no PWM pulses and no SONAR triggers are being emitted.
    Interrupts are the way around blocking commands. With interrupts, you can be listening for 4 separate pulses in, while pulsing 4 separate pulses out, while listening for the sonar ping, and blinking a few led's, etc, etc. With PicBasic commands alone, you are still stuck at pulsin, listening for a single pin for x duration. Don't get me wrong, blocking sounds so bad, but what it really does, is give the user a simple way do some complex things, with a single line of code. And without having to read about 50 extra pages of the data sheet. This is one of the best features of PicBasic. But there is a time for interrupts. Pulsin, Pulsout, PWM, serin, serout, freqout, count, debug, debugout are a few blocking commands.

    That said, they will not block an interrupt. An interrupt, does what it does best. It butts in an interrupts, gets out, and then whatever PicBasic command it was in the middle of completes.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    Up to this moment I have not seen any specifications of the cars.

    What speed they reach, how fast thay accelerate and how fast do they stop.

    If youhave this figures then you may do the calculations about reaction time and maximum speed to reach in order to hit the brakes in time, before crashing on the walls.

    Ioannis

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