Hi!
This is my first posting here, so I hope I am doing everything alright.
So far, I have practically no coding experience, but I found the
"ardublock" software, so this is where my code comes from.
Basically, I have two tasks to perform. Both are related to this power
supply, a DPS-2000BB:
I will use the PS to power my armada of RC chargers.
I want to make a fan control depending on the output current, and I want
to lower the output voltage when the PS is near it's limit, which is
around 160A.
Thankfully, the PS has a so-called "current share" pin called "CS" from
now on. Here, the voltage rises when the current rises, so it would be
possible to roughly estimate the current depending on the voltage here.
It is a bit non-linear at the beginning:
0.36V at 0A
0.78V at 2A
1,50V at 50A
4,30V at 150A
Also, one can raise the output voltage from 12.5V to 14.5V by connecting
the 5V output (I also intend to power the arduino from) to the sense pin
via a trimmer, which can be adjusted, and so the voltage can be
adjusted. This will later be important for the current control.
Let's assume in the program that Pin 1 reads analog the CS voltage, Pin
2 writes analog PWM to control the fan, and Pin 3 writes analog PWM to
lower the output voltage.
My thinking so far on the fan control:
I want the fan to run at 30% when the CS voltage is <0.7V. I want it to
run at 100% when the CS voltage is >= 1,50V.
I informed myself a little about the math the arduino does when reading
analog and writing analog PWM, and created a formula which will convert
any CS voltage in the range of 0.7 to 2.0V into a PWM value between 30%
and 100% in a linear manner.
I used this graph calculator to determine the mathematical function which converts the analog input to the desired PWM output in a linear manner:
http://www.arndt-bruenner.de/mathe/9/geradedurchzweipunkte.htm
This PWM I will feed to a NPN transistor which will control my fan(s).
Output voltage control:
First, one has to understand that my RC chargers are programmed to lower
their input current when their input voltage (=output voltage of the PS)
approaches 12.5V, similar to a supply battery which has lower voltage
when being drained.
So, I am going to read the CS voltage, and when I reach and overshoot a level which
corresponds to around 140A output (4.0V), I want to gradually reduce the PWM on
Pin 3 from 100% to 0%. 0% is when the current approaches 157A (4.4V).
To achieve this, I will not connect the sense pin with a trimmer
directly to 5V as usual, but to Pin 3 of the Arduino (trimmer still in between).
If the current is below 140A, this Pin will provide a steady 5V, so the
power supply will have 14.5V, as if the sense pin was connected directly
to the 5V.
If the current is at 157A, the PWM will arrive at 0%, meaning 0V, and
thus the PS will only have 12.5V, as if the sense Pin was NOT connected
to the 5V.
In between, the PWM will vary, and so the PS output voltage will depend
on the load between 140A and 157A, to avoid rapid changes, which the
chargers don't like.
One question of the PWM in general: I read it works with around 490Hz,
but the arduino works with 16MHz. So, multiply cycles are computed while
the PWM creates just one pulse. How often is the PWM updated then? It
can't possibly be within one pulse.
Another thing which would be nice is a feature to prevent oscillations in the range where the output voltage gets reduced. It would be nice if the PWM could be reduced as quick as possible, when the overcurrent situation exists. But without overcurrent, it should be able to rise only 5% per second once it was reduced, so for example it would take 20s to rise from 0% to 100%.
OK, enough talk, here is my first program. Does it look ok and will
perform as I intend?
I just ordered an Arduino Uno, 5 pieces Mini, some breadboars and jumper cables today, so it will need a week or two until I can do practical tests.
Thanks for reading,
Julez
###############
void setup()
{
pinMode( 2, OUTPUT);
pinMode( 3, OUTPUT);
pinMode( 2 , OUTPUT);
pinMode( 3 , OUTPUT);
delay( 5000 );
analogWrite(3 , 0);
analogWrite(2 , 255);
delay( 2500 );
analogWrite(3 , 255);
delay( 2000 );
}
void loop()
{
if (( ( analogRead(1) ) < ( 140 ) ))
{
analogWrite(2 , 77);
}
else
{
analogWrite(2 , ( ( ( 178 / 163 ) * analogRead(1) ) - ( 12903 / 163 ) ));
}
if (( ( analogRead(1) ) < ( 800 ) ))
{
analogWrite(3 , 255);
}
else
{
analogWrite(3 , ( ( ( -255 / 82 ) * analogRead(1) ) + ( 114495 / 41 ) ));
}
}


