Author Topic: Primer Counter - PLC Arduino  (Read 4385 times)

alfsauve

  • Semper Vigilantes
  • Top Forum Member
  • *****
  • Posts: 6883
  • DRTV Ranger
  • Liked:
  • Likes Given: 336
Primer Counter - PLC Arduino
« on: December 17, 2020, 11:01:15 AM »
I decided to take the plunge.  Had been wanting to learn about PLCs (programmable logic controllers) for a while.  They're basically very simple uProcessors with built-in memory and I/O.  Raspberry PI is probably one of the well known versions.   I selected Arduino.  It's very simple, well established, open source, and lots of parts and kits are available.  Got my first one (yes first one) on 12/7 and have completed (except for enclosure) my "intelligent" reloading counter.

A 1/3 of my career was spent as a systems analyst and I programmed from machine level on IBM mainframes down to microprocessors in languages from Assembler to COBOL, with things in between like RPG, Pascal, ForTran and SQL in between, so this wasn't hard to figure out.

Four inputs.  A "primed" switch when the primer is fully seated, a "primer reset" switch to undo the 1st switch so you don't have multiple counts.  A "primers out" switch for when the tray is locked back.  And finally a system/counter reset switch.   Initially I was going to utilize my external counter, but decided I didn't really need it.  What I need was for the module to flash the "primer out" light when the counter got to 98.  That warns me I'm almost out.  I also added a buzzer along with the green LED for each time a primer is seated.  This is on a separate output and is pulsed so it's just a short beep.

Below are the Arduino board, a close up of the header interface with the buzzer on board and the two boards hooked up.   Not shown yet, are the two LEDs which are going to be mounted in an model railroad block signal.  Thought that would be cuter than having the LEDs on the enclosure.  I've also include a video link showing me testing it with a breadboard.  No audio as James Earl was busy this week.


https://vimeo.com/489870522/



 

Will work for ammo
USAF MAC 437th MAW 1968-1972

alfsauve

  • Semper Vigilantes
  • Top Forum Member
  • *****
  • Posts: 6883
  • DRTV Ranger
  • Liked:
  • Likes Given: 336
Re: Primer Counter - PLC Arduino
« Reply #1 on: December 18, 2020, 02:06:23 PM »
Just did my first 300 rounds using the new PLC.  everything went smoothly.   The low primer warning worked great.  And I love the audio  affirmation.

BUT,  and this is why software is so much better than hardware solution, I nee-e-e-e-d two "enhancements".   (Dang I'm the end user and the software provider.  Best of times, worst of times.)

When I began this with a hardware solution 10 years ago, the objective was to warn me whenever I forgot to prime a case.   The "primed" light does help a bunch, now with s/w all I have to do at every upstroke reset is ask whether the "primed" light is on.  If not then a little warning, maybe flutter the green LED.

Second, having a  counter helps you mark progress.  I have painted rings on my primer follower at 25, 50 and 75 primers so I can just glance at it to know about how many I've done.   But my attention is on the cases to check for powder and seat bullets.  Without interfacing a readout, I could do a double beep every 10 primers to act as a motivator though. 

First however, ExKev just told me I have to get the TPS reports completed or I'll have to work on Saturday.

Will work for ammo
USAF MAC 437th MAW 1968-1972

alfsauve

  • Semper Vigilantes
  • Top Forum Member
  • *****
  • Posts: 6883
  • DRTV Ranger
  • Liked:
  • Likes Given: 336
Re: Primer Counter - PLC Arduino
« Reply #2 on: December 27, 2020, 11:12:51 AM »
Not finished yet, but here's an update.

After building an interface board, I found the cutest little pre-made board.   It piggybacks on the Arduino using the header pins.  Makes it easy to remove the Arduino and take it to my office for s/w upgrades.

Everything else is working... EXCEPT.  You know that magnetic security switch I was using for the reset switch (picture below).  Turns out it has too much "bounce" in the contacts.  This is a problem because the first contact resets the primed indicator and then the bounce tells the uP that I've on an upstroke without a primer.  Now I can de-bounce it in software, but then I'd always know that switch was a kluge.  So I've ordered a some microswitches and will see about mounting one for the reset function.

Will work for ammo
USAF MAC 437th MAW 1968-1972

Rastus

  • Mindlessness Fuels Tyranny
  • Top Forum Member
  • *****
  • Posts: 6398
  • DRTV Ranger
  • Liked:
  • Likes Given: 331
Re: Primer Counter - PLC Arduino
« Reply #3 on: December 27, 2020, 02:33:37 PM »
You kinda lost me on the "contact" portion is the bounce in the actual contact portion of the switch or internal to it's relay contacts (if it has an internal relay)? 
Necessity is the plea for every infringement of human freedom.
It is the argument of tyrants; it is the creed of slaves.
-William Pitt, British Prime-Minister (1759-1806)
                                                                                                                               Avoid subjugation, join the NRA!

alfsauve

  • Semper Vigilantes
  • Top Forum Member
  • *****
  • Posts: 6883
  • DRTV Ranger
  • Liked:
  • Likes Given: 336
Re: Primer Counter - PLC Arduino
« Reply #4 on: December 29, 2020, 05:20:04 PM »
When switches make contact it's not always as we picture.  Some switches are less perfect than other sand they create a lot of "noise" as the transition from open to close (and visa-versa).    Below you can see a picture from my o-scope of a snap-action switch.  Pretty perfect wave form, at least for low frequency applications.

But then there's the picture from the magnetic reed switch (security type switch) that I was using for my "reset" function.   This doesn't happen every time, but enough to be annoying.  The magnetic field doesn't reliably interact with the switch and the switch (the reed inside) doesn't know whether to close or not.  This "noise" or "bounce" causes my little uProcessor to do funny things.   In my application it performs a "reset" then it thinks I've lower the ram and raised it again without priming. 

I've done two things.  a)  Ditched the magnetic switch as not really suitable for this app.   I could have done a work around, but why fight it.
b) I've inserted a 100ms delay in reading this switch.  This will insure positive contact for this function regardless of the switch in use. 

