PDA

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



thump_rrr
03-21-2021, 09:34 PM
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.
https://i.postimg.cc/pdpSj5dC/DBD7-A668-F913-4139-90-F7-C16-BF6-C67-C6-D.jpg (https://postimg.cc/7CrX860J)
https://i.postimg.cc/qRjckjsv/6-DFD5765-876-D-439-E-AB56-CE6-E4-D147454.jpg (https://postimg.cc/0MKKnGXT)
https://i.postimg.cc/C52j856y/6-C5-FB3-F0-2-E10-44-E0-BEA7-07-E2-F3-F71-AFA.jpg (https://postimg.cc/XBwGSjbx)does my keyboard work (https://keyboardtester.co/)

https://youtu.be/5-yu0px3KZg

Tazza
03-22-2021, 12:22 AM
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.

thump_rrr
03-22-2021, 12:52 AM
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.

skeettx
03-22-2021, 12:59 AM
Well done, well done
Thank you for sharing
Mike

Tazza
03-22-2021, 05:20 AM
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:
280013
280014
280015
280016

thump_rrr
03-22-2021, 07:21 AM
Just to be clear the flyback diode goes across the coil and not in series.
https://en.m.wikipedia.org/wiki/Flyback_diode

Tazza
03-22-2021, 06:04 PM
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.

thump_rrr
03-22-2021, 07:03 PM
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.

Tazza
03-22-2021, 07:31 PM
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.

Assnolax
03-23-2021, 03:28 PM
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.

jim147
03-23-2021, 06:19 PM
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.

thump_rrr
03-23-2021, 11:30 PM
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()

Tazza
03-24-2021, 12:01 AM
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.

thump_rrr
03-24-2021, 12:23 AM
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.

Assnolax
04-05-2021, 12:46 AM
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.

thump_rrr
04-06-2021, 07:56 AM
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.

dansedgli
04-06-2021, 08:06 AM
If you dont know how to code, like me, you could buy one of these.

https://www.frightprops.com/electronics1/frightideas-controllers/picoboo-controllers/picoboo-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.


https://www.youtube.com/watch?v=srO5kk84W3Y

thump_rrr
04-06-2021, 08:23 AM
If you dont know how to code, like me, you could buy one of these.

https://www.frightprops.com/electronics1/frightideas-controllers/picoboo-controllers/picoboo-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.


https://www.youtube.com/watch?v=srO5kk84W3Y
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.

Plate plinker
04-06-2021, 09:20 AM
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.

Assnolax
04-06-2021, 03:17 PM
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

thump_rrr
04-19-2021, 02:34 PM
Update: I now have the touchscreen installed and running on the control panel.
https://i.postimg.cc/SKxQ9qyb/E3-C614-F7-C264-47-E5-9-FE3-6-F557-ABFD350.jpg (https://postimg.cc/SnHp0B2g)

Tazza
04-19-2021, 05:37 PM
Update: I now have the touchscreen installed and running on the control panel.
https://i.postimg.cc/SKxQ9qyb/E3-C614-F7-C264-47-E5-9-FE3-6-F557-ABFD350.jpg (https://postimg.cc/SnHp0B2g)

That's awesome, you can check the forum while casting :)

That's a decent size touch screen too, what adjustments are you hoping to control with it, and setup pre-sets?

thump_rrr
04-19-2021, 08:15 PM
That's awesome, you can check the forum while casting :)

That's a decent size touch screen too, what adjustments are you hoping to control with it, and setup pre-sets?
I will be able to adjust the timing of the pour, dwell time before ejecting and mold cool down time.

I will simply make a separate program for each bullet mold with the necessary changes.

The 7” touchscreen was $84 shipped here in Canada on Amazon.

I could have waited 6 weeks for one from China for $51.00

Tazza
04-19-2021, 08:50 PM
Some times it's just more convenient to buy it locally, even though it will no doubt have come from China, you pay for the speedier delivery. If i have plenty of time, i just let it come from china, if i want it fast, i get it locally if there is a big price difference.

Can you add a feature so you can fine tune on the fly too? so have different basic times set in the profiles, but make it so you can adjust them as you go, i know as my pot level changes, i need slightly different pour times.

Roger Kehr
05-14-2021, 04:38 PM
This looks like an awesome setup and I am very intrigued. What happens when a bullet gets stuck in the mould?

Tazza
05-15-2021, 05:23 AM
This looks like an awesome setup and I am very intrigued. What happens when a bullet gets stuck in the mould?

Sorry, i was an idiot and replied to this post on my phone, thinking it was a different thread, ignore my previous reply.

On mine, if something gets stuck, it will try and clear the jam 5 times and stop if it doesn't succeed.

Roger Kehr
05-24-2021, 12:17 PM
Thanks Tazza.