Cruch Time Help! 3 LabVIEW Tutorial Videos: State Machines; Faster Code; Simulation

Hello All,

Well, we’re down to the last week, and I’ve been talking to lots of teams. I know many are in great shape, and many are just getting started on their programming.

So, I wanted to squeeze in as much help as I could, as quickly as possible.

Check out the following 3 videos:
**

  1. State Machines: Writing Flexible, Modular Code. Lifter Mechanism Example (http://www.lvmastery.com/TipJar2009-02-08_1)**

In this blog entry, I discuss how to use a state machine within LabVIEW to write flexible, modular code. In this example I code and explain the state machine for a mechanical lifting system. much like what many FRC teams may use.

I discuss:

  • What state machines are
  • How to draw and interpret a basic state diagram
  • Creating typedefs for state machine data
  • Creating enums to store the actual state
  • Storing all sensor inputs and machine outputs in the state machine data for use in debugging and/or the dashboard program
  • How to write the state machine code using the case structure, including how to speed up development by duplicating similar cases

**

  1. TipJar #14 - Speeding Up Slow Tele-Op Code and How Parallel Loops Can Communicate (http://www.lvmastery.com/TipJar2009-02-08_2)
    **
    In this blog entry, I discuss how to speed up time-critical code by pulling it out of the Tele-Op.vi, while maintaining the ability to share data.

I discuss:

  • The fact that there is a lot of stuff going on in TeleOp, and the main loop: can take up to 200ms to run, potentially causing robot damage if limit switches are missed
  • How to move the state machine created in TipJar #13 into its own deterministic, accurate, fast loop
  • How moving the state machine out of TeleOp causes the debugging dashboard to fail because the state data is no longer available
  • How to create a global variable to share the state machine data with the main loop for debugging
  • Race conditions: why you should never write to global variables from more than one VI
  • How to send info from TeleOp to the parallel loops in an easy, scalable way using a “Command Signal” global
  • How using a single command signal can help ensure your important code runs perfectly in TeleOp AND autonomous modes

3. TipJar #15 - Simulating and Testing: How to put your FRC code through its paces on YOUR computer. (http://www.lvmastery.com/TipJar2009-02-08_3)

In this blog entry, I discuss how to simulate your state machine code. The real benefit here is the opportunity to test your logic on your development PC, without needing a functioning robot.

I discuss:

  • How to simply modify the previous state machine example for simulation
  • How to use a global “Simulate” boolean variable to selectively replace all Hardware inputs and outputs with front panel controls and indicators
  • Using case structures to “case out” WPI library calls
  • How to watch and debug using execution highlighting, watching the global variables and the front panel
  • How you must be sure to simulate all sensors, which includes things like turning off simulated limit switches when the system “moves” away from them
  • How to simulate the manual override mode by writing to the “Command Signal” global just like the TeleOp or Autonomous VIs would

I’d like to view these, but I still can’t find the link to download the videos using my iBook. Is the lvmastery site simply not compatible with Macintosh computers?

Alan,

Please let me know if you have flash and javascript enabled. If that is true, and you are still not able to view, I will look into it immediately.

FYI: TipJar #13 just tested successfully using Safari 3.2.1 on OS X 10.5.6 and dual intel Imac 24".

Ben

Works fine on my mac.

Specs: MacBook Pro 15" Intel Core 2 Duo 2.16 GHz with 1 GB of RAM, running 10.5.6

Flash: got it. I have no trouble viewing .flv files, for example.

I don’t see an option for “javascript enabled” in the Flash settings. JavaScript is enabled in the Safari security preferences. As much as I would like to turn it off, too many web sites nag at me if I do (though the lvmastery site didn’t seem to mind).

The thing that makes me wonder most, however, is the lack of a reference to anything resembling a video file in the source of the web page. It doesn’t really matter what I have enabled or not if the site doesn’t present a link to the video in the first place, does it?

Alan,

Trust me, the video is there. The video call itself is buried in a js script, which unfortunately means you need js enabled to view it.

Ben

Oh, I trust you. Other people don’t seem to be having any trouble with it.

The “video call” must be very well hidden. The only javascript I see on the page is a trio of scripts in the <head> that actually look like they’re skipped for non-IE browsers, and something that looks like line noise after the “click here to install the latest version of flash” link. Based on that, I tried viewing it with Internet Explorer (on a Windows computer, even). There still is nothing obvious to click in order to view the video. Where is it supposed to be on the page? There is a largish blank spot after the “latest version of flash” and before the “Testimonials / Want to See More? / Already Registered?” where that cryptic script would fit, but it doesn’t respond to clicks and doesn’t show any hidden text when I select through it.

Oh, and one other weird thing about the Tip Jar pages: no matter how wide I make the window, the bottom scroll bar never goes away.

It looks like the line that inserts the inline Flash player is this: (it comes on the line in the source right after “Trouble viewing these videos?”)


<SCRIPT language='JavaScript' type='text/javascript'>var code="'1AQAPKRV'02nclewceg'1F'05HctcQapkrv'05'02v{rg'1F'05vgzv-hctcqapkrv'05'1Gtcp'02WPN'1Fuklfmu,nmacvkml,jpgd'1@tcp'02qrnkv'02'1F'02WPN,klfgzMd'02'0:'02'00ntocqvgp{,amo'00'0;'1@kd'02'0:qrnkv'1A2'0;'02'5@nmacvkml,jpgd'1F'00uuu,ntocqvgp{,amo'00'1@'5Fgnqg'5@fmawoglv,upkvg'0:wlgqacrg'0:'00'071Akdpcog'0702qpa'071F'0700jvvr'071C--uuu,ntocqvgp{,amo-dkngq-VkrHcp37]:Dg`2;-VkrHcp37]:Dg`2;,jvon'0700'0702ukfvj'071F'0700:42'0700'0702jgkejv'071F'0700442'0700'0702ocpeklukfvj'071F'07003'0700'0702ocpekljgkejv'071F'07003'0700'0702dpcog`mpfgp'071F'07002'0700'0702kf'071F'0700gzvgplcn'0700'071G'071A-kdpcog'071G'00'0;'0;'1@'5F'1A-QAPKRV'1G"; var res="";var len=code.length; var i;for (i=0;i&lt;len;i++) {res+=String.fromCharCode(code.charCodeAt(i)^2)} res=unescape(res);document.write(res);&lt;/SCRIPT&gt;&lt;table&gt;

Looks like that decodes some obfuscated HTML and inserts it into the document. Why it needs to be obfuscated is beyond me. The way that is being done could be triggering an ad-blocker perhaps?

Yeah, that’s what I called “line noise”.

Looks like that decodes some obfuscated HTML and inserts it into the document. Why it needs to be obfuscated is beyond me. The way that is being done could be triggering an ad-blocker perhaps?

Is the actual video (and/or player) hosted on a different server? The firewall here is pretty draconian when it comes to things like YouTube or other public video/image/blogging sites.

Here’s what that line noise decodes to:
{removed by request}

Guys, I appreciate the interest!

The line you are referring to is an obfuscation, which is intended to make it difficult for sites to extract my videos and play them without my knowledge or approval. Personally, I don’t think that’s unreasonable?!?

Even if that wasn’t there, the tool I’m using to create these screencasts is Camtasia Studio, and it uses a javascript controller to play the flash video files.

Now, I’m never one to complain about any attention, good or bad, and I’m sorry if the way I posted my videos is distracting, but I’m not really sure its relevant to this forum.

I’m a LabVIEW programmer, not a web programmer, and the web development tools I’m using seem to work well for for most situations, but if you are having trouble, I’d be happy to help as much as I can. However, I won’t be able to remove the js requirement, and, frankly, you are the first ever to comment on it being an issue.

Ben

It’s reasonable until it makes it difficult for a user (e.g., me) to play your videos with your approval.

…if you are having trouble, I’d be happy to help as much as I can.

The one piece of information I could use is the name of the server on which the video is hosted. With that, I can either confirm or rule out my theory that firewall rules are causing me grief.

I haven’t tried accessing the lvmastery site using my home connection since I got the information that JavaScript is strictly required. I’ll try to remember to give it a go again late this evening when I’m there (it’s a real pain not having Internet access at the robotics shop).