Help with pic 12f629


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 40 of 53
  1. #1
    Join Date
    Sep 2010
    Posts
    23

    Default Help with pic 12f629

    Hi there,

    I am new to this worl of pics, and know very little about them. I started this as a new hobby, and got really into it.

    At the moment, I am having difficulties to make my pic count upto 3 presses of a switch connected to pin 2, and turn off a led connected to pin 1.

    Please any advice will be much appreciated.

    Best regards.
    Frank.
    Code:
    cnt VAR BYTE
    boton VAR GPIO.2
    mosfet VAR GPIO.1
    
    CMCON = 7
    
    'Ports
    Output mosfet
    Input boton
    
    cnt=0
    boton = 1
    
    'Begin Program
    TEST:
    high mosfet
    count 2, 1, cnt
        if cnt = 3 then
            cnt = 0
            low mosfet
            pause 1000
        endif
    
    
    GOTO TEST
    end

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


    Did you find this post helpful? Yes | No

    Default

    Welcome to the forum.

    Maybe this will get you started.
    Code:
    CHECK:
    high mosfet
    IF boton = 0 THEN TEST
    GOTO CHECK
    
    TEST:
    cnt = cnt +1
    IF cnt = 3 THEN OFF_LED
    RETURN
    
    OFF_LED:
    cnt = 0
    low mosfet
    pause 1000
    GOTO CHECK
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Thanks Dave!!! grate stuff!!!
    I will post the results later on.

    Thanks again.

  4. #4
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    No Dave...no luck....I am going mad!!!....

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


    Did you find this post helpful? Yes | No

    Default

    What exactly is happining?
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    now to show off my newbieness. If that is the entire program, won't he need SOME sort of init type stuff? setup tris,osc,...? something?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    TRIS is taken care of in the HIGH/LOW commands.
    The vars will need defined. The OP had that.
    DEFINE the OSC and set the configs someplace. Figured the OP had those too. Seemed the code was running, just not running as expected.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    DOH!!
    That chip has an ADC I think.
    Add
    ANSEL=%00000000

    http://www.picbasic.co.uk/forum/showthread.php?t=561
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Is If_then a goto or gosub? I am used to it being a goto unless gosub is called out. But I clearly haven't read my PBP book yet. - sorry

    If goto then return will break the code - yes?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    Bert,
    You are correct. Thanks for catching that.
    Dave
    Always wear safety glasses while programming.

  11. #11
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    so please confirm:

    test should have "goto check" instead of "return"?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    Yes

    that pretty much does it for me today. Too many DOHS.
    Dave
    Always wear safety glasses while programming.

  13. #13
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Yes

    that pretty much does it for me today. Too many DOHS.
    you intended to right?

    I thought you were just giving us new folks a chance to help Better to teach than to do. that way we learn something.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  14. #14
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    hi guys,

    thanks all for your help, but no luck so far, before the last suggested changes, the code will just stay on forever.
    Now, with the ANSEL part, just wont compile, it says "syntax error".

    Removing the ansel part, it compiles, i run it and after the boton is pressed it jumps direct to the last part of the code (off_led/off_mosfet)

    This is my actual code:

    Code:
    cnt VAR BYTE
    boton VAR GPIO.2
    mosfet VAR GPIO.1
    
    
    CMCON = 7
    
    'Ports
    Output mosfet
    Input boton
    
    cnt=0
    
    CHECK:
    high mosfet
    IF boton = 0 THEN TEST
    GOTO CHECK
    
    TEST:
    cnt = cnt + 1
    IF cnt = 3 THEN OFF_MOSFET
    GOTO CHECK
    
    OFF_MOSFET:
    cnt = 0
    low mosfet
    pause 1000
    GOTO CHECK
    end
    Any sugestions?
    Much appreciated, and thanks again.

  15. #15
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Having no idea what your circuit looks like, my first guess is your button is bouncing. So when you press it, the pic sees any number of presses during that short time between starting to make contact and fully pressed. To test, add a pause in the "test" :

    TEST:

    pause

    cnt = cnt + 1
    IF cnt = 3 THEN OFF_MOSFET
    GOTO CHECK

    I don't know the exact format of pause, but set it for something big like 100mS. That way for every button press, execution waits to allow your finger to catch up with the pic.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  16. #16
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Smile

    Thanks, My circuit is just real pic simulator, so no circuit yet.
    but it should be something like a push boton normaly open, and a led with the resistor.
    I think it is the ansel thing, to set things digital.

    Excuse my ignorance....but if there is a newbie, my level is the same as the pet, of the pet of the newbie.

    Well, thanks again for your help guys.
    I will keep doing as you say.
    Thanks.

  17. #17
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gutisie View Post
    Thanks, My circuit is just real pic simulator, so no circuit yet.
    but it should be something like a push boton normaly open, and a led with the resistor.
    I think it is the ansel thing, to set things digital.

    Excuse my ignorance....but if there is a newbie, my level is the same as the pet, of the pet of the newbie.

    Well, thanks again for your help guys.
    I will keep doing as you say.
    Thanks.
    I don't know if the simulator simulates switches as de-bounced or not. This is all the help I can be at this time, I too do not understand. It looks like it should be working to me. -Sorry

    I will keep watching to see what the "pro's" have to say.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    Code:
    DEFINE OSC 4
       @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
        CMCON=7 
        
        cnt VAR BYTE
        boton VAR GPIO.2
        mosfet VAR GPIO.1
    
        cnt = 0
       
        CHECK:
        IF boton = 0 THEN TEST
        LOW mosfet
        GOTO CHECK   
        
        TEST:
        IF cnt < 3 THEN OFF_MOSFET
        IF cnt => 3 THEN ON_MOSFET
        GOTO CHECK
        
        OFF_MOSFET:
        PAUSE 100
        IF boton = 0 THEN
        low mosfet
        cnt = cnt + 1
        ENDIF
        GOTO CHECK
        
        On_MOSFET:
        HIGH mosfet
        pause 1000
        low mosfet
        cnt = 0
        GOTO CHECK
        end
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cncmachineguy View Post
    you intended to right?

    I thought you were just giving us new folks a chance to help Better to teach than to do. that way we learn something.
    Nope, I made one of my many mistakes. I was planning to give the OP a basic working code like I just did for something to "start" with. Then if needed try to do a little "teaching".

    Seems like a simple operation, but to make it work well some sort of de-bouncing and maybe an interrupt will be needed.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Hi,

    May be that one ???

    Code:
    '****************************************************************
    '*  Name    : Bôton.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 17/09/2010                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    DEFINE OSC 4
    DEFINE BUTTON_PAUSE 10    ' 10 is default value
       @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
     
        cnt VAR BYTE
        delay var byte
     
        boton VAR GPIO.2
        mosfet VAR GPIO.1
     
     
     '   ANSEL           = 0     '12F675 for test
        CMCON           = 7
        OPTION_REG.7    = 0    'Pullups  enabled
        WPU             = %00000100
     
        cnt             = 0
        GPIO            = %00000110                 ' Nosurprise startup ...
        TRISIO          = %00000100 
     
    '******************************************************************************
    Detect: 'Button presses W/Debounce
    '
    delay = 0
    BUTTON Boton ,0,255,0,delay,1,pressed
        Pause 20                                    ' Slow Things down
        GOTO Detect
     
    '******************************************************************************    
    Pressed:  ' Some > 10ms press detected
        IF cnt < 3  Then
     
            cnt = cnt + 1
     
        ELSE
     
            cnt = 0
            LOW mosfet
            PAUSE 1000
     
        ENDIF
     
    WHILE !Boton : WEND                                ' Wait Boton release !!!    
    goto detect
     
    END
    Alain
    Last edited by Acetronics2; - 18th September 2010 at 14:42. Reason: Inverted Mosfet on/Off
    ************************************************** ***********************
    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 " !!!
    *****************************************

  21. #21
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Code:
    DEFINE OSC 4
       @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
        CMCON=7 
        
        cnt VAR BYTE
        boton VAR GPIO.2
        mosfet VAR GPIO.1
    
        cnt = 0
       
        CHECK:
        IF boton = 0 THEN TEST
        LOW mosfet
        GOTO CHECK   
        
        TEST:
        IF cnt < 3 THEN OFF_MOSFET
        IF cnt => 3 THEN ON_MOSFET
        GOTO CHECK
        
        OFF_MOSFET:
        PAUSE 100
        IF boton = 0 THEN
        low mosfet
        cnt = cnt + 1
        ENDIF
        GOTO CHECK
        
        On_MOSFET:
        HIGH mosfet
        pause 1000
        low mosfet
        cnt = 0
        GOTO CHECK
        end
    Hi guys, thanks again, your are wonderfull!!.

    Unfortunately, this code gives me error 118.

    Thanks.
    Best regards.

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


    Did you find this post helpful? Yes | No

    Default

    If you are setting the configs in code space comment that line out.
    Dave
    Always wear safety glasses while programming.

  23. #23
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hi Dave, yes thats it.

    When I delete the first 2 lines "define ocs" and "@...", both codes compile ok.

    Unfortunately, the behaviour is basicaly the same....they start with led off, and it should be on, more over, the counting is not regular, it depends in the speed of the click.
    Some times, it goes off at 3, others at 5...etc....

    I dont know....it is very over me.
    I have tried to cut here and there taking ideas from both codes, but it does not work either.

    I have to mention, that the clicks will be very fast, we could have posibly.......20 clicks per second, but we need to stop the mosfet after counting 3 clicks, hence the pause for 1 second.

    I am sorry, my spanish brain is too tyre and can not speak properly.

    Thanks for helping me guys.
    Much appreciated.

    Best regards.

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


    Did you find this post helpful? Yes | No

    Default

    You might not need the
    DEFINE OSC 4
    but it is a good idea to put it in. That is the line that tell PBP how fast the chip is running. I assume you are using the 4MHz internal.

    The state of the mosfet/led depends on how you have the hardware setup. Just change the LOW/HIGH around to do what you want.

    Like I said before. This will need a good denouncing routine to work correctly. Now that you say the button could be pressed at 20HZ even more so. What is going to press a button that fast?

    Here are a couple of threads that might help you.
    http://www.picbasic.co.uk/forum/showthread.php?t=13516
    http://www.picbasic.co.uk/forum/showthread.php?t=2180

    Read them all the way through.
    Dave
    Always wear safety glasses while programming.

  25. #25
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hi dave,

    Thanks for your help, I will have a look at the links later.

    Yes you are right, I am using the internal oscillator at 4 mhz.

    The botton is pressed by a piston.
    So I need to stop the piston after 3 pulses.

    Thanks.

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


    Did you find this post helpful? Yes | No

    Default

    Is it really a button type switch or some other kind of sensor?

    I ask because a mechanical switch may not be the best at high speeds.

    And the way you have the code implies the button is pulled high and at button press goes to zero volts. This can cause arcing as the contacts open giving the chance of several "make/breaks" on each press.

    If the switch were wired pulled low and pressing it brought it high then the arcing is almost not a problem.

    Just thoughts....
    Dave
    Always wear safety glasses while programming.

  27. #27
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Is it really a button type switch or some other kind of sensor?

    I ask because a mechanical switch may not be the best at high speeds.

    And the way you have the code implies the button is pulled high and at button press goes to zero volts. This can cause arcing as the contacts open giving the chance of several "make/breaks" on each press.

    If the switch were wired pulled low and pressing it brought it high then the arcing is almost not a problem.

    Just thoughts....
    yes the idea is a proper botton switch, the wired to pull it low it is some thing that i dont understand.
    The voltage for the circuitry is 5v....amperes very little, I think is not going to be a problem.

    I am more concern with the switch being able to work at that speed...i dont know...i rather first understand the code, see what it should be, have something that i can built my proptotype on, and then see pros and cons.
    Otherwise this can be very long...

    Thanks for the help guys.
    Best regards.

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


    Did you find this post helpful? Yes | No

    Exclamation

    Quote Originally Posted by gutisie View Post

    The botton is pressed by a piston.
    So I need to stop the piston after 3 pulses.

    Thanks.
    Some Hall effect sensor would be to consider, instead ...

    just me ...

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

  29. #29
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gutisie View Post
    The voltage for the circuitry is 5v....amperes very little, I think is not going to be a problem.
    You should ALWAYS assume EVERY mechanical contact switch bounces. The effects can be made less with tricks like DAVE suggests, and with higher quality snap type switches. But heres the thing: as 1 contact approaches the other, they WILL arc. The arc is the "bounce" this happens when opening and closing. Also, switches HATE DC. So if you want this to work for any lengh of time, be certain the switch is DC rated. DC causes the contacts to "plate" and then the bounceing gets worse until the switch quits all together.

    I am more concern with the switch being able to work at that speed...i dont know...i rather first understand the code, see what it should be, have something that i can built my proptotype on, and then see pros and cons.
    Otherwise this can be very long...

    Thanks for the help guys.
    Best regards.
    Not a bad approace at all. Good luck!
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    # 20 updated to our friend's desires ...

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

  31. #31
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by Acetronics View Post
    # 20 updated to our friend's desires ...

    Alain
    oooooomg!!!! you did it!!! it works!!!

    but i had to change it a bit.
    I will post the results later
    I am still shaking....

  32. #32
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Wink

    hi, the code works fine under slow speed, it will count up to 3 and go off the led for 1 s, then on back again.

    Please see actual code.

    Code:
    DEFINE OSC 4
      
     
        cnt VAR BYTE
        delay var byte
     
        boton VAR GPIO.2
        mosfet VAR GPIO.1
     
     
     '   ANSEL           = 0     '12F675 for test
        CMCON           = 7
        OPTION_REG.7    = 0    'Pullups  enabled
        WPU             = %00000100
     
        cnt             = 0
        GPIO            = %00000110                 ' Nosurprise startup ...
        TRISIO          = %00000100 
     
    '******************************************************************************
    Detect: 'Button presses W/Debounce
    '
    delay = 0
    BUTTON Boton ,0,255,0,delay,1,pressed
                                      ' Slow Things down
        GOTO Detect
     
    '******************************************************************************    
    Pressed:  ' Some > 10ms press detected
        IF cnt <=1  Then 'tocount uptu 3, bigger values will add up.
     
            cnt = cnt + 1
     
        ELSE
     
            cnt = 0
            LOW mosfet
            PAUSE 1000
            high mosfet
     
        ENDIF
     
    WHILE !Boton : WEND                                ' Wait Boton release !!!    
    goto detect
     
    END
    I need much faster reading from the pic, other wise, it will count moreto go off, on breadboard, it may not even go on again.
    For some oscure reason, my Pbasic compiler, does not like the configuration line you put, after the OSCAL SETTING, in line one.
    So I have to set it manualy, using software configuration bit facility.

    See my circuit, but, instead of 2 only one led, on GP1, and Push boton on GP2.

    Best regards.



    Thanks Acetronics.
    Last edited by gutisie; - 26th September 2010 at 12:21.

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


    Did you find this post helpful? Yes | No

    Default

    Hi,

    oooooomg!!!! you did it!!! it works!!!
    Keep cool ... there's no miracle in that ...

    If you need faster response ... forget about your pushbutton !!! Button bouncings will give a totally random functionning ...
    another "detector" type has to be used.

    Now, modified code reacts for 2 pushings only ???

    The obscure reason is you use PM as an assembler and not MPASM with your Microcode IDE ...

    Alain
    Last edited by Acetronics2; - 26th September 2010 at 16:29.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  34. #34
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by Acetronics View Post
    Hi,



    Keep cool ... there's no miracle in that ...

    If you need faster response ... forget about your pushbutton !!! Button bouncings will give a totally random functionning ...
    another "detector" type has to be used.

    Now, modified code reacts for 2 pushings only ???

    The obscure reason is you use PM as an assembler and not MPASM with your Microcode IDE ...

    Alain
    Hi thanks for your response, much appreciated.

    The compiler, i use is Pbasic?..with Mplab ide....these are at least the software names.
    Do you need a screen capture of the compiling results?

    And about the button...what type would you use?...I am absolutly clue less.....and desperate...and tyre...and bald....and...etc...

    Any way....Ir sensors?...proximity switches?....

    I once more depend on your wisdom master....

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


    Did you find this post helpful? Yes | No

    Default

    Some testings show the minimum time for 3 pushes is ... around 78 ms !!! @ 10ms debounce time and a Pause 0 for scanning ...

    so, I really doubt any finger could do that !!!

    Quote Originally Posted by gutisie View Post
    And about the button...what type would you use?...I am absolutly clue less.....and desperate...and tyre...and bald....and...etc...

    Any way....Ir sensors?...proximity switches?....
    so What moves the button ???

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

  36. #36
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hi Ace,

    Thanks for your reply.

    The button is pressed by the piston on a gear box. As i said on other post, my actual reading is 15 to 20 cycles per sec. And i need to stop the piston, after 3 cycles.

    I have some Ir sensors. But putting them inside the gearbox or some where around, it is not a good idea.

    Hence, buttons is the best for my application i think.

    Thanks.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gutisie View Post
    Hi Ace,

    , my actual reading is 15 to 20 cycles per sec. And i need to stop the piston, after 3 cycles.

    Thanks.
    20 c/s is 50 ms ... 3 cycles are 150 ms ...

    electronics works for 80 ms per 3 cycles ...

    SO ... if your switch is a good quality / low inertia one... it Works !!!

    but, of course ... if it works in oil ... ( gear box ...)

    magnetic detector looks to be THE thing ... I think telemecanique also have nice proximity switches that can reach 50 or 100 Hz ... ( I have some home ...)

    at least it's no more an electronics problem ...

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

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


    Did you find this post helpful? Yes | No

    Default

    Why not a mag/prox sensor on a connecting rod or gear.
    Maybe even find a gear that is 3/1??
    Dave
    Always wear safety glasses while programming.

  39. #39
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    20 c/s is 50 ms ... 3 cycles are 150 ms ...

    electronics works for 80 ms per 3 cycles ...

    SO ... if your switch is a good quality / low inertia one... it Works !!!

    but, of course ... if it works in oil ... ( gear box ...)

    magnetic detector looks to be THE thing ... I think telemecanique also have nice proximity switches that can reach 50 or 100 Hz ... ( I have some home ...)

    at least it's no more an electronics problem ...

    Alain
    Thanks guys for your reply.

    So Alain, telemec?...ummm....I think they dont sell m5 or less like omron...any way...there are a bit expensive.

    Could you guys put me a link of a good button for this application?, Ebay?...thanks.
    Regards.

  40. #40
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hello All,

    After trying with different sensor, and switches, I have found out that the reason for the strange behaviour, or mal functioning of the code, it is due to the excess of current supply.

    I have notice that when you have the "finger" on any of the conections, the systems works!!, but if you remove the finger, starts to go nuts again.

    So at the moment i am supplying from 3v = 2xAA bateries. I will put a LM317 to allow only 250ma to go through.

    See if that helps.

    I will post my results.

    Best regards.

    And thank you all for your help.

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