Load DataRotoMetals2Lee PrecisionMidSouth Shooters Supply
Inline FabricationRepackboxReloading EverythingTitan Reloading
Wideners
Page 1 of 2 12 LastLast
Results 1 to 20 of 27

Thread: Magma Master Caster automated using a Raspberry Pi and EP-0099 Relay board.

  1. #1
    Boolit Buddy
    Join Date
    Sep 2011
    Posts
    144

    Magma Master Caster automated using a Raspberry Pi and EP-0099 Relay board.

    My goal was to automate my Magma Master Caster using components that I already had on hand or that kept the cost low.
    I have less than $200 in parts that I purchased including the relay board, PID controller, SSR and Thermocouple, all the switches and pneumatics

    Counter is a Red Lion Cub1.
    I bought 3 of these years ago when they were being liquidated for $5.00 a piece
    The EP-0099 relay board can be ordered for as low as $13.99
    One issue with the relay board is that the identification of the N/O and N/C contacts is backwards.
    You can stack up to 4 relay boards for 16 outputs on 1 Raspberry Pi.

    I could have used an Arduino and the same board will work with it however I had the Raspberry Pi already.

    I forgot to mention that I left space at the top of the panel to install a 7" touchscreen.

    The programming language is Python.
    I can provide the code to whoever is interrested
    I have never programmed before and I had a little assistance by member seek2 on ARFCOM.


    does my keyboard work
    Last edited by thump_rrr; 03-21-2021 at 09:41 PM.

  2. #2
    Boolit Master
    Join Date
    Oct 2013
    Location
    Brisbane, Australia
    Posts
    1,775
    I'm going to have to check the video out when i get home, but awesome job.

    I had the awesome help of Kyak1 when he automated his, he sent me the source code for his arduino based setup and i use that as the base of mine. It has about 800,000 projectiles to it's name, and will have many more in the future.

    The arduino is not really suited to an industrial situation and it does glitch from time to time, mostly from RF noise in the power source. I actually used MOSFETs for my switches, not relays, i had one partially fail about 2 months ago giving weird lead pouring. Other than that, it'd done very well. An occasional air line will blow from lead hitting it and melting, one new set of seals in the main air ram, and same for the lead pour ram.

    Mine doesn't have a touch screen, i think it's a 4x20 LCD with I2C interface. timers are set with 10 turn pots on 3 analogue inputs.

  3. #3
    Boolit Buddy
    Join Date
    Sep 2011
    Posts
    144
    I’m using 1N4007 diodes on the DC solenoids (line goes to positive side) to prevent electrical noise.
    If you are using AC solenoids you would use a capacitor to reduce the electrical noise.

  4. #4
    Boolit Master



    skeettx's Avatar
    Join Date
    Jul 2009
    Location
    Amarillo, Texas
    Posts
    4,102
    Well done, well done
    Thank you for sharing
    Mike
    NRA Benefactor 2004 USAF RET 1971-95

  5. #5
    Boolit Master
    Join Date
    Oct 2013
    Location
    Brisbane, Australia
    Posts
    1,775
    Quote Originally Posted by thump_rrr View Post
    I’m using 1N4007 diodes on the DC solenoids (line goes to positive side) to prevent electrical noise.
    If you are using AC solenoids you would use a capacitor to reduce the electrical noise.
    The solenoids were all 24vDC, when the compressor kicked in, the noise from it kicking in some times made it angry, i have two phases available, so switching phases fixed that. If i run a VFD to size projectiles, the carrier frequency from that makes it lock up too. I have never investigated it to put a line filter on the input to the machine to see if it fixed it, or even shield it.

    See if these images will attach without me finding a host on the internet:
    Click image for larger version. 

Name:	rsz_20190826_163745.jpg 
Views:	45 
Size:	57.6 KB 
ID:	280013
    Click image for larger version. 

Name:	rsz_20190826_163752.jpg 
Views:	39 
Size:	64.8 KB 
ID:	280014
    Click image for larger version. 

Name:	rsz_20190826_163802.jpg 
Views:	39 
Size:	63.2 KB 
ID:	280015
    Click image for larger version. 

