Jump to content
  • 0

Analog Discover 2 simple voltage detection


Lidong

Question

Hi folks,

i would like to take some measurements with the AD2.
OS: Xubuntu 20.04.2

It should go like this:
 - Switch On MasterEnable of the PowerSupply 
 - Set W1 to DC -0.2V
 - wait 10ms (settling time)
 - take the DC voltage on CH1 and save it
 - Set W1 to DC -0.1V
 - wait 10 ms 
 ...
 - Switch Off MasterEnable of the PowerSupply


I tried to change the example "Scope and Wavegen" for my purposes
but it doesn't realy work.


My script:
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.Type.text = "DC";
Wavegen.Channel1.Simple.Offset.value = -0.2;
Scope.Trigger.Trigger.text = "Repeated";
Wavegen.run();
Scope.run();

for(var idx = 0; wait(1) && idx < 5; idx++){
    if(!Scope.wait(1)) throw "Stopped";
    var average = Scope.Channel2.measure("Average");
    print(idx+" Average: "+average+" V");
    Wavegen.Channel1.Simple.Offset.value += 0.1;
}
Wavegen.Channel1.Simple.Offset.value = 0;


The results should be:
-0.2V       
-0.1V        
 0.0V        
 0.1V       
 0.2V       

But the results are
0 Average: -0.20239697277474542 V
1 Average: -0.20253002566270656 V
2 Average: -0.10329074933481859 V
3 Average: -0.0045972176319548546 V
4 Average: 0.1936384543240268 V


I used a time base of 100µs/div so a full acquisition takes 1ms.
Waiting for a second before catching the average should be enough to get a full aquisition.
Is there a command to trigger the scope by software like "Scope.Trigger.now"?

I changed the lines 
for(var idx = 0; wait(1) && idx < 5; idx++){
    if(!Scope.wait(1)) throw "Stopped";

into 
for(var idx = 0; wait(0.05) && idx < 5; idx++){
    if(!Scope.wait(1)) throw "Stopped";
    Scope.wait(0.05);

The second wait() doesn't really wait for a ms. Instead it checks if you pressed
the "Stop"-button.
The third wait() seams to trigger the scope.
Is that right? Is that the way to go?

Next question:
I can't find a command to to switch the MasterEnable of the power supply on or off.
What is the command for that?


Many thanks in advance.
 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hello Attila,

thanks for your answer.

Changing

Scope.Trigger.Trigger.text = "Repeated";

into

Scope.Trigger.Trigger.text ="None";

doesn't help.

The result is still

0 Average: -0.20256204946957707 V

1 Average: -0.20255704714549083 V

2 Average: -0.10340124710078286 V

3 Average: -0.0047285733028118795 V

4 Average: 0.0947865008039129 V

It should be -0.2  -0.1  0  0.1  0.2  

But when i use

for(var idx = 0; wait(0.05) && idx < 5; idx++){
    if(!Scope.wait(1)) throw "Stopped";
    Scope.wait(0.05);
    ...

it works.

Now i see. The arg in "Scope.wait(1) is ignored. Only wait(0.05) takes the value 0.05 as an argument and waits for the wanted delay.

So the first aquisition is ignored and the second aquisition is evaluated.

What about switching V+ and V- on and off? Do you have a command for that?

Regards.

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...