Radek
-
Posts
6 -
Joined
-
Last visited
Posts posted by Radek
-
-
OK, agree, thanks.
-
Perfect, Resolved, thank you for your help it works with the 18.1.
Regards, Radek.
Final code for ref>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/////PICO SCOPE Measurment Block read
//global PSBufferCHA_raw[8192][2] = 0global PSBufferCHA_raw = new(DMemory)
PSBufferCHA_raw.alloc(8192*2)
global PSBufferCHA_rawPointer = 0
PSBufferCHA_rawPointer = PSBufferCHA_raw.getPointer()
global PSBufferCHA_rawWord[8192] = -1global PSsampleInterval = 20 //Sample time in us / mikrosekund cas pro samplovani - NENI POUZITO, je to jen pro stream, ktery nefunguje
global PSTimebase = 500 ///500 is cca 40kHz 20e6/(500-1)
global PSsampleInterval_ns = 20 //real sample time ins ns / skutecny samplovaci cas v ns, je pak aktualizovano funkci ..GetTimebase
global PStimeIndisposedMs = 0 //real time to take one block / skutecny cas na sebrani jednoho bloku v Ms
global PSmaxSamples = 8192 //max no of samples / skutecne mnozstvi samplu ktere umoznuje pamet zarizeni, je pak aktualizovano funkci ..GetTimebase
global PSnoOfSamples = 8192 //on entry: the number of samples requested; on exit,the number of samples actually returned, aktualizovano funkci ..GetValues
global PSnoOfSamplesExit = 8192 //samples in buffer after data acquisistion /pocet dat buferu po mereni
global PSoverflow = 0 //indicate whether an overvoltage has occurred on any of the channels. It is a bit pattern with bit 0 denoting Channel A and bit 1 Channel B.
global PSReady = 1 //on exit, indicates the state of the collection. If zero, the device is still collecting. If non-zero, the device has finished collecting and ps4000GetValues can be used to retrieve the data.global PICOStatusRunBlock = -1
global PICOStatusIsReady = -1
global PICOStatusSetDataBuffer = -1
global PICOStatusGetValues = -1private i = 0
extern("ps4000.dll","long ps4000SetChannel(word, byte, word, word, byte)","ps4000SetChannel","stdcall") //CH A setting / nastaveni kanalu A
extern("ps4000.dll","long ps4000GetTimebase(word, ulong, long, long[1], word, long[1], uword)","ps4000GetTimebase","stdcall") ///Time base check / zjisteni Time Base
extern("ps4000.dll","long ps4000RunBlock(word, long, long, ulong, word, long[1], uword, long, long[1])","ps4000RunBlock","stdcall") ///spusteni mereni Bloku
extern("ps4000.dll","long ps4000GetValues(word, ulong, ulong[1], ulong, word, uword, word[1])","ps4000GetValues","stdcall") ////stazeni hodnot z buferu driveru pro Blok mod
extern("ps4000.dll","long ps4000IsReady(word, word[1])","ps4000IsReady","stdcall")
extern("ps4000.dll","long ps4000SetDataBuffer(word, word, ulong, long)","ps4000SetDataBuffer","stdcall") ///registrace data Bufferu Ai=0
while (i <= PSnoOfSamples) ///baseline buffer setting -1 set to confirm it is reading something/ vycteni hodnot z bufferu do virtualniho kanalu
PSBufferCHA_rawWord = -1
i=i+1
endwhile
///SET CHANNELS
while (PICOStatus != 0)
PICOStatus = ps4000SetChannel(PSHandle,0,1,1,8) ///handle, channel, enabled, AC /DC (0/1), range
PICOStatus = ps4000SetChannel(PSHandle,1,0,1,8)
endwhile///GET TIME BASE
PICOStatus = ps4000GetTimebase(PSHandle,PSTimebase,8192,@PSsampleInterval_ns,1,@PSmaxSamples,0) ///handle, timebase (500 odpovida cca 40kHz 20e6/(500-1)), noSamples, *timeIntervalNanoseconds, oversample, *maxsample, segmentIndexPSnoOfSamples = 8192 ///sresetovani nastaveni bufferu aby se stale nezmensoval
if (PSnoOfSamples > PSmaxSamples ) ///check if buffer demand is not higher then capability of the device / kontrola zda neni pozadovan vetsi bufer nez zarizeni zvladne
PSnoOfSamples = PSmaxSamples
endif
///SET DATA BUFFER
PICOStatusSetDataBuffer = ps4000SetDataBuffer(PSHandle,0,PSBufferCHA_rawPointer,PSnoOfSamples) ///handle, channel, buffer, buffer length////MEASUREMENT
while (1) ///opakovani mereniPSReady = 0
///RUN BLOCK / spusteni mereni Bloku
PICOStatusRunBlock = ps4000RunBlock(PSHandle,0,PSnoOfSamples,PSTimebase,1,@PStimeIndisposedMs,0,NULL,NULL) ///handle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, oversample, * timeIndisposedMs, segmentIndex, lpReady, * pParameterPSnoOfSamplesExit= PSnoOfSamples //srovnani velikosti buferu aby se nezmensoval
///IS READY
PICOStatusIsReady = ps4000IsReady(PSHandle,@PSReady) ///handle, *PSReady
while (PSReady == 0) ////procedura ceka na ukonceni mereni
PICOStatusIsReady = ps4000IsReady(PSHandle,@PSReady)
delay(0.05)
endwhile
///GET VALUES / stazeni hodnot z buferu driveru pro Blok mod
PICOStatusGetValues = ps4000GetValues(PSHandle,0,@PSnoOfSamplesExit,1,0,0,@PSoverflow) ///handle, startIndex, * noOfSamples, downSampleRatio, downSampleRatioMode, segmentIndex, * overflowPSBufferCHA_rawWord = PSBufferCHA_raw.getAsWord()
V.PICO_CH_A.AddValue = PSBufferCHA_rawWord
endwhilePSBufferCHA_raw.free() ///this to be included also in closing PICO close Sequence to freeup memory
End Code>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
Sorry tge repsonse was> "Class does not exist, can't instantiate.: PICOBlockRead Line 4 - Uncaught error in sequence PICOBlockRead"
-
Thank you for reply.
Looks like the Daq Factory cant find Class "DMemory". Also havent found the DMemory in DAQF help.
My code>
global PSBufferCHA_raw = new(DMemory)
PSBufferCHA_raw.alloc(8192*2)Response> global PSBufferCHA_raw = new(DMemory)
PSBufferCHA_raw.alloc(8192*2) -
Hello,
I woudl appreciate if someone would be able to help me :).
Im trying to read Picoscope 4224 IEPE (4000 Series). Im using the ps4000.dll from the Pico SDK. Following their programmer's Guide Im able to connect the unit, also it looks all the functions for the "Block" read mode are returning no errorr messages. However Im not able to get any data into the PSBufferCHA_raw or V.PICO_CH_A, there are only -1 values I set as a baseline. Please see bellow the code for the Block acquisistion. Also attachig the programmer's guide.
Thanks,
Radek
Code>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/////PICO SCOPE Measurment Block read
global PSBufferCHA_raw[8192] = 0global PSsampleInterval = 20 //Sample time in us / mikrosekund cas pro samplovani - NENI POUZITO, je to jen pro stream, ktery nefunguje
global PSTimebase = 500 ///500 is cca 40kHz 20e6/(500-1)
global PSsampleInterval_ns = 20 //real sample time ins ns / skutecny samplovaci cas v ns, je pak aktualizovano funkci ..GetTimebase
global PStimeIndisposedMs = 0 //real time to take one block / skutecny cas na sebrani jednoho bloku v Ms
global PSmaxSamples = 8192 //max no of samples / skutecne mnozstvi samplu ktere umoznuje pamet zarizeni, je pak aktualizovano funkci ..GetTimebase
global PSnoOfSamples = 8192 //on entry: the number of samples requested; on exit,the number of samples actually returned, aktualizovano funkci ..GetValues
global PSnoOfSamplesExit = 8192 //samples in buffer after data acquisistion /pocet dat buferu po mereni
global PSoverflow = 0 //indicate whether an overvoltage has occurred on any of the channels. It is a bit pattern with bit 0 denoting Channel A and bit 1 Channel B.
global PSReady = 1 //on exit, indicates the state of the collection. If zero, the device is still collecting. If non-zero, the device has finished collecting and ps4000GetValues can be used to retrieve the data.global PICOStatusRunBlock = -1
global PICOStatusIsReady = -1
global PICOStatusSetDataBuffer = -1
global PICOStatusGetValues = -1private i = 0
extern("ps4000.dll","long ps4000SetChannel(word, byte, word, word, byte)","ps4000SetChannel","stdcall") //CH A setting / nastaveni kanalu A
extern("ps4000.dll","long ps4000GetTimebase(word, ulong, long, long[1], word, long[1], uword)","ps4000GetTimebase","stdcall") ///Time base check / zjisteni Time Base
extern("ps4000.dll","long ps4000RunBlock(word, long, long, ulong, word, long[1], uword, long, long[1])","ps4000RunBlock","stdcall") ///spusteni mereni Bloku
extern("ps4000.dll","long ps4000GetValues(word, ulong, ulong[1], ulong, word, uword, word[1])","ps4000GetValues","stdcall") ////stazeni hodnot z buferu driveru pro Blok mod
extern("ps4000.dll","long ps4000IsReady(word, word[1])","ps4000IsReady","stdcall")
extern("ps4000.dll","long ps4000SetDataBuffer(word, word, word[8192], long)","ps4000SetDataBuffer","stdcall") ///registrace data Bufferu Ai=0
while (i <= PSnoOfSamples) ///baseline buffer setting -1 set to confirm it is reading something/ vycteni hodnot z bufferu do virtualniho kanalu
PSBufferCHA_raw = -1
i=i+1
endwhile
///SET CHANNELS
while (PICOStatus != 0)
PICOStatus = ps4000SetChannel(PSHandle,0,1,1,8) ///handle, channel, enabled, AC /DC (0/1), range
PICOStatus = ps4000SetChannel(PSHandle,1,0,1,8)
endwhile///GET TIME BASE
PICOStatus = ps4000GetTimebase(PSHandle,PSTimebase,8192,@PSsampleInterval_ns,1,@PSmaxSamples,0) ///handle, timebase (500 odpovida cca 40kHz 20e6/(500-1)), noSamples, *timeIntervalNanoseconds, oversample, *maxsample, segmentIndexPSnoOfSamples = 8192 ///sresetovani nastaveni bufferu aby se stale nezmensoval
if (PSnoOfSamples > PSmaxSamples ) ///check if buffer demand is not higher then capability of the device / kontrola zda neni pozadovan vetsi bufer nez zarizeni zvladne
PSnoOfSamples = PSmaxSamples
endif
////MEASUREMENT
while (1) ///opakovani mereniPSReady = 0
///RUN BLOCK / spusteni mereni Bloku
PICOStatusRunBlock = ps4000RunBlock(PSHandle,0,PSnoOfSamples,PSTimebase,1,@PStimeIndisposedMs,0,NULL,NULL) ///handle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, oversample, * timeIndisposedMs, segmentIndex, lpReady, * pParameterPSnoOfSamplesExit= PSnoOfSamples //srovnani velikosti buferu aby se nezmensoval
///IS READY
PICOStatusIsReady = ps4000IsReady(PSHandle,@PSReady) ///handle, *PSReady
while (PSReady == 0) ////procedura ceka na ukonceni mereni
PICOStatusIsReady = ps4000IsReady(PSHandle,@PSReady)
delay(0.05)
endwhile///SET DATA BUFFER
PICOStatusSetDataBuffer = ps4000SetDataBuffer(PSHandle,0,@PSBufferCHA_raw,PSnoOfSamples) ///handle, channel, buffer, buffer length
///GET VALUES / stazeni hodnot z buferu driveru pro Blok mod
PICOStatusGetValues = ps4000GetValues(PSHandle,0,@PSnoOfSamplesExit,1,0,0,@PSoverflow) ///handle, startIndex, * noOfSamples, downSampleRatio, downSampleRatioMode, segmentIndex, * overflow
V.PICO_CH_A.AddValue = PSBufferCHA_raw
endwhileCode>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Array cross correlation
in Channels, Conversions and general data acquisition
Posted
Hello,
Im trying to calculate crosscorrelation between sine signal (base with 1/rev frq) and vibration signal to get vibration response for the 1/rev (unbalance calculation), the vibration signal is very noisy, therefore crosscorrelation is used.
The code is very simple, see bellow. But it is very slow, it takes around 1s to calculate it within my application. Is there any faster way?
The number of loops is maxci*Vibe_Window_Skut in my case it is approx 20*100=2 000. The CorrBase is sine function with -1 to 1 amplitude. The testVibes is also in the range around -1 to +1.
Code>>>>>>>>>>>>>>>>>>>>
for (ci=0, ci<= maxci, ci++)
for (cj=0, cj<=(Vibe_Window_Skut-1), cj++)
ck = ci+cj
if (ck > Vibe_Window_Skut)
ck=ck-Vibe_Window_Skut-1 ///pri preteceni okna se zacne brat od zacatku
endif
Vibe_CrossCorr[ci] = Vibe_CrossCorr[ci] + testVibes[cj]*CorrBase[ck] ///vypocet krosskorelace
endfor
endfor
Vibe_CrossCorr = Abs(Vibe_CrossCorr)
v.Vib1rev.AddValue=Max(Vibe_CrossCorr)*Corr_Koef*KoefAkcelerometru