Jump to content

Semi-auto control with a Hall effect sensor


Yuri

Recommended Posts

For a while now I've been wanting to get rid of the mechanical semi-auto function that all AEGs have. It would free up space and allow me to fit my FETs inside the gearbox. If the mechanical trigger was replaced with a micro switch, the pull of the trigger could be shortened to 1mm if desired. I figured that this would be a great way to learn to use micro controllers so I bought an Atmel AVR programmer off Ebay.

 

My original plan was to use a micro switch to monitor the posisition of the sector gear, but while googling for general info on AVR chips, I came upon an Instructable where the author was using a Hall effect sensor to turn on the lights in his wardrobe. This is where I learned about latching Hall effect sensors. Normally a Hall effect sensor will give an analog outpot, a voltage that depends on the magnitude of the outside magnetic field. A latching sensor however works like an on/off switch. The output voltage will remain at ground, until the outside field passes a preprogrammed step, then the sensor will open and put out whatever voltage it's being given. This really brings the required level of programming down to my level. So I wen't and bought one.

 

I have three magnets at my disposal:

 

mag1.jpg

 

Two rod shaped normal magnets and a single disc shaped rare earth magnet. My test setup looks this:

 

mag2.jpg

 

This really shows how smart the sensor is. The setup consists of a power source, a led and the sensor, nothing else. And it works. The led is actually lit up in the picture. Yeah, it's not very bright. This is because the sensor can put out just 15mA of current. I could throw a transistor in there and make it more visible but I ain't gonna bother.

 

Like I said, the test setup works. Passing any of the magnets near the sensor will turn the led on. However, only the Neodymium magnet is powerful enough to work on its own. Putting it close to the sensor will turn the led on, taking it away turns it off. With the other magnets, they will only turn the led on but removing them will not turn it off. It can only be turned off by turning the magnet around and again placing it near the sensor. This will generate a big enough change in the magnetic flux that the sensor can register it, or someting. Maybe I'm just talking out of my *albatross*. I don't know precisely how the senor works, the datasheet didn't say.

 

Next it was time to try it in the gearbox:

 

mag3.jpg

 

Again, the Neodymium magnet works on its own. Placing the sensor above the gear and rotating the gear, the led will light up every time the magnet passes under the sensor. I can spin the gear as fast as I can and it will work, though at very high speeds it becomes difficult to see the led flashing.

 

I got the rod magnets working in the following arrangement:

 

mag4.jpg

 

The first magnets turns the led on. The second magnet has been placed on the gear with opposing polarity. It turns the led off.

 

It seems to me that the best results could then be had with a setup where two powerful rare earth magnets were placed like the rod magnets in the previous picture. So I wen't online and ordered 76 Neodymium magnets on varying sizes, along them 20 that will fit into the 5mm diameter holes on the side of the sector gear. I will be updating this thread once my magnets arrive sometime next week.

 

So the idea is to take the input from the Hall effect sensor and feed it into a microcontroller that will then stop the motor once a single shot has been fired. Or three shots, or whatever you please. It should also be obvious that a gearbox fitted with this setup could be made to pre-cock simply by placing the magnets into holes on the opposing side of the sector gear.

 

I have just a vague idea of the electronics and programming required in this project. All I know is just that it will be fairly simple. This will be my first foray into digital electronics so I anticipate an amount of trial and error when it comes to the programming but we shall see. When this gets underway input from people experienced in programming AVR chips will be appreciated once I run into problems. Once my programmer arrives I will be doing some of those blinky led programs to familiarize myself with the system.

Link to post
Share on other sites
  • Replies 75
  • Created
  • Last Reply

Thanks!

 

I will be reporting every step of the project as it progresses and posting all the wiring diagrams and codes once I get around to that part.

 

I really do like this idea. The Systema revolution gearbox does something similar, but it uses an optical sensor. At this point I honestly think my idea is more elegant, but it remains to be seen if there is some massive problem that I have yet to realize. Only time will tell.

