Quantcast
Channel: All LabVIEW posts
Viewing all 203588 articles
Browse latest View live

Make one loop wait for another?

$
0
0

I'm trying to run two laser scanners, one in the X direction and one in the Y. I need them to work in sync, so after the X deflector travels all the way to a point, I need the Y to change positions, and then the X deflector scan again (sort of in a zig zag pattern). Right now I put each deflector in a different loop, and was thinking I could make the Y scanner "wait" for the X one to get in position, however, I'm not sure if that would even work. I'm running on my R series multi function RIO, and have attached a snippet some code I've started. Thank you for any advice!


Re: Steering system of a ship

$
0
0

Yes, it is an undergraduate problem that I have to run in LabVIEW. I am sad to tell that help is not provided by tutor/mentors and local partners are struggling too. I could spend many hours in the library but time is limited and I both I and my classmates are newbies using the software...

Thanks for your help and sorry for any inconvenience.

Re: Call DLL via Python: Pass String to String Cluster

$
0
0

This isn't exactly the same, but perhaps it is useful - I tested this to allow me to pass something like error clusters from C++ to LabVIEW via Event Structure:

 

 

#pragma pack(1)
typedef struct _EventSend
{
	_EventSend()
	{
		code = 0;
		severity = 2;
		message = nullptr;
	}
	int code;
	unsigned short severity; // Uses a U16 in LabVIEW for the enum
// Make sure the class matches the enum typedef. LStrHandle message; } EVENT_SEND; #pragma pack() EVENT_SEND eventStruct; void LabVIEW_ErrorEvent::sendErrorEvent(int errorCode, Severity severity, std::string message) { LabVIEW_Info::init(); eventStruct.code = errorCode; eventStruct.severity = static_cast<unsigned short>(severity); // Allocate a LabVIEW String Handle LStrHandle newStringHandle = CreateLabVIEWString(message); eventStruct.message = newStringHandle; // Send the event LabVIEW_Info::f_PostLVUserEvent(*eventRef, static_cast<void *>(&eventStruct)); } LStrHandle CreateLabVIEWString(std::string message) { // Calculate needed memory space int stringLength = message.length(); const unsigned int memSize = sizeof(int32) + stringLength * sizeof(uChar); LStrHandle handle = reinterpret_cast<LStrHandle>(LabVIEW_Info::f_DSNewHandle(memSize)); // Empties the buffer memset(LStrBuf(*handle), '\0', memSize); // Add data sprintf(reinterpret_cast<char*>(LStrBuf(*handle)), "%s", message.c_str()); // Inform the LabVIEW string handle about the size of the string LStrLen(*handle) = stringLength; return handle; }

The f_DSNewHandle and f_PostLVUserEvent are just wrappers around the C .lib functions available with LabVIEW (to allow DLLs, if I recall correctly).

 

Here you can see how I created the strings using the LabVIEW library to allocate the memory and pass the value. Probably you're already doing this for the non-cluster case, but perhaps there's some small detail that will help if it's the same in Python.

 

Re: Make one loop wait for another?

$
0
0

First.  Index Array is expandable!  Delete all but one.  Drag the bottom border downwards.  You can even get rid of all the constants because it will default to index 0, 1, 2, 3.....  Less nodes, less wiring.

 

There are several ways of communicating between loops telling one to wait for another.  Look at Notifiers or Queues.

Re: Is there a better way to code this?

$
0
0

Awesome - thank you for that.

 

I'd start by suggesting that when you have a lot of duplicate code, you'll probably remove some of your problems if you can reduce it.

 

In your specific case, one way to do that without changing the functionality or framework/structure of your code would be to group all of the letters into the same Event Case (with many triggering events) and then use the Control Reference (available at the left of the Event Structure in that box that you just can't get rid of, no matter how much you might want to) to determine which letter was clicked.

 

A simple way to do this is with the Label.Text property of the control, which is accessible as a property node for any control (so you don't need to use To More Specific Class).

 

It's also not obvious what the selector on the F is doing - probably you don't care about the transition back because you're using latching controls, so you should only get an event for the false -> true transition (assuming you don't start with any of them being true). Perhaps someone can clarify this if I'm a little (or a lot) inaccurate.

 

As to all of the hidden Display booleans, what you really want to know is which box is being typed into, so store that information directly using an Enum (and perhaps a shift register, or similar). Include a "Not Currently Inputting" option or similar, so that you can handle the case that nothing has been selected.

 

Once you have these two changes, it should be a lot easier to program each case (and it will be one case, not 40+).

Re: Having issue VISA Read reading entire serial response

$
0
0

Sorry RavensFan I was unclear on that. The code I have been posting is just the "send_cmd.vi" I use to send the commands for each device (which is indeed sequentially sending the commands to 1 device).

I have a parent vi containing multiple copiess of the "send_cmd.vi" in order to multicast the commands and run the devices in parallel ("send_cmd_device_1.vi", "send_cmd_device_2.vi", etc.), they are all a copy paste of the .vi we have been modifying in this post. The parent .vi which holds these multiple iterations does nothing else aside from telling all the copies to "start" at the same time (i.e. telling all the "send_cmd.vi" duplicates to send the commands to their respective device aka send the commands in parallel).

 

I omitted including the parent as it literally just a Boolean Start Button that sets the case to "True" allowing all the .vi's to fire off. In that essence, I don't believe the Start Button would cause the issue that I am seeing.

It appears to possibly be a USB Bandwidth issue in which the Hub is having difficulty managing the USB Bandwidth causing the latter USB ports to lose connection while sending back responses.

Re: Is there a better way to code this?

$
0
0

Here's a partially implemented version (2017) for T and F, for Display 1. I didn't make the enum a typedef to simplify sharing here, but you definitely should (to simplify changing it later).

 

Be careful when removing event cases, if you delete the button with the case it will of course delete the letter key too (doh!)

I'm not sure what handling you want, but you can do it differently in each case. It may also be true that you don't need all of the local variables (although not sure). You can at least get rid of the confusing Select nodes.

 

Edit: I removed your global variables in I think the timeout case, so be careful with that if you make edits directly in the attached file!

Control third party application through labview

$
0
0

I am trying to send keyboard commands to a third party application. I have successfully launched the app, but can't send alt+u+enter command to the app.third party app control.png

Can someone please tell me how can I accomplish this?

Thanks.


Re: How NOT to clear graph/chart between each VI run

$
0
0

Yes that NI Verified was an example program (I assumed it's certified by NI to be a much cleaner minimal working example than the one I wrote Smiley Very Happy)

 

Anyway, I will re-structure and try with Producer-Consumer architecture. The last 2 points you provided in specific are really fundamental to maintain code clarity and clean UI. Thank you !Smiley Happy

Re: Is there a better way to code this?

$
0
0

Thank you for all this feedback!

 

I will work on these elements you pointed out and will followup once I get a working version.

Re: Panasonic FZ-G1 tablet

$
0
0

Seems I figured it out.  In Control Panel>Tablet PC Settings, there is a Buttons tab where I was able to change the function of the A1 and A2 buttons.  I selected the Action "Press a Key or Key Combination" and made that combination "Ctrl+Shift+1."  Then using the Acquire Input Data.vi I get 1, LCONTROL, LSHIFT, in the output array.  Using the Key Down? event, I get ! (33) in the Char event data and Shift and Control in the PlatMods data.  Easy peasy!

Re: Random Sample not updated

$
0
0

You can embed images to your post, no need to zip it. Don't use disallowed formats such as tiff, though.

 

diag.png

 

What does the code represent? What is "k"? What is "real time data"?

 

Code cannot look into the future, so k+1, k+5, etc. are typically not known yet. Maybe you want to rewrite it in terms of "k", "k-1", .... "k-5" Shift registers and feedback nodes allow you to look at historic values if done right. See how far you get.

Re: LV Installer include RTE-Do Not Reboot PC after Install

Re: Get Malleable VI Path

$
0
0

 wrote:

You're almost there. The instance VI has a tag called "_OriginalInstancePath". That should give you what you need.


I've found my "user-created" malleable VIs don't have this tag (using 2017 SP1).  Is this in a later LabVIEW version, or is there another way to expose this information?  Thank you.

Re: PXIe-6674T sync to backplane

$
0
0

Tyler,

So there's no indication whether the PXI_CLK10_IN is actively being used to derive the PXIe-CLK100 backplane clock?

Cody


Re: Random Sample not updated

$
0
0

I don't think you "get it".  I'm going to make some assumptions (that make sense to me):

  • When you say "real time data X" and "X(k+5) ... X(k+1, X(k)", the k's are indexes into an array X
  • Thus if k=0, the above become X(5), ... X(1), X(0).
  • What is "strange" (to me) is that you seem to be talking about "data in the future", especially if we consider that k represents "now", the "k"urrent point.
  • LabVIEW is pretty good about dealing with "recent" data (one, two, three loop cycles ago, see Shift Registers), but does not (yet) allow us to work with future data.

So I'm going to restate Functions A and B, and see if this is what you want:

  • I'm going to use "i" as the "index" variable, and will assume X(i) is the latest point acquired, so we have a stream X(i), X(i-1), ... X(i-5).
  • Function A, Y(i) = X(i) + 8 (I think you have a Typo in your Function A).
  • Function B, Z(i) = X(i) + Y(i-5) = X(i) + X(i-5) + 8.

Note that if we don't need to use Y except to compute Z, we don't really even need to save it.  You can do this computation in a single step with a While Loop having a Shift Register with 5 "left edges" (look up Shift Registers and how they work if you don't understand what I'm saying).  You'll (of course) need to decide how to initialize the Shift Register to set values for X before you start running the loop.

 

Bob Schor

Re: Get Malleable VI Path

$
0
0

Make sure you're reading the tag of the *Instance VI*, and not the original .vim file on disk.

 

To get a reference to the instance VI, you need to get the SubVI reference, then read the "VI Reference" property of the SubVI class. That VI reference should have the _OriginalInstancePath tag.

Re: The VI is not executable. The full development version...

$
0
0

Just adding that enabling .NET Framework 3.5 fixed my instance of this problem.  

Re: Make one loop wait for another?

$
0
0

Are the DIO2 through DIO16 channels of a 16-bit DIO Register?  Instead of splitting all of the bits out one at a time, set DIO1 (why are they numbered 1..16 instead of 0..15?) as appropriate and write the register all-at-once as a U16.  [In most NI DAQ devices, a DIO device can be addressed either as a Port (multiple lines) or as individual Lines (I hope I didn't get Ports and Lines mixed up ...][nope, MAX agrees with this terminology].

 

There's a function on the Boolean palette that turns a number into an array of Booleans.  You have 14 "bits", and want them to go into Bits 1..15, so you need to shift all the bits up by one.  If you think of this as a number, this is a "multiply by 2", and if you consider it as an array of 16 booleans, there's an Array operation "Rotate 1D Array" (you pays your money, you takes your choice).

 

Why bother to worry about this?  Makes your Block Diagram much neater (and smaller), may "map" better with what you are really trying to do (I'm assuming that you are not turning bits on and off completely independently).

 

How do you discover these things?  Pay (much) more attention to what you want to do, and put off as long as possible how you are going to do it.  So thinking of 14 bits as a "thing", manipulating it, and keeping it together may lead you to the "all-at-once" idea.

 

Bob Schor

Re: PXIe-6674T sync to backplane

$
0
0

It's working.  This has helped immensely!

Viewing all 203588 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>