DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

dac sampling frequency in formula

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

0 Kudos
Message 1 of 4
(5,252 Views)

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

0 Kudos
Message 2 of 4
(5,246 Views)

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.

Message Edited by ralfn on 02-03-2010 12:03 PM
0 Kudos
Message 3 of 4
(5,186 Views)

Thanks! Worked great!

 

Jeff.

0 Kudos
Message 4 of 4
(5,165 Views)