PDA

View Full Version : Confused?! Tryingto control a paintball solenoid.



leland
- 16th October 2004, 02:40
Very very new to all programming.. I have read the entire PicBasic Compiler book and still do not even know where to start. I'm trying to configure a simple code to activate a solenoid.

The paintball gun trigger is a micro-switch, I need a code that would ...
After the swtich has been hit 8 time (activating the solenoid each time) the program would then jump to firing (activate the solenoid) 3 times which each trigger pull.

The problem I am having is when it fire the 3 burst the shots seem to delay. i am trying to achieve maxium rate of fire. Anyone have and ideas?

PLEASE HELP! ! !

c_Moore
- 23rd October 2004, 14:19
Hi Leland,
I'm from SC too.Can you post your code so we can see what you are doing.


Regards Charlie

Dwayne
- 25th October 2004, 17:05
Hello Ieland,

I>>The problem I am having is when it fire the 3 burst the shots seem to delay. i am trying to achieve maxium rate of fire. Anyone have and ideas?<<

I do not know what your setup is, I can only guess.

1. You will need the PIC to have complete control of your firing.
2. One pin will be connected to your switch... the other pin will control the firing.
3. Need to have a timer to measure the timing between each of the shots.

This is just a quicky, and some of it is in psuedo code and C/C++... But the idea is there.


Trigger var Porta.2
Sil var Porta.1
Var Timer;
Var Counter;

Counter=0;
Timer=0;
Loop:
Trigger=0; 'does it have pulling resistors?
if Trigger=1 gosub Fire
pause 50 'only allow 1 shot every 1/20 of a second
if Trigger=0 then Timer++
if Timer>50 Counter=0; 'resets to single shot, this adjusts delay
goto Loop

Fire:
if Counter<8
Sil=1 'fire the sucker
pause 5
Sil=0
pause 5 'make sure you are not too fast!
Endif

if Counter=8
Counter=6
while Counter<8
Sil=1 'fire the sucker
pause 5
Sil=0
pause 5
Counter++
Wend
Counter=7
Endif

Counter++
Return

leland
- 27th October 2004, 17:27
thank you, finially some one is willing to help, thanks

Dwayne
- 27th October 2004, 17:46
Hello Ieland,

I>>thank you, finially some one is willing to help, thanks<<

Its not that we are not willing to help, but sometimes

1. We do not understand fully what is trying to be accomplished.
2. We do not know what equipment you have.
3. We do not know your limitations of your device.
4. We may not have ever played with a project like yours.
5. We do not know how the device is controlled or how it is communicating.

All of these are Very important. Each has a different answer and way of doing things!


Thus, we can only "Assume" at what you want, and do you know what "Assume" means (when you break it down). It means the following: Assume = Ass U Me

It makes a fool out of you and me <g> (I did it in nicer terms). In other words, we (I) can help, but when we (I) get done helping, it was a total help in the wrong direction, because we (or I) failed to understand your whole situation!

When I answered your question, I am still in confustion on

1. How long you want to wait until it reverts back to single shot. (Without pulling trigger).

2. How long you want to wait before it resets itself and says "I want another 8 shots again, not another 3 more and go into automatic bang bang bang!?

3. How fast can it fire????I know the chip can easily pull that trigger 1000 times faster than it can actually fire!

Thus these questions will TOTALLY change the timing and programming of what I wrote to you. I only wrote a generic and simplified psuedo-code with timing that may or maynot work.

I have absolutely no experience with paintball guns.

We are not perfect! But if the group out there can help, they definitely will jump in and do their best to help out! Just forgive us all if me make a mistake and give the wrong answer to your question.

Dwayne

mister_e
- 27th October 2004, 17:52
Totally right Dwayne,
plus, as i know some paintball gun have some internal switch to tell you when you can shoot to avoid a *paint ball jam* inside. so, if there's is not... what is the fastest burst time, wait after each shot, hold time on detent ???

for shure we can also send a short PWM wich it will be easier.

What are the things you know on your guns. I mean what goes in and out. Maybe we always have to ask it???

let us know

mister_e
- 27th October 2004, 23:50
Ò.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




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.

leland
- 28th October 2004, 01:58
yes.. the DM4 that is what im trying to program if it helps the chip it PIC16F628A. The gun has "Break beam eyes" meaing the gun will not fire unless a ball is in the breach and the beam is broken.
My loader will feed 35 balls per second (Bps)

I need the Dwell, the time the solenoid stays open, to be 19 milliseconds.

so basicly once i hit 8 Bps, with 1 shot per pull, the gun jumps to shooting 3 shots per pull with nodelay what so ever between shots.

lastly what would i need for the debounce to be set to 1 millisecond

thank you so much you don't understand how important this is to me

mister_e
- 28th October 2004, 04:02
yes.. the DM4 that is what im trying to program if it helps the chip it PIC16F628A. The gun has "Break beam eyes" meaing the gun will not fire unless a ball is in the breach and the beam is broken.
My loader will feed 35 balls per second (Bps)

I need the Dwell, the time the solenoid stays open, to be 19 milliseconds.