Name:	rsz_20190826_163812.jpg 
Views:	39 
Size:	64.1 KB 
ID:	280016

  6. #6
    Boolit Buddy
    Join Date
    Sep 2011
    Posts
    144
    Just to be clear the flyback diode goes across the coil and not in series.
    https://en.m.wikipedia.org/wiki/Flyback_diode

  7. #7
    Boolit Master
    Join Date
    Oct 2013
    Location
    Brisbane, Australia
    Posts
    1,775
    Quote Originally Posted by thump_rrr View Post
    Just to be clear the flyback diode goes across the coil and not in series.
    https://en.m.wikipedia.org/wiki/Flyback_diode
    Definitely needed for relay coils, i'm using MOSFETs to drive anything with a coil, my understanding was that the output of the ones i'm using has a diode across the source and drain to prevent the back EMF from frying it.

    How do you adjust lead pour times, or are you just casting one weight? so you don't need to adjust it. I found that with different lead amounts in the pot, it does alter the puddle on the sprue plate a little, but keeping it fairly full works just fine for consistency.

    I like the proximity switch idea, have you thought of adding one at the bottom too? this way you know the mould has opened and that something hasn't stuck, i get the occasional projectile land on the base where the mould carrier strikes and will not fully open. It also acts as the start of my timer.

    I like the counter setup too, mine has a cycle counter, so i just double it and i know how many i have hopefully cast. There are a few that fly out and hit the ground, but it's a small price to pay over hand casting.

  8. #8
    Boolit Buddy
    Join Date
    Sep 2011
    Posts
    144
    Quote Originally Posted by Tazza View Post
    Definitely needed for relay coils, i'm using MOSFETs to drive anything with a coil, my understanding was that the output of the ones i'm using has a diode across the source and drain to prevent the back EMF from frying it.

    How do you adjust lead pour times, or are you just casting one weight? so you don't need to adjust it. I found that with different lead amounts in the pot, it does alter the puddle on the sprue plate a little, but keeping it fairly full works just fine for consistency.

    I like the proximity switch idea, have you thought of adding one at the bottom too? this way you know the mould has opened and that something hasn't stuck, i get the occasional projectile land on the base where the mould carrier strikes and will not fully open. It also acts as the start of my timer.

    I like the counter setup too, mine has a cycle counter, so i just double it and i know how many i have hopefully cast. There are a few that fly out and hit the ground, but it's a small price to pay over hand casting.
    Lead pour time is set in the software as are cooldown time before the mould releases and time the mould stays at the bottom of the stroke.
    Once the touchscreen arrives I will be able to change them directly on screen.

    I have 3 different moulds for the time being.
    I can make 3 different programs with different timing. It only takes seconds.
    I don't think it is worth spending the time making a graphic user interface.

  9. #9
    Boolit Master
    Join Date
    Oct 2013
    Location
    Brisbane, Australia
    Posts
    1,775
    Looking forward to seeing how your touch screen goes, i may add it to mine to make things a bit easier to change.

    I need to cast some .300 BO in the next few weeks, i'll try and do a video of it when i do it.

    I do enjoy seeing how different people make theirs, same results, just different ways of doing it.

  10. #10
    Boolit Mold
    Join Date
    Nov 2011
    Posts
    21
    That's cool. I'd love to see the code. I bought a pi 4 and have been learning some python basics. Will you be automating your lube sizer as well? I've seen that done with a simple timer relay and pneumatics.

  11. #11
    Boolit Master
    Join Date
    Mar 2011
    Location
    Western, MO
    Posts
    629
    Looks like a neat project. I'm trying to teach my daughter some sudo vudo. She has my python book at the moment. She has been into robotics for years.

    While I set up custom pid's for commercial jobs I still do the old school adjust cast temp and how fast I work depending on what the boolits look like. I think I might set up at least a pid in my pot this year.

  12. #12
    Boolit Buddy
    Join Date
    Sep 2011
    Posts
    144
    Quote Originally Posted by Assnolax View Post
    That's cool. I'd love to see the code. I bought a pi 4 and have been learning some python basics. Will you be automating your lube sizer as well? I've seen that done with a simple timer relay and pneumatics.
    Yes that is the next project.
    I'm currently trying to add the collator from the special project forum to the sizer since it has the bullet feeder.

    This is the code as it currently sits.
    As I've said in the past I've never written code before so there are things that may be done differently but at least it's working.
    I'm open to any suggestions.
    This site doesn't seem to allow spacing in the quotes so you will need to run the code through an editor for proper indentations.
    #!/usr/bin/python

    import time as t
    import smbus
    import RPi.GPIO as GPIO
    import sys
    import atexit

    def shutdown():
    print("shutting down")
    # Put your shutdown code here
    pass

    # Set up relay interface
    DEVICE_BUS = 1
    DEVICE_ADDR = 0x10
    bus = smbus.SMBus(DEVICE_BUS)

    # Set up GPIO input
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    # Register exit code
    atexit.register(shutdown)

    while True:

    # Monitors GPIO pin 17, halts until pin is low
    while GPIO.input(17) == 1:
    t.sleep(0.5)

    try:
    # Time delay before lead pour.
    t.sleep(1)
    for i in range(1,2):
    # Relay #1 Lead pour time
    bus.write_byte_data(DEVICE_ADDR, i, 0xFF)
    t.sleep(.95)
    # Lead cooldown time
    bus.write_byte_data(DEVICE_ADDR, i, 0x00)
    t.sleep(6)

    for i in range(3,4):
    # Relay #3 Round count relay (2 cycles)
    bus.write_byte_data(DEVICE_ADDR, i, 0xFF)
    t.sleep(.04)
    bus.write_byte_data(DEVICE_ADDR, i, 0x00)
    t.sleep(.04)
    for i in range(3,4):
    bus.write_byte_data(DEVICE_ADDR, i, 0xFF)
    t.sleep(.04)
    bus.write_byte_data(DEVICE_ADDR, i, 0x00)
    t.sleep(.04)
    #
    for i in range(2,3):
    # Relay #2 Mould eject and hold for cooldown timer
    bus.write_byte_data(DEVICE_ADDR, i, 0xFF)
    t.sleep(6)
    bus.write_byte_data(DEVICE_ADDR, i, 0x00)
    except KeyboardInterrupt as e:
    print("Quit the Loop")
    sys.exit()

  13. #13
    Boolit Master
    Join Date
    Oct 2013
    Location
    Brisbane, Australia
    Posts
    1,775
    For someone that hasn't coded before, you have done a good job. I'm not at all a person that is good with code, but most people don't label each segment to say what it's for, yet it makes it far easier for others to look at and know what's going on.

  14. #14
    Boolit Buddy
    Join Date
    Sep 2011
    Posts
    144
    Quote Originally Posted by Tazza View Post
    For someone that hasn't coded before, you have done a good job. I'm not at all a person that is good with code, but most people don't label each segment to say what it's for, yet it makes it far easier for others to look at and know what's going on.
    As mentioned in the OP I had a little help from member seek2 on ARFCOM with a bit of the coding.
    He started the notations so I continued it so that I could share it and others would know what was going on.
    Relay #3 code was a last minute addition so that it would count actual rounds instead of how many times the mould moved down.
    It could probably be cleaned up somehow or located elsewhere in the code but it is functional.

  15. #15
    Boolit Mold
    Join Date
    Nov 2011
    Posts
    21
    I got the relay hat and played with your code a bit to control some leds. I removed the gpio pin portion though. How is pin 17 setup, I'm assuming the proximity sensor as well as the stop button tie into it?

    Thank you.

  16. #16
    Boolit Buddy
    Join Date
    Sep 2011
    Posts
    144
    Quote Originally Posted by Assnolax View Post
    I got the relay hat and played with your code a bit to control some leds. I removed the gpio pin portion though. How is pin 17 setup, I'm assuming the proximity sensor as well as the stop button tie into it?

    Thank you.
    Exactly. The way it is setup it’s a normally closed loop to operate Anything on that loop opens and it will go to the end of the code and stop.
    I don’t want it to stop in the middle of the code and potentially leave the lead pour solenoid energized.

    The proximity sensor triggers one of the relays and the dry contact of the relay is in series with GPIO 17 and ground.

    You can use any GPIO that is not being used, just modify the code.

    CAUTION. Different versions of the Raspberry Pi use different pin locations so confirm which model and pin location you have.
    Last edited by thump_rrr; 04-06-2021 at 08:03 AM.

  17. #17
    Boolit Buddy
    Join Date
    Sep 2016
    Posts
    249
    If you dont know how to code, like me, you could buy one of these.

    https://www.frightprops.com/electron...coboo-mp3.html

    You just have to add your valves and pneumatic gear. No mosfets, coding or hard wiring to do.

    You can program the up, down and pour processes by pushing buttons for your desired amount of time or you can use a computer and their free software to do it more precisely.


  18. #18
    Boolit Buddy
    Join Date
    Sep 2011
    Posts
    144
    Quote Originally Posted by dansedgli View Post
    If you dont know how to code, like me, you could buy one of these.

    https://www.frightprops.com/electron...coboo-mp3.html

    You just have to add your valves and pneumatic gear. No mosfets, coding or hard wiring to do.

    You can program the up, down and pour processes by pushing buttons for your desired amount of time or you can use a computer and their free software to do it more precisely.

    I was originally going to use the picoboo Jr with 2 outputs but I just wanted to prove to myself I could do it with the Raspberry Pi.
    This way I also have a touchscreen at my fingertips for about the same money.

  19. #19
    Boolit Master

    Plate plinker's Avatar
    Join Date
    May 2012
    Location
    Indiana
    Posts
    2,297
    Nice work fellas. I need to learn how to make such a control device for a new casting machine i have in my mind to build.

  20. #20
    Boolit Mold
    Join Date
    Nov 2011
    Posts
    21
    I put the gpio bit back in and tested with a jumper from a pin to ground. I've only watched a few youtube tutorials on python and this is my first attempt at coding in general so I'm a total amateur but its nice to have something to start with. I'm trying to build a gui with a Run button, a stop button, a counter and a clear button. Might be easier to have a physical toggle switch instead of the stop button. Problem I am trying to solve now is that the counter only updates after the while loop is done running and none of the buttons work while the loop is running. Disconnecting the jumper puts the loop in pause and none of the other buttons work but I believe that will be solved with threading and create more problems in the process.
    ## Cycle Relays when button is pressed##

    from tkinter import *
    import tkinter.font
    import smbus
    import sys
    import RPi.GPIO as GPIO



    ### HARDWARE DEFINITIONS ###

    DEVICE_BUS = 1
    DEVICE_ADDR = 0x10
    bus = smbus.SMBus(DEVICE_BUS)

    # Set up GPIO input
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    ### GUI DEFINITIONS ###
    root = Tk()
    root.title("Relay Test")
    myFont = tkinter.font.Font(family = 'Helvetica', size = 12, weight = "bold")
    d = Entry (master = root)
    d.grid(row=0,column=1)


    #counter counts by 2s every time run goes through
    root.counter=0
    c=Label(text = "Rounds Made")
    c.grid(row=6, column=1)

    ### Event Functions ###
    def Run():

    # How many times loop should be run (I want text box to enter how many times it should run)
    count=int(d.get())

    # gpio in series with proximity switch and stop button
    while count > root.counter:

    if GPIO.input(17) == 1:
    root.after(500)
    else:



    # Time delay before lead pour.
    root.after(1000)
    # Relay #1 Lead pour time
    bus.write_byte_data(DEVICE_ADDR, 1, 0xFF)
    root.after(950)
    # Lead cooldown time
    bus.write_byte_data(DEVICE_ADDR, 1, 0x00)
    root.after(6000)
    # Relay #2 Mould eject and hold for cooldown timer
    bus.write_byte_data(DEVICE_ADDR, 2, 0xFF)
    root.after(6000)
    bus.write_byte_data(DEVICE_ADDR, 2, 0x00)
    root.counter += 2
    c['text'] = 'Rounds Made: ' + str(root.counter)

    #interrupt the cycle and stop everything where it is doesnt work, might need threading in def run

    def Pause():
    bus.write_byte_data(DEVICE_ADDR, 1, 0x00)
    bus.write_byte_data(DEVICE_ADDR, 2, 0x00)

    #turn off relays and reset counter to 0

    def Clear():
    bus.write_byte_data(DEVICE_ADDR, 1, 0x00)
    bus.write_byte_data(DEVICE_ADDR, 2, 0x00)
    root.counter=0
    c['text'] = 'Rounds Made: ' + str(root.counter)

    #Close and Clean up everything
    def Close():
    root.destroy()



    ### WIDGETS ###


    # Button, triggers the connected command when it is pressed
    pausebutton = Button(root, text='Pause', font=myFont, command=Pause, bg='bisque2', height=1, width=24)
    pausebutton.grid(row=3,column=1)

    runbutton = Button(root, text='Run', font=myFont, command = Run ,bg='bisque2', height=1, width=24)
    runbutton.grid(row=2,column=1)

    clearbutton = Button(root, text='Clear', font=myFont, command=Clear, bg='bisque2', height=1, width=24)
    clearbutton.grid(row=4,column=1)

    exitButton = Button(root, text='Exit', font=myFont, command=Close, bg='red', height=1, width=6)
    exitButton.grid(row=5, column=1)

    root.mainloop() # Loops forever

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Abbreviations used in Reloading

BP Bronze Point IMR Improved Military Rifle PTD Pointed
BR Bench Rest M Magnum RN Round Nose
BT Boat Tail PL Power-Lokt SP Soft Point
C Compressed Charge PR Primer SPCL Soft Point "Core-Lokt"
HP Hollow Point PSPCL Pointed Soft Point "Core Lokt" C.O.L. Cartridge Overall Length
PSP Pointed Soft Point Spz Spitzer Point SBT Spitzer Boat Tail
LRN Lead Round Nose LWC Lead Wad Cutter LSWC Lead Semi Wad Cutter
GC Gas Check