Electronic Engineer Discuss

View: 407|Reply: 0
Print Prev. thread Next thread

Segmented acquisition on 6004EU

[Copy link]

2

Threads

2

Posts

2

Credits

新手上路

Rank: 1

Credits
2
Jump to specified page
1#
Post time 2024-5-7 02:48:02 | Show the author posts only Reply Awards |Descending |Read mode
Edited by lorenco.santos at 2024-5-7 03:05

Hi!
I have an application where I perform a segmented memory acquisition with a 6074EU oscilloscope and my own software using the provided SDK, mainly HTHardDll.dll.
My flow of work is basically the following:

1) First I set the parameters like number of segments to be acquired and the acquisition mode:
  1. dsoHTAttribsSegmentNum(m_deviceIndex, ref nSegments, 0);

  2. // set acquisition mode to segmented memory
  3. byte nChar = 6;
  4. dsoHTAttribsAcqOption(m_deviceIndex, ref nChar, 0);

  5. // start the acquisition
  6. ushort nStartControl = 0;
  7. m_Collect = true;
  8. nStartControl |= (ushort)((m_TriggerSweep == (byte)THantekTrigSweep.Auto) ? 0x01 : 0);
  9. nStartControl |= (ushort)(m_Collect ? 0 : 0x04);
  10. dsoHTStartCollectData(m_deviceIndex, nStartControl);
  11. m_bRestartCollect = false;
Copy the Code
Here I need to clarify one thing: what is the role of m_Collect  and of the third and fourth bits of nStartControl? According to the SDK manual, the first bit refers to trigger mode (AUTO, SINGLE, NORMAL). The second bit refers to normal or scrolling mode. The third and fourth bits is related to acquisition mode. This is where m_Collect affects. When I use segmented memory mode, what must be the values of the third and fourth bits of nStartControl? Maybe this could help to solve the problem described below.

2) At this point, the scope is acquiring the segments according to the trigger condition and I can monitor if the acquisition is finished or not by checking the first byte of the device status array. It occurs that the complete acquisition (i.e. acquire the total number of segments set with  dsoHTAttribsSegmentNum) could take so much time if the trigger threshold is high or if few events are occuring.
For this, I've set up a timeout. My software starts the acquisition and wait for example 30 seconds while checking if the acquisition is finished. If the timeout value is reached and the acquisition is not over, I want to retrieve (collect) the already acquired segments and end the acquisition.


The timeout and device status checking are done like this:
  1. RecordtimedOut = false;
  2. Task t = Task.Run(() => {
  3.                     do
  4.                     {
  5.                         Thread.Sleep(sleep);
  6.                         if (RecordtimedOut)
  7.                             return;
  8.                         dsoHTGetState(m_deviceIndex, DeviceStatus.Ptr);
  9.                     } while ((DeviceStatus[0] & 2) != 2);

  10.                 });

  11. if (!t.Wait(timeOut))
  12. {
  13.     RecordtimedOut = true;
  14.     return false;
  15. }

  16. return true;
Copy the Code


3) After the acquisition is finished (because all segments were acquired, i.e. (DeviceStatus[0] & 2) == 2), or because the counter has timed out), I collect the segments.
First I check how many segments were acquired and collect them.
  1. dsoHTGetState(m_deviceIndex, DeviceStatus.Ptr);
  2. uint nSegments = (uint)(DeviceStatus[34] * 256 + DeviceStatus[33]);

  3. if (nSegments < 1)
  4.     return false;

  5. for (int k = 0; k < nSegments; k++)
  6. {
  7.     unsafe { m_ReadOK = dsoHTCollectSegment(m_deviceIndex, m_pSrcData[0].Ptr, m_pSrcData[1].Ptr, m_pSrcData[2].Ptr, m_pSrcData[3].Ptr, k, hGC_SegmentTimesStruct.AddrOfPinnedObject()); }
  8.     if (m_ReadOK != 1)
  9.         continue;
  10.     kk++;
  11. }
  12. actualNumSegments = kk;
Copy the Code
All the things are working great when the acquisition is finished because all segments were acquired, i.e. (DeviceStatus[0] & 2) == 2). But when timeout occurs and I try to collect some segments acquired, the collected data do not represent reality. For example, If I asked for 100 segments using dsoHTAttribsSegmentNum and 100 segments were acquired, everything if fine. But if I asked for 100 segments and only 30 segments were acquired and has timed out, I try to collect only the 30 segments, but the data put on m_pSrcData contains erros (do not represent the reality). Maybe this is occuring because the hardware waits the acquisition to complete  (DeviceStatus[0] & 2) == 2) to do some sort of memory consolidation or reorganization. I don't know.

So my question is: Is it possible to correctly collect segments before the acquisition is done?




Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Dark room|Mobile|Archiver|Electronic Engineer Discuss

2024-5-20 00:04 GMT+8 , Processed in 0.218556 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

Quick Reply To Top Return to the list