Link to post
Share on other sites

Indeed, no need for a rickety trigger arm setup when you can just have a micro switch at the end of a wire. Anyways:

 

mag7.jpg

 

As you can see, my magnets have arrived, and immediately I've run into a spot of trouble. My original idea was to take a working gearbox from one of my AEGs and do a final proof on concept test. I was going to fit the magnets in and see if they have any effect on the operation of the gearbox and then do another test with the sensor and see if I could get a signal with each shot.

 

The trouble is something that I anticipated might happen. See, the magnets are so strong that once I commit a magnet into its hole, I'm never getting it out unless I destroy the gear. I bought so many magnets that I can afford to waste a few, but I can't waste any gears. Luckily I also ordered some smaller diameter magnets. They might be small enough that I can somehow pluck them out.

 

So I either need to use the smaller magnets for the test or find a scrap gearset that can still be shimmed and works. The sector gear I've been using for mock-up is from an old Systema helical set that is somewhat broken but might still work for this.

 

About the programming. I had to rehash my meagre C writing skills but now I've got the code for this pretty much figured out. I've also enlisted the help of a friend who's a computer science major.

Link to post
Share on other sites

Just drill out the magnet; mount the gear in a vice, drill a small hole in the magnet (all the way through), and then pry it out.

 

I'm VERY interested in seeing how this project pans out. I have wanted to shorten my trigger pull and figure out how to install a MOSFET inside a gearbox aswell. I don't know if you've considered this yet, but if you are using an AVR to control semi-auto then there is no reason that you couldn't add Triggermaster-like burst features.

Link to post
Share on other sites

Very interesting concept.

Why not raise up the bottom of the holes with some epoxy or something that will be hard. Might make it easier for you to remove from just blow the surface, rather than 5mm down or whatever it is..

 

I was able to work it out, but I will think about this when I'm doing the actual install in my M4, it's possible that I will need to get the magnets as flush with the side of the sector gear as I can.

 

Just drill out the magnet; mount the gear in a vice, drill a small hole in the magnet (all the way through), and then pry it out.

 

I'm VERY interested in seeing how this project pans out. I have wanted to shorten my trigger pull and figure out how to install a MOSFET inside a gearbox aswell. I don't know if you've considered this yet, but if you are using an AVR to control semi-auto then there is no reason that you couldn't add Triggermaster-like burst features.

 

The magnets are very brittle, I just broke one when I tried to pry it out with a screwdriver. The outer layer is hard, but inside it pretty much turned to dust as I poked at it. So drilling in probably out of the question. I actually though about this when I ordered the magnets and looked for ones that already had a hole in the middle but they didn't have any in the size I needed.

 

About the burst function, I personally don't see much sense in it, but will probably try to write the code for it just as an intellectual exersize and in case anyone else wants to use it. Sinse I'll be designing the PCB to fit a V2 gearbox, maybe I'll do an M16A2 style thing where full auto is replaced with burst.

 

 

If you need I can hook you up with a bunch of old marui standard gears to play with?

 

A marui sector gear might have been ideal for a test, since if memory server me right it doesn't have those small holes on the side but a big depression that goes around the whole gear. There would be no problems with getting the magnets out then. However, I believe that marui gears are made of some alloy, and very much doupt that they are magnetic. In my setup the magnets just hold themselves in, there is no other retention, so the gear being magnetic is essential.

 

Anyways, I think I've done all the testing I need. I was able to figure out a way to get some of the smaller magnets out, by pulling with a magnet from one side, and pushing with another from the other side of the gear.

 

I then took the gearbox out from my G36, fitted some of the 4mm diameter magnets and assembled the gearbox again. Then I hooked it up to a 11.1V lipo and with my sensor rig at hand, pulled the trigger. The led was flashing very nicely on each revolution.

 