In my code :
T_ON=19
T_OFF=10 ;wich will gives you your Dwell time + max 35 Bps



so basicly once i hit 8 Bps, with 1 shot per pull, the gun jumps to shooting 3 shots per pull with nodelay what so ever between shots.

just to be sure to understand exactly your need. Once you've reach the 8 balls per second with the detent, you want the gun switch from 1 ball per shot to 3 balls/shot. Right?

And i assume then if you leave shot for a few secondes or you're below 8 shot/secondes the gun return to 1 ball/shot. Right??

if all above are right code will really be different.


lastly what would i need for the debounce to be set to 1 millisecond

I assume you mean debouce time for detent button??? if it's, to the previous code add PAUSE 1 after the second WEND statement.



thank you so much you don't understand how important this is to me

as i see in eyes of those guys... paintball is often more interesting than their whole life :)

leland
- 28th October 2004, 15:38
---"just to be sure to understand exactly your need. Once you've reach the 8 balls per second with the detent, you want the gun switch from 1 ball per shot to 3 balls/shot. Right?

And i assume then if you leave shot for a few secondes or you're below 8 shot/secondes the gun return to 1 ball/shot. Right??"

Yes, mister_e that is where Im running into probelms big time, I have no idea how i would run an operation like that.


any ideas?

mister_e
- 28th October 2004, 15:56
Hi leland,
For sure i've some idea based on timer method. For now i've not really the time for it but as soon i can do something based on it (few days) i'll let you know.

You must have a timer working background who will read you shot speed/sec. Once this task is done... everything can be don easy.

Here's may be a good start:
http://www.picbasic.co.uk/forum/showthread.php?s=&threadid=550

i'll not leave you alone with this. If any else here have a snippet of code ... please let us know.

leland
- 28th October 2004, 23:34
thanks mister_e for all the help

BigWumpus
- 30th October 2004, 07:59
Hello Iceland,

now we understand your problem and I think you also...

If you press the trigger faster than 8 Balls per Second should result in firing three times.

So you have to use a Timer...

Find out, at which frequency your chip is running,
maybe 4 MHZ,
so programm the Timer1 to use the clock from the Oszilator (divided by 4), set the prescaler to 1/8.

;Timer1 setzen
;Teiler /8 OSC/4 als Input = 125kHz
T1CON.5=1
T1CON.4=1

calculate the Timer-value:

8 Shots per second are 125msec.
OSC=4MHz
OSC/4=1MHz (Input of Timer1)
Prescaler /8=125kHz

1 sec = 125000 Counters
0,125sec = 15625 Counters !
-15625 = $C2F7 (because the timer is incrementing until there is an overrun)

At the ending of loop, when the trigger is released, start the timer:

TMR1H=$C2
TMR1L=$F7
;INT-Flag cleared
PIR1.0=0
;GO!
T1CON.0=1

and at the beginning of the loop, when the trigger is pulled and the solenoid should be triggered one or three times, you check the Bit PIR1.0 !
If it is cleared, you where faster than 8 triggers per second, if the bit is set, you loose... ;-)

You have to clear the bit PIR1.0 at the beginning of the program to avoid problems with the first shoot !

These is again quick and dirty, and I think Iceland has to code somes lines by himself, but it is a first step.
The measure of the time isn't exact. We can discuss, if the timer starts while pressing the trigger (better) or when releasing (easier to code for Iceland)...

Luciano
- 30th October 2004, 17:57
Hello Leland!

I will never join you on the Paintball Battlefield but I still find your project very interesting.
The original electronic of the DM4 Paintball gun is based on the PIC16F628A. My advice is to do first some reverse engineering of your DM4 in order to figure out its electronic circuit. If you don't understand the electronic circuit of the DM4 there is a risk that you will cause some damage while experimenting on it. Make sure there is no danger for people during this project and that your soldering iron it is in a safe place all the time. I hope I will never hear on the news that a Paintball shooter has been arrested in Leland South Carolina.
Also if you work on your DM4 you will probably void its warranty. Once you have the schematic on paper, replicate the circuit with all its components on a breadboard and start your programming from there. Start with a simple program easy to verify on your circuit on the breadboard. (Simple program = Just one shot). When you are confident your program works on the breadboard, then replace the original PIC of your DM4 with the PIC you have programmed on the breadboard. Try your first simple program on the DM4. Go back with your PIC on the breadboard and work more on your program. I am sure it is going to take several months before you will achieve what you are looking for. During this time people on this forum will help you discover the features of the PIC16F628A and overcome the difficulties you will for sure encounter during this project. This is my personal opinion but if you have questions for people on this forum try to limit the scope down to the particular feature of the PIC you are implementing in your program in that particular moment. Try first the feature aside your program. A small program is simple to understand and share for discussion on a forum. Also most of these questions have already been answered on this forum. Use the search tool of the forum. Open also the Datasheet of the 16F628A and all related application notes. (Microchip web site).

For the readers of this forum there is link to a web page that will give some ideas of a similar project.

http://www.wickedairsportz.com/products/eqdm4.htm

Have fun!


Regards

Luciano
(Beretta 9 mm).