Let me explain you how I want anyone else to help me, ha ha…
Working principle for electrolisys:
Two electrodes , having electrons flowing through .. the scheme is the same than a dc motor power control with rotation control using and H bridge . Here , it is a little of explanation: pay attention to pic1. We can replace the dc motor for two electrodes, one being the positive or cathode, the other one, the anode.
Polarity is changed depending of which transistors are in a high or low state, as seen in pic 2 and 3.
In the pics, diodes are for protecting of transient currents , but inour case, with just electrodes, with no inductive loads, it is not necessary t o use them.
If you want to split /separate the pic controller of the control, for Arduino protection or whatever , you can use optocouplers/phototransistors .
What is the difference between electrodes and a DV motor? Electrodes can give two failures because of the chemical reaction: they can be in short (when ionization precipates again metallic ions, forming a path between both electrodes) and open circuitç (when they have been completely reacted , no more metal to become metallic ions). With a potentiometer as a n input to Arduino, we modulate the pwm voltached reached at electrodes.
IMPORTANT: I need to identify y both states.
At this point , you may think: hey dude!!!! Just do an analogic read between the electrodes, to know if there is 0 voltage (short) or if there is an open circuit ( placing a small value resistor in serie with the electrodes …at this point I tell you:
a) If you wanna do that, think that that small resistor should have tow parallel resistors because analog reading input of arduino just reads from 0 to 5V.
b) I don’t suggest to do that because of the optocouplers, grounds are not shared.
c) If you do, without optocouplers , Arduino shows different values. You can use a voltmeter and you will see how values of potentiometer and voltmeter have a linearity, it is, achieve any continous value in scale 0 to 1023 for arduino, and 0 to 5 , as the value of the resistor was chosen for that.
BUT VALUES READ TO BETWEEN ELEC TRODES ARE NOT USEF ULFOR US…why? Because the analog read of arduino reads the exact va lue of the signal, it is not as a voltmeter.. It means that it reads the va lal ue of modulation at that moment and it is so unstable because of the readings ( 1million reads per second) that I can not use an analog reading input from a modulated signal…
So, how can I do that? It would be easy if I c ould use an optocoupler whose input diode would allow me to connect it directly in serie, so it should resist around 200 mA (or if there isn’t any of that given value , we would use a current divider , I mean, two allowed to have a forward continous current of 100 mA….BUT that, when change of polarity is done , it will have to resist a revers e voltage, so, the reverse voltage/ breakdown must be above 24V, as the power will be a 24 V dc inverter ..
It would be for detecting the open circuit. For a short, the first idea would do its job great….
So, if these values are difficult to achieve (optocoupler with reverse voltage above 24 v and minimum 100mA of forward current , how would you do?????
(I have thought in relays and so on, hall effect sensor maybe)