So that's fairly decisive. I don't think there's any pitfalls in this that I might fall into anymore, so I can get on with it sure that I'm not wasting my time. I was afraid that the spinning magnets might create eddy currents in the gearbox shell that would in turn slow down the gears. This is how magnetic breaks work so it's a real concern. But that fear has proven baseless. Tomorrow I will shoot a video of the test.

Link to post
Share on other sites

I was looking at the Systema revolution gearbox and that thing seems to have just a normal AEG M4 trigger that presses on one of those tiny round surface mount buttons. I might go that route, but if there's enough space, I'd like to use a proper micro switch with a lever. You could then do a little adjusting just by bending the lever. Then surely you could use a GBBR trigger if you can get it to fit.

 

 

Very interesting concept.

Why not raise up the bottom of the holes with some epoxy or something that will be hard. Might make it easier for you to remove from just blow the surface, rather than 5mm down or whatever it is..

 

I'm re-quoting this post because I gave it some more thought and it's a fantasic idea. Most of the magnetic force holding the magnet in place against the gear comes from the flat surface of the magnet since that's where the pole is. If I placed something non-metallic, like a disc of plastic in the hole under the magnet, it might reduce the force holding the magnet in place enough so that it can be easily plucked out with one of my bigger magnets. It could solve any reservations I might have about putting the magnets into the holes. If I put the magnets in wrong, say I get the polarity mixed up, if I can't pull them out then something has to be broken.

Link to post
Share on other sites

I think that'll work, the fields from these things seems to be strongly influenced by the distance to the magnetic surface :)

 

Where are you looking to go with this? Will you be offering MOSFET packages at some point or are you just playing around for science and all that? :) There are so many interesting things that could be

done once your control unit can communicate directly with the gearsm like ROF control and such. I'd love something that would lower my ROF to 20ish at full auto and just let it run at full speed for a 3 round burst.

Link to post
Share on other sites

I'm just going to put all the info in this thread so people can make their own if they please. I have a feeling that the final product will be a bit of a pain to assemble so I most likely won't be making them beyond my own needs.

 

I hadn't really thought about controlling the rate of fire. Could it be done just by programming a small delay between each shot? That's something to investigate.

 

Here's the video I said I'd shoot:

 

 

http://www.youtube.com/watch?v=ZZF9XTYaejQ

 

Youtube butchered the quality pretty badly but you can still get an idea of what's going on. I first use a pair of magnets to demonstrate the sensor and then place it against the side of the gearbox.

 

My programmer hasn't arrived yet and I haven't decided which specific AVR chip I'm going to use. My local electronics store has some but none of the 8 pin ATtinys I was planning to use. I might have to buy them online. Right now there isn't much else for me to do on this other than to study the programming.

 

EDIT: My internet has just pretty much died so I can't view the video myself, hopefully it will work for others.

Link to post
Share on other sites

I hadn't really thought about controlling the rate of fire. Could it be done just by programming a small delay between each shot? That's something to investigate.

yes, you can very well program a delay between each shot, but if the controller have an"AB" feature a lot of heat would build up and it will fail during a long burst.

Link to post
Share on other sites

That is very useful information, thanks. I've been a bit on the fence wether I should do 'active' breaking or not. Having AB might be in the spirit of how I'm planning to do the code.

 

My idea is that the gun will only do complete revolutions. I imagine that every AEG owner has at some point pulled the trigger and let go too fast, so that the gears start to spin but there is no shot. Some of my friend who've been in the army before they started airsofting have this happen a lot. They've developed some sort of reflex from firing real guns where they let go of the trigger as soon as something starts happening.

 

So the plan is to have it so that in full auto, when you let go of the trigger, the motor will continue to spin the gears until a signal comes from the Hall sensor to the controller telling it that a full revolution has been completed. Similarily in semi, if the trigger is let go of before a single shot has been fired, the motor will keep spinning until the signal comes in from the sensor.

 

