01-25-2010 11:40 PM
Hello DIAdem team,
I have a DAC formula block to calculate the rate of change (slope)of a signal. The calculation therefore needs to know the sampling rate of the signals entering the block. I entered in the sampling rate as a fixed value, however if someone changes the sampling frequency / Takt, the calculation is invalid.
Is there an internal variable that I can use in the formula that represents the system sampling frequency being used?
ie the Formula would be: "(Y2-Y1)/5*(1/SamplingRate)" in stead of my existing "(Y2-Y1)/5*(1/200)", where the sampling rate = 200Hz
Thanks,
Jeff
01-26-2010 04:21 AM
I wish there was an internal variable, but not that I know about...
What I do is that I use a StopWatch block and a SignalCopy block to delay the signal one sample and then a FormulaBlock to calculate the difference between the actual stopwatch signal and the delayed signal..
/Sven
02-03-2010 11:54 AM - edited 02-03-2010 12:03 PM
Hello Jeff,
you can read and modify internal variables of DAC-blocks via script. This must be done before the DAC-plan is running!
To get an insight what variables are available, open the configuration-dialog of the block and press <CTRL> + A.
You'll find the following information in the clipboard (clock-block).
Call DACObjOpen("Takt1")
BlMeasType = "Standard"
BlExtClock = 0
BlClockRate = 100
BlClockUnit = "Hertz"
Call DACObjClose("Takt1")
When you need the clock-rate in a formula it's a little bit more tricky.
Because the DAC-plan must not be running, you have to write a user command (special VBS-functions which are available after starting DIAdem).
See Help » User Commands. (I only have the German version here: "Definieren von Anwenderbefehlen und globalen Variablen", maybe in English 'Defining User Commands and Global Variables' ???)
The User Command should read out the clock-rate and write the result to a internal variable (for best performance in formula). Similar like this:
Sub ReadClockRateDAC( BlockName )
Call DACObjOpen(BlockName)
L1 = BlClockRate
Call DACObjClose(BlockName)
End Sub
This User Command should be excecuted before the measurement starts. So insert 'ReadClockRateDAC("blockname")' under Settings » Circuit-Parameters » Commands to Excecute » Pre Measurement (see attachment).
Now you can use L1 in your formula.
I hope this helps.
With best wishes,
Ralf N.
02-04-2010 04:15 AM
Thanks! Worked great!
Jeff.