Reply To: BB60C matlab bbgetiq.m example code

Forums BB Series Discussions BB60C matlab bbgetiq.m example code Reply To: BB60C matlab bbgetiq.m example code

#237480
AndrewAndrew
Moderator

Jon,

Here is some code to get this going.

First, you will want to ensure you configure the external port to accept a rising edge (or falling) external trigger.

calllib('bb_api', 'bbConfigureIO', handle, int32(0), int32(64));

The best time to call this would be right after opening the device and only once. The 64 is taken from the header, it is the value for BB_PORT2_IN_TRIGGER_RISING_EDGE (0x40).

Then you will want to create a trigger array and count just like the iq data.

% Trigger parameters
triggerptr = libpointer('int32Ptr', zeros(4, 1));
triggercount = int32(4);

In this instance I am creating an array of 4 integers to store trigger positions. If I am only expecting 1 trigger, then an array of one will work fine.

Now I need to call bbGetIQ with these new parameters.

status = calllib('bb_api', 'bbGetIQUnpacked', handle, ...
         iqarrayptr, iqcountint, triggerptr, triggercount, purgearg, ...
         nullptr, nullptr, nullptr, nullptr);

And pull out the array when it returns

triggers = triggerptr.Value;

If a trigger occurred during this capture of I/Q, you will see it in the trigger array.

disp(triggers);

Might show

230722
        0
        0
        0

Meaning an external trigger event occurred at sample index 230722 (zero-based).

Regards,
Andrew

  • This reply was modified 6 years ago by AndrewAndrew.
  • This reply was modified 6 years ago by AndrewAndrew.
  • This reply was modified 6 years ago by AndrewAndrew.
  • This reply was modified 6 years ago by AndrewAndrew.