Problem with 12F629, servo and EEPROM


Closed Thread
Results 1 to 14 of 14

Hybrid View

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


    Did you find this post helpful? Yes | No

    Post

    Hi,

    Did you check ( W/Multimeter ) GPIO 4 and 5 state when your Min and Max Buttons are pushed ???

    stupid question , ehhhh ???

    MPSIM shows memory is well written ... so, I do suspect a harware problem !!!

    I'll give a try with a '675 ... to be sure ( no 629 home ! )

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  2. #2
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Bruce - Good catch on the Data statement (DUH!)! However, if I run my original code as in my first post (with the change in the data statement), I still get the same results: perfect servo movement when first booted up, but when I move the servo to the center position, switch on the SetLimitSw, press the Min button and then switch off the SetLimitSw, the servo no longer responds to the pot - as though both the min and max buttons were pressed at the same position.

    I am beginning to think I have some underlying hardware issue (as Alain suggests). I will do some metering to see if I see anything fishy. If I don't, I'm going to rebuild the board with new components. If it still does it after all that, I'll shoot myself! (just kidding!).

    Thanks guys - let me know if you think of anything else!

  3. #3
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Problem Solved!

    Well, just as I expected, it was me and yes, I'm embarassed! I started metering the min and max buttons and noticed that if I pressed either button, both pins went high - explaining why the servo just stayed in one spot when either the min or max button was pressed. After scratching my head over how that could possibly be happening, I noticed that my pull-down resistors were put in vertically instead of horizontally. If you look at the circuit diagram in my first post, you will see what I mean. How stupid was that! Anyway, I rotated the resistors and everything works perfectly! Go figure!

    I'd like to thank those who helped me and apologize for wasting their time. I knew it would be something like this...

    Well, I made a few changes to the code and here it is in it's final form:

    @ DEVICE pic12F629, INTRC_OSC_NOCLKOUT ; Using Internal Clock, no clock out
    @ DEVICE pic12F629, WDT_ON ; Enable Watch dog timer
    @ DEVICE pic12F629, PWRT_ON ; Enable Power-up timer
    @ DEVICE pic12F629, MCLR_OFF ; Disable MCLR pin
    @ DEVICE pic12F629, BOD_ON ; Enable Brown-out detect
    @ DEVICE pic12F629, CPD_OFF ; EEPROM Protect
    @ DEVICE pic12F629, PROTECT_OFF ; Code Protect off

    TRISIO = %11111110
    INTCON.6=0 ' Disable all unmasked Interrupts
    INTCON.7=0 ' Disable Global Interrupts
    CMCON = 7 ' Disable analog comparator

    ServoOut var GPIO.0
    SetLimitSw var GPIO.1
    PotIn var GPIO.2
    MinSw var GPIO.4
    MaxSw var GPIO.5

    wPosit var word
    Posit var byte
    MinPosit var byte
    MaxPosit var byte

    'load starting min and max positions
    data @ 0, 100
    data @ 1, 250

    '************************************************* ***************
    low Servoout

    'read in stored min and max limits
    read 0, MinPosit
    read 1, MaxPosit

    'for power-on reset of positions:
    if minsw = 1 then
    minposit = 100
    write 0, minposit
    endif
    if maxsw = 1 then
    maxposit = 250
    write 1, maxposit
    endif
    pause 1000

    Start:
    gosub GetServoPosition
    pulsout servoout, posit
    pause 20

    if setlimitsw = 1 then 'check min max buttons
    if minsw = 1 then
    MinPosit = Posit
    write 0, MinPosit
    pause 250
    endif

    if maxsw = 1 then
    MaxPosit = Posit
    write 1, MaxPosit
    pause 250
    endif
    endif

    goto start

    '************************************************* ***************
    GetServoPosition:
    high potin
    pause 1
    rctime potin, 1, wPosit 'at 4 mhz, returns 0 - 120

    'adjust posit to get values between 75 and 250
    'use word-sized variable because calculation might exceed 255
    wposit = wposit + 75 + (wposit / 2)

    'now limit posit to 100 - 250 (1 ms - 2.5 ms)
    'and put into byte-sized variable
    if wposit > 250 then
    posit = 250
    else
    posit = wposit
    endif

    if posit < 100 then posit = 100

    if setlimitsw = 0 then 'apply limits
    if Posit < MinPosit then Posit = MinPosit
    if Posit > MaxPosit then Posit = MaxPosit
    endif

    return

    '************************************************* ***************

    End

  4. #4


    Did you find this post helpful? Yes | No

    Default Beware the PULSOUT inversion problem

    PULSOUT is a toggle. Sooner or later you will get some interference that flips the state of the SERVOOUT line and your system will be off in the weeds.

    To guarantee correct working of the PULSOUT command you should first force the SERVOOUT line to a defined state.

    For example, put
    SERVOOUT = 0
    or
    LOW SERVOOUT
    before calling the Pulsout command.

    One of my RC aircraft went berserk because of that little oversight.

    HTH
    Brian

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BrianT View Post
    One of my RC aircraft went berserk because of that little oversight.
    HTH
    Brian
    You mean like pulling UP out of an inverted low pass?
    I lost a hopped-up clipped wing (+an extra bay) Goldberg Cub that way....(sigh)....

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


    Did you find this post helpful? Yes | No

    Default

    Hi, BrianT

    To fullfill your Pulsout knowledge ...

    You are to use LOW Output ...

    with some Hot plugged servos ( Graupner i.e.) or High capacitive loads ( some µF ) , Output = 0 is not enough to have a neat O level prior to Pulsin.
    I know it's not supposed to happen in flight ... but, ...

    Service,Sir ...

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

Similar Threads

  1. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03:17
  2. Writing to a table.
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th December 2005, 16:20
  3. Servo Recording
    By kenpo in forum General
    Replies: 3
    Last Post: - 2nd September 2005, 16:03

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