09-11-2018 11:53 AM - edited 09-11-2018 11:57 AM
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:
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?
Solved! Go to Solution.
09-11-2018 03:05 PM
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.
09-11-2018 05:59 PM
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!
09-11-2018 07:58 PM
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.
09-12-2018 05:22 AM
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.
09-18-2018 10:43 AM
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.
09-18-2018 04:47 PM - edited 09-18-2018 04:53 PM
I think your solution can be improved.
Hope that makes sense. Am writing fast.
mcduff
EDIT : Changed Snippet to 2017
09-26-2018 12:53 PM - edited 09-26-2018 01:03 PM
@mcduff wrote:
I think your solution can be improved.
- 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
09-26-2018 01:11 PM
Glad you found your error.
A couple of things:
mcduff
09-26-2018 01:25 PM - edited 09-26-2018 01:28 PM
@mcduff wrote:
Glad you found your error.
A couple of things:
- 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.
- 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
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?