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

    Talking Some successes

    Mucho frustrations followed by some successes. The PC board proto challenge is beyond me for now. Created instead a car that toggles itself between radio and PIC control without using a third radio channel and negotiates a maze that includes both right and left turns.

    The auto toggle is a function of the car being out in the clear - not in or too near the cardboard maze. The right and left turns were pretty obvious after numerous stupidities.

    I hope to post a video next week.

    Thanks again for all your support.

    Ken

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


    Did you find this post helpful? Yes | No

    Question Could use some suggestions

    I think the code is pretty solid. Now the problem is response time, size of maze passageways and RC car speed. A fraction of a second does not seem very long when the car is up on blocks, but it is enough time at speed to crash into a far wall when it should have detected a turning opportunity and done its thing.

    I think I need:
    1. Techniques using PICBASIC Pro for recording data in memory that can be read back into my PC for analysis. How do I do this? I have not the faintest idea what app to use.

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


    Did you find this post helpful? Yes | No

    Default

    This is a tough one.

    If the trouble is speed and timing then using more MCU cycles might make it worse.

    You can look at writing data to the on-board EEPROM.
    http://melabs.com/resources/samples/pbp/eeword.htm
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kenjones1935 View Post

    I think I need:
    1. Techniques using PICBASIC Pro for recording data in memory that can be read back into my PC for analysis. How do I do this? I have not the faintest idea what app to use.
    This thread might help:

    http://www.picbasic.co.uk/forum/arch...p/t-13317.html

    Regards,

    Anand

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


    Did you find this post helpful? Yes | No

    Default I think the PIC is plenty fast enough

    Thanks for your attention and replies.

    I think the PIC is plenty fast enough. I think the SFR05's are responding quickly enough judging from their flashing LED's. My guesses are either SFR inconsistencies and/or weakness in my jury rigged PWM signal.

    The servo and the speed control want PWM pulses at 50 per second. I have not been able to do that with my PIC. I get the pulse width correct, but I can not get the rep rate down to once each 20 millisec.

    Ken

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


    Did you find this post helpful? Yes | No

    Talking I think I've got it...

    The PIC KIT2 programmer has, at the bottom, reference to EEPROM. It has addresses 00 - FF.

    I think that if I use the PBP WRITE command at run time I can store data in the inchip EEPROM space. 00 to FF in size. I can then manually read this out with PIC KIT2 programmer.

    Sound correct??

    Ken

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


    Did you find this post helpful? Yes | No

    Default

    Sound correct??
    Yup, that will work.
    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

    Default A prototyping problem

    I need to be able to connect my PICkit 2 to three SRF05 sonar sensors. The easiest way would be to solder J or JR (or whatever - I do not know one connector from another) headers to the board.

    I looked carefully at the connectors that came with my radio control car. The pin separation does not match the hole separations in my PICkit 2 forty four pin demo board. Do any of you know the name of the connector header - if it exists - that would solder directly into that row of holes along the sides of my proto card? They are definitely not 1/10 inch centers. I have no means to measure their separation accurately.

    Ken

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


    Did you find this post helpful? Yes | No

    Default Servo pwm passthrough using PCPWM

    The 18F2431 makes it slightly easier to perform servo PWM because it's PCPWM module can go down to 19 htz while maintaining fast OSC rates, unlike other PIC chips HPWM. Here is an example of using the PCPWM to output 3 servo signals. This specific example senses the pulses (up to 5 channels) by using the CCP1 capture pin. To get 5 channels into one pin for PW capture, channels 1, 3 and 5 are input using small signal diodes. Then, since this drops the signal down to under 3 volts, I used two 2n3904 transistors. One to boost up the voltage, and the other one to invert the signal back to normal. (It was all I had lying around). Somehow, you will need to boost your signal after the diodes for the CCP1 capture to sense the incoming pulses.

    Note: Because the PCPWM was used, this will not work on any chip outside of the 18F2431 family.

    Code:
    ;This only works on a 18F2431 family device with Power Control PWM (PCPWM)
    ;By Scale Robotics Inc. 
    ; The input signal should look something like this:- 
    ;
    ;        |<------------------ 1 frame (~20mS) -------------->|
    ;        |<1~2mS>                                 
    ;         ______        ______        ______                  ______
    ; _______|      |______|      |______|      |________________|      |____
    ;   gap    ch1    ch2    ch3    ch4    ch5      sync  gap      ch1    etc
    define OSC 40
    asm
        __CONFIG    _CONFIG1H, _OSC_HSPLL_1H
        __CONFIG    _CONFIG2H, _WDTEN_OFF_2H & _WDPS_512_2H
        __CONFIG    _CONFIG4L, _LVP_OFF_4L
    endasm
    clear 
    ADCON0 = %00000000
    ADCON1 = %00000000
    portb=0
    trisb = %11000000
    trisc = %00000110
    trisa = %00000000
    DTCON = %00000101   'dead time for complimentary ouputs
    PTCON0 = %00001101  '1:1 postscale, Fosc/4 1:64 prescale, Sincle Shot mode
    PTPERL = 255        ' 
    PTPERH = 251
    PWMCON0 =%01010000  'PWM[5:0] ouputs enabled
    PWMCON1 = 1         'updates enabled, overrides sync w/timebase
    PTCON1 = %10000000  'PWM timebase is on, counts up
    FLTCONFIG = %00000010 'disable fault A, cycle by cycle mode
    CCP1CON = %00000101    'Capture mode; every rising edge
    
    duty1 var word        'width of outgoing pulse1
    duty2 var word  'duty values 625 to 1250 = 1 to 2 ms pulse (Center at 625)
    duty3 var word
    risetime1 var word    'Rise Time for incoming pulse1 
    risetime2 var word
    risetime3 var word
    falltime1 var word     'falltime for incoming pulse1
    falltime2 var word
    falltime3 var word
    pulsewidth1 var word    'pulse width for incoming pulse1
    pulsewidth2 var word
    pulsewidth3 var word
    pulsewidth4 var word     
    pulsewidth5 var word
    pulseNumber var byte
    pulseNumber = 1         'tells which pulse we are reading
    CCP1CON.0  = 1
    timerone var word 
    timerone = 60315 ;
    
    INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System 
    ASM
     
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR5_INT,   _PulseOut,   ASM,  yes
            INT_Handler   CCP1_INT,   _PulseMeasure,   ASM,  yes
            INT_Handler   TMR0_INT,   _TimeOut, ASM, yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
     
    T1CON = %00110001            ;Timer1 used by CCP1 capture
    T5CON = $01                  ;used as pulseout timer
    T0CON = %11000111              ; Prescaler = 8, TMR1ON
    
    @   INT_ENABLE  TMR5_INT     ; Enable Timer 1 Interrupts            
    @   INT_ENABLE  CCP1_INT      ; Enable Capture Compare for pulse width measurement
    @   INT_ENABLE  TMR0_INT    ; deadtime (sync gap) indicator for lull between pulses
    Main:
            pause 10
            'do something to these values if you want to filter, center, etc
            'Below we are just passing values through
            duty1 = pulsewidth1 >>1  'send channel 1 out PCPWM on PortB.1
            duty2 = pulsewidth3 >>1  'send channel 3 out PCPWM on PortB.3
            duty3 = pulsewidth5 >>1  'send channel 5 out PCPWM on PortB.4
    GOTO Main
     
    '---[TMR5_INT - interrupt handler]------------------------------------------ 
    PulseOut: 'set up pulse width values for pulseout and reset single shot bit
        TMR5L = timerone.byte0
        TMR5H = timerone.byte1
        PDC0L = duty1.lowbyte
        PDC0H = duty1.highbyte
        PDC1L = duty2.lowbyte
        PDC1H = duty2.highbyte
        PDC2L = duty3.lowbyte
        PDC2H = duty3.highbyte
        PTCON1.7=1  'resets single shot PTEN bit
    @    INT_RETURN
        
    '---[CCP1_INT - interrupt handler]------------------------------------------
    PulseMeasure:
    if CCP1CON.0  = 1 then ; Check CCP1M0 for rising edge watch
        select case pulseNumber
            case 1
                TMR0L = 0    'reset timeout timer0
                TMR0H = 0
                risetime1.lowbyte = CCPR1L
                risetime1.highbyte = CCPR1H
            case 2
                TMR0L = 0    'reset timeout timer0
                TMR0H = 0
                risetime2.lowbyte = CCPR1L
                risetime2.highbyte = CCPR1H    
            case 3
                TMR0L = 0    'reset timeout timer0
                TMR0H = 0
                risetime3.lowbyte = CCPR1L
                risetime3.highbyte = CCPR1H
        End select 
        @ BCF     CCP1CON, CCP1M0 ; Now capture the trailing edge     
    Else     'check for falling edge time
        @ BSF     CCP1CON, CCP1M0 ; Re-set for trailing edge capture
        select case pulsenumber
            case 1
                falltime1.lowbyte = CCPR1L
                falltime1.highbyte = CCPR1H
                pulsewidth1 = falltime1 - risetime1
            case 2
                falltime2.lowbyte = CCPR1L
                falltime2.highbyte = CCPR1H
                pulsewidth2 = risetime2 - falltime1
                pulsewidth3 = falltime2 - risetime2
            case 3
                falltime3.lowbyte = CCPR1L
                falltime3.highbyte = CCPR1H
                pulsewidth4 = risetime3 - falltime2
                pulsewidth5 = falltime3 - risetime3
        end select 
        pulsenumber = pulsenumber + 1 'get ready for next channel
            
    endif
    @    INT_RETURN
    '---[TMR0_INT - interrupt handler]------------------------------------------
    TimeOut:
        pulsenumber = 1 'if pause between pulse in exceeds about 7 ms, get ready
        'to receive pulse 1 (senses dead time between pulse bursts)
    @   INT_RETURN
    To see a similar project, but using SPWM, look here: http://www.picbasic.co.uk/forum/showthread.php?t=12657
    Last edited by ScaleRobotics; - 28th July 2010 at 19:08.

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


    Did you find this post helpful? Yes | No

    Default Thank you, Dave

    Yes, the 18F2431 looks like a winner for my PWM construction. It is included in my PICkit2 programmer.
    It comes in a 40 pin package. It would easily replace my 40 pin 16F887 on the solderless protoboard. To use it effectively I need to master ASM coding. I have not succeeded in cracking that nut.

    Here is my latest stumbling block. I have an arrangement with some folks who are willing to contribute brand new HPI Racing Sprint cars to my project. I received my first new car last week. HPI has drastically changed the Electronic Speed Control. This is the package that translates incoming PWM signals (from the radio receiver or from my PIC) into outgoing DC current for the motor that drives the wheels. I am not doing well with the HPI WEB site getting technical information about this SC-15 WITH REVERSE SPORT CONTROL.

    Ken

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


    Did you find this post helpful? Yes | No

    Default Cool chip for R/C PWM: 18F2431 series

    After reading about some of Bruce's cool projects with the 18F2431 series chips, I have been playing around with them for a little while. One thing that caught my eye is that they can do Power Control PWM as low as 19 hertz (while running at 40 mhz). Something you have to bring other chips OSC down to 0.5 mhz to do. This, and a few more of it's features, make it pretty nifty for creating PWM servo output. I mocked up a quick test, and have been able to do about 10bit PWM 1 to 2ms pulses at the proper 50 hertz spacing on 3 pins with the 18F2431. The larger chips of this series can do 4 pin PCPWM. I will post a little code once I get it cleaned up a bit.
    Last edited by ScaleRobotics; - 26th July 2010 at 18:15.

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


    Did you find this post helpful? Yes | No

    Question The new Electronic Speed Control is messing with my head

    I received a brand new HPI Racing Sprint car. This is the same model which I have been using. It is just the most recent version.

    I am having a problem with the new Electronic Speed Control a SC-15. It has some kind of mind of its own. My old code which told my old car where to go is not working with this new ESC.

    Do any of you have the contacts to get me the specs on this "SC-15 ESC WITH REVERSE SPORT CONTROL".

    Does is have a PIC? Is it programmable? What are its design algorithms?

    Ken

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


    Did you find this post helpful? Yes | No

    Default

    Since it doesn't have to be exact, you could simplify your code.

    Instead of:
    Code:
    Checkpot:
    adcin PORTA.0, Potread
    write 4, word Potread
    select case Potread
    case Potread < 36
    Forward = 112
    case Potread => 36 and Potread < 73
    Forward = 113
    case Potread => 73 and Potread < 109 
    Forward = 114
    case Potread =>109 and Potread < 146 
    Forward = 115
    case Potread => 146 and Potread < 182 
    Forward = 116
    case Potread => 182 and Potread < 219
    Forward = 117
    case Potread => 219
    Forward = 118
    end select
    write 2, word Forward
    something like:
    8 bit ADC:
    Code:
    Checkpot:
    adcin PORTA.0, Potread
    Potread = Potread/37
    Forward = Potread+112
    10 bit ADC:
    Code:
    Checkpot:
    adcin PORTA.0, Potread
    Forward = Potread/147 + 112
    Last edited by ScaleRobotics; - 2nd September 2010 at 16:15.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Smile Beautiful!!

    I chose your first suggestion:
    Potread = Potread/37
    Forward = Potread+112

    It works beautifully. Tomorrow I shall make a video of my car on blocks in its "going forward" state with me making it go faster and slower by twisting the pot's knob. At least I intend to do that tomorrow.

    THANK YOU!!!

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


    Did you find this post helpful? Yes | No

    Smile Did not work at all as planned....

    Sorry for the delay. I have been discouraged. The new HPI Sprint R/C car has an ESC-15 that thinks for itself. The HPI manufacturing/sales organization refuses to give me the behavioral specs. This is a STEM educational project. Not a by guess and by golly exercise in inductive reasoning.

    One solution is to make an ESC on my solderless proto board. (Complete with cooling fins?)

    My PIC (like the R/C receiver) makes appropriate PWM digital signals. The car wheels want appropriate PWM bi-directional current pulses. Have any of you seen a design I could copy?

    Ken

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


    Did you find this post helpful? Yes | No

    Default

    Here is some more info about StickOS with some youtube videos by the guy the wrote it. Pretty cool stuff.

    http://www.picbasic.co.uk/forum/show...9397#post89397
    http://www.scalerobotics.com

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