New domain and blog

New domain and blog
Please head over to my new domain to view my blog and current projects

Wednesday 17 July 2013

LabVIEW: Twitter toolkit

I have had this post in my head for a while but just haven't gotten around typing it up yet. I came across the LabVIEW Twitter Toolkit some time ago and gave it a go. It took a while to understand all the security features, but once I got my head around that, everything went smoothly.


The place to start is here. This will guide you through setting up your Twitter Developer Account and creating your application credentials. 

A few points to take note of:
  • You must add a callback URL, even if you just add your website. This field must be a valid URL and cannot be blank.
  • Your application must have read and write access.
  • Generate your Access Token if it has not been generated yet.
I have edited the basic single tweet example to count characters etc. Here is my version of the block diagram.



I count the characters in the Tweet string and if more than 140 are entered, I disable the Tweet button and change the font colour to red. The block diagram looks as follows.



So the idea is, the first time you run the program after you have set up your Twitter Application, enter only the Consumer Key and Consumer Secret. Then type a tweet and press the Tweet button. A browser tab will open and ask you to verify your application. Do this and then the tweet will be posted.

Now enter your Access Credentials and use them for every tweet in the future. By explicitly entering the Access Credentials, you prevent having to authorise your application every time you send a tweet.

That is all there is to it. Once you have it all set up sending tweets from LabVIEW is pretty simple thanks to the toolkit.

Here is a copy of my application if you want to give it a go.

Greg

Friday 5 July 2013

LabVIEW: CLD Timing Engine

After working through the example programs from National Instruments, I found that most of them have a common trait. Since I have worked through the programs twice and seem to have an understanding of the architecture that I plan on using, that might all change later today – story for another day, I am focusing on getting set pieces of code together that I can generate quickly to save time.

One of the very important functions that I have been practicing is a Timing Engine. This Timing Engine needs to be able to be Started, Stopped, Paused, Reset, have a Target Time set, indicate whether the timer Has Elapsed and indicate the running Elapsed Time.


Here is my main program that I used to test my Timing Engine. It starts off by resetting the Timing Engine and setting a Target Time. It will then run until the Target Time has been reached at which time the Time Elapsed? indicator will be set. The Timing Engine can be paused by clearing the Advance Time control and reset by pressing the Reset control. 

The actual Timing Engine looks like this. (I got the idea from one of the example programs so this is not entirely my own work.) I like the way it works and can be put together really quickly so works well for me.


Basically, a time stamp is taken each time the vi is run. The previous time stamp is subtracted from the current time stamp giving the change in time (dt). If the Advance Time control is set, dt is added to the Elapsed Time and if the Reset control is set the Elapsed Time is set to zero. Once the Elapsed Time reaches the Target Time, the indicator is set. 

I have used this Timing Engine for the Car Wash, Sprinkler Controller and Boiler Controller and it works really well. There are many other ways to perform this same task, but this works for me and I hope it can help you in some way.

You can download the source files here.

Greg