From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Button Operation

Solved!
Go to solution

I am writing a driver to control my HP 8642A signal generator and I am getting some funky behavior.

8642A Block 1.jpg

As shown, I have made a case structure, with a button control set to "switch when pressed," that is meant to turn on/off the RF output on my signal generator.

 

When the button is pressed to ON, it sends the RF ON code "R1" to the device, and turns on the output.  This function works well.

When the button is pressed to OFF, it sends the RF OFF code "RO" to the device, and then turns off the output, but there is a problem.  About 3-4 times per second (I'm guessing about the time it takes to go once around the while loop) it seems to reset, turn ON for a split second (long enough to get to about half its set amplitude) and then turn back OFF.  It's almost as if there is a preset to default to the RF ON condition, and everytime it goes around the loop it auto turns on the RF for a split second and then turns it back off.

 

0 Kudos
Message 1 of 17
(5,070 Views)

I don't even want to think about your problem since the architecture is just plain wrong in the first place. You do NOT want to have a case statement where you are doing a write with each iteration of the loop. You would be swamping the instrument and bus with an incredibly large amount of unnecessary traffic. Use an event structure with a value change event and a latch when released action.

 

p.s. The stacked sequence structure should never be used and you really want to use proper error handling. I also think you are makin a mistake in using GPIB and not VISA but I've mentioned that before and you've ignored that advice as well.

Message 2 of 17
(5,059 Views)

well it must be something we can't see from the picture- attach the vi and I'll peek at the code


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 17
(5,054 Views)

Its because I dont know anything about how the VISA functions work, do they work just like the GPIB functions?  Do they work with super old devices?  What do the VISA functions do that the GPIB ones dont?

0 Kudos
Message 4 of 17
(5,052 Views)

VISA adds a layer to communications protocols that abstracts out the specific protocol and physical layer.  Yes they work with old instruments.  VISA write and VISA read work the same (from the developers standpoint) for GPIB, COM ports, Ethernet, USB. etc.  They are like vitamins- they are good for you and will make your code easier to read and maintain.


"Should be" isn't "Is" -Jay
Message 5 of 17
(5,046 Views)

Dennis has a point about bombarding the device with code using the case structure.  I think I am just going to try to re-design how it does this, and hopefully that will end up solving the problem.  I need to design it so it only sends the command once, but will send it again if I want it to.  Also, just for fun, I made a whole new thread just for everyone to tell me how much better visa is than gpib. 

Oh and "VISA adds a layer to communications protocols that abstracts out the specific protocol and physical layer."

I understand only about the first half of that 🙂

0 Kudos
Message 6 of 17
(5,041 Views)
Solution
Accepted by topic author LarsUlrich

Could be your signal generator.  I have a few that turn the output ON momentarily any time a setting is changed, as if changes can only be allied to a default On state.  Doesn't matter if the changes are made remotely or via the front panel. 

 

VISA/GBIP, you should only have to send a command when changing state.  The attached uses a feedback down to compare the current and previous state of the selector switch.  The comparision Not Equal? is TRUE when the state changes.  The Append True/False vi selects the appropriate command based on the current state of the selector switch.  The FALSE case (selector switch state is unchanged) simply passes the error wire through, i.e. nothing is written to the GPIB.

 

 

GPIB_Write.png

Message 7 of 17
(5,025 Views)

What is the function you have wired in under "error in" and "error out"?

0 Kudos
Message 8 of 17
(5,015 Views)

>>>What is the function you have wired in under "error in" and "error out"?

 

Those are just the standard LabVIEW error clusters

0 Kudos
Message 9 of 17
(5,008 Views)

As in the "Error cluster from error code.vi"?

I am searching for them in the functions panel but the icon looks different, it may be from different versions of labview though.  I'm in 8.5

0 Kudos
Message 10 of 17
(5,005 Views)