Shop OBEX P1 Docs P2 Docs Learn Events
Basic stamp in a paintball marker! — Parallax Forums

Basic stamp in a paintball marker!

FireHelixFireHelix Posts: 42
edited 2006-10-16 16:18 in BASIC Stamp
Well, I'm fairly new to the basic stamp scene, but I've had great luck finding answers and learning material here in the parallax forums. My curent project involves using a pbasic setup to controll the functions of a paintball marker. At it's base level the program needs to monitor the trigger (lever switch), monitor breech eyes (ir led and reciever) for making sure a paintball is loaded before fireing, and activating the pnumatic solenoid that fires the marker. I'm planning on posting more to this thread as my project progresses.

The structure I'm using just scans for trigger pulls repeatedly till it sees a pull, which it then checks the breech eyes. If it sees no paintball, it returns to checking the trigger, if it does see a ball, it jumps to the solenoid routine.

ok whew... that was a lot of explaining right off the bat. so here's my scenario I need help with. I need to be sure that when the stamp sees a trigger pull that it actually is a valid pull, not just electronic or mechanical bounce. Id like to do this by having the routine make sure the trigger is pulled for atleast 2-3ms before passing TrigPull = 1 back to the main program. Looking around a little I thought RCTIME might be what i need but I'm not entirely sure.

Any suggestions on how to monitor the trigger and make sure it's pulled for a set amount of time before counting it as valid?
«1

