Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: OHICAD on March 26, 2021, 08:07:03 AM

Title: Planned expansion board
Post by: OHICAD on March 26, 2021, 08:07:03 AM
I'm aiming to simplify the I/O setup for the machine, anyone see any issues with my planned I/O board? Pneumatics are all run off 24v switches and the board can only output 5v, hence the relays.

Does anyone see any mistakes or issues?
(https://drive.google.com/file/d/13_MtF9QWAILUzQU8qx4Ey7IX7GmGtANM/view?usp=sharing)
(https://drive.google.com/file/d/1Zs372bgd3zpw2YYr9dyfQYDHqQr7TLr7/view?usp=sharing)
Title: Re: Planned expansion board
Post by: ZASto on March 26, 2021, 08:16:13 AM
If you do not need galvanic isolation, you can use logic level MOSFETs instead of relays.
Title: Re: Planned expansion board
Post by: OHICAD on March 26, 2021, 09:42:05 AM
Big thoughts that I vaguely understand and had to read up on a bit to figure out.

So firstly, and I mean this, thanks. Read and thought a bit to make sure I was following your words as I didn't quite catch it initially. Any time I learn something new is a good time.

I was thinking the system does need galvanic isolation as my 5v ground is from a different supply than my 24v ground.
Title: Re: Planned expansion board
Post by: MN300 on March 26, 2021, 01:23:30 PM
Here is a simpler version of the output.
These MOSFET solid state relays can drive your relays directly. Max rating is 60V, 500mA although I would only use them at about half that. By the way, they can also switch AC.
There is a resistor in series with the inputs to set the current.
Indicator LEDs run on 24 VDC as do the relays. I drew them as 24 VDC since that's the supply in your diagram. The circuit could be used for 12 VDC if you prefer.
Diodes across the relays to catch the turn off spike that might harm the MOSFETS.
Title: Re: Planned expansion board
Post by: OHICAD on March 27, 2021, 06:57:31 PM
Here is a simpler version of the output.
These MOSFET solid state relays can drive your relays directly. Max rating is 60V, 500mA although I would only use them at about half that. By the way, they can also switch AC.
There is a resistor in series with the inputs to set the current.
Indicator LEDs run on 24 VDC as do the relays. I drew them as 24 VDC since that's the supply in your diagram. The circuit could be used for 12 VDC if you prefer.
Diodes across the relays to catch the turn off spike that might harm the MOSFETS.

I've kind of sold myself on the optocouplers and got parts on order now.
Is there a reason to prefer MOSFETS over optocouplers?
Title: Re: Planned expansion board
Post by: MN300 on March 27, 2021, 07:08:40 PM
The MOSFET SSRs can handle more current and voltage than the typical optocoupler and eliminate the need for an intermediate driver. For low power they're equivalent to a relay contact.
If your circuit didn't use both an NO and NC contact they could have replaced the relays too.
Title: Re: Planned expansion board
Post by: OHICAD on March 28, 2021, 07:48:56 AM
The MOSFET SSRs can handle more current and voltage than the typical optocoupler and eliminate the need for an intermediate driver. For low power they're equivalent to a relay contact.
If your circuit didn't use both an NO and NC contact they could have replaced the relays too.
Ah, that makes sense. I wanted the relays to swing both ways for future expansion purposes too.
Title: Re: Planned expansion board
Post by: ZASto on March 28, 2021, 07:58:12 AM
You can always put relays behind SSRs.
Title: Re: Planned expansion board
Post by: Steve Stallings on March 28, 2021, 09:07:11 AM
Caution... many SSRs are A/C only output and would not work to drive 24 VDC relay coils.
Title: Re: Planned expansion board
Post by: MN300 on March 28, 2021, 09:54:08 AM
The TLP222AF can handle AC or DC. The 60 volt rating is more than enough for a 24V circuit. I would keep the current under 200 mA to keep the heat down. 200 mA is not a limiting factor as the coil current of a small signal relay is usually under 50 mA.
They are packaged in a 4 pin DIP like the typical opto coupler and cost only a bit more, $1.09 from Digi-Key.
Title: Re: Planned expansion board
Post by: Stuart on March 28, 2021, 10:13:58 AM
what about the back inductive voltage spike will they handle that ok or you will have to put a clamp diode across the coil

Title: Re: Planned expansion board
Post by: Steve Stallings on March 28, 2021, 10:39:14 AM
A clamp diode for reverse back EMF is needed.

While all MOSFETs will self zener and clamp, the devil is in the details. Unless the manufacturer specifies a maximum energy (typically in joules) to be absorbed it is not safe to run without an external clamp. Toshiba does not specify a maximum energy, so assume that this is not safe. A simple 1n4001 diode is fine for DC but you will need a MOV if the load is AC.
Title: Re: Planned expansion board
Post by: ZASto on March 28, 2021, 11:34:58 AM
A diode is mandatory across DC powered relay coil.
SSR, which is low side switching can have internal body diode, but that diode is useless in relay application.
Title: Re: Planned expansion board
Post by: OHICAD on March 28, 2021, 03:55:54 PM
The TLP222AF can handle AC or DC. The 60 volt rating is more than enough for a 24V circuit. I would keep the current under 200 mA to keep the heat down. 200 mA is not a limiting factor as the coil current of a small signal relay is usually under 50 mA.
They are packaged in a 4 pin DIP like the typical opto coupler and cost only a bit more, $1.09 from Digi-Key.

I mean the optocouplers are a lot less than that over on mouser (ref: https://www.mouser.com/ProductDetail/852-PC817X3NSZ9F), I'm getting all my board components there since it's more coinvent and much cheaper.
Title: Re: Planned expansion board
Post by: OHICAD on March 28, 2021, 09:13:55 PM
Board plan is done, 2 sided PCB. Red is top, blue is bottom.
Title: Re: Planned expansion board
Post by: ZASto on March 29, 2021, 05:24:33 AM
You are still missing diodes across relay coils.
You could kill your LEDs with Back EMF generated when powering off relays.
Title: Re: Planned expansion board
Post by: OHICAD on March 29, 2021, 06:27:28 AM
Huh, I need to read a bit more.
Title: Re: Planned expansion board
Post by: OHICAD on March 29, 2021, 07:14:34 AM
Diodes inbound then, going to have to rework my PCB layout to include space for the flyback diodes.

Thanks for catching that, electricity isn't my first language so I tend to miss things.
Title: Re: Planned expansion board
Post by: Steve Stallings on March 29, 2021, 07:42:37 AM
The external diode is not needed in this case. There is a diode inside the ULN2803 between the output and its COM pin which is intended to serve this purpose. Just connect the COM to your +24V or whatever is the positive supply of the relays.
Title: Re: Planned expansion board
Post by: MN300 on March 29, 2021, 08:30:03 AM
There is no series resistor on the opto coupler inputs to limit the current. The outputs you're connecting to are probably CMOS and designed for 8 mA.

The resistors on the opto output are too low, when the input current is limited to a reasonable value the operation may be marginal. You probably don't need them as the input resistors of the ULN2803 should provide enough bypass for any leakage current.

The 330 ohm resistors for the indicator LEDs will allow about 30 mA. A typical LED is specified at 20 mA max. 5 mA is probably more than enough, experiment and see what you think is right.

8 LEDs times 30 mA plus 20 mA for the relays equals 400 mA. Times the 12 volt drop on the regulator equals 4.8 watts. You're going to need a big heat sink! There are lots of step down switching power supplies based on the LM2596 on eBay.

The ULN2803 can handle 24 volts. Using 24 volt relays would halve the load on the power supply and eliminate the need for a regulator.

What you are doing on the input wiring is not clear. If you connecting to 5 volt logic you will be forcing current into the protection diodes and the 5 volt power supply. If you connecting to opto couplers the 27K resistors only allows a milliamp of current.
Title: Re: Planned expansion board
Post by: OHICAD on March 29, 2021, 08:56:56 AM
The external diode is not needed in this case. There is a diode inside the ULN2803 between the output and its COM pin which is intended to serve this purpose. Just connect the COM to your +24V or whatever is the positive supply of the relays.

I shamelessly borrowed the basic design and logic from a existing open source opto isolated relay board that fit my needs (ref: https://www.electronics-lab.com/project/8-opto-isolated-relay-board/ ), so I can't claim full credit for working through all the engineering behind it, I know just enough to grab the parts I think I need to make it work and then shuffle it around a bit to make it fit my application.
I try my damndest to figure out the how of the functionality while I'm at it.
Title: Re: Planned expansion board
Post by: MN300 on March 29, 2021, 09:16:03 AM
I have looked over the PCB layout and see one ground is used for everything which defeats the purpose of using opto couplers.
The ULN2803 is intended for 5 volt input. The ULN2804 is made for the 12 volts you are using.
Title: Re: Planned expansion board
Post by: ZASto on March 29, 2021, 09:55:47 AM
Steve, that diode is not across relay coil :)

Attached is the schematic how it should be connected.

BTW I don't like the routing, and you have a common ground which voids opto isolation.
Even your board does not look like schematic that you used.
What is the 12pin connector for? Are you going to place wire links from that one to 8pin one to establish connection for series resistors for opto couplers?
Title: Re: Planned expansion board
Post by: Steve Stallings on March 29, 2021, 11:04:59 AM
Please look again. If you connect the COM pin of the ULN2803 to the +12V or +24V that supplies the relay coil, then the internal diode is indeed across the coil. That was the whole purpose of including it inside of the ULN2803 device.
Title: Re: Planned expansion board
Post by: MN300 on March 29, 2021, 11:50:34 AM
The PCB traces to the relay contacts could be wider, especially the one from the 24V input which is common to all. I am guessing you will have only light logic level loads but if you control large solenoids that should be addressed. A dead short might destroy the common trace, a fuse would be good if your 24 volt supply can supply high current.

There are multi-relay opto isolated boards on eBay that would likely fit your needs.

If you have parts and are trying to save this design tell us more about what you are connecting to the inputs and outputs.
Title: Re: Planned expansion board
Post by: OHICAD on March 29, 2021, 01:37:52 PM
The PCB traces to the relay contacts could be wider, especially the one from the 24V input which is common to all. I am guessing you will have only light logic level loads but if you control large solenoids that should be addressed. A dead short might destroy the common trace, a fuse would be good if your 24 volt supply can supply high current.

There are multi-relay opto isolated boards on eBay that would likely fit your needs.

If you have parts and are trying to save this design tell us more about what you are connecting to the inputs and outputs.

Outputs are going to a bit of a gas piano controlled by these:
https://www.smcpneumatics.com/VQZ2151-5LO1-Q.html

Inputs are a bunch of 24v PNP sensors to replace the old NAMUR sensors that were originally there and lost their translator with the old black box controller.. Currently everything is getting mechanical limit switches that have WAY too big a variance for my comfort.

The primary aim of building an expansion board is to avoid/eliminate the rats nest that I had to clean up previously, further I'm not adverse to ripping up the existing board traces and reworking them. I left a significant amount of room on the traces anyway and could likely just expand the size based on recommendations.

Lastly, thanks for pointing out that I grounded everything on the same circuit. Considering I've got the single 24v supply point, where else would I ground it? Chassis?
Title: Re: Planned expansion board
Post by: OHICAD on March 29, 2021, 02:29:25 PM
Steve, that diode is not across relay coil :)

Attached is the schematic how it should be connected.

BTW I don't like the routing, and you have a common ground which voids opto isolation.
Even your board does not look like schematic that you used.
What is the 12pin connector for? Are you going to place wire links from that one to 8pin one to establish connection for series resistors for opto couplers?

As I've said, electricity isn't my first language, so mistakes are due to ignorance. I really do appreciate you folks taking a look and having a think on what I'm doing.

The inputs are to the PNP proximity sensors. The manual for the C11G BO board I'm using requires a 27kOhm resistor with those 24v sensors before it gets to the board, so that's what the 12 pin connector is for. Rather than adding another separate board to manage those I'm trying to consolidate it to one.

The board I'm pulling from is a source, but I didn't directly copy and paste it since I wanted to do more than just have a relay board and eat up real estate with another board for the sensors and another for the driver pin out and another for the tool changer, etc, etc, etc.
Title: Re: Planned expansion board
Post by: MN300 on March 29, 2021, 03:21:36 PM
If I am decoding the solenoid part number correctly the coil is 24 volts 0.45watt with an indicator light and surge suppression. That means it draws only 19 mA so no problem with trace size. Still, it wouldn't hurt if you can increase the trace width. Who knows what the future may bring.

I looked at the C11G manual to see how the 27K resistor from 24 volts works into a 5 volt input. If you set the jumpers for pull down the 4.7K pulldown and the 27K resistor form a voltage divider that presents 3.5 volts to the buffer IC inputs. That's above the nominal 3 volt threshold.

If your not going to put opto isolation on both the inputs and outputs you could just connect the C11G outputs to the ULN2803 and run its outputs to the 24 volt solenoids, no 12 volts needed.
Title: Re: Planned expansion board
Post by: ZASto on March 29, 2021, 03:34:11 PM
You need 2 supplies to have opto isolation between your inputs and ULN chip because you NEED different Commons (aka GNDs) for each side (input side and output side).
If you do not need galvanic isolation, then you can omit optos and drive ULN inputs directly. Relays are, anyway, galvanic isolation between your inputs and pneumatic valves.

Preliminary "reverse engineered" board from your picture, omitted voltage stabilisator. :)
Title: Re: Planned expansion board
Post by: MN300 on March 29, 2021, 04:15:53 PM
If ZASto's board is using a ULN2803 it is not connected correctly.
The relay contacts are connected differently too.

Also I'm wondering where the 12 inputs connect as the C11G has only 5 inputs.

Title: Re: Planned expansion board
Post by: OHICAD on March 29, 2021, 04:18:58 PM
Sorry, brain edited out a couple important things.
ESS smooth stepper driving a C11G and this is intended to compliment a C25S that has not yet been installed.
I'm trying to make damn sure I've got all the things thought through before I change anything.
Title: Re: Planned expansion board
Post by: MN300 on March 30, 2021, 11:09:15 AM
Here is an idea for the output board. You could output to relays or solenoids. The ULN2803 has the protection diodes built in. If you already have 12V relays an LM2596 module from eBay will make 12V from 24V much more efficiently than a linear regulator. They are available with or without screw terminals. One without could be mounted on your PCB. Match the pad spacing on your board and use stiff wire like resistor leads to connect it.
Title: Re: Planned expansion board
Post by: OHICAD on April 01, 2021, 06:37:31 AM
Alright, so I've taken you guy's input and I'll be giving the board a rethink. I'll post up a new thread after I plan it out to get some further input.

Keep being awesome guys.