My first arduino Mega shield does not work ;)

Hello everyone,

I made my first Mega shield with kicad and Eurocircuit manufacturer.

  • I would like to control 30 electro-valves from an aduino Mega
  • I tried a little circuit I bought online
  • I wanted to duplicate this circuit on my own shield :

I choosed the components references you can read on the image.

But it does not work as expected of course :wink: :

  • When I plug the shied to the arduino, supply the arduino with 12V, supply the electro-valves (+ and -) on the shied with 24V :
  • All the indicators LED should be normally switched off

  • When I set an output to HIGH, it should switch the corresponding LED on

  • And I should be able to read 24V between + and - of the corresponding electro-valve.

But.. :

  • When all LED are normally swiched ON..
  • When I set an arduino output to HIGH, the corresponding LED stayed swiched ON.
  • When I measure the voltage on the + and - of the corresponding electrovalve, I have NO voltage (0V)
  • When I measure the voltage at the output of the optocoupler, I read around 12V.

For the moment I found that :

  • I made one mistake using a normal "switching diode" instead of a "Zener 12V" diode.

But I dont fully understand :

  • Why all LED are switched ON ?
  • Is this Zener diode is the only mistake or can you see something else wrong ?
  • What would you advice me to modify before ordering a new board ?

I'm a total begginer, so I'm really not sure I made this project well.. Despite I tried to do it as best as I can.

Here is the link to download the kicad project :

Thanks by advance for your help.
Roman M.

@rogerlette
Please post a pdf of the schematic.
A link to a kicad pcb file is useless to those who don't have that version of kicad.
There is no Zener diode in the circuit, do you mean the schottky diode?

1 Like

Only if the Mega output pin is set to LOW

Looking at the photograph of the PCB, it looks to me as though you have at least two mistakes (x30) :

  • The pins of the opto isolators are transposed.
  • The source and drains of the MOSFETs are transposed.

On the schematic that you are copying, the Arduino output connects to pin 1 of the opto-isolator (via a resistor). You have it going to pin 2. - This means that the LEDs in the opto-isolator are connected the wrong way round.
Similarly pins 3 and 4 are swapped about.

The tab of the MOSFET is the drain, you have it connected to GND, where the source should be. The LEDs (and output pins) are connected to the source, not the drain of the MOSFETs.

The MOSFETS have an internal diode between drain and source, it is normally reverse biased, but by having drain and source transposed they become forward biased, hence putting the LEDs on.

Hello Jim,

Thank you very much (both of you) for your super quick reply.
Sorry for the pdf, you will find it here : PDF

Here is a picture if the link expire :slight_smile:

  • I did check that all Mega output are set to LOW
  • I did test with a simple blink program, and I even check the input of the optocoupler with a multimeter, and it correctly display 5V when the output are set to HIGH, and 0V when set to LOW.
  • I assume I need a zener diode according to this topic : arduino forum

John, thank you very much, I indeed swap the components.. So stupid..

Since I'll have to re-print the board, can you tell me if I need a zener diode or not ?
Does the other components seems ok to you ?

I think that the zener was put into the original design to give it the wide operating voltage of 6V - 36V.
As you are using the circuit at 24V it is probably not necessary, though having it fitted won't do any harm.

If the only error had been the opto-isolator, you could have got round the problem by mounting the component on the other side of the PCB.

Did you not check the schematic against the one you were copying from before doing the layout?

A 12V zener diode would protect the MOSFET gate from any transients, so a good idea but more importand is the flyback diode which you do not have on your board.

Post your new schematic before you make the next board.

Sure I did not check enought..

I have to say that it was my first time with Kicad, my first time selecting components, I struggle with many details, I had to do and re-do several time the schematic, and I finally did stupid mistakes..

Anyway, Jim I will follow your advice for sure and I will post my schematic before printing the next board !! :wink:

Hello,

Here is the modified schematic :

  • Does the flyback diode is a special diode ? Or can I use such diode diode datasheet

  • Does this Zener diode seems ok for you for D2 : zener diode

Thanks again for your help!

How much current do the valves use?

This is a more conventional way to draw a schematic
Notice that it is almost identical to the protosupply schematic.
I changed the 1K resistor to 750 to ensure thet the 817 get 5mA

2 Likes

Looks better Jim, but should the input not be on the left?

1 Like

In most cases yes but the idea is to duplicate the protpsupplies schematic so it's easy to compare the two

Hello and thanks again,

I modified my schematic to match exactly the one you sent, looks better indeed and it help to understand. I change the 1K resistor to 750.

The EV is 0.2A.

If I undersand, in this case you advice a "Schottky" diode because it's able to stop more current than a normal switching diode ?

What do you think about the Zener diode I selected ?

Thanks again

I think the 4.7k resistor feeding the optocoupler (and eventually the MOSFET gate) is too high a value. With the other 4.7k resistor going to ground, you have a voltage divider that will only put HALF of VCC on the gate. That could be enough, or maybe not.
I don't think you need that resistor at all, actually (not the Zener or any diode in that position, either.) But something around 470 ohms would be OK.

(Another alternative would be for the 4.7k resistor going to ground to be a much higher value, like 47k.)

1 Like

Zener diode:
Use this zener. Here is why, it is 14V 5% so the actual voltage will be somewhere between 13.3 and 14.7. Since the MOSFET gate is +/-20V it is low enough to protect the MOSFET but higher enough to make sure the gate voltage is 12V.

Schottky diode:
Schottkys are faster than silicon and are no more expensive.

Where is the new schematic?

Hello Jim,

Here is the updated schematic, it should be exactly the same as yours.
Thanks for you help choosing the components, it's really not easy to be sure of what I'm doing...

Hello Bill,

I'm not sure to understand exactly what is your point, should I simplify it like this ?

Hi,

To make schematic even clearer.

Tom.. :smiley: :+1: :coffee: :australia:

That is fine except you should note the the zener is 14V.
Also you should correct the AOD4184 pin numbering, it only has 3 pins