From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ni- Scope How to change the time base?

Solved!
Go to solution

We recently purchased our first NI USB oscilloscope. (USB-5132)

 

Instead of a bunch of dedicated VI's like I would get with a stand alone O-scope the NI devices use the NI-Scope VI set. 

 

Changing the time base seems like a very basic function for an oscilloscope, yet I have gone through all of the examples and in every single one of them there is no way to change the time base

 

The " Configure Horizontal Timing" vi. only allows me to change these things:

  1. min sample rate
  2. min record length
  3. reference position
  4. number of records
  5. enforce realtime

How do I change the horizontal time base?

Do I have to do some kind of crazy math involving the sample rate and record length?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 1 of 16
(5,772 Views)

Well due to the absolutely zero responses about how to set the horizontal timebase using NI-Scope VIs and a NI USB oscilloscope I did a little playing around with the examples and I can see there is some relationship between Sample Rate/Record Length and the time/div horizontal axis.

 

But I can not figure out what that relationship is:

 

My application requires me to have a time/div control for the oscilloscope display just like an oscilloscope has.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 16
(5,771 Views)
Solution
Accepted by RTSLVU

Unencumbered by any "facts" (I've not used NI-Scope nor a USB oscilloscope, but have used numerous "real" scopes, both the old "moving CRT beam" and the more modern "fast internal A/D and digital display" model.

 

So a "traditional" scope has a Time/Div setting, and there are usually 10 Divisions on the screen, so if you have it set to 1 sec, then you'll see 10 seconds of data as the beam moves (slowly) across the face of the scope.  If you need to see a Rising Edge, you set it to 0.1 msec (or less) per division and use triggering to get the rising edge in your 1 msec of display.

 

Now consider Sample Rate (Samples/sec) and Record Length.  Let's say (remember, unencumbered by the facts!) that you are going to display the Record to fit on the screen.  What is the total time represented there?  Let RL = Record Length, SR = Sample Rate, and ST = Sample Time = Full Screen time.

   ST = RL / SR.

Example -- the width of the screen is 1000 samples, and you sample at 1KHz.  It takes 1000(samples)/(1000 samples/s) = 1 second to take the data that fills the screen.  If the Screen has 10 "divisions", then 1 div = 0.1 sec.

 

You probably want to sample (speaking as a non-engineer!) 100 to 1000 times faster than the shortest time interval you are interested in seeing (this might be low by a factor of 10, but probably not by a factor of 100, and I'm happy to be corrected on this).

 

So if we are using a Digital Scope, have a display with 10 Divisions across the Screen, know the Sample Rate (SR) and Record Length (RL),

   Time/Div = (RL/SR) / .

 

Bob Schor

 

P.S. -- I love your Quote!

Message 3 of 16
(5,748 Views)

Hmm... That makes sense and gives me something to think about tonight.

Other than cursing NI for making me go through this. I have automated several real oscilloscopes both analog and digital and they all usually had time/div as part of their horizontal vi and in the case of DSO's also had a separate vi with sample rate settings.

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 16
(5,738 Views)

I am not sure if you can change the horizontal timebase but you can change the sample clock time using property node. Below image migh help you.

timebase.png


CLD Using LabVIEW since 2013
0 Kudos
Message 5 of 16
(5,719 Views)
Solution
Accepted by RTSLVU

Just in case this comes up again I thought I would post my soultion.

 

I made a vi that calculates the record length given the desired Time/Div and sample rate.

 

Time-Div.png

 

========================
=== Engineer Ambiguously ===
========================
Message 6 of 16
(5,626 Views)

I think your solution can be improved.

  1. Use text rings. You can associate a text value and value with the ring, no need to carry arrays around, see snippet 1. (This shows how to make a text ring, after the control is made, then you can copy the control around) I do NOT like this solution, but it works.
  2. Do this dynamically, that way you never need to change your array with a new scope. I do this with DAQmx, but am unsure whether the property nodes exist for NI-Scope.
    1. Determine the Clock Rate that the sample clock uses (A property node in DAQmx, maybe in NI-Scope also)
    2. Determine the Max Sampling Rate of the Device, once again hopefully a property node
    3. Find the Integer Factors of (1). A Jeff B VI helps here
    4. Your allowed sample rates should be integer factors up to the max sampling rate with a possible lower bounds.
    5. Choose which rates you want.

Hope that makes sense. Am writing fast.

 

mcduff

 

snip1.png

EDIT : Changed Snippet to 2017

snip2.png

0 Kudos
Message 7 of 16
(5,611 Views)

@mcduff wrote:

I think your solution can be improved.

  1. Use text rings. You can associate a text value and value with the ring, no need to carry arrays around, 

Okay so I tried this and am now getting an error message and do not understand where it's coming from. 

 

Never mind I found the mistake in my sub-vi

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 16
(5,555 Views)

Glad you found your error.

 

A couple of things:

  1. Typically there is only 1 Event structure in a VI that handles UI Events. I do use multiple Event Structures within 1 VI, but 1 loop typically only handles User Events, not UI Events.
  2. It is typically good practice to include the terminals of your controls within the Event Structure as opposed to outside it, although there are obviously exceptions. (See Below)

mcduff

Snap3.png

 

 

 

0 Kudos
Message 9 of 16
(5,546 Views)

@mcduff wrote:

Glad you found your error.

 

A couple of things:

  1. Typically there is only 1 Event structure in a VI that handles UI Events. I do use multiple Event Structures within 1 VI, but 1 loop typically only handles User Events, not UI Events.
  2. It is typically good practice to include the terminals of your controls within the Event Structure as opposed to outside it, although there are obviously exceptions. (See Below)

mcduff

Snap3.png

 

 

 


I have always wondered about that. Does it matter and why?

 

Could that explain why my tab control is sometimes one click behind the radio buttons? 

 

What if you need the value of that control in more than one event case? Should I use locals or place the terminal outside the structure and wire it in?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 16
(5,543 Views)