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

    Ken,
    I do not know anything about RC stuff, but here is something to play with.
    Code:
    <font color="#000080"><i>'16F887 INT RUPT
    '44 PIN DEMO BOARD
       </i></font>@ <font color="#0000FF"><b>__config _CONFIG1</b></font>, <font color="#0000FF"><b>_INTRC_OSC_NOCLKOUT </b></font>&amp; <font color="#0000FF"><b>_WDT_ON </b></font>&amp; <font color="#0000FF"><b>_MCLRE_OFF </b></font>&amp; <font color="#0000FF"><b>_LVP_OFF </b></font>&amp; <font color="#0000FF"><b>_CP_OFF
       INTCON</b></font>.<font color="#800000"><b>5 </b></font>= <font color="#800000"><b>1    </b></font><font color="#000080"><i>'ENABLE TMR0  DATA SHEET SECTION 14.3.2
       </i></font><font color="#0000FF"><b>OSCCON </b></font>= <font color="#800000"><b>%01110000 </b></font><font color="#000080"><i>'8 Mhz
       </i></font><font color="#0000FF"><b>OPTION_REG </b></font>= <font color="#800000"><b>%10000111  </b></font><font color="#000080"><i>' 1:256 PRESCALE
       </i></font><font color="#FF0000"><b>ON INTERRUPT GOTO </b></font><font color="#0000FF"><b>TLOOP
       CNT  </b></font><font color="#FF0000"><b>VAR BYTE
       </b></font><font color="#0000FF"><b>D    </b></font><font color="#FF0000"><b>VAR BYTE
       </b></font><font color="#0000FF"><b>D </b></font>= <font color="#800000"><b>0
       
       </b></font><font color="#0000FF"><b>START</b></font>:
       <font color="#FF0000"><b>FOR </b></font><font color="#0000FF"><b>CNT </b></font>= <font color="#800000"><b>0 </b></font><font color="#FF0000"><b>TO </b></font><font color="#800000"><b>150
       </b></font><font color="#FF0000"><b>PWM </b></font><font color="#0000FF"><b>PORTD</b></font>.<font color="#800000"><b>7</b></font>,<font color="#0000FF"><b>D</b></font>,<font color="#800000"><b>100
       </b></font><font color="#0000FF"><b>D </b></font>= <font color="#0000FF"><b>D </b></font>+ <font color="#800000"><b>2
       </b></font><font color="#FF0000"><b>NEXT </b></font><font color="#0000FF"><b>CNT
       </b></font><font color="#FF0000"><b>GOTO </b></font><font color="#0000FF"><b>START
       
       </b></font><font color="#FF0000"><b>DISABLE
       </b></font><font color="#0000FF"><b>TLOOP</b></font>:
       <font color="#0000FF"><b>INTCON</b></font>.<font color="#800000"><b>2</b></font>=<font color="#800000"><b>0 </b></font><font color="#000080"><i>' DATA SHEET SECTION 14.3.2
       </i></font><font color="#FF0000"><b>TOGGLE </b></font><font color="#0000FF"><b>PORTD</b></font>.<font color="#800000"><b>4
       </b></font><font color="#FF0000"><b>RESUME
       ENABLE
    </b></font>
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default Why is the pulse width jumping all over?

    I had earlier success in getting a servo pulse width to be smooth on a Pic18F2520. But I am now trying to make DT_INTS servo pulse width for a PIC12F683. I have it sweeping from about .95ms to 1.9 ms, but it is not smooth at all. In fact, on the scope, it sometimes switches direction (starts to get wider instead of narrower for a fraction of a second). It is pretty darn ugly in fact.

    Any ideas what I might have done (or not done) to cause this?

    PIC12f683
    Code:
    </i></font><b>DEFINE </b>OSC 8
    <b>INCLUDE </b><font color="#FF0000">&quot;DT_INTS-14.bas&quot; </font><font color="#000080"><i>;interrupt routines
    </i></font><b>INCLUDE </b><font color="#FF0000">&quot;sub16.inc&quot;       </font><font color="#000080"><i>; subtract 16 bit macro
    
    </i></font><b>DEFINE </b>DEBUG_REG	GPIO
    <b>DEFINE </b>DEBUG_BIT	0
    
    <b>DEFINE </b>DEBUGIN_BIT	1
    <b>DEFINE </b>DEBUG_BAUD	38400
    <b>DEFINE </b>DEBUG_MODE	0
    
    INTCON = %10101000 <font color="#000080"><i>'internal oscillator
    </i></font>OSCCON = %01110000 <font color="#000080"><i>'set for 8mhz internal
    </i></font>CMCON0 = 7 <font color="#000080"><i>'TURN COMPARITORS OFF
    </i></font>TRISIO = %010000 <font color="#000080"><i>'Set GSIO 4 INPUT, others to OUTPUT
    </i></font>OPTION_REG = %11000010
    T1CON = %01000001
    T2CON = %01001110
    servo <b>VAR </b>GPIO.2
    servo = 0
    pulse <b>VAR BYTE
    
    </b>pulse = 0
    bittest <b>VAR BIT
    
    ASM
    </b><font color="#008000">INT_LIST  macro    </font><font color="#000080"><i>; IntSource,        Label,  Type, ResetFlag?
            </i></font><font color="#008000">INT_Handler   TMR0_INT,   PulseOut,   ASM,  yes
            INT_Handler   TMR2_INT,   period,     ASM,  yes
            INT_Handler   TMR1_INT,   test,       ASM,  yes
        endm
        INT_CREATE               </font><font color="#000080"><i>; Creates the interrupt processor
    
        </i></font><font color="#008000">INT_ENABLE  TMR0_INT     </font><font color="#000080"><i>; Enable pulseout interrupts  
        </i></font><font color="#008000">INT_ENABLE  TMR2_INT     </font><font color="#000080"><i>; enable period interrupt (20ms)
        </i></font><font color="#008000">INT_ENABLE  TMR1_INT     </font><font color="#000080"><i>; enable interrupt to increment pulse width (test)
    </i></font><b>ENDASM
    
    </b>Main:
        nop
    <b>GOTO </b>Main
    
    <font color="#000080"><i>'---[TMR0_INT - interrupt handler]------------------------------------------
    
    </i></font><b>ASM
    </b><font color="#008000">PulseOut
        btfsc _bittest      </font><font color="#000080"><i>;test status of bittest bit
        </i></font><font color="#008000">goto $+7            </font><font color="#000080"><i>;if high skip 7 lines
        </i></font><font color="#008000">bcf OPTION_REG,5    </font><font color="#000080"><i>;stop timer
        </i></font><font color="#008000">movf _pulse,w       </font><font color="#000080"><i>;load TMR0 with value of pulse variable
        </i></font><font color="#008000">movwf TMR0
        bsf _bittest        </font><font color="#000080"><i>;set bittest bit, indicating we are on second half
        </i></font><font color="#008000">bsf OPTION_REG,5    </font><font color="#000080"><i>;start timer again for second interrupt
        </i></font><font color="#008000">goto $+3            </font><font color="#000080"><i>;skip to return from interrupt
        </i></font><font color="#008000">bcf OPTION_REG,5    </font><font color="#000080"><i>;stop timer
        </i></font><font color="#008000">bcf _servo          </font><font color="#000080"><i>;bring servo pin low for end of pulse width
        </i></font><font color="#008000">INT_RETURN
    
    </font><b>ENDASM
    </b><font color="#000080"><i>'---[TMR2_INT - interrupt handler]------------------------------------------
    </i></font><b>ASM
    </b><font color="#008000">period
        bsf _servo          </font><font color="#000080"><i>;set servo pin high (begin pulse width)
        </i></font><font color="#008000">movlw d'0'          </font><font color="#000080"><i>;set timer0 to 0 (full length of timer)
        </i></font><font color="#008000">movwf TMR0    
        bsf OPTION_REG,5    </font><font color="#000080"><i>;start timer0, now PulseOut interrupt will occur
        </i></font><font color="#008000">bcf _bittest        </font><font color="#000080"><i>;clear bittest bit
        </i></font><font color="#008000">INT_RETURN
    </font><b>ENDASM
    </b><font color="#000080"><i>'---[TMR1_INT - interrupt handler]------------------------------------------
    </i></font><b>ASM
    </b><font color="#008000">test 
        incf _pulse
        INT_RETURN
    </font><b>ENDASM
    
    </b></code></pre><!--EndFragment--></body>
    </html>
    Last edited by ScaleRobotics; - 28th January 2010 at 09:45.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink one idea

    Hi,

    I remember some batches of 12F683 did not like the duty value to be changed " on the fly " and needed to stop and restart the CCP module.

    Was written on the µChip datasheet ( prior to D release )...

    I think some lines about it exist on this forum.


    But you don't use the CCP module ...

    What I see more is you want to stop Timer0

    Code:
    bcf OPTION_REG,5    ;stop timer
    Option.5 is the TOCS bit ... and that's not a good thing to switch clock to TockI pin ...

    Alain
    Last edited by Acetronics2; - 28th January 2010 at 12:45.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Thanks Alain, that was it!

    I changed those to:
    Code:
    bsf INTCON,5        ;enable timer0 interrupt
    
    and 
    
    bcf INTCON,5        ;disable timer0 interrupt
    and now the pulse runs smoothly. Only I don't get the initial set timer0 to 0, then add the second half of pulse width. I only get the second half where TMR0=pulse. So pulse width is between 0 and 1ms.

    But I will work on that!

    Thanks again,

    Walter

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


    Did you find this post helpful? Yes | No

    Default ds33014K is it!!

    Thank you for setting me straight on which document is which.

    DS33014K is just what I have been looking for.

    Tuesday Darrel Taylor's site said that it was under construction and that it would not accept new membership.

    I have coded in C and in Assembly. More recently in shell and tcl. I never had a reason to use Basic as none of my professional work used a PC.

    I think this 33014 will get me started.

    Scalerobotics, if you get a chance see if you can record the radio receiver output signals for the other channels. In particular one which is just ON-OFF from the point of view of the transmitter.

    Ken - thanks gang.

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

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