I am new to arduino but feel its the best solution for a project I am working on.
So the idea behind the project... It is a current meter which measures the current flowing in a circuit then adjusts the resistance accordingly, and if necessary can inject current into the circuit from a different supply.
I have got the circuit sorted so that is not a worry, it is the programming of the arduino which I have no idea.
The circuit has a mosfet in series whose gate is controlled by the arduino (so it acts as a controlled potentiometer).
The following assessment will run every ten mins.
Initially the arduino will set the mosfet to have extremely high resistance which will slow the current of the circuit close to 0Amps. The arduino will then increment the mosfet with a little less resistance until the "float" (wanted) current level is met. Once this current is met the arduino will halt until ten mins later when it is run again.
If the measurement loop runs and finds even with the mosfet fully saturated (0.0016 ohms resistance) and the current is still not enough, it will open circuit the mosfet, switch a relay and increment an injection voltage/current to create a new supply for the circuit until the required current is met. If the injected voltage/current goes over a threshold, the circuit will alarm to notfiy the user the required current cannot be met.
I have included a Flow diagram to how the circuit needs to work.
If anyone has spare time that they can have a crack at this programming I would be stoked.
I am new to arduino but feel its the best solution for a project I am working on.
So the idea behind the project... It is a current meter which measures the current flowing in a circuit then adjusts the resistance accordingly, and if necessary can inject current into the circuit from a different supply.
I have got the circuit sorted so that is not a worry, it is the programming of the arduino which I have no idea.
The circuit has a mosfet in series whose gate is controlled by the arduino (so it acts as a controlled potentiometer).
The following assessment will run every ten mins.
Initially the arduino will set the mosfet to have extremely high resistance which will slow the current of the circuit close to 0Amps. The arduino will then increment the mosfet with a little less resistance until the "float" (wanted) current level is met. Once this current is met the arduino will halt until ten mins later when it is run again.
If the measurement loop runs and finds even with the mosfet fully saturated (0.0016 ohms resistance) and the current is still not enough, it will open circuit the mosfet, switch a relay and increment an injection voltage/current to create a new supply for the circuit until the required current is met. If the injected voltage/current goes over a threshold, the circuit will alarm to notfiy the user the required current cannot be met.
I have included a Flow diagram to how the circuit needs to work.
If anyone has spare time that they can have a crack at this programming I would be stoked.
Alex
You haven't posted your circuit.
Not the best device for controlling current, a modern power MOSFET, they are designed to switch fast and the gate voltage doesn't change very much as the current changes.
I would suggest using a Darlington instead driven by an opamp. You can sense the current
using a resistor in the emitter circuit whose voltage is amplified by the other opamp (if a
dual packaged one).
But without more information about the voltages, currents, power levels involved its
guesswork...
[BTW your flowchart doesn't render properly in OpenOffice - not the friendliest
format to choose in an open source forum, convert to jpg and include inline please]
Sorry about the lack of info, i didn't know into what depth I should go so I will go a little deeper.
On a boat when you submerge two dissimilar metals into a electrolyte and electrically bond them a current will flow which causes galvanic corrosion. If the current is to high, hydrogen bubbles form under the paint of the boat, if it is too low, your sacrificial Zinc or Magnesium anode is not providing sufficient protection to your propeller or other metals. With time the surface area of the anode decreases - increasing the resistance of the electrolyte and decreasing the current flow.
The project I am working on will measure the natural current flowing (every ten or so mins) and react by doing the following.
The current is to high
If the current is to high it will use a Mosfet as a potentiometer to add resistance
The current is to low
It will saturate the Mosfet (0.0017Ohms resistance) so that the natural current has the best chance at flowing.
The current is still to low
It will open circuit the Mosfet (to redirect current flow) and Inject an artificial voltage from another source which will be controlled by the Arduino Uno to try and match the measured value to the "float". An LED will also light up to warn that it has moved into an "active mode".
The injected voltage meets the "maximum inject threshold"
If it still cannot meet the required "float" voltage (determined by the potential divider circuit) and it hits the "maximum inject threshold" The circuit will alarm to warn that the circuit cannot provide any more external voltage and the boat is not protected any more.
On the attached circuit diagram the natural galvanic circuit is highlighted in Pink. The instrumentation amplifier will measure a potential drop over the resistor which will be proportionate to the current flowing in the circuit. This voltage drop is amplified and is compared against the "float" voltage determined by the potential divider circuit. It controls the Mosfet to either add or remove resistance, or it open circuits the mosfet and controls the injected voltage.
The reason a Mosfet was picked is due to the low resistance. Also the low natural voltage supplied by the two metals (0.7Volts) so It couldn't afford a 0.7Volt depletion layer drop inherit with transistors.
Another consideration was the propellor is earthed to the chasis of the boat so I have to use an isolated supply when injecting an artificial current into the galvanic circuit.
I have the circuit built on multisim and it seems to work but I will gladly take any advice on the circuit design.
I have no idea how to program the arduino, from what I hear it is fairly straight foward but I really wouldnt know. I have added the flow diagram as a .PDF so hopefully it opens a little better
Also more thought has gone into the Injected voltage line it just kind of made it all look quite messy so I have left the detail out
rellimxela:
If anyone has spare time that they can have a crack at this programming I would be stoked.
There is a "gigs and collaborations" section of this forum that is specifically for finding people who are willing to write code for you. Maybe this post belongs there...
Yea I have been trying to learn but realistically I will spend hours trying to learn arduino when I am only being assessed on the documentation not the programming but I do need a working product so I will see if anyone wants the challenge, otherwise If all else fails I guess I will have to see what I can put together myself but it probably wont be very good.
Cheers for the info, I have re posted in that forum so hopefully it drums up some interest
OK, well you have a ton of misunderstandings here! (Metric: tonne.)
Firstly: Electricity is fast! As you adjust the transconductance of the FET, the current changes instantaneously! Not only can you not wait ten minutes to assess the effect of that change on the current in the circuit, you cannot even wait the few microseconds it takes your program to measure the current and compensate. You are looking for a digital approach to a problem which really requires an analog solution.
Next, the Arduino does not have analog outputs such as from a DAC. It has digital outputs, either "on" or "off". Some of these have internal hardware support for a technique called "PWM" whereby you use an integrator network - most simply a resistor and capacitor - to provide the average value of the pulse stream over time - at least ten times the cycle time of the pulses to achieve a stable result. While you could incorporate into your circuit, such a "low pass filter" to determine the control voltage on the FET, it may or may not have a sufficiently fine resolution to control the current to the degree you require.
It possibly is do-able in this respect. Your ten minute monitoring cycle may not adequately account for changes that build up when you adjust the current - particularly the possibility of gassing or salt deposition on the electrodes. And the PWM that you use to set the bias on the FET requires the Arduino to be actually running, even if program processing is halted - it cannot "sleep" and conserve power.
Your auxiliary current injection will also need to be controlled in the same manner, presumably by another FET rather than a relay. If it is not sufficient for the electrolytic circuit to be either switched on or off, then the same would apply for that. I presume you realise that you need a complete circuit for current from the auxiliary circuit, and that it must be of the opposite polarity to the electrolytic circuit, so you have to arrange the two FETs so that they can both be controlled, with their sources connected to the Arduino ground.
And just incidentally, you do not really need an instrumentation amplifier to monitor the current, there are current monitors available for this purpose which will interface with an (analog) Arduino input.
Yea sorry if it wasnt clear, the ten mins is the delay between assessment times.
So the programming will tell the mosfet to start as an open circuit (Meg Ohm resistance is series). Then it will reduce the resistance and re-assess until the loop determines the correct amount of current is flowing. once it is happy it will hold this level of resistance for ten mins, then re run the assessment. If it continually looped with out this ten min delay it would spend more time open circuited then it would giving the correct resistance.
Im not fully sure whether arduinos can control a MOSFET with an integrated PWM output but my all my eggs are sitting in that basket.
The current injection phase is definatly where it will all come apart but this is an additional part to the original project. The relay is just there to make sure current doesnt flow through places it shouldnt, the actual injection will initially be by an opto-coupler controlled by the arduino as the required voltages are so small and current is in the milliamps.
Cheers for the advice though, Is this a hard thing to do on an arduino ? how long do you think it will take someone to do ?
rellimxela:
Im not fully sure whether arduinos can control a MOSFET with an integrated PWM output but my all my eggs are sitting in that basket.
You can build a low-pass filter with a resistor and a capacitor, to "smooth" the PWM output from the Arduino into something that is more like a true analog signal. For best results, set the PWM frequency on the Arduino as high as possible, which will maximize the attenuation of the signal as it passes through the filter. If the Arduino's PWM frequency is set to 32 kHz, then building a low-pass filter with a 10k resistor and a 0.1 uF capacitor gives a cutoff frequency of 159 Hz, a ripple of only 0.4 volts, and a settling time of 0.002 seconds. The ripple is how much the output will vary around the average value, so lower ripple is better. If 0.4 volts of ripple is too much for your application, then just increase the resistor value and/or decrease the capacitor value. As you do so, the circuit's settling time will increase, so there is an inverse relationship there. For example, with a 100k resistor and a 0.1 uF capacitor, the ripple voltage is 0.003 volts, and the settling time is 0.02 seconds. You can try other values here to find a combination that will work for you:
Just copy/paste it into your code. If you change the frequency on pins 5 or 6, you will also affect the operation of the millis() and delay() functions, as they are based on the same timer.
rellimxela:
Is this a hard thing to do on an arduino ? how long do you think it will take someone to do ?
Don't know about a hard thing, but a very odd approach.
Implementing a constant current is usually done by a simple feedback circuit, generally a couple of transistors. If more efficiency is desired, a switch-mode circuit using an IC purpose-designed for the job of which there are plenty available. You usually set the desired current with a potentiometer and leave it at that. The addition of your "boost" circuit would be essentially similar.
That said, if you are determined to do this with an Arduino, then it will be running continuously to effect the PWM output. Since conditions - in regard to electrolysis - are quite likely to vary over a ten minute interval, particularly where there is movement in the water (and this is clearly the case with a boat), it would seem far more sensible to continuously measure and adjust the current.
And as you will note from other discussions here, FETs which are designed for high current use, generally require gate control voltages (substantially) greater than the 5V on which the Arduino operates.
Where is the Common connection shared between the Arduino and the boat?
What does that strange symbol for the MOSFET signify?
How much current are you expecting?
Paul__B is right, it will take far too long for the Arduino to respond. I'd build an analog feedback circuit, and use the Arduino to decide if the passive circuit is enough or if it should switch in an extra power source.
BTW, if you -don't- use a darlington pair, the saturation voltage of a bipolar power transistor can be quite low, on the order of 10s of mV.