I am using Tektronix MSO5034B in one of my project through LabVIEW. In the NI driver for scope to set the timebase "Configure Timebase.vi" is given with 3 controls "Timebase Range", "Position" and "Record Length". There is no straight control to set time/div.
How to find out the values of these 3 parameters from desired time/div? Also, How to find time/div value from these 3 values?
Thanks
Ashutosh
For those who may have this question, I do have found a way around.
Sampling rate of Scope = Record length / Range
Where range is entire horizontal width of oscilloscope time range which is given below as
Range = Number of divisions * Time/Div
For almost any oscilloscope, number of divisions in horizontal axes are 10.
And time/div is desired value.
For me max sampling rate is 5GS/s and record length is number of samples taken in entire visible window of scope.
hence, Sampling Rate = Record Length / (time/div * 10)
In above calculation, just make sure you do not cross your sampling rate provided by vendor. This calculation holds till 500ns/div, after that does some weird behaviour which I am still working on.
Related
I have a strange issue using Double type variables in my VBA Macros.
The Macro works fine when I test it on some systems, but causes a runtime error '1004' when tested on another system with different language settings.
Both systems use Office 2013.
I have a ScrollBar in a form, with values ranging from -50 to + 50.
Basically an indicator to increase/decrease the value of a range by -/+ 50%
The Macro is something simple like follows:
Dim multiplier As Double
multiplier = CLng(Me.DPScroll.Value) / 100 + 1
ThisWorkbook.ActiveSheet.Range("AB11:AB" & LR).Formula = "=H11*" & multiplier
When the DPScroll.Value = 0 (Multiplier = 1), the form runs file without any errors, but if it has a positive or negative value, it returns
Run-time Error 1004 : Application Defined/Object Defined Error
(On my system, both work fine)
So, I'm guessing the Multiplier is unable to take values in Decimal Points (Eg. 1.07 to increase by 7%)
(Less important issue)
It also causes a strange formatting error on another sheet.
I'm calculating the average of a few rows in a list box and pasting the value to a range. On some systems, the format is retained, but on others it changes and gets multiplied by millions and a Large number is displayed (like 10^E6 times)
Since this is restricted to some systems - are there any regional/language compatablity issues with suing "Double" variable type.
It is indeed a localization issue. As long as you use .Formula the regional settings are always standard US that means the multiplier has to be 1.07 (e.g. not 1,07).
But if the localization is German for example then if the multiplier is cast to a string it becomes 1,07 but .Formula needs the US standard 1.07.
Solution 1
Replace any comma , in multiplier to . using replace()
Solution 2
use .FormulaLocal to use the localized formula:
ThisWorkbook.ActiveSheet.Range("AB11:AB" & LR).FormulaLocal= "=H11*" & multiplier
But then you probably have to deal with other issues like e.g. =IF(A1=0,TRUE,FALSE) becomes localized too (e.g. for german): =WENN(A1=0;WAHR;FALSCH).
Solution 3
Another approach would be to write the multiplier into a named range, so you can use that name in your formula directly as following:
ThisWorkbook.ActiveSheet.Range("AB11:AB" & LR).Formula = "=H11*multiplier"
Therefore you can use ActiveWorkbook.Names.Add "multiplier", multiplier so you even don't need a helper cell for that named range.
But then if you change the multiplier any time, it also changes for every old formula in your sheets where the named range multiplier was used.
See image for what I have going on
So the red column will at some point, which is different every day, change from 20 to 50. The start cell up top uses that lookup formula to find when this is. So for this example it is 10/11/16 14:37. I want to graph the green and blue columns, starting at that cell time and ending at the end time (which is just a max() of the times to get the end time).
I've looked into offset and name manager but I am really confused on those. Either using VBA or something else to change the graph (on a different sheet) to start at whatever that start time is would be awesome.
You can try the following:
In the column AL set, in each cell, the value to be defined by the following formula
AL1 = IF(AI1<50,0,1)
AL2 and following = IF(AL1=1,1,IF(AI2<50,0,1))
Then define each AM to be AL*AK, and plot AM.
I've created a Time Sheet for my dog walkers to fill in. They enter TIME STARTED and TIME ENDED for each of their dog walks and then a TOTAL TIME is generated using the =X-Y formula. This TOTAL TIME is formatted to be displayed in hh:mm but its true VALUE is a long integer.
Using the MATCH and INDEX functions, I've set up a formula to match the TOTAL TIME value generated to an index on the "Payment Schedule" sheet and locate the respective payment.
I keep getting errors that state the total time VALUES can't be matched but I know that formatting isn't the issue and the values are clearly on the "Payment Schedule" sheet. And when the MATCH function does return a row it returns the incorrect row, which locates the incorrect payment/rate.
Here is the Google Sheets I'm having trouble with.
Found the answer on another website:
it's floating point rounding error on the time values. I don't fully
understand what's happening, but I was able to reproduce it on my
system, and I found a work-around: Change your formula to
=INDEX(B:B, MATCH($I$4+TIME(0,0,1), A:A)) This adds one second (TIME(0,0,1); the arguments are TIME(hours,minutes,seconds)) to the I4
value; that seems to be enough to get it "over the hump", so that it
tests as being ≥ the value in A4 (or A7 or A10). BTW, I tried
TIME(0,0,0.9), but apparently TIME() won't honor fractional seconds,
and so it just treats that as TIME(0,0,0); i.e., just plain zero. If
you want to get a millisecond, you can use TIME(0,0,1)*0.001.
link
VB 2008
.NET FRAMEWORK 3.5
MSCHART - FASTLINE CHART TYPE
Is it possible to have an MS Chart control contain 20,000 data points, but only show the last 100?
I know that I can select the last 100 from my datatable and use it as a datasource.
Chart1.DataSource = cMs2.dsData.Tables("readings").Select(wFilter, wSort).Take(100)
That's not what I want.
I know that I can populate an array or collection with the last 100 data points and use it as a data source.
Chart1.Series("readings").Points.DataBindXY(colCtr, colReadings)
That's not what I want.
I need to do 1 of 2 things:
Manually add data points and be able to show only the last 100 or last 1000 of them that just came in. This must be done without re-populating the chart. Just show a portion of the complete set of data points.
wSample = wSample + 1
Chart1.Series("readings").Points.AddXY(wSample, wReading)
Chart1.Series("readings").SHOWONLYTHELAST100DATAPOINTSWITHOUTCLEARING
Initialize a chart with a certain number of the total readings with a databind, then manually add new data points one at a time while removing the oldest data point. For example, initialize the chart with 100 data points, then add a new data point, remove the first data point, getting us back to 100. (I'm successfully doing this one, except the chart doesn't behave like I expect. The chart grows, remaining blank/empty where the 'removed' data points were. I do chart.update but it doesn't refresh it.) Note that I am allowed to take more time to initialize the chart (clear/populate), I don't have that time to do it as each new data point comes in.
wSample = wSample + 1
Chart1.Series("readings").Points.AddXY(wSample, wReading)
If Chart1.Series("readings").Points.Count > 100 Then
Chart1.Series("readings").Points.RemoveAt(0)
Chart1.Update()
End If
NOTE: Doing a process that causes me to have to clear and rebind the data to handle the addition of a single data point causes me problems because it takes too long. I'm just looking for the quickest, most efficient way to handle this. Thank you for taking the time to read this...!
You can manually set the Minimum and Maximum values of each axis by modifying the .Minimum and .Maximum values of the axes like
Chart1.ChartAreas(0).AxisX.Minimum = 100 'Example value
Chart1.ChartAreas(0).AxisX.Minimum = 200 'Example value
As discussed in the comments to your question you can either use your method #2 (add datapoint and delete datapoint index 0 and then select the new minimum and maximum X-Value from the series with LinQ:
Chart1.ChartAreas(0).AxisX.Minimum = (From p As DataVisualization.Charting.DataPoint In Chart1.Series(0).Points Select p.XValue).Min
Chart1.ChartAreas(0).AxisX.Maximum = (From p As DataVisualization.Charting.DataPoint In Chart1.Series(0).Points Select p.XValue).Max
or you can, as you have now done, just set the minimum value to a X-value some points before the last point.
I'm trying to find the Min/Max value of a textbox that has 1 variable and display it to the user, so the variable changes everytime the button is clicked. How would I find the maximum value of something that is constantly changing? The trick is that I can NOT use if statements or case statements. I'm totally at a loss here.
Ok, the things that limit you.
One variable
no if/case statements
The lesson seems to revolve around using Math.Max().
Math.Max(), as we can see on MSDN returns
the larger of two 32-bit signed integers.
The one variable we are going to use needs to exist outside of the button's click event. So, just make it a class variable.
This variable will essentially store the largest value. Math.Max() returns the largest of two values... see what I am getting at here? You can pass the current largest variable as a parameter to Math.Max() without any issues.
Example:
Dim max As Integer
max = Math.Max(1, 100)
'max would be 100
max = Math.Max(max, 10)
'max would be 100
max = Math.Max(max, 1000)
'max would be 1000