Translate

Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Saturday

Count to Three

Just like a programmer starts off printing "HELLO WORLD" on the screen, in LabVIEW you can start off by learning to count to three. It's not easy or intuitive to find a way to count between two numbers. The key words are "Quotient & Remainder." On the Block Diagram hit CTRL and then SPACEBAR at the same time to pull up the Quick Drop dialog box. Type in Quotient & Remainder. It should find it by just typing in Quo....
Now add a While Loop around the Quotient & Remainder.

 

We will use the iteration (i) terminal from the while loop to show the current loop count. The iteration terminal starts with zero on the first sequence. We connect a wire from the iteration (i) terminal to the X input of the Quotient& Remainder.



We need to add an upper limit number to the Y input of the Quotient & Remainder.  So Right-Click your mouse over the Y input and Create a Constant.  We want this vi to count from 0 to 3.  Put a 4 in the constant box.  The output will count from 0 to 3 because the first count will be the zero and the fourth count will be the number 3.

Right-click on the upper right output connector of the Quotient & Remainder and create an Indicator.  This numeric indicator will be shown on the Front Panel.  This is where the numbers will be seen.  If you want to use this number for another operation, just add a wire and connect to another vi, or a graph, etc.

You will need to add a Stop button to the front panel for this example and wire it to the Stop if True function of the While Loop at the lower right hand corner.  Let's also slow it down a little so we can see the operation working.  Add a Wait Until Next ms Multiple icon with 500 as a constant wait time.

Hit run and watch the numeric indicator count from 0 to 3 on the Front Panel.  Hit the Stop button to end the process.

Thanks for learning how to Count To Three using LabVIEW with me.  Feel free to leave a comment.



Sunday

Website scraping with LabVIEW

Scrape or retrieve data from a website using LabVIEW. This is also called data harvesting or data extraction from websites.

One difficulty is finding good HTML data to scrape. Most data like stock quotes have been replaced with dynamic data that doesn't have a clear and consistent text strings that can be searched.

Here is an example that opens a URL website, reads the HTML, picks out a string keyword and displays the data after that keyword. I've chosen a weather site that has a consistent keyword like "temp"> and the page is dedicated to only one city. So the number after "temp"> will be that city's temperature.


This vi will be great for any instrument attached to a network with a web-page to access.

Use the data socket open and then read to capture all the raw text of the webpage.  Then use a string match pattern to search through the text to find the matching strings before the data that you want to scrape.  The example show searches through the text of the webpage to find "temp">.


More details can be found here.