Schematic for this?

Discussion in 'General Electronics Chat' started by stanman11, Oct 1, 2011.

  1. stanman11

    Thread Starter Member

    Nov 23, 2010
    230
    4
    I'm looking for a schematic close to what I need.
    PWM
    servo control
    1 button
    (on) Left: (off) Center: (on) Right (off) Center:
    Then reset to The First command.


    Sorry for explaining it that way, I have ADHD and its hard for me to explain.

    I have a programming and PIC ready for this
     
  2. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Hello Stanman
    OK, let me try to understand what you wrote.

    You need to control a servo via PWM.
    As I understand it, a servo requires a pulse every 20mS; the pulse width is what determines the position of the servo. A pulse 1.5mS wide has the servo centered, a pulse 1mS wide has the servo at one limit, a pulse 2mS has the servo at the other limit.

    You have a Microchip PIC and some programming code that apparently are "ready to go".
    You should post the source code that you are planning on using, and tell us what the part number of the PIC uC is - or post a link to where you copied the code from.

    You mention 1 button, and the sequence of operation is:
    1) Switch off (released) - servo centered.
    2) Switch on (depressed) - servo full left.
    3) Switch off (released) - servo centered.
    4) Switch on (depressed) - servo full right.
    5) Go to step 1

    Is that correct? You only want one pushbutton switch?

    If so, you will need to tell us not only what PIC uC that you have, its' package type, and also what I/O pin you need the switch on, and whether the switch needs to connect to GND, Vdd, or perhaps another pin when pressed.
     
  3. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Assuming you are using the PIC10F200 mentioned in the other thread:
    VDD and servo red wire -> +5V
    VSS and servo black wire -> 0V
    GP2 -> other servo wire (maybe white)
    GP0 -> normally open pushbutton -> 0V
    VDD -> 100nF capacitor -> VSS
    +5V -> 100μF capacitor -> 0V

    GP0 has a (software controlled) internal pullup resistor so nothing else is required, and it will be programmable in circuit (don't press the pushbutton while programming).
     
  4. stanman11

    Thread Starter Member

    Nov 23, 2010
    230
    4
    This is all very confusing to me lol. maybe I should pick a different hobby lol
    yeah im using the PIC10f200
    Would you be able to set me on the right path on how to get started?
    what should be my first step?
     
  5. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I suppose the first step is to make the simplest program that just sets the pins to high so you can check that your programming setup is working.
    Start with the template from:
    c:/Program Files/Microchip/MPASM Suite/Template/Code

    Code ( (Unknown Language)):
    1. ;**********************************************************************
    2. ;   This file is a basic code template for assembly code generation   *
    3. ;   on the PIC10F200. This file contains the basic code               *
    4. ;   building blocks to build upon.                                    *
    5. ;                                                                     *
    6. ;   Refer to the MPASM User's Guide for additional information on     *
    7. ;   features of the assembler (Document DS33014).                     *
    8. ;                                                                     *
    9. ;   Refer to the respective PIC data sheet for additional             *
    10. ;   information on the instruction set.                               *
    11. ;                                                                     *
    12. ;**********************************************************************
    13. ;                                                                     *
    14. ;    Filename:        xxx.asm                                           *
    15. ;    Date:                                                            *
    16. ;    File Version:                                                    *
    17. ;                                                                     *
    18. ;    Author:                                                          *
    19. ;    Company:                                                         *
    20. ;                                                                     *  
    21. ;                                                                     *
    22. ;**********************************************************************
    23. ;                                                                     *
    24. ;    Files Required: P10F200.INC                                      *
    25. ;                                                                     *
    26. ;**********************************************************************
    27. ;                                                                     *
    28. ;    Notes:                                                           *
    29. ;                                                                     *
    30. ;**********************************************************************
    31.  
    32.     list      p=10F200            ; list directive to define processor
    33.     #include <p10F200.inc>        ; processor specific variable definitions
    34.  
    35.     __CONFIG   _MCLRE_ON & _CP_OFF & _WDT_OFF
    36.  
    37. ; '__CONFIG' directive is used to embed configuration word within .asm file.
    38. ; The lables following the directive are located in the respective .inc file.  
    39. ; See respective data sheet for additional information on configuration word.
    40.  
    41.  
    42.  
    43.  
    44. ;***** VARIABLE DEFINITIONS
    45. temp    EQU     0x10        ;example variable definition
    46.  
    47.  
    48.  
    49. ;**********************************************************************
    50.     ORG     0xFF             ; processor reset vector
    51.  
    52. ; Internal RC calibration value is placed at location 0xFF by Microchip
    53. ; as a movlw k, where the k is a literal value.
    54.  
    55.     ORG     0x000             ; coding begins here
    56.     movwf   OSCCAL            ; update register with factory cal value  
    57.  
    58.  
    59.  
    60.  
    61. start    
    62.     nop                       ; example code
    63.     movlw   0xFF              ; example code
    64.     movwf   temp              ; example code
    65.  
    66. ; remaining code goes here
    67.  
    68.  
    69.  
    70.  
    71.  
    72.  
    73.     END                       ; directive 'end of program'
    You just need a few lines to clear the TRIS bits and set the GPIO bits, then put in an empty loop to stop the code from rolling back to the start again.
    <ed> Also change the config line to :
    __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF
    </ed>
    The next step I'd recommend is getting to know the simulator in MPLAB, then looking at some code examples.
    My reply in the the thread in Electronics Resources has some code which does almost what you want.
    Once you get started it gets easier quickly.
     
    Last edited: Oct 9, 2011
Loading...