LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

My code looks normal as it should, but when executing, it does not do the job!

Dear all,

 

Can anyone please help me with my problem?

 

I wrote a code for a Keithley 2200 DC power supplies. In one of the first steps of the program, current and voltage are measured, then it goes to next step. In this step I want to do the followings:

 

1- Set current (e.g. I= 100 mA) and read voltage

2- If the voltage fluctuations are less than 0.1V , Divide current by 2  ( I ---> I ÷ 2, e.g. I = 100÷2=50 mA)

3- Set new current  on 50 mA

4- Read voltage

5- Again, if the voltage fluctuations were less than 0.1V, Divide current by 2  (e.g. 50÷2= 25 mA)

6-Set new current on 25 mA

7-Read voltage

8- Continue this process until final voltage is reached (We determine the final voltage ourself)

 

I do not know if my program is working as I want! 

 

Please let me know if you can help.

 

Best regards.

0 Kudos
Message 1 of 16
(3,706 Views)

How have you tested it?

 

What does it not do? Does it set up the serial connection correctly? Does it send the correct string to the PS? Does the PS give a reasonable reply over the serial line? Does the voltage change at all, and if so, in the direction you want? What provision have you made to stop the program when it has reached its (user determined) final voltage, or if it never gets there, to stop manually (Note: using the "Stop Sign" is NOT a good way to stop in normal operation, it is really meant for when you have a problem and have to abort in development)? Break it down and test each step wherever possible.

 

No one can really help you if they don't know what's wrong (and in your message, you actually say that you don't know if there is anything wrong or not!).

 

One more thing, your VI is really drawn pretty well (very readable, good job), but avoid at all costs hiding a wire under an object (like the wires under the T/F case structure). That will come back to bite you eventually.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 2 of 16
(3,687 Views)

At first glance two things:

1- uninitialized shift register, there is no way to know the output of the standard deviation pt by pt for the first iteration

2-race condition, the current division by 2 might occur before or after the VISA Write command, there is no way to know. You should enforce dataflow.

 

Ben64

0 Kudos
Message 3 of 16
(3,678 Views)

Hi Cameron,

 

Thanks for the replay.

I am sure all the connections and commands are correct.

 

Lets put it in this way. 

 

I need the condition of the program to be checked whether it is true or not? Tell me from the code writing point of view, is this code exactly following the following Scenario?

 

 

1- Read voltage,

2- If the voltage Fluctuations are less than 0.1V over a period of ONE SECOND, divide current and set new current

3- Repeat 1 and 2 until the final Voltage is less than the certain value.

4- Terminate the program.

 

 

0 Kudos
Message 4 of 16
(3,670 Views)

Thanks Ben64

 

1- The first itteration is not practically important for my application but thank for pointing it out and remembering me!

 

2-So how do you think I should implement the condition to make sure that it allocates the current before the visa write when is needed?

0 Kudos
Message 5 of 16
(3,662 Views)

Prince2014 wrote:

1- Set current (e.g. I= 100 mA) and read voltage

2- If the voltage fluctuations are less than 0.1V , Divide current by 2  ( I ---> I ÷ 2, e.g. I = 100÷2=50 mA)

3- Set new current  on 50 mA

4- Read voltage

5- Again, if the voltage fluctuations were less than 0.1V, Divide current by 2  (e.g. 50÷2= 25 mA)

6-Set new current on 25 mA

7-Read voltage

8- Continue this process until final voltage is reached (We determine the final voltage ourself)


How can you set the current if "current(mA)" is an indicator? Shouldn't it be a control (or diagram constant)?

Why is it DBL since you only format it as integer?

The current should go into a shift register to eliminate all local variables.

The ptbypt function should go right after the read operation. No need for a shift register.

Can you show a typical response string from the device?

0 Kudos
Message 6 of 16
(3,652 Views)

Hi 

 

Thanks a lot for your response...

 

I am implementing your suggestions into the code, It sounds you have found the bug!

 

I do not have specific file from the device but let me run it after modifications and will upload a file after having it.

 

You are great...

 

Thanks a million.

0 Kudos
Message 7 of 16
(3,642 Views)

Let's put it this way:

 

Does it work the way you want it to?

Does it take into account the points that Ben64 and I raised? [Answer: apparently not.] (And that others might, but you can't answer that part now.)

 

As far as your scenario is concerned, I don't see this program reading a voltage anywhere. All it does is read a serial line, and I have no idea whether the PS is giving you what you want or not. That's what testing is all about.

 

I also have no idea where the "ONE SECOND" comes into play or how you are manipulating your current - (apparently) using the local variable for both control and measurement confuses the situation considerably.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 8 of 16
(3,630 Views)

Lets assume you have a working subVI that takes a current, communicates with the device, and retunrs the voltage. Here's how the rest of the code could look like. (you probably also want to stop once the current is zero or other errors occur).

 

 

 

 

0 Kudos
Message 9 of 16
(3,620 Views)

I implemented the suggestions, and ran the experiment!

It only iterates once and then stops!! just returns 2 numbers which are from the buffer of the power supply!

 

The main question is?

 

(Lets Forget about the device commands)

 

Write a program from scratch that applies a current, measures the voltage fluctuations and if the fluctuations are less than X (whatever value), divides the current and put it as new current value and repeats these steps until final voltage is achieved!

 

 

 

 

0 Kudos
Message 10 of 16
(3,598 Views)