Shop OBEX P1 Docs P2 Docs Learn Events
help with paintball gun trigger progect project before i spend money i dont have - Page 2 — Parallax Forums

help with paintball gun trigger progect project before i spend money i dont have

2»

Comments

  • Dr. EvilDr. Evil Posts: 4
    edited 2005-02-13 22:57
    Why is it when i debug the Shots its always 1 more than what i set as my variables?
    example 1 to 6 as the program showa will show up as 7 on the debug screen
  • steve_bsteve_b Posts: 1,563
    edited 2005-02-13 23:09
    Attach your program or post the part that applies!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://members.rogers.com/steve.brady
    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • Dr. EvilDr. Evil Posts: 4
    edited 2005-02-13 23:19
    Sorry, here is the program
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    TRIGGER PIN 0
    TrMODE PIN 1
    SOLENOID PIN 15
    SHOOT CON 0
    RELEASE CON 1
    MdSINGLE CON 1
    MdBURST CON 0
    IsOn CON 1
    IsOff CON 0
    SHOTS VAR Nib
    Reset:
    LOW Solenoid
    Main:
    DEBUG ? Shots···························· ' Here is the debug command
    IF ( Trigger = Shoot )THEN
    IF ( TrMode = MdSingle) THEN
    GOSUB Fire_Solenoid:
    ELSE
    FOR shots = 1 TO 3····················· ' The solenoid will fire 3 times but will show up on the debug as 4?
    GOSUB Fire_Solenoid
    IF (Trigger = Release) THEN EXIT
    NEXT
    ENDIF
    DO : LOOP WHILE (Trigger = Shoot)
    ENDIF
    GOTO main:
    Fire_Solenoid:
    Solenoid = IsOn
    PAUSE 250
    Solenoid = IsOff
    PAUSE 250
    RETURN
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-02-13 23:27
    ·· John, at the completion of the FOR NEXT loop, the value is going to be one higher due to the way the testing is done in the command.· Please see the online help for the FOR...NEXT, it explains this.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --==<{Chris}>==--
  • ShootPaintShootPaint Posts: 9
    edited 2005-02-27 05:15
    Here is a fully functional code with trigger programmable menus. The only thing I have not finished at this time is the BPS counter.

    It has user input abilities for:

    Solenoid on time
    Solenoid off time
    Trigger Debounce
    Anti chop eye delays
    Anti Chop eye automatic override
    Anti Chop eye manual override.

    Load the program into your chip and then cycle power to the chip while holding down the trigger switch. Your debug screen should come up and display the program menu. If you do not wish to enter the menu simply cycle the power to your chip and the program will be ready to fire.

    To change values in the program mode you must:
    1) Power chip up with trigger pressed.
    2) Release trigger when disired option is displayer
    3) Pull trigger until desired time is entered
    4) Release trigger
    After a few ms the chip will enter the firing mode and be ready to cycle. If you wish to program additional options you will need to cycle power to the chip and repeat the above steps.

    If you want to disable the anti-chop eye set the PDSVal to 3 or hold the trigger down for about a half second. This should disable the anti-chop eye mod in the software.

    1 = Solenoid on time (duration the solenoid is on. This is selectable from 2-30ms in 2ms steps)
    2 = BPS counter (this is non functioning in this software)
    3 = Solenoid off time (duration the solenoid is off. This is selectable from 2-50ms in 2ms steps)
    4 = Anti -Chop Eye delay (electronic firing delay after the Eye detects paint. Selectable in 2ms steps from 2-40 ms)
    5 = Trigger Debouce (timer to debounce the trigger switch. Selectable in 5ms steps from 5-100ms)
    6 = Current Settins (displays·values for all options listed above)

    The trigger is looking for a high input on Input 10 to intiat the firing sequence. A firing status LED is connected to pin 5. The positive side of the LED should goto pin 5 through a 330 ohm resistor. The Anti-Chop eye system may need to have the FREQOUT tuned to your infared transmitter and reciever. The Anti-Chop eye system is hooked up to pin 5 for power and pin 2 for input from the reciever.

    By simply changing a few of the Menu options you can use it to program your firing modes via the trigger instead of a secondary buttom. Each option is stored as a varible and called by the program as needed.

    This is the last version of the code I was working on before I moved onto a new chip with higher memory abilities. This will leave very little room in your BS2. I think that pretty well documents all function of the code below. If you have any questions give me a shout.

    Heres the code. Hope it helps.


    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    MENU:
    MENReg VAR Word
    Dwell VAR Word
    BPS VAR Word
    OFFTM VAR Word
    PDSDLY VAR Word
    TrgDeBnce VAR Word
    PDSval VAR Word
    TRGval VAR Word
    READ 10, Word dwell
    READ 20, Word BPS
    READ 30, Word OFFTM
    READ 40, Word PDSDLY
    READ 50, Word TrgDeBnce
    READ 60, Word PDSval
    READ 70, Word TRGval

    IF (IN10=1) THEN
    · DEBUG "Menu Entered"· ,CR
    ·· PAUSE 250
    ··· DO
    ····· menreg = menreg +1
    ······· IF menreg =1 THEN
    ······· DEBUG "Dwell" ,CR
    ······· FREQOUT 5, 500, 1
    ······· LOW 5
    ······· PAUSE 1000
    ······· DEBUG CLS
    ······· ELSE
    ······· ENDIF
    ················· IF menreg=2 THEN
    ················· DEBUG "BPS" , CR
    ················· FREQOUT 5, 1000,2
    ················· LOW 5
    ················· PAUSE 1000
    ················· DEBUG CLS
    ················· ELSE
    ················· ENDIF
    ····················· IF menreg=3 THEN
    ····················· DEBUG "OffTm" ,CR
    ····················· FREQOUT 5, 1000,3
    ····················· LOW 5
    ····················· PAUSE 500
    ····················· DEBUG CLS
    ····················· ELSE
    ····················· ENDIF
    ························· IF menreg=4 THEN
    ························· DEBUG "PDS Dly" ,CR
    ························· FREQOUT 5, 1000, 4
    ························· LOW 5
    ························· PAUSE 500
    ····················· DEBUG CLS
    ························· ELSE
    ························· ENDIF
    ······························· IF menreg=5 THEN
    ······························· DEBUG "Trgr Debnce" ,CR
    ······························· FREQOUT 5, 1000, 5
    ······························· LOW 5
    ······························· PAUSE 500
    ····················· DEBUG CLS
    ······························· ELSE
    ······························· ENDIF
    ······································· IF menreg=6 THEN
    ······································· DEBUG "Display settings" ,CR
    ······································· FREQOUT 5, 1000, 6
    ······································· LOW 5
    ······································· PAUSE 500
    ······································· DEBUG CLS
    ······································· ELSE
    ······································· ENDIF
    ········· IF (IN10=0) THEN
    ············ GOTO Compare:
    ···················· ELSE
    ···················· ENDIF
    ··· IF menreg = 6· THEN
    ··············· menreg = 0
    ··············· ELSE
    ··············· ENDIF
    ·············· LOOP
    · ELSE
    · GOTO Trigger
    ENDIF
    END





    Compare:
    BRANCH menreg, [noparse][[/noparse]trigger, dwel,bp, offt, pdsdl, trgdebnc, set]
    END
    set:
    DEBUG HOME, CLS, " Board settings", CR,LF
    DEBUG "Dwell=" ,DEC dwell,CR,LF
    DEBUG "BP=", DEC BPs, CR,LF
    DEBUG "Sol offtm=" ,DEC offtm, CR,LF
    DEBUG "PDS Delay=" ,DEC pdsdly,CR,LF
    DEBUG "Trigger Debounce=",DEC trgdebnce,CR,LF
    DEBUG "Please cycle marker power"
    DO
    FREQOUT 5,1000,8
    LOOP UNTIL(IN10=1)
    DO
    FREQOUT 5,1000,8
    LOOP UNTIL (IN10=0)
    GOTO Cycstart
    END
    Dwel:
    dwell = 0
    DO
    DEBUG CLS, "Need input"
    LOOP UNTIL (IN10=1)
    DO
    DEBUG CLS, "Dwell = " , DEC dwell
    ···· dwell = dwell + 1
    ··· FREQOUT 5, 1000, dwell
    ··· PAUSE 1000
    ····· IF dwell >= 15 THEN
    ······· dwell = 0
    ······· ELSE
    ······· ENDIF
    ··· IF (IN10=0) THEN
    ····· dwell = dwell * 2
    ····· DEBUG CLS, "Dwell = ", DEC dwell, CR
    ····· WRITE 10, Word dwell
    ····· PAUSE 250
    ····· GOTO Set
    ····· ELSE
    ····· ENDIF
    ····· LOOP
    END
    BP:
    BPS = 0
    DO
    DEBUG CLS, "need input"
    LOOP UNTIL (IN10=1)
    DO
    DEBUG CLS, "BPS = ", DEC BPS
    · BPS = BPS + 1
    · FREQOUT 5,1000, bps
    ····· PAUSE 750
    ····· IF BPS >= 36 THEN
    ······· GOTO BP
    ······· ELSE
    ······· ENDIF
    · IF (IN10=0) THEN
    · DEBUG CLS, "BPS = ", DEC BPS
    · bps = 1000/bps
    · WRITE 20, Word bps
    · PAUSE 500
    GOTO Set
    ELSE
    ENDIF
    LOOP
    END
    OFFT:
    offtm = 0
    DO
    DEBUG CLS, "Need input = "
    LOOP UNTIL (IN10=1)
    DO
    DEBUG CLS, "Solenoid off time = ", DEC offtm, CR
    · offtm = offtm + 1
    ··· FREQOUT 5,1000, offtm
    ··· PAUSE 750
    ··· IF offtm >= 25 THEN
    ··· offtm = 0
    ··· ELSE
    ··· ENDIF
    · IF (IN10=0) THEN
    · offtm = offtm * 2
    · DEBUG CLS, "Solenoid off time = ", DEC offtm, CR
    · WRITE 30, Word offtm
    · PAUSE 250
    · GOTO Set
    · ELSE
    · ENDIF
    · LOOP
    END

    PDSDL:
    pdsdly = 0
    DO
    DEBUG CLS, "Need input = "
    LOOP UNTIL (IN10=1)
    DO
    DEBUG CLS, "PDS Delay = ", DEC pdsdly, CR
    · pdsdly = pdsdly + 1
    · FREQOUT 5,1000, pdsdly
    · PAUSE 750

    ·· IF pdsdly > 15 THEN
    ····· pdsdly = 0
    ····· ELSE
    ····· ENDIF
    · IF (IN10=0) THEN
    · pdsdly = pdsdly * 2
    · DEBUG CLS, "PDS Delay Time = ", DEC pdsdly, CR
    · WRITE 40, Word pdsdly
    · PAUSE 250
    · GOTO Set
    · ELSE
    · ENDIF
    · LOOP
    END
    TRGDEBNC:
    trgdebnce = 0
    DO
    DEBUG CLS, "Need input = "
    LOOP UNTIL (IN10=1)
    DO
    DEBUG CLS, "Trigger Debounce Setting = ", DEC trgdebnce, CR
    · trgdebnce = trgdebnce + 1
    · FREQOUT 5,1000, trgdebnce
    · PAUSE 750

    ··· IF trgdebnce >= 21 THEN
    ····· trgdebnce = 0
    ····· ELSE
    ····· ENDIF
    · IF (IN10=0) THEN
    · trgdebnce = trgdebnce * 5
    · DEBUG CLS, "Trigger Debounce Setting = ", DEC trgdebnce, CR
    · WRITE 50, Word trgdebnce
    · PAUSE 250
    · GOTO Set
    · ELSE
    · ENDIF
    · LOOP
    END

    ERROR:
    DO
    DEBUG HOME, CLS, "MenReg error", CR
    DEBUG "please power marker off and back on",CR
    LOOP
    END

    Trigger:
    PAUSE offtm
    DO
    · IF (IN10 = 1) THEN
    ··· DEBUG CLS, "Trigger pulled", CR
    ····· GOTO PDS
    · ELSE
    ··· PAUSE 1
    ·· ENDIF
    LOOP
    END

    PDS:
    PDSval= pdsval + 1
    IF PDSval = 3 THEN
    DEBUG "Eyes Blocked" ,CR
    ··· DEBUG "Turn PDS off"
    ··· GOTO cylce
    ···· ELSE
    ··· FREQOUT 5,pdsdly,5000
    ····· IF (IN2 = 0) THEN
    ··· DEBUG "Paint Detected" ,CR
    ······· PAUSE pdsdly
    ······· PDSVal = 0
    ······· GOTO Cycle
    · ELSE
    ··· DEBUG "NO Paint" ,CR
    ··· PAUSE pdsdly
    ···· IF (IN2 = 0) THEN
    ····· GOTO Cycle
    ··· ELSE
    ··· GOTO PDS

    · ENDIF
    · ENDIF
    END

    Cycle:
    OUTPUT 15
    PAUSE dwell
    OUTPUT 15
    · DO
    ··· trgval= trgval + 1
    ··· LOOP UNTIL IN10=0
    ··· DEBUG "Trigger Released" ,CR
    ··· PAUSE trgdebnce
    ··· HIGH 5
    ··· IF trgval = 50 THEN
    ··· PDSval = 3
    ··· Trgval=0
    GOTO Trigger
    END
    CycStart:
    DEBUG "Release trigger"
    DO
    FREQOUT 5, 1000,8
    LOOP UNTIL IN10=0
    DEBUG "Trigger Released"
    GOTO trigger
    END

    Post Edited (ShootPaint) : 2/27/2005 5:44:23 AM GMT
  • glitchglitch Posts: 7
    edited 2005-02-27 13:22
    one thing you could do to combat seting it up to fire to quickly for the gun to spring back to cocked,,, a potentiometer, to a pin, controloing bps, with a simple display inside, with reguards to bps (ball per second) a tippman is prolly the best choice to "jerry rig" a triger, since its prolly one of the faster guns,, personally thoughi woldnt want to be held back to a perticular seting if im gonna go threw the time to make it imma add in some bells and wistles, one i sugest is pot controlled bps, so you can slow the gun down when yer running low on paint, if im not mistaken there factory rating is 26 0r 28 bps, i know the whats a microprossesor book by paralax will give you code to operate a pot, then lable bps a var, corosponding to position of pot, juala now your paintball trigger has something unique there for making it a step above a jerry riged triger to a one of a kind, adjustable rate, custom triger that every one will want , id put the pot inside the handle ive never changed my gun setings in play,, and you dont want it open to the dirt mud snow water etc of a good field,,
    an even beter thing to do ,, like the spyders , make 3 or 4 diff setings via your second buton, make one of them relate to the pot position for bps, if you make your "B" button more easily acessable then the spyder ones ( i happen to have here) youll be able to quickly ( with prtective gloves) acces the buton in play for those times u run low on paint, are just laying cover fire, and some what easily switch from one to another,

    it astonishes me that a low budjet baller like my self, didnt think of this since a box of paint is 100 $, and my tweeked spyder shoots about 30 bps, or a hoper in less then a min, if youve ever used an e trig, i personally never used the 1 3 shot setings, or either of the slow ones, since controling setings in game is extreamly dificult, instad i leave it on the fastest i got, and then i run outta paint, *but if you design ti prperly with a gloved user inmind, you might make a uniquely functional triger.
    just keep in mind , at 25 cents a ball, 30 bps might not be the way to go for a budjet player, i cant count how many times i got unloaded on by some rich 14 yr old with a tippman , cause i was outa paint and shotting air at him
  • Pinoy NYCPinoy NYC Posts: 30
    edited 2005-03-01 16:00
    Hi Nick,

    I just have a question regarding the circuit, I'm not an electronic expert.
    Just regarding a pull down 10k resistor on the 2n7000 and also a 10k resistor for the BS pin,
    bot connected to the gate.

    if they are both 10k, they are passing the same current from ground and from the BS2pin signal,
    and the 2n7000 can't tell exactly which one to follow, correct me if I'm wrong.

    Should the 10k resistor from the BS2 pin be at least less than the pull down resistor (10k)?
    so that it will override the pulldown when it sends out the signal?


    nick bernard said...
    Lets verify your circuit to make sure we all understand each other.

    does your circuit look anything like this?
    are your inputs active high or low?
    what are the specs on your solenoid?
    etc....
    Post Edited (Pinoy NYC) : 3/1/2005 4:10:21 PM GMT
  • blink13blink13 Posts: 65
    edited 2005-03-01 22:55
    yeh thnx alot im sorry i havent been here for about a week i was on vacation i will try the code and i am thinking of ordering a solenoid but not shure wich one to get
  • blink13blink13 Posts: 65
    edited 2005-03-01 22:57
    ok what is "EEPROM full" mean
  • OrionOrion Posts: 236
    edited 2005-03-01 23:07
    End of program! No more memory in the stamp for code.
  • blink13blink13 Posts: 65
    edited 2005-03-01 23:34
    oh then shoot paints program is to long
  • OrionOrion Posts: 236
    edited 2005-03-02 01:07
    or your stamp is too small...
  • blink13blink13 Posts: 65
    edited 2005-03-02 01:42
    how can i get mor space on my stamp???
  • nick bernardnick bernard Posts: 329
    edited 2005-03-02 19:58
    other stamps (bs2sx, bs2p, bs2pe, bs2e) have more programming space than the bs2
    Pinoy NYC said...

    if they are both 10k, they are passing the same current from ground and from the BS2pin signal,
    and the 2n7000 can't tell exactly which one to follow, correct me if I'm wrong.

    Should the 10k resistor from the BS2 pin be at least less than the pull down resistor (10k)?
    so that it will override the pulldown when it sends out the signal?
    Hail Pinoy,

    1) when a bs2 resets all the pins become inputs and high impedance which would cause the gate of the fet to float and maybe fire the Solenoid. the pull down resistor simply keeps the fet off while the IO pin gets ready. also, current does not flow from ground.

    2) the resistors between the stamp and fet form a voltage divider.
    Vgs = Vpin*R1/(R1+R2); since R1 = R2 Vgs = .5*Vpin; since Vpin =5v, Vgs = 2.5v < 2.0v hence the 2n7000 will saturate and supply ground to the coil of the solenoid

    rox on dude
    nickB

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    League Bowling.... it's not a sport, it's a way of life

    Post Edited (nick bernard) : 3/2/2005 8:04:08 PM GMT
  • blink13blink13 Posts: 65
    edited 2005-03-02 22:27
    oh thanx ill probably be gettin a new stamp cause my homework boards voltage regulator board blew and i sent it in but who knows when ill get it back, any suggestions for stamps that i should use??
  • ExilictExilict Posts: 31
    edited 2005-03-03 02:39
    blink13,
    Your tippman? Doesn't that opperate off of a sear? If that is a case you need to design a sear tripper program, not a solenoid program.

    By the way guys.... ( If any of you remember who I am smile.gif )

    http://home.comcast.net/~c.lobozzo/Timmy3.mov
    http://home.comcast.net/~c.lobozzo/Timmy2.mov
    Woo Wooo Wooo....

    100% Cheaterboard.. It is the only one like it in the world....

    -X

    Post Edited (Exilict) : 3/3/2005 2:42:39 AM GMT
  • Pinoy NYCPinoy NYC Posts: 30
    edited 2005-03-03 17:11
    Hi Nick,

    yes, i know the function of pulldown, it just got me confuse since there are two 10k resistor in there.
    just from what I've learned from electronic class, that have to use less resistance on the controlling pin to overpower the pulldown.
    and also that electrons flow from NEGATIVE side to POSITIVE, not the other way around as we made to believe.

    shakehead.gif

    But thanks for bringing up the voltage divider thing, and that it is a FET, not a regular transistor (PNP/NPN) , I didn't notice that...

    nick bernard said...
    other stamps (bs2sx, bs2p, bs2pe, bs2e) have more programming space than the bs2
    Hail Pinoy,

    1) when a bs2 resets all the pins become inputs and high impedance which would cause the gate of the fet to float and maybe fire the Solenoid. the pull down resistor simply keeps the fet off while the IO pin gets ready. also, current does not flow from ground.

    2) the resistors between the stamp and fet form a voltage divider.
    Vgs = Vpin*R1/(R1+R2); since R1 = R2 Vgs = .5*Vpin; since Vpin =5v, Vgs = 2.5v < 2.0v hence the 2n7000 will saturate and supply ground to the coil of the solenoid

    rox on dude
    nickB
    Post Edited (Pinoy NYC) : 3/3/2005 5:50:17 PM GMT
  • nick bernardnick bernard Posts: 329
    edited 2005-03-03 20:47
    righto Pinoy,
    fets are voltage controlled and bjt's are current controlled wrt Hfe.

    when the founding fathers of electricity defined current they arbitrarily stated that current flows from positive potential to negativepotential. it makes sense if you dont know about electric field theory. my physics prof in college used to poke fun at engineers for getting it backwards... this also helps to explain why physics/engineer double majors are self-hating... heh, thats a little joke there....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    League Bowling.... it's not a sport, it's a way of life
  • ShootPaintShootPaint Posts: 9
    edited 2005-03-18 04:25
    Sorry about that. I posted the wrong code.

    Here is another version of the software. This one doesnt have the manual or automatic ACE override.



    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    MENU:
    MENReg VAR Word
    Dwell VAR Word
    BPS VAR Word
    OFFTM VAR Word
    PDSDLY VAR Word
    TrgDeBnce VAR Word
    READ 10, Word dwell
    READ 20, Word BPS
    READ 30, Word OFFTM
    READ 40, Word PDSDLY
    READ 50, Word TrgDeBnce

    IF (IN10=1) THEN

    · DEBUG "Menu Entered"· ,CR
    ·· PAUSE 250
    ··· DO
    ····· menreg = menreg +1
    ······· IF menreg =1 THEN
    ······· DEBUG "Dwell" ,CR
    ······· FREQOUT 5, 500, 1
    ······· LOW 5
    ······· PAUSE 1000
    ······· DEBUG CLS
    ······· ELSE
    ······· ENDIF
    ················· IF menreg=2 THEN
    ················· DEBUG "BPS" , CR
    ················· FREQOUT 5, 1000,2
    ················· LOW 5
    ················· PAUSE 1000
    ················· DEBUG CLS
    ················· ELSE
    ················· ENDIF
    ····················· IF menreg=3 THEN
    ····················· DEBUG "OffTm" ,CR
    ····················· FREQOUT 5, 1000,3
    ····················· LOW 5
    ····················· PAUSE 500
    ····················· DEBUG CLS
    ····················· ELSE
    ····················· ENDIF
    ························· IF menreg=4 THEN
    ························· DEBUG "PDS Dly" ,CR
    ························· FREQOUT 5, 1000, 4
    ························· LOW 5
    ························· PAUSE 500
    ····················· DEBUG CLS
    ························· ELSE
    ························· ENDIF
    ······························· IF menreg=5 THEN
    ······························· DEBUG "Trgr Debnce" ,CR
    ······························· FREQOUT 5, 1000, 5
    ······························· LOW 5
    ······························· PAUSE 500
    ····················· DEBUG CLS
    ······························· ELSE
    ······························· ENDIF
    ······································· IF menreg=6 THEN
    ······································· DEBUG "Display settings" ,CR
    ······································· FREQOUT 5, 1000, 6
    ······································· LOW 5
    ······································· PAUSE 500
    ······································· DEBUG CLS
    ······································· ELSE
    ······································· ENDIF

    ········· IF (IN10=0) THEN
    ············ GOTO Compare:
    ···················· ELSE
    ···················· ENDIF
    ··· IF menreg = 6· THEN
    ··············· menreg = 0
    ··············· ELSE
    ··············· ENDIF

    ·············· LOOP
    · ELSE
    · GOTO Trigger
    ENDIF
    END










    Compare:
    BRANCH menreg, [noparse][[/noparse]trigger, dwel,bp, offt, pdsdl, trgdebnc, set]
    END

    set:
    DEBUG HOME, CLS, " Board settings", CR,LF
    DEBUG "Dwell=" ,DEC dwell,CR,LF
    DEBUG "BP=", DEC BPs, CR,LF
    DEBUG "Sol offtm=" ,DEC offtm, CR,LF
    DEBUG "PDS Delay=" ,DEC pdsdly,CR,LF
    DEBUG "Trigger Debounce=",DEC trgdebnce,CR,LF
    DEBUG "Please cycle marker power"
    DO
    FREQOUT 5,1000,8
    LOOP UNTIL(IN10=1)
    DO
    FREQOUT 5,1000,8
    LOOP UNTIL (IN10=0)
    GOTO Cycstart
    END

    Dwel:
    dwell = 0
    DO
    DEBUG CLS, "Need input"
    LOOP UNTIL (IN10=1)
    DO

    DEBUG CLS, "Dwell = " , DEC dwell
    ···· dwell = dwell + 1
    ··· FREQOUT 5, 1000, dwell
    ··· PAUSE 1000
    ····· IF dwell >= 15 THEN
    ······· dwell = 0
    ······· ELSE
    ······· ENDIF
    ··· IF (IN10=0) THEN
    ····· dwell = dwell * 2
    ····· DEBUG CLS, "Dwell = ", DEC dwell, CR
    ····· WRITE 10, Word dwell
    ····· PAUSE 250
    ····· GOTO Set
    ····· ELSE
    ····· ENDIF
    ····· LOOP
    END

    BP:
    BPS = 0
    DO
    DEBUG CLS, "need input"
    LOOP UNTIL (IN10=1)
    DO
    DEBUG CLS, "BPS = ", DEC BPS
    · BPS = BPS + 1
    · FREQOUT 5,1000, bps
    ····· PAUSE 750
    ····· IF BPS >= 36 THEN
    ······· GOTO BP
    ······· ELSE
    ······· ENDIF
    · IF (IN10=0) THEN
    · DEBUG CLS, "BPS = ", DEC BPS
    · bps = 1000/bps
    · WRITE 20, Word bps
    · PAUSE 500
    GOTO Set
    ELSE
    ENDIF
    LOOP
    END

    OFFT:
    offtm = 0
    DO
    DEBUG CLS, "Need input = "
    LOOP UNTIL (IN10=1)
    DO
    DEBUG CLS, "Solenoid off time = ", DEC offtm, CR
    · offtm = offtm + 1
    ··· FREQOUT 5,1000, offtm
    ··· PAUSE 750
    ··· IF offtm >= 25 THEN
    ··· offtm = 0
    ··· ELSE
    ··· ENDIF
    · IF (IN10=0) THEN
    · offtm = offtm * 2
    · DEBUG CLS, "Solenoid off time = ", DEC offtm, CR
    · WRITE 30, Word offtm
    · PAUSE 250
    · GOTO Set
    · ELSE
    · ENDIF
    · LOOP

    END


    PDSDL:
    pdsdly = 0
    DO
    DEBUG CLS, "Need input = "
    LOOP UNTIL (IN10=1)
    DO
    DEBUG CLS, "PDS Delay = ", DEC pdsdly, CR
    · pdsdly = pdsdly + 1
    · FREQOUT 5,1000, pdsdly
    · PAUSE 750



    ·· IF pdsdly > 15 THEN
    ····· pdsdly = 0
    ····· ELSE
    ····· ENDIF
    · IF (IN10=0) THEN
    · pdsdly = pdsdly * 2
    · DEBUG CLS, "PDS Delay Time = ", DEC pdsdly, CR
    · WRITE 40, Word pdsdly
    · PAUSE 250
    · GOTO Set
    · ELSE
    · ENDIF
    · LOOP

    END

    TRGDEBNC:
    trgdebnce = 0
    DO
    DEBUG CLS, "Need input = "
    LOOP UNTIL (IN10=1)
    DO
    DEBUG CLS, "Trigger Debounce Setting = ", DEC trgdebnce, CR
    · trgdebnce = trgdebnce + 1
    · FREQOUT 5,1000, trgdebnce
    · PAUSE 750


    ··· IF trgdebnce >= 21 THEN
    ····· trgdebnce = 0
    ····· ELSE
    ····· ENDIF
    · IF (IN10=0) THEN
    · trgdebnce = trgdebnce * 5
    · DEBUG CLS, "Trigger Debounce Setting = ", DEC trgdebnce, CR
    · WRITE 50, Word trgdebnce
    · PAUSE 250
    · GOTO Set
    · ELSE
    · ENDIF
    · LOOP

    END


    ERROR:
    DO
    DEBUG HOME, CLS, "MenReg error", CR
    DEBUG "please power marker off and back on",CR
    LOOP
    END



    Trigger:
    PAUSE offtm
    DO
    · IF (IN10 = 1) THEN
    ··· DEBUG CLS, "Trigger pulled", CR
    ····· GOTO PDS
    · ELSE
    ··· PAUSE 1

    ·ENDIF

    LOOP

    END


    PDS:
    ··· FREQOUT 5,pdsdly,5000

    · IF (IN2 = 0) THEN
    ··· DEBUG "Paint Detected" ,CR
    ······· PAUSE pdsdly
    ······· LOW 5
    ······· GOTO Cycle

    · ELSE
    ··· DEBUG "NO Paint" ,CR
    ··· PAUSE pdsdly
    ···· IF (IN2 = 0) THEN
    ····· GOTO Cycle
    ··· ELSE
    ···· LOW 5
    ···· GOTO Trigger

    · ENDIF
    · ENDIF
    END


    Cycle:

    HIGH 15
    PAUSE dwell
    LOW 15
    · DO
    ··· LOOP UNTIL IN10=0
    ··· DEBUG "Trigger Released" ,CR
    ··· PAUSE trgdebnce
    ··· HIGH 5
    GOTO Trigger
    END

    CycStart:
    DEBUG "Release trigger"
    DO
    FREQOUT 5, 1000,8
    LOOP UNTIL IN10=0
    DEBUG "Trigger Released"
    GOTO trigger
    END
Sign In or Register to comment.