So it might be advantageous to have AB to ensure that the gears always end up in the same position. After a long burst the gears will have gathered more momentum than say after a single shot, so they would not normally stop in the same place. I've no idea how big the difference would actually be though. It's nearly impossible to test since there's normally no way to ensure that in full auto the power is cut at the same moment as it would be in semi.

Link to post
Share on other sites

I think AB would be a lot more interesting than this whole ROF control thing. I just saw other people had something like that, I have no idea how (or if) they resolved any potential overheating: http://forums.airsoftmechanics.com/index.php?topic=3054.0 An alternativ solution may be to monitor the ROF and regulate the voltage dynamically?

 

For full auto AB isn't it just a question of applying AB after the sensor signals that the last shot has been fired, and then hope for the best? It may not leave the spring totally relaxed, but it will be a lot better that the random position you get without. If you want to reset from then, just fire a single shot.

Link to post
Share on other sites

Yeah, there will need to be some sort of input from the selector plate. Either a micro switch or I might possibly try to utilize the original electronic safety. Have the copper plate on the selector bridge two contacts when the selector slides into full auto.

 

One thing to consider with active braking is that the wiring will need to be a bit different. With a normal mosfet, the positive wire going into the fet doesn't need to carry current, so it can be very slim. In an AB mosfet it will need to carry some. In a rearwired M4 this might pose a problem since it means that I will need to pass two thick wires into the front of the gearbox. I think I can work it out though.

 

A small update, I've gotten hold of a book titled Embedded C programming and the Atmel AVR. It's supposed to be very good. I'm trying to read most of it over the weekend so when my programmer arrives next week I'll be ready to build a prototype.

Link to post
Share on other sites

My programmer came in the mail today. I also ordered some ATTiny85's. I'll have those in a few days. In the mean time, I drew a quick circuit diagram:

 

semi.jpg

 

You might notice that it's nearly a carbon copy of the Extreme Fire sw-computer. I'm no electrical engineer and it would've been difficult for me to choose the correct component values, so figured that there's no reason to reinvent the wheel. I just took out some parts I didn't need. Gandolf has made all his designs public and all credit goes to him.

 

Some of the values are still in the air, I will have to see what MOSFET's and voltage regulators I can find locally. Also I'm not sure if I should take the trigger and selector switches to ground like in the picture or to the five volts coming from the regulator. It will affect the programming slightly.

 

The break in the diagram siginifies how I'm going to devide the chip into two. The ATTiny85 and the regulator will be on their own board, while the FET's will be on theirs. This is so that I can fit it all inside the gearbox.

 

EDIT: Also I will have to put an electronic safety in there somewhere, possible inline with either the trigger or with the gate pin of the drive FET.

Link to post
Share on other sites

I would recommend linking the trigger and selector to the +5v supply with a resistor to pull them up when the switch is open, other wise the pin may "float" which can cause problems. Some chips have internal pull up resistors built in (Don't know the exact spec of your chip) but as the guy who was building his own crono discovered some times they can be insufficient. I think he was having problems with the pulses from the light sensors, might be some thing to keep in mind if you have problems with timing

 

Good luck

Link to post
Share on other sites

Thanks for the advice, that will help immensely. I will need to look into the possibility of the pins "floating". The ATTiny85 does have internal pull up resistors, but it will make more sense from a programming standpoint to do it the way you describe, I will need to do a little less bit masking then.

Link to post
Share on other sites

I'm going to have to rethink the way I'm using the hall effect sensor, apparently I'm doing it sort of backwards. It's not a big deal, but I will have to order new sensors online since the one I've been using seems to be some strange no-name device that I can't find any info on. I need something with a good datasheet.

 

I've been looking into the switch thing and it seems I'll be using an external pull-up or a pull-down resistor. Haven't desiced which yet.

Link to post
Share on other sites

Just spotted some thing else from your diagram, normally the reset pin needs to be held either high or low depending on the chip, other wise it can constantly reset.

 

Hope you have some luck sorting out the hall effect sensor, looking forward to seeing how this comes out.

 

Good luck

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and the use of session cookies.