Comments

  • bsparkybsparky Posts: 52
    edited 2006-08-09 10:41
    You might try this:

    Trigger:

    DO WHILE Trig = 0
    LOOP
    PAUSE 50
    IF Trig = 0 THEN Trigger

    rest of code here


    This way the trigger has to be held for a shot period. You can adjust the PAUSE length to your liking. Hope this helps.
  • FireHelixFireHelix Posts: 42
    edited 2006-08-09 12:15
    well, a pot of coffee, a pack of cigarettes and an annoyed girlfriend later... i came up with this

    TriggerTest:
    TimeCount = 0
    FOR x = 0 TO 1000               'long loop to cover normal fire, forced fire, and eye disable
      IF Trigger = 1 THEN           'checks trigger status
        TimeCount = TimeCount + 1   'if trigger is pulled incrament TimeCount to keep track of how long its pulled
        IF TimeCount = 3 THEN       'if trigger pulled for 3 loops then check eyes
          GOSUB Eyes                 'goes to eye status sub, sets EyeStatus to 1 or 0 and returns
          IF EyeStatus = 1 THEN     'if paintball detected...
            TimeCount = 0           'resets trigger pull timer
            GOTO Solenoid           'goes to solenoid switching sub (firing routine)
          ENDIF                     'end of if eyestatus=1
        ENDIF                       'end of if timecount=3
        IF TimeCount = 700 THEN     'if continued to be pulled with no eye detection, then force fire
          GOTO Solenoid             'skips eyes and fires marker.  does not clear TimeCount 
        ENDIF                       'end of if timecount = 700
      ENDIF                         'end of if trigger = 1
    NEXT
    
    
    



    i make it cycle through the for loop checking the trigger status and if it's still pulled, add 1 to the time counter. if the time counter reaches 3, it checks the eyes. if theres a paintball, it resets the time counter and fires the marker. if no paintball, it keeps checking till it gets to 700 at which point it fires with out checking the eyes (forced fire if the eyes break or get gooed with paint). the for loop goes to 1000 to allow TimeCount to get to 999 at which point it will shut off the eye checking routine and be able to fire "blind" (not written in yet)

    idea.gif comments? nono.gif criticism? skull.gif yell at me if i'm going to break something?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...

    Post Edited (FireHelix) : 8/11/2006 12:26:20 PM GMT
  • metron9metron9 Posts: 1,100
    edited 2006-08-10 04:53
    Well a few things with your code I can comment on.

    If you are using the basic stamp2 at 2000 lines of code pre second you only execute 20 lines of code in the loop from 0..3 so only 10ms
    will pass for your debounce of the switch, that may not be enough time.

    Your nested code can be simplified. Try not to nest so many if then constructs. For example your input routine "Triggertest" should be just that, an input routine that sets a flag to the main program loop, the main program loop should execute the solenoid nd eyes routines.

    I also fail to see the logic in disabling the eyes and firing after 500ms pass if that is the case what good are the eyes if you simply ignore them after 1/2 second.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
  • FireHelixFireHelix Posts: 42
    edited 2006-08-10 09:39
    it only gets to the eye disable part if after hitting the TimeCount = 3 the eyes dont see a paintball. for example, dirt gets into the eyes preventing them from reading if a paintball is present or not. just pulling the trigger like normal would do nothing (because it thinks theres nothing there), but if i pull and hold the trigger, after a short delay it will fire regardless if it sees a paintball or not. and for the eye disabling part, if the eyes are broken, i can hold the trigger, make it force fire, and continue to hold it to disable the eyes and be able to fire quickly without having to rely on broken eyes

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
  • FireHelixFireHelix Posts: 42
    edited 2006-08-11 12:20
    ok... i crammed out a little more of my project. I tried to comment it to the best of my ability but im planning on drawing up a flow chart of the functions for myself and to help describe what im doing to others. I reworked a large chunk of it at the advice of metron9 (though prolly not what he was suggesting).

    with that being said, here's the code

    '*************************************************
    'Cody Anderson
    'anderson.cody@gmail.com
    'Paintball Marker controll program
    ' -program to run a BS2 powered Dye Matrix (DM3) paintball marker
    ' -basic operation including fireing with and without anti-chop eyes
    '   forced shot for clearing barrel, and disabling of eyes in event of a malfunction
    '
    'future: selection between semi-auto, full auto, and various ramping modes
    '        LED (or possibly LCD display) for selecting modes / changing settings
    '        menu for adjusting solenoid, trigger, and eye settings
    '*************************************************
    
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    '********Constants******************
    Trigger PIN 0
    EyeRec PIN 1
    EyeSend PIN 2
    Noid PIN 3  'havent looked up if i need another pin for this or not
    
    
    '**********Variables****************
     TimeCount VAR Word
     x VAR Word
     TriggerStat VAR Bit
    EyeEnable VAR Bit
    EyeStatus VAR Bit
    
    '********start of main program**************
    EyeEnable = 1
    Start:
    
    DO
      GOSUB CheckTriggerStat     'scans trigger to catch the pull...
      IF TriggerStat = 1 THEN    'if trigger is pulled, then...
        GOTO TriggerTest         'check if it's a valid pull and act accordingly
      ENDIF
    LOOP
    
    
    '********Subroutines************
    TriggerTest:
    TimeCount = 0                   'reset trigger time counter for the start of each pull
    FOR x = 0 TO 1000               'long loop to cover normal fire, forced fire, and eye disable
      IF Trigger = 1 THEN           'checks trigger status
        TimeCount = TimeCount + 1   'if trigger is pulled incrament TimeCount to keep track of how long its pulled
        SELECT TimeCount            'catch for events that happen depending on how long trigger is pulled
          CASE 3                    'if trigger pulled for 3 loops then check eyes
            GOSUB NormalShot
          CASE 650                  'if trigger is held for 650 loops, fire once regardless of eye status
            GOSUB ForcedShot
          CASE 999                  'if trigger is still held, disable eyes and return to start of program
            GOTO EyeChange
        ENDSELECT
      ELSE
        GOTO Start                  'if trigger is let go during cycle, go to start of program
      ENDIF                         'end of if trigger = 1
    NEXT
    '*********************************
    CheckTriggerStat:                'quick check that returns trigger status
    IF Trigger = 1 THEN
      TriggerStat = 1                'set "trigger pulled flag" to yes
      RETURN
    ELSE
      TriggerStat = 0                'set "trigger pulled flag" to no
      RETURN
    ENDIF
    '*********************************
    NormalShot:
    IF EyeEnable = 1 THEN             'check to see if eye routines are enabled
      GOSUB Eyes                      'if they are enabled, check if they see a paintball
      IF EyeStatus = 1 THEN           'if there is a paintball, start fireing process
        GOSUB Solenoid                'go to solenoid activation routine
        GOSUB TriggerStall            'stall to wait for trigger to be released (prevent full auto)
        GOTO Start                    'go back to start after fireing cycle is complete
      ELSE
        RETURN                        'if eyes are on, but no paintball go back for potential force fire or eye disable
      ENDIF
    ELSE                              'if eyes are not enabled
      GOSUB Solenoid                  'go to solenoid firing routine
      GOSUB TriggerStall              'stall till trigger is released
      GOTO Start                      'reset to beginning once all is complete
    ENDIF
    
    '*********************************
    ForcedShot:
    GOSUB Solenoid                    'forced shot, no regard for eyes
                                      'fires once and returns to trigger time counting loop
    RETURN                            'in case eyes need to be shut off
    '*********************************
    EyeChange:                        'routine for disabling eyes in case of malfunction
    IF EyeEnable = 1 THEN             'if the eyes are enabled, then disable them
      EyeEnable = 0
      GOSUB TriggerStall              'wait for trigger to be released
      GOTO Start                      'go to the beginning
    ELSE
      EyeEnable = 1                   'if eyes are off, turn them back on
      GOSUB TriggerStall              'wait for trigger to be released
      GOTO Start                      'go back to the start
    ENDIF
    '*********************************
    
    Eyes:
    IF EyeEnable = 1 THEN             'check to see if eyes are enabled or not
      EyeSend = 1                     'if they are, turn on the LED
      PAUSE 2                         'wait for everything to settle (may need to be adjusted)
      IF EyeRec = 0 THEN              'check ir detector. if blocked, paintball is present
        EyeStatus = 1                 'set "paintball is present" variable to 'yes'
      ELSE
        EyeStatus = 0                 'if no paintball (EyeRec=1) then set no paintball loaded
      ENDIF
    ELSE                              'if the eyes are off...
      EyeStatus = 1                   'make it think theres a paintball there no matter what
    ENDIF
    RETURN
    '*********************************
    TriggerStall:
    DO UNTIL Trigger = 0              'keep looping nothing until the trigger is released
    LOOP
    
    
    
    '*********************************
    Solenoid:                         'yah... havent written this yet because i need to research the solenoid in my marker
    
    
    RETURN
    
    




    Comments? Suggestions? stuff i screwed up really bad?
    I think at some point I should put some debug strings in there for when I actually try the program out, but before hooking it up to critical parts of my marker.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-08-11 12:48
    Cody -


    1. You are missing a RETURN at the end of - TriggerTest: subroutine

    2a. In your SELECT TimeCount routine, you can be more specific with your· CASE statements if you wish to:

    EX.
    ·Select TimeCount

    ·CASE > 0 and < 5
    ··blah,blah

    ·CASE 5 to 256
    ··blah, blah

    2b. In that same routine, you have no CASE ELSE if you intended to put one in.

    3. Routine - TriggerStall has no RETURN statement

    Regards,

    Bruce Bates
  • FireHelixFireHelix Posts: 42
    edited 2006-08-11 13:12
    To # 1 and 3... dang, I gotta stop working on this stuff at 4am. Thanks for spotting those. to #2, i want the program to act only at specific points in a held trigger pull, not run them multiple times during a range. thats why i set the cases to specific values. as for the no CASE ELSE, i dont want it to do anything if its not at one of the 3 specific case values, just continue watching the trigger

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
  • metron9metron9 Posts: 1,100
    edited 2006-08-11 15:47
    I like to have one point in and one point out on subroutines and functions. I would rewrite the following code with one goto command at the end instead of inside the if then.
    Otherwise reading the code it looks like it can fall through the ENDIF into the subroutine below it.

    Try to write IF THEN structures so that when you look at the program flow you do not have to follow the code inside the structure.

    The following code is eaiser to follow because you can see the in point and the out point without reguard to what happens inside the if then logic.

    This should be a subroutine with a return instead of a goto.

    Only one gosub triggerstall is needed as your code calls it from both the IF and ELSE clause.

    
    EyeChange:                        'routine for disabling eyes in case of malfunction
    
    IF EyeEnable = 1 THEN             'if the eyes are enabled, then disable them
      EyeEnable = 0
    ELSE
      EyeEnable = 1                   'if eyes are off, turn them back on
    ENDIF
    
    GOSUB TriggerStall              'wait for trigger to be released
    GOTO Start                      'go back to the start
    
    '*******************************************
    
    
    



    Your main code jumps to Triggertest with a goto instead of a gosub although it will work because you use "goto start" instead of a return but the Normalshot subroutine has a "goto start" for one of it's exit points and that will crash your program when the stack runs over.



    Rewrite the modules to exit at only one point
    Remove ALL the goto statements by rewriting the logic flow so that ecah function/subroutine is bullet proof. It does a specific task and returns to the calling program.

    GOTO's are Basic's worst command as far as trying to follow program logic flow, try to avoid using goto unless the logic has no other way.

    Code rewritten with flow changes

    *NOT TESTED i AM AT WORK ON A BREAK so I may have made some mistakes*

    I usually try and make changes on a piece by piece basis, testing the change as I go. Make only one change to the code and test it when it is working do the next change or with larg programs you will get confused very quickly.



    
    
        '*************************************************
    'Cody Anderson
    'anderson.cody@gmail.com
    'Paintball Marker controll program
    ' -program to run a BS2 powered Dye Matrix (DM3) paintball marker
    ' -basic operation including fireing with and without anti-chop eyes
    '   forced shot for clearing barrel, and disabling of eyes in event of a malfunction
    '
    'future: selection between semi-auto, full auto, and various ramping modes
    '        LED (or possibly LCD display) for selecting modes / changing settings
    '        menu for adjusting solenoid, trigger, and eye settings
    '*************************************************
    
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    '********Constants******************
    Trigger PIN 0
    EyeRec PIN 1
    EyeSend PIN 2
    Noid PIN 3  'havent looked up if i need another pin for this or not
    
    
    '**********Variables****************
     TimeCount VAR Word
     x VAR Word
     TriggerStat VAR Bit
    EyeEnable VAR Bit
    EyeStatus VAR Bit
    
    '********start of main program**************
    EyeEnable = 1
    Start:
    
    DO
      GOSUB CheckTriggerStat     'scans trigger to catch the pull...
      IF TriggerStat = 1 THEN    'if trigger is pulled, then...
        GOSUB TriggerTest         'check if it's a valid pull and act accordingly
      ENDIF
    LOOP
    
    
    '********Subroutines************
    TriggerTest:
    TimeCount = 0                   'reset trigger time counter for the start of each pull
    FOR x = 0 TO 1000               'long loop to cover normal fire, forced fire, and eye disable
      IF Trigger = 1 THEN           'checks trigger status
        TimeCount = TimeCount + 1   'if trigger is pulled incrament TimeCount to keep track of how long its pulled
        SELECT TimeCount            'catch for events that happen depending on how long trigger is pulled
          CASE 3                    'if trigger pulled for 3 loops then check eyes
            GOSUB NormalShot
          CASE 650                  'if trigger is held for 650 loops, fire once regardless of eye status
            GOSUB ForcedShot
          CASE 999                  'if trigger is still held, disable eyes and return to start of program
            GOSUB EyeChange
        ENDSELECT
      ELSE
        EXIT                        'if trigger is let go during cycle, go to start of program
      ENDIF                         'end of if trigger = 1
    NEXT
    RETURN
    
    '*********************************
    CheckTriggerStat:                'quick check that returns trigger status
    
    'You could just use TriggerStat = Trigger I am not sure about this as I can't test it but it syntax checks , I don't have a stamp to test the code here.
    
    IF Trigger = 1 THEN
      TriggerStat = 1                'set "trigger pulled flag" to yes
    ELSE
      TriggerStat = 0                'set "trigger pulled flag" to no
    ENDIF
    RETURN
    
    '*********************************
    NormalShot:
    IF EyeEnable = 1 THEN             'check to see if eye routines are enabled
      GOSUB Eyes                      'if they are enabled, check if they see a paintball
      IF EyeStatus = 1 THEN           'if there is a paintball, start fireing process
        GOSUB Solenoid                'go to solenoid activation routine
        GOSUB TriggerStall            'stall to wait for trigger to be released (prevent full auto)
      ENDIF
    ELSE                              'if eyes are not enabled
      GOSUB Solenoid                  'go to solenoid firing routine
      GOSUB TriggerStall              'stall till trigger is released
    ENDIF
    RETURN
    
    '*********************************
    ForcedShot:
     GOSUB Solenoid                    'forced shot, no regard for eyes
                                       'fires once and returns to trigger time counting loop
    RETURN                            'in case eyes need to be shut off
    '*********************************
    EyeChange:                        'routine for disabling eyes in case of malfunction
    
    IF EyeEnable = 1 THEN             'if the eyes are enabled, then disable them
      EyeEnable = 0
    ELSE
      EyeEnable = 1                   'if eyes are off, turn them back on
    ENDIF
    
    GOSUB TriggerStall              'wait for trigger to be released
    RETURN
    
    '*********************************
    
    Eyes:
    IF EyeEnable = 1 THEN             'check to see if eyes are enabled or not
      EyeSend = 1                     'if they are, turn on the LED
      PAUSE 2                         'wait for everything to settle (may need to be adjusted)
     
    ' this one line of code can replace the if else endif below 
    ' Eyestatus = EyeRec ^ 1
    
    '********************>>> From the Pbasic Help File <<<************************
    'The Exclusive OR operator    (|)     returns the bitwise exclusive OR of two values. Each bit of the values is subject to the following logic:
    
    '**NOTE->>> looks like a typo in the Pbasic Help File should be "(^)" not "(|)" in the above line
    
    '    0 ^ 0 = 0
    '    0 ^ 1 = 1
    '    1 ^ 0 = 1
    '    1 ^ 1 = 0
    
    '*****************
    
    
     IF EyeRec = 0 THEN              'check ir detector. if blocked, paintball is present
        EyeStatus = 1                 'set "paintball is present" variable to 'yes'
      ELSE
        EyeStatus = 0                 'if no paintball (EyeRec=1) then set no paintball loaded
      ENDIF
    ELSE                              'if the eyes are off...
      EyeStatus = 1                   'make it think theres a paintball there no matter what
    ENDIF
    RETURN
    '*********************************
    TriggerStall:
    DO UNTIL Trigger = 0              'keep looping nothing until the trigger is released
    LOOP
    RETURN
    
    
    
    '*********************************
    Solenoid:                         'yah... havent written this yet because i need to research the solenoid in my marker
    
    
    RETURN
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!

    Post Edited (metron9) : 8/11/2006 3:56:30 PM GMT
  • FireHelixFireHelix Posts: 42
    edited 2006-08-11 23:30
    Thank you very much for the pointers! Right now I am waiting to hear back from a couple paintball parts stores / websites to get the part number of the solenoid to find a spec sheet on it(one of the screws on my marker is stripped so I can't get to mine). Id rather know it's input values before I start tinkering with mine. Hopefully I'll be able to do a full "on-the-gun" test within the week.

    Thanks again for all the advice and help!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
  • willthiswork89willthiswork89 Posts: 359
    edited 2006-08-12 01:52
    by marker do you mean gun? im confused on what your doing here im familiar with paintball guns but you keep talking about markers and im not sure if were on the same page here lol/
  • FranklinFranklin Posts: 4,747
    edited 2006-08-12 05:14
    Paintball "guns" were developed as a way to mark things from a distance like cattle and trees to be cut in a forest. Only man would think of taking a tool and turning it into a weapon. [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • FireHelixFireHelix Posts: 42
    edited 2006-08-12 08:19
    technicaly they are not a "firearm" as they do not use bullets or gunpowder and hence not guns. they propel gelatin paint capsuls intended on marking a target. but for all intents and purposes the term "marker" and "gun" are interchaingable in this situation

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
  • drewdaydrewday Posts: 1
    edited 2006-08-14 00:37
    Have you considered a hardware solution to cleaning up the trigger switch output?
  • FireHelixFireHelix Posts: 42
    edited 2006-08-14 03:12
    actually no I havent... I'm fairly new to this (my signature says it perfectly) and really have no clue how I'd go about trying a "hardware solution"

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
  • metron9metron9 Posts: 1,100
    edited 2006-08-15 06:07
    I still don't get it. What is the point of holding the trigger down to disable the eye and fire the gun? You can tell if a paintball fires from the gun vs a blank shot I assume 9never fired a paintball gun) Is it because there is a delay between firing and reloading so you dont rapid fire blanks? How about a visual LED to show if there is a paintball ready to fire? (hardware solution)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
  • FireHelixFireHelix Posts: 42
    edited 2006-08-15 11:55
    ok... if paintballs are loading properly, the marker fires fast as it goes through it's normal routine. say something happens... a paintball breaks in the breech and gums up the eyes, causing them to not work. at this point, the gun would not fire as it couldnt tell if a paintball is present or not. in comes the forced shot (by holding the trigger down longer) to help clear out any junk blocking the eyes. if the eyes are still jammed, hold the trigger down longer to disable the eyes (at the risk of chopping more paintballs due to the gun being "blind") thats where the forced shot and eye-disable parts come in.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
  • metron9metron9 Posts: 1,100
    edited 2006-08-15 13:43
    If the paintball breaks in the breech.

    Without the BasicStamp and eyes another shot through the breech clears the breech on the next shot.
    With the BasicStamp you have to wait 1/2 second for it to filre

    when you hold the trigger down longer to disable the eyes (at the risk of chopping more paintballs due to the gun being "blind"

    Without the BasicStamp it fires without holding the trigger for 1 second
    With the BasicStamp you still risk chopping paintballs.

    Hmmm I guess the only reason I can come up with to have this on a gun would be if it was in automatic mode
    where holding the trigger fires paintballs at one per second or more so you dont chop a bunch of paintballs if it jams?

    If it's a single shot gun then I still dont see the need for it as it just inserts a delay that seems unnecessary.

    Is jamming of paintballs a problem with most paintball guns?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
  • FireHelixFireHelix Posts: 42
    edited 2006-08-16 00:25
    ok... I'll try and explain this some more to the best of my ability
    metron9 said...
    Without the BasicStamp and eyes another shot through the breech clears the breech on the next shot.
    With the BasicStamp you have to wait 1/2 second for it to filre
    without the stamp (or a commercially produced control board) the gun would not run at all. there has to be something in there to at the very least monitor the trigger and control the solenoid. without the eyes, yes the gun could work but then entire control of the firing procedure is based on timing, including loading. the problem that arises with that is if a paintball hasn't completely fallen into the chamber (stuck half way or something) without eyes, the gun could still fire and would chop the paintball and make a big mess. with the eyes, the board actually waits till it sees a paintball in place before allowing the firing sequence to start, thus preventing a "chopped ball"

    ok... after that being said you're prolly wondering "well why would you ever want to disable the eyes then?"
    the reason for that is just being prepared for the worst. if the eyes happen to get damaged or paint filled or something that causes them to not work right anymore i'd need some way to byepass them quickly and easily (they may break in the middle of a game... and you cant really call "time-out" or anything like that in paintball). with the eyes byepassed i'd still be able to continue the game in progress.

    as for automatic modes and such, that's in the plans but not till I get this thing working at a base level first. different paintball leagues allow different firing modes. examples are single-pull single-shot only, ramping (must keep pulling trigger like semi-auto, but the gun adds shots to get up to a certain speed of shots per second), and capped full auto (hold trigger and it fires fully automatic up to the shots-per-second cap)

    to your last question, is jamming paintballs a problem with most guns.... yes and no
    tournament level paintball markers(guns) can run upwards of $1300. the distinctive qualities of the guns are their accuracy, consistency, and rate of fire.
    for referance sake, a millitary M16 fires roughly 12-15 rounds per second... paintball guns can reach upwards of 25-30 shots per second (yes, in semi-automatic mode). trying to load gelatin shelled goo filled balls into a chamber and fire them at that rate can make for a messy time if things arent working properly, hence the need for electronic control. if the gun happens to get goo-ed up, then that hurts both accuracy and consistency, thereby reducing the effectiveness of the gun as a whole. So theres a big potential for jams, but due to electronics, they can be kept to a very minimal level.

    hopefully one of these days I'll be able to post up a couple pictures to help explain
    for anyone curious... the board thats in my gun right now is made by tadao technologies and after snooping around, it has a PIC12F629 controlling it. mfr's site

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...

    Post Edited (FireHelix) : 8/16/2006 5:39:35 AM GMT
  • TumbleweedTumbleweed Posts: 45
    edited 2006-08-17 23:54
    What marker are you tinkering with?

    Most of the e-boards I've seen as upgrades are between $50-$150 so I think using a STAMP will probably not save you any money....what it will do is let you customize how the firing works smile.gif

    I can just imagine how cool it would be to set up a firing sequence that just happens to rock out a drum beat from Matalica for instance...hehe.

    My GF plays with my old starter Spyder and routinely rips me apart even though I've got a Dye tournament grade marker now. It's all about your skill, not your gear.

    Lance
  • FireHelixFireHelix Posts: 42
    edited 2006-08-18 00:04
    The marker I'm tinkering with is my Dye Matrix (DM3, the old big bulky style matrixes) and the goal of this project isn't to save money. You hit the nail square on the head with the whole custom firing sequence idea. And yes, I know paintball is all about player skill, not the gear used. All in all, this project is just for my own satisfaction to say that I did it.
    Just for information's sake, First Strike Paintball is the field / team that I play for. Have a look see and even drop a line in our forums and say hi if you feel like it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
  • TumbleweedTumbleweed Posts: 45
    edited 2006-08-18 00:11
    Sweet project. If it works for you, you might look at commercializing it. Most of those boards out there are just that.

    We just play woodsball for fun and stress relief. Our company does a regular outing. You wouldn't believe how much fun it is to shoot the HR manager in the butt smile.gif
    Last game I walked 15 rounds across his back....luckily for him most hit his pod harness. That was with a A-5 set to 20/sec. Next game its with my new DM6 set to 30.
  • FireHelixFireHelix Posts: 42
    edited 2006-08-19 13:59
    well, I finally found a part number for the solenoid in my gun, but unfortunately it was a "custom design" that Dye Paintball had SMC make for the gun. the good news: it's controlled simply by +V = on... 0V = off. the bad news: I couldnt find what voltage it's supposed to run at. one person I talked to thought it was +5.5V but wasnt completely sure. It's not a part I'd want to blow out so I need to find out for sure what it's supposed to run at. hopefully I'll be able to control it easily with a PULSOUT. normal solenoid on time for this gun is around 15ms but can range from 10 -30 depending on setup, so I guess I'll be starting with 15ms for my testing

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
  • FireHelixFireHelix Posts: 42
    edited 2006-08-20 11:24
    ok... talked with some tech support guys and turns out the solenoids in most paintball guns are rated for around 5 volts but can handle up to 9 (with a slightly shortened life... but i think the gun itself along with my wallet would wear out before i hit 2million cycles). so, it seems that makes it quite easy for me.

    but... i do have 1 question still. I'm shooting for a 15ms pulse to the solenoid... but the number base for the PULSOUT duration is 2us. maybe ive done my math wrong (read: probably did my math wrong... its 6am and ive been up all night) but would i use a duration value of 7500? 1000us in 1ms? 15000us... divide by 2 because of the 2us base... 7500 right?

    if i'm right... then i'm looking at the first code ready for hardware testing!!! WOOHOO!!!!
    i dub thee "please please please work!!" also known as beta 1 :-P

    *edit: added attachment of current code in case anyone wants to take a look-see

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...

    Post Edited (FireHelix) : 8/20/2006 11:45:33 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-08-20 13:14
    Yes, a duration count of 7500 at 2us per count gives a grand total of 15ms. Good luck!
  • Tom RoseTom Rose Posts: 1
    edited 2006-08-20 13:37
    You have had a lot of discussion so far about how to handle a failure of the eye sensor. I think this is critical to the correct function of your fire routine and you are wise to consider it. What worries me is that it seems to me that you have all assuming that the eyes will fail-off. I think the eyes are more likely to fail-on. (I'm assuming it's some sort of infra-red sensor checking for balls.) I used to play a lot of paintball, and it's entirely possible for you to chop a ball, or get some dirt up in your eye sensor. I feel that what would happen in that situation is that your eyes would give a false positive, not a false negative response. Meaning, it will inditate to your controller that there is a ball present, even when there isn't one causing you to chop balls like crazy because you'll keep firing and firing with the breach half loaded.

    Your work arounds so far all assume that the only user-input-device is the trigger, and the only user-output-device is the solenoid valve. Have you considered using LEDs and/or pushbuttons for changing modes and indicating modes? You'll need a reset switch anyway, or a routine to automatically shift back to default mode after 5 minutes or something. Otherwise your marker will be stuck in blind mode. I would think that you could benefit from a button or switch that puts the eye subroutine into a force-succeed mode rather than responding to a long trigger hold. That way, you can flip the switch back at any time.

    Also, the way your program works right now, I think it only goes into blind mode if the eye detects nothing for a long time. I can only see that happening if you're out of balls, in which case you wouldn't want to force blind. If the eye fails-possive, then the gun will just fire and fire and fire with nothing present in rapid fire mode, which is something you definitely don't want.

    Something you coulud definitely benefit from is having a marker that never dry fires. Opponents can hear the difference between a dry fire and a real fire, and in my day if you ever shot a single dry fire, then your *** was grass in about 5 seconds because you would be bunkered. So, preventing the dry fire by not firing if they eye doesn't see anything is great and I don't think you really need to worry about disabling that too often. I feel like a fail negative would be pretty rare. You should hook your eye output up to an o-scope and simulate all the failures you're talking about to see how the output changes under those conditions.

    This is a great project. Good luck!
  • FireHelixFireHelix Posts: 42
    edited 2006-08-21 11:42
    well Tom thank you very much for the feedback! I'll try and address / comment on as many of the topics you brought up as I can.

    For starters, I am using a break-beam eye setup (infra-red LED on one side of the breech, reciever on the other)
    and yes, in this setup, if the eyes fail (reciever for LED sees nothing, which normally indicates a ball present) then the gun could fire at a point when a ball was only partly loaded, resulting in a chop. I am currently working on a routine to check the eyes again as soon as the solenoid turns off to make sure theres a point when the reciever DOES get a beam from the LED (indicating no ball loaded, eyes still work). that way if the eyes never see that open breech right after firing (even though its only open for a split second) the board would be able to tell that the eyes are not working.

    the reason I'm basing this code off of a trigger input only is that I'm half way modeling it after the current board I'm using (The Matrix Center's eyes and board, which the board is a Tadao 1.1) This board has the trigger input, a push button on-off, and the eyes. as outputs, the solenoid and a status LED. I'm not really a fan of having a slide switch for control over the eyes as switches can be hard to use with gloves on. much easier to just pull and hold the trigger. I'm working on coding in a status led (solid on = gun on, eyes on. blinking = gun on eyes off) but at some point I'd like to add a LCD to it.
    you commented on being able to turn the eyes back on if needed. that is already written into my code. the eye change routine turns the eyes off if theyre on, and vice versa.

    right now, the only way the program goes into blind mode is if you pull the trigger and hold it till it goes through the eye change sub. it never forces itself into blind mode.

    as for simulating eye failures with an o-scope... I'm just out of college and flat broke smile.gif a scope is far down on the list of things to spend my money on. my girlfriend nearly shot me when she found out I bought the parts I got now (the BS2... the board...)


    at some point, though I know it would be overkill, but to rewrite all this for a propeller would be kinda fun. have a separate cog for trigger monitoring, eye monitoring, solenoid controll, lcd display and main program... ah dreams... lol rolleyes.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...

    Post Edited (FireHelix) : 8/21/2006 11:55:07 AM GMT
  • FireHelixFireHelix Posts: 42
    edited 2006-08-21 12:54
    well, I did some work on the code and added the following:
    -a status LED, solid on = marker working fine, fast blinking = eye error
    -eye checking sequence, checks that after solenoid turns off there is a short time that the eyes see an empty breech, if they dont, the program goes into an eye error routine that flashes the led and waits for the trigger to be pulled and held for a short time to disable the eyes (acts as a warning, but allows the eyes to be shut off to continue a game in progress)

    still working on having the led flash at a slow rate when the gun is on but the eyes are disabled

    I'd post up the new code, but I want to look it over again after I've had some sleep. (yes I know I'm making this post at 7:50am... I'm a night owl and normally awake from 4pm till now. product of working night shift at my old job)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
  • willis123willis123 Posts: 11
    edited 2006-08-28 16:42
    Firehelix,
    By some strange turn of events I ran across an article on WARPIG (World And Regional Paintball Information Guide) about 2 weeks ago that got me started on a project to put an ebolt in my 98 with a BS2 running it. I'm interested in how you're setting up the code to check if the eyes are working properly. Hopefully you can post the code some time. I was mainly wondering how long you wait after the bolt returns to the cocked position to see if a ball has loaded yet. Oh, you may have seen it already, or may know more than the article says, but here's a link to part 1 of the WARPIG article:

    http://www.warpig.com/paintball/technical/electronics/basic_stamp/
  • FireHelixFireHelix Posts: 42
    edited 2006-08-29 03:11
    willis123 thank you VERY much!! you found a gem that will and already just in reading it has been a huge help. I was writing the code completely from scratch which, for my first project other than my boe bot, was proving to be quite a challenge. now you've given me a referance point to build from. thank you again and code is on the way.

    as for te eye, i use break beam eyes so when a paintball is present the beam is blocked. this poses a problem if the eyes break, it would appear a paintball is always present.
    i countered this by checking the eyes again as the bolt in my matrix is pulling back (fireing complete). the eyes should see a point in which there is no paintball in the breech (it's falling down into the breech at this point) if the stamp never gets a "breech clear" signal from the eyes, it assumes they are broken and effectively disables the gun while flashing the status LED. the gun is reenabled in eye off mode when the trigger is held down for approx 1 second. or, the other option is to turn the gun off and then back on again (the eyes are on by default on startup)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
  • FireHelixFireHelix Posts: 42
    edited 2006-08-29 12:42
    well, here is the code from the article. the article states that it was written for a BS1 so i'm going to have to translate it into a little more BS2e friendly coding. definitely going to see if i can use the button command to detect my trigger pulls, but im not sure if i'll be able to use that with my whole system of using trigger pull lengths for setting eye-status and such.

    '### Semi-Auto simulation Software for single solenoid
    '### design  Copyright 2002, William R. Mills III All
    '### Rights ReservedThis program may only be used in a
    '### Basic Stamp with LEDssimulating the physical
    '### interface to a paintgun, for educationalpurposes.
    '###
    
    
    '#  Configure and set variables
     SYMBOL dwell=B10 '# call b10 dwell which is easier to
                      'remember
     SYMBOL drop=B11 '# call b22 drop which is easier to
                      'remember
     LET B2=0  '# clear b2 so BUTTON can use it for the
                'trigger
     LET B3=0  '# clear b3 so BUTTON can use it for the
                'mode button
     LET dwell=30  '# set the dwell delay to 30 ms
     LET drop=30  '# set the drop delay to 30 ms
    '# The dwell delay is how long the solenoid must be
       'held open for a full and
    '# complete firing cycle.  The drop delay is the minimum
        'amount of time the
    '# breech must be held open between shots to give time
        'for a new ball to fall
    '# into the breech.
    '######
    
    
    '# Flash the power LED to show that the board is working
      'properly
    '# when the power is turned on, and then leave it on
     LOW 0   '# Make sure that the power LED is off
     PAUSE 100  '# Wait for 100 milliseconds &#8211; 1/10
                 'of a second
     TOGGLE 0   '# Turn the power LED from off to on
     PAUSE 100  '# Wait again
     TOGGLE 0   '# Turn the power LED back off
     PAUSE 100  '# Wait again
     TOGGLE 0   '# Turn the power LED back on
    '######
    
    '##### Safe mode &#8211; Gosafe comes before safe mode so we
           'don&#8217;t waste processor
    '# time constantly setting the safe LED when
       'we&#8217;re running the BUTTON command
    '# waiting for the paintgun to get switched
       'into semi mode.  This isn&#8217;t so important
    '# now as when we&#8217;re also taking the time to
       'send data to an LCD each time we go
    '# into safe mode.
    
     Gosafe:    '# Label the gosafe procedure
      LOW 1  '# Turn I/O pin 1 low to turn off the safe/semi
                'LED
     Safe:   '# Label the safe procedure
      BUTTON 7,1,255,1,B3,0,skip1
           '# If the mode button is not pressed go to Skip1
      GOTO Gosemi  '# If the button was pressed we goto Gosemi
      Skip1:  '# If the button wasn&#8217;t pressed we end up here
      GOTO Safe '# and then go back to safe and keep
        '# waiting for the button to be pressed
    '#######
    
    '####### Semi-auto mode, here we have to watch the
           'trigger for button presses
    '# and act on them, as well as watch the
    '# mode button and go back to safe mode
    '# if it is pressed.  Notice a new command here &#8211;
    '# gosub.  Goto will go to a new
    '# place in the program and just continue on.
    '#  Gosub will go to a subroutine and
    '# when that subroutine is done (subroutines
    '# are ended with a return command)
    '# the program will come back and continue on, right
    '# after where the gosub command
    '# was in the list.
    
     Gosemi:   '# That&#8217;s the label for this procedure
      HIGH 1  '# Turn I/O pin 1 high to light the
              '# LED and show we
              '# are live in semi-auto mode
     Semi:   '# Now were in the semi auto procedure
      BUTTON 6,1,255,1,B2,0,skip2
     '# If the trigger was not pressed skip ahead to skip2
      GOSUB fire
    '# If the trigger was pressed execute to the
    '#firing subroutine
      Skip2:  '# whether we did or didn&#8217;t shoot we end up here
      BUTTON 7,1,255,1,B3,0,skip1
    '# If the mode button is not pressed go to Skip3
      GOTO Gosafe '# If mode was pressed we go back to safe
      Skip3:  '# Here we are at skip3
      GOTO Semi: '# If we didn&#8217;t change modes
    '#look for the next trigger press
    '##########
    
    
    '###### The firing sub-routine &#8211; this is where
    '# we trip our firing solenoid/LED
     Fire:   '# That&#8217;s the name of the subroutine
      LOW 0  '# We&#8217;ll blink off the power LED
        '# while firing to show that
        '# we&#8217;re trying to fire even if
        '# there&#8217;s some malfuction
      HIGH 2  '# Give the MOSFET power to open
         '#the solenoid valve
      PAUSE dwell
        '# Now we&#8217;ll wait for the number of milliseconds we
        '# specified when we set the dwell value earlier
      LOW 2  '# Now we&#8217;ll drop I/O Pin 2 and close the valve
      PAUSE drop '# Now we&#8217;ll pause before the next
                 '#shot to allow time for
        '# a ball to feed
      HIGH 1  '# And now turn the power light back on
      RETURN  '# We&#8217;re done shooting so we return
              '#to the line in the
        '# program just below the gosub command that sent
        '# us here
    '######
    



    cant wait to see what a modified version of this plus my eye routines can make my paintball gun do

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know just enough to tinker with something... but not enough to fix it when I break it. Thank the techie gods theres forums...
Sign In or Register to comment.