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

    PAUSE puts the code into a loop for a certain amount of instructions. It does not stop the hardware interrupts.

    This is what a PAUSE in ASM looks like. Just a routine to eat some time.
    Code:
    ; Delay = 0.1 seconds
    ; Clock frequency = 4 MHz
    ; Actual delay = 0.1 seconds = 100000 cycles
    ; Error = 0 %
    Delay	;99993 cycles
    	movlw	0x1E
    	movwf	d1
    	movlw	0x4F
    	movwf	d2
    Delay_0
    	decfsz	d1, f
    	goto	$+2
    	decfsz	d2, f
    	goto	Delay_0	;3 cycles
    	goto	$+1
    	nop		;4 cycles (including call)
    	return
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    If you have hardware interrupts enabled, it will jump out of any code routine, execute whatever code you have in your interrupt handler, then return to where it was prior to the interrupt.

    Note I wasn't recommending you use this routine to control your motors, I was just curious if it worked. Once you know what you'll need to do to handle all the other things you need to like light sensing, ultrasonic, etc, then you'll have some idea of how to incorporate all your routines (or most) into a single interrupt handler.

    Your particular type of application could also benefit from a few dedicated application specific ICs like maybe some 8-pin PICs programmed to do nothing but generate your motor control signals by just monitoring a few inputs, and using these inputs to determine speed, direction, etc. Then you main controller could control motors by just taking a pin or 2 high or low.

    A lot of robotics applications use distributed processing like this to take some of the repetitive tasks off of the primary controller.

    Example: Instead of using a sonar sensor, you could build this into your main controller. But then your main controller wastes a ton of time doing what the external sonar sensor does.

    So - most people will just buy & use a sonar sensor rather than design it into the main circuit. Just take that a step further, and make your own 8-pin servo controllers.

    If you have a lot of things going on, motors, sensors, measurements, etc, etc, you can take a huge burden off the main controller by just creating a few of your own litle application specific PICs with a few I/O-pins on the primary controller telling them what to do.

    You could have a whole herd of little 8-pin PICs interfaced & controlled by the primary controller, and it only takes a few pins on the primary to control them, and just a few instruction cycles to make that happen.

    Or you could shove it all into just one with some crafty interrupt handler to sort it all out. Just an idea. Sounds like a fun project.

    Microchip has a new 8-pin PICs coming shortly with a hardware USART & other goodies that could make some really interesting little peripheral controllers.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Bruce View Post
    Microchip has a new 8-pin PICs coming shortly with a hardware USART & other goodies that could make some really interesting little peripheral controllers.
    Hi, Bruce ...

    Could you give some little details ... please ??? a number ???

    I have been DREAMING of it for so long !!!

    Alain

    PS: 1822 ???
    Last edited by Acetronics2; - 4th February 2010 at 09: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 " !!!
    *****************************************

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Alain,

    Yes. It's the 8-pin PIC12F1822.
    Code:
     Enhanced Mid-range Core with 49 Instruction, 16 Stack Levels
     Flash Program Memory with self read/write capability
     Internal 32MHz oscillator
     Integrated Capacitive mTouch Sensing Module
     Data Signal Modulator Module
     MI2C, SPI, EUSART w/auto baud
     ECCP (Enhanced/Capture Compare PWM) Module
     Comparator with selectable Voltage Reference
     4 Channel 10b ADC with Voltage Reference
     25mA Source/Sink current I/O
     Two 8-bit Timers (TMR0/TMR2)
     One 16-bit Timer (TMR1)
     Extended Watchdog Timer (EWDT)
     Enhanced Power-On/Off-Reset
     Brown-Out Reset (BOR)
     In Circuit Serial Programming (ICSP)
     On Board In-Circuit Debug
     Wide Operating Voltage (1.8V – 5.5V)
     Low Power PIC12LF182x variants (1.8V – 3.6V)
     Standby Current (PIC12LF182X):  30 nA @ 1.8V, typical
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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


    Did you find this post helpful? Yes | No

    Red face Feeling a bit overwhelmed

    Guys and Gals,

    I might take a side trip to a scenic view along this road.

    Here is a pointer to a BASIC (which BASIC I do not know) program that controls a toy level RC car. Toy levels have no Electronic Speed Control. The DC motor and servo are driven by direct current controlled by four DPDT switches. (Bang-Bang: full speed forward, full stop, full speed back.) This project has only autonomous control. The radio receiver has been eliminated. These simplifications plus the fact that the details are on the WEB make this diversion very tempting.

    http://letsmakerobots.com/files/wall_racers.bas
    and
    http://letsmakerobots.com/node/928

    I have an appropriate RC car.
    I have a spare PICkit2.
    I need to translate wall_racers.bas into PBP.
    I need to adapt the resulting ASM to my 16F887.
    I think I have enough proto. parts for both projects.

    My ego needs a boost.

    Ken:

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


    Did you find this post helpful? Yes | No

    Default

    Ken,

    You are kind, intelligent, and I hear good looking.

    There is your ego boost

    Your new approach does sound like a good way to start. Save the PWM for later and work on the other parts.

    You may want to think about what Bruce said and go "modular". Then when you do get back to the PWM part it could live on a separate chip.

    You said you have some solder-less breadboards, so you could get a few of the 8 or 14 pin chips with ADC to play with. Remember MicrChip has a samples program so you could get three from them to start.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Talking Lookit this great picture

    On the other hand==>

    Look at this great oscilloscope-like picture of the PWM pulses (fifty per second) very close to 1.75ms long created by Bruce's PAUSEUS technique. I finally figured out the Analyzer part of the PICkit 2 Logic Tool.

    Ken
    Attached Images Attached Images  

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