element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Test & Tools
  • Technologies
  • More
Test & Tools
Forum MULTICOMP PRO MP750065 Function Generator - Programming Pt4: LabVIEW Driver Lib Init block
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Test & Tools to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 3 replies
  • Subscribers 356 subscribers
  • Views 1947 views
  • Users 0 members are here
  • MP750065
  • function_generator
  • labview
  • scpi
Related

MULTICOMP PRO MP750065 Function Generator - Programming Pt4: LabVIEW Driver Lib Init block

Jan Cumps
Jan Cumps over 3 years ago

In this 4th post in this Program the Device series I develop a Virtual Instrument Initialize block.
It's the follow up of MULTICOMP PRO MP750065 Function Generator - Programming Pt3: LabVIEW tryout (b).
For the MP750668, UTG900C-II, UTG1010 owners: this will very likely work for you too.

image

I'm designing LabVIEW Virual Instrument blocks (Init, Close, basic Read and Write, and some advanced blocks to set and get favourite values, e.g. Set Freq, Get Freq, Set Waveform, ...)
Because this is the first one in the series, I'll do a dive into the VI approach. I'll discuss design decisions and create a reusable error handling block.

Initialize block design

In the draft flow that I made in post 2 and 3, I put raw DLL calls on the canvas of my functional flow. That was the easiest way to test if things work: an unstructured prototype.
I now know that the approach works. Time to split the example up into reusable blocks. Blocks that use the typical LabVIEW VI pattern.

The functionality of this first block is identical to what happens on the proto. I'll explain that first.
But I morphed the return status handling in the standard LabVIEW error handling process. This is covered at the end of this post.

image

The block diagram is very similar to what we saw before:

image

The dll function is uci_Open(). Its setup and use has been reviewed in post #2.

The inputs are exactly the same:

  • connectstring: optional, defaults to the one that matches my instrument Slight smile
  • timeout in: optional, defaults to 6000 ms - the default value used by the UCI api.

The outputs have one signal less. The DLL error handling is no longer a status you have to check for.
It's encapsulated and becomes part of the error signal. It's separately handled in the Error block that I describe below.

  • session out: handle to the UCI session.
    Used by the functional blocks downstream. Needs to be closed by the (to be written) Close block. Invalid in case of error.
  • timeout out: a pass-through of the input value. Can be used downstream if you settle for a single wait throughout your process.

In a design, this is how you'd use this:

image

In the next posts, you'll see that also the downstream flow will be turned in to the functional blocks.

Error block design

This first iteration of the driver build is a good time to introduce a first utility block: handling UCI api errors.
The dll uses return values to report success and failure. In LabVIEW, this is commonly done with their specific error handling mechanisms.

image
What this error block does, is check if an api error occurred.
If yes, it generates a custom error (-8999, in the custom error range of LabVIEW), with the dll error code provided in the text.
In the example below, the device USB cable wasn't connected.
image

Snippet of the text message reference. You'll find error -1060 back:
image

image: snippet of UCI api help document

The next blocks are going to be similar. I'll take the prototype steps and turn them in reusable components.
While doing that, I'll allow for additional functionality, like choosing the instrument channel, ...

Related blog:

MULTICOMP PRO MP750065 Function Generator - 1st impressions
Programming Pt1: SDK Demo
Programming Pt2: LabVIEW tryout (a)
Programming Pt3: LabVIEW tryout (b)
Programming Pt4: LabVIEW Driver Lib Init block
Programming Pt5: LabVIEW Driver Lib Read, Write and Close blocks
Programming Pt6: LabVIEW Driver Lib: High Level Functional blocks
  • Sign in to reply
  • Cancel
  • Jan Cumps
    Jan Cumps over 3 years ago

    Optimalisation is possible.
    In my original Error block above, part of the error message preparation is done at all times, even if the return value is 0: success.

    I've rewritten it like below. When the dll returns 0, the block does as little as possible. Else it prepares the string.

    This is the execution path when the dll returns 0:

    image

    In any other case (default), there is something wrong and the custom error is injected:

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 3 years ago in reply to Jan Cumps

    The advantage of creating utility blocks is that it makes all future block developments easier.
    This one, the Close block, took maybe 10 minutes, including the icon creation.

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 3 years ago

    The next post completes the low level design: MULTICOMP PRO MP750065 Function Generator - Programming Pt5: LabVIEW Driver Lib Read, Write and Close blocks

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube