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

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

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

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

  5. #5
    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 20:08.

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

  7. #7
    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
    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.
    Hey Ken,

    Congratulations on getting the donation! It is a great idea you have, and I am glad you have stuck with it. As for your newest stumbling block, what code are you currently using? You might be running into the same problem of not having a standard R/C output pulse going to the controller. And MIBAM will not work, because it is meant for lighting, and will confuse your speed controller even more.

    All analog servos (not the newer digital ones) use a standard protocol. A pulse width from about 0.9mS to 2.1mS or so, pulsed every 20 mS. Since this controller does not say digital on it, I would bet that it is analog, and works the same as all the servos in my house. Since it has reverse, as well as forward, I would bet that somewhere in between .9mS and 1.1 mS is neutral. Less is probably reverse, and more is forward.

    I don't think you need a manual for it. Just start feeding it some PWM that matches that protocol, and you will be good.

    Assembly is a tough nut to crack. It's just one of those things, the more you use it, the more you learn. But one of the things I learned this week from the forum, was that I could have an instant ASM interrupt without using any ASM. No, I didn't know that when I wrote some similar code for the 12f683. So in my example above, I only used two lines of assembly code. a BSF and a BCF. (Bit set and bit clear). So you can have almost no nuts with this code, or you can change them to PBP code if they drive you ... um ..... nuts.

    I think you already know this, but I just found the gif file, and I like it, so I'll post it here. - Walter

    Attached Images Attached Images  
    Last edited by ScaleRobotics; - 29th July 2010 at 17:04.

  8. #8
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    All analog servos (not the newer digital ones) use a standard protocol. A pulse width from about 0.9mS to 1.1mS or so, pulsed every 20 mS.
    I was always led to believe it was typically 1ms to 2ms with a 20ms frame rate this gave 1.5ms pw for centre stick, at least that's what I've always based my SSC type projects on.

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


    Did you find this post helpful? Yes | No

    Default I think this ESC is different

    I agree with both of you on the size, shape and frequency of standard PWM signals. I have been running my car (an older version of this same HPI Sprint) successfully for the last couple of months. With the exception of frequency my HPWM pulses agree with your specs. I found the correct HPWM commands by trial and error.

    This new Transmitter, Receiver, ESC combo is different. Leaving out my PIC for the moment if I on the radio transmitter I give full forward (trigger full back) and suddenly go to full reverse (trigger full forward) the car goes from full forward to stop (neutral in the PWM sense) and stays there until I bring the trigger to neutral for at least two seconds. Then giving it full back will work fine.

    Somewhere in the system is protection against slamming the DC motor with reversed polarities. That is good, but when I tried to emulate that system in my code it did not work.

    Thank you sooo much for your support and interest. Oh, yes, the electronic speed control wheel driving system is not a classic servo. Steering is. Wheels used to be - in the day - but no longer.

    Ken

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    I was always led to believe it was typically 1ms to 2ms with a 20ms frame rate this gave 1.5ms pw for centre stick, at least that's what I've always based my SSC type projects on.
    Edit: oops, yes I meant to say 2.1 as the highpoint, not 1.1. Thanks Malc!

    Hey Malc,
    Yeah, me too! As a basic rule it works. But then I built my first passthrough device, I built it for that range and it got discombobulated when the signals from my transmitter exceeded the 2 mS. My transmitter has endpoint adjustments, so it allows you to go beyond the 1 to 2 mS. Some transmitters will only give 1.1 to 1.9ms.

    Check out the HiTech web site regarding the signals:

    Quote Originally Posted by HiTech
    Q. What signal do servos require to operate?
    A. All Hitec servos require a 3-4V peak to peak square wave pulse. Pulse duration is from 0.9ms to 2.1ms with 1.5ms as center. The pulse refreshes at 50Hz (20ms).
    You are probably right, I just was not sure if a forward and reverse speed control would be centered at 1.5 mS. My planes don't have reverse.
    Last edited by ScaleRobotics; - 29th July 2010 at 17:04.

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


    Did you find this post helpful? Yes | No

    Default

    Usually an H bridge is used for forward and reverse. It is pretty much what you describe, only using two more fets. Microchip has an application note about one here: http://ww1.microchip.com/downloads/e...tes/00893a.pdf . It shows a nice diagram of the different states of forward and reverse on page 3.

    In your post, I don't understand the " It could steer the correct MOSFET signal with a third 'direction' output." part though.... Don't you steer with a servo?
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default Not the clearest I am

    When I wrote, "It could steer the correct MOSFET signal with a third 'direction' output."
    I was thinking of simplifying the speed control functionality by separating out the FORWARD and BACKWARD aspect. HPWM can easily create a PWM signal between one and two millisec. A second digital HIGH and LOW could dictate rotation direction. I've seen reference to something like this, but I did not think it through.

    Ken

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 13:55
  2. PBP Extensions, What are they?
    By PJALM in forum PBP Extensions
    Replies: 9
    Last Post: - 28th September 2021, 12: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, 20:01
  4. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th December 2005, 00:30
  5. Making PBP code more modular
    By forgie in forum General
    Replies: 30
    Last Post: - 25th October 2005, 17:24

Members who have read this thread : 2

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