LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Developing HALs

In an effort to bring even more flexibility to my code I've started to create HALs (Hardware Abstraction Layers) using NI Shared Network Variables.  This has helped me a lot because it enables me to create applications that just consume Shared Network Variables that are being broadcasted from a "HAL" vi that talks directly to the hardware.

 

I was wondering what people's thoughts were on this approach.  I find for anything less than 100S/s it seems to work great.  Most of the time I just point my consumer app at "localhost".  This approach seems to make more sense than to integrate the device driver VIs in my code and change them out per-machine.  It also means that an application that consumes shared network variables can run on any node in my network.

0 Kudos
Message 1 of 5
(2,753 Views)

First off, if your solution is working well, then great stick with it.

 

but.....

 

HALs are a great way to get introduced to Object Oriented programming. You basically have a parent classed called something like "Hardware.lvclass" it has a few basic methods like Open, read, close. Then, for each type of hardware you create a child class. So you'll probably have items like "Simulated.lvclass" and "DAQ.lvclass". Each of them would override Open, read close to perform the specific action that they need to. Now in each different machine you just need some simple logic to determine what type of child class to instantiate, and the rest of the code will just work.

 

Obviously, if you've never do any OO programming, it's probably worth it to check out some of the NI generated material.

0 Kudos
Message 2 of 5
(2,736 Views)

Hi!

 

I'm familiar with LVOOP and most my code is geared towards it.  I do an OOP HAL as you suggest already.  Still learning how to make things better but LVOOP is a godsend.

0 Kudos
Message 3 of 5
(2,731 Views)

I'm with DerekMGI.  The application I am working on currently needed a HAL.  The application tests tuner/demod functionality and performance for our products.  As time goes along, we get new chipsets, sometimes from different vendors and we use different interfacing (I2C direct, through a host processor, and others).  I found the best way to support the various interfaces, and chipsets, was to create the HAL using OOP.  I used LabVIEW OOP and Dynamic Dispatching to do this.  It makes it very easy to incorporate new chipsets, as I just have to write the override VIs for the specific requirements. 

Troy
0 Kudos
Message 4 of 5
(2,723 Views)

HAL using LVOOP works great Smiley Happy we set up one here which works just great for our purpose.

Before starting, I highly recommend proper architecture with regards to dynamically loading new classes from PPLs. There are some pitfalls here Smiley Surprised

0 Kudos
Message 5 of 5
(2,694 Views)