Confused?! Tryingto control a paintball solenoid.


Results 1 to 14 of 14

Threaded View

  1. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Ò.K. after few Paintbal Gun user and gamers talkin. I learn a few things on a common gun DM4. I'll assume these i heard

    1. Human can shoot about 20 balls/seconds
    2. Full automatic : about 13 balls/seconds

    let's figure your gun,loader and everything i don't know, can do this. i'll figure more time for loader time than solenoid time.

    let's figure it a the maximum of 20 balls/seconds. we will use 20Hz as frequency with an 40% duty cycle (i figure high level as time on gun solenoid). So about 20ms for solenoid time, 30ms for loader time. i'll use an PIC12F675


    Code:
    ANSEL=0
    CMCON=7
    TRISIO=1  ; GPIO.0 as input, other as output
    GunDetent  VAR     GPIO.0  ;GP0 as detent input
    Solenoid   VAR     GPIO.1  ;GP1 as Solenoid output
    KillEmAll  VAR     BYTE
    Loop       VAR     BYTE
    T_ON       VAR     BYTE
    T_OFF      VAR     BYTE
    IsItTimeFiring VAR BYTE
    
    KillEmAll=3
    T_ON=20
    T_OFF=30
    IsItTimeFiring=0
    Solenoid=0
    
    start:
            
         While GunDetent=0 ;wait for detent press
         Wend
    
         If IsItTimeFiring !=8 then
                  Gosub ActivateSolenoid
                  IsItTimeFiring=IsItTimeFiring+1
         ELSE
                  FOR Loop=0 to KillEmAll
                         Gosub ActivateSolenoid
                  NEXT
                  IsItTimeFiring=0
          ENDIF
          WHILE GunDetent ;wait for detent release
          WEND
          GOTO start
    
    ActivateSolenoid:
         Solenoid=1
         PAUSE T_ON
         Solenoid=0
         PAUSE T_OFF
         RETURN
    this should work as you want.
    Last edited by mister_e; - 28th October 2004 at 01:24.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. A logic gate chip with 1 ea XOR and 2 ea AND gates?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 5th August 2009, 05:29
  2. Control RC servo via Parallax Servo Control
    By cibotsan in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th September 2005, 08:18
  3. HPWM Motor Control
    By hughgoodbody in forum General
    Replies: 7
    Last Post: - 30th January 2005, 22:41

Members who have read this thread : 0

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