CLEAR AS MUD?

More pictures and final description of the project soon.  Just painted the switch mounting plate Hornady red.

Will work for ammo
USAF MAC 437th MAW 1968-1972

Sponsor

  • Guest
Re: Primer Counter - PLC Arduino
« Reply #5 on: Today at 09:11:49 AM »

alfsauve

  • Semper Vigilantes
  • Top Forum Member
  • *****
  • Posts: 6883
  • DRTV Ranger
  • Liked:
  • Likes Given: 336
Re: Primer Counter - PLC Arduino
« Reply #5 on: December 30, 2020, 10:03:08 AM »
And it's DONE.   Works quite well.  Can't wait to reload a batch.  Maybe this weekend.

I replaced the magnetic reset switch with a snap action micro switch.  That means I had to make a new bracket for the two switches.  The Arduio board is attached to the bottom of the closure, but everything else is on the top half.  By unplugging the piggy back connector board, the Arduino unit is free to take to the lab for updates.

And I always wanted a model railroad signal lights so I've glued them where they point directly at me when I'm reloading.    There's pictures of the iterations of this project from the hardwired version (red board) to the Arduino interface to the piggy back connections board.  Video to follow once I edit it.

Here's the functions it performs:

Press the Sys Reset Button:  The internal counter is set to zero and the lights & buzzer flash/beep 4 times rapidly
Prime a case: The green light comes on and a single short beep is heard and the counter is incremented.
Go to the top of the stroke:  The green light is reset.
Go to the top of the stroke without priming:  4 long beeps.
Internal counter goes above 97:  Red light start flashing.
Internal counter goes above 100:  No warning about missing primer.
Primer tray locked back (no primers):  Red light is on at bottom of stroke and the counter cannot be advanced.




Will work for ammo
USAF MAC 437th MAW 1968-1972

J. Kennedy-ar154me

  • Top Forum Member
  • *****
  • Posts: 841
  • NRA Life Member
  • Liked:
  • Likes Given: 998
Re: Primer Counter - PLC Arduino
« Reply #6 on: December 30, 2020, 10:14:49 AM »
Do you think you will need either a cover to protect it or a fan to keep it cool?
The time for action is upon us and the enemy is at our gates. Let us not allow them one more inch of advancement but instead throw them through the gates of Hell.

alfsauve

  • Semper Vigilantes
  • Top Forum Member
  • *****
  • Posts: 6883
  • DRTV Ranger
  • Liked:
  • Likes Given: 336
Re: Primer Counter - PLC Arduino
« Reply #7 on: January 01, 2021, 11:03:10 AM »
No cover, other than the enclosure needed.   Might need a fan to cool me down because I'll be reloading at breakneck speeds.


Got the Arduino Nano (yes, the also make a micro) and am going to update the whole project, ALREADY.   Smaller board, but the wire will be soldered to it not using the screw terminals.  The Nano board though will be plugged into the board and I can remove it for s/w updates easily.

Here's the Nano board on the bench breadboard.  The final board will be just a little bit smaller.  It will take a while because there about 28 solder connection to make.

Will work for ammo
USAF MAC 437th MAW 1968-1972

alfsauve

  • Semper Vigilantes
  • Top Forum Member
  • *****
  • Posts: 6883
  • DRTV Ranger
  • Liked:
  • Likes Given: 336
Re: Primer Counter - PLC Arduino
« Reply #8 on: January 02, 2021, 04:25:31 PM »
And done with the conversion to Nano.

Put the whole thing on a smaller breadboard.  Of course I had to solder my leads to the board, but the Nano just unplugs so that I can do upgrades.   If you look at the picture you'll notice the power cable doesn't fit through the grommet.

But I'm already onto the next version.  It'll also use the Nano, but on a bigger breadboard so I have room for the screw terminals.  At that point I'll probably add a 4-digit display to show the counter value.    And I'll probably get another enclosure at that point as well.

Will work for ammo
USAF MAC 437th MAW 1968-1972

Rastus

  • Mindlessness Fuels Tyranny
  • Top Forum Member
  • *****
  • Posts: 6398
  • DRTV Ranger
  • Liked:
  • Likes Given: 331
Re: Primer Counter - PLC Arduino
« Reply #9 on: January 02, 2021, 06:15:02 PM »
Alf maybe you should market this as a kit to one of the manufacturers...
Necessity is the plea for every infringement of human freedom.
It is the argument of tyrants; it is the creed of slaves.
-William Pitt, British Prime-Minister (1759-1806)
                                                                                                                               Avoid subjugation, join the NRA!

 

SMF spam blocked by CleanTalk