Jump to content
  • 0

correct reading of ad1 and ad2 for data logging


Lidong

Question

Hello,

i would like to catch the decharging curve of an akku.
For that i need
 - a controllable voltage output and
 - two analog inputs

The output sends a voltage to a voltage controlled current drain.
It's simpified spoken a NPN-Transistor and a resistor at the emitter.
              -------o to the + pole
           /           \
   o---|                \
          \                \
            |--o         IN2
OUT1  -   IN1     /
           | |           /
            -          /
   o------|--o----o to the - pole

IN1 corresponds to the current and
IN2 tells me the voltage over the akku.

The decharging should be done by constant current.
Because the transistor gets hot while decharging the voltage OUT1 should be
regulated when IN1 increases after some time.
The approx. decharging time is 3 hours.

It would be fine having a sample point from IN1 and IN2 every 20 seconds.
The data should be stored in a csv file.
Is there an example i could use as a starting point.


I have tried to adapt the script example 'Scope and Wavegen' but with no luck.
The OUT1-voltage is correct but the voltage from the Scope Channel 1 is wrong.

What is the right way to measure the DC voltage over CH1 and CH2?

My poor code:
clear()
if(!('Wavegen' in this) || !('Scope' in this)) throw "Please open a Scope and a Wavegen instrument";

Wavegen.Channel1.Mode.text = "Simple";
Wavegen.Channel1.Simple.Offset.value = 0.0;
Scope.Trigger.Trigger.text = "Repeated";
Wavegen.run();
Scope.run();
for(var idx = 0; wait(2) && idx < 10; idx++){
    Wavegen.Channel1.Simple.Offset.value = idx/10.0;
    if(!Scope.wait()) throw "Stopped";
    var middle = Scope.Channel1.measure("Middle");
    var average = Scope.Channel1.measure("Average");
    print(idx+" Middle: "+middle+" V"+" Average: "+average+" V");
}
Wavegen.Channel1.Simple.Offset.value = 0.0;

Output Window:
0 Middle: -0.001674841884156804 V Average: -0.0017567767298392212 V
1 Middle: -0.001674841884156804 V Average: -0.0017567767298392212 V
2 Middle: -0.001674841884156804 V Average: -0.0017567767298392212 V
3 Middle: -0.001674841884156804 V Average: -0.0017567767298392212 V
...

Regards
  Norbert

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...