Hi everybody,
Since I got so many good suggestions I wanted to post my (this time hopefully) complete circuit diagram (I will post the values for the resistors/capacitors soon). However, I made one unprofessional simplification to make it more easy to read: The orange lines to the relays: Here I just use one I/O output from the Arduino connected to all three relais to change between charge (Relay 1 closed, Relay 2 open, Relay 3 "down") and discharge (Relay 1 open, Relay 2 closed, Relay 3 "up"). I wanted to change this just with one command in the code. I hope that is alright.
To the question why I am not using a DAC I have to explain a tiny bit more about the project:
As general idea I wanted to create a battery simulator where I can create dynamic current profiles to get practical data for battery models, test state estimation etc., without the need for expensive test hardware. Since we work with MATLAB to simulate batteries, and test our algorithms, I wanted to have something simple, without the need of converting data all the time. Luckily, I quickly had reasonable results with combining the shown current controlled circuit with the MATLAB Arduino IO Package (
http://www.mathworks.com/matlabcentral/fileexchange/32374-legacy-matlab-and-simulink-support-for-arduino), allowing to control the Arduino directly with matlab code (only basic commands like analog write/read etc.). So after a bit of fiddling, now I am able to create current profiles (see figure current profile generation) very simple with a Simulink model and then run a loop from matlab code that works like this:
• Read the ith value from the Simulink current demand vector and send the corresponding integer to the Arduino microcontroller board via USB.
• Ask for the measurement of the voltage over the power resistor, calculate the current and store the value.
• Ask for the measurement of the battery terminal voltage, calculate the voltage and store the value.
• Wait until the next second
• If the battery terminal voltage is too low: STOP
The result you can see in the figure measurement (The circuit I used for that contained just the discharge function. I used six NiMH cells in series and had just a voltage devider for the terminal voltage measurement). Therefore I want to stick to the simple low pass filter and avoid the DAC, since it allows me to directly use the "matlab code".
@ BigBobby: Thank you for your general suggestions. I will try to implement R7, R19, C4 , R2 from your diagram and see whether things improve.
Regarding the 1k resistance between the OP Amp and MOSFET I have one question: I found that my current signal got really messy when I try to increase the current (see figure one OPAmp). My solution for this was to use two LT1001 in parallel to increase the current output and it worked fine.
Won't a resistor limit the current again so that there is the possibility to run into the same issue again?
@raschemmel:
Your circuit diagram looks really interesting. Thanks for all the effort you invested in this! I have one question: What is the advantage of your feedback loop, using three LT 1215 OP Amps to drive the MOSFET? The first one just amplifies when I am right. Then you have a low pass filter next to the PWM output. After that the OP Amp is clear as well. But the one directly in front of the MOSFET raises only question marks

Best regards
Karsten