Software Interface
Assuming that the 4 cards are analog data acquisition cards with 4 channels each we can simply setup a synchronous system with all channels
of all cards being trigger source. The following setup will show how to set up all trigger events of all channels to be OR connected. If any of
the channels will now have a signal above the programmed trigger level the complete system will do an acquisition:
for (i = 0; i < lSyncCount; i++)
{
int32 lAllChannels = (SPC_TMASK0_CH0 | SPC_TMASK0_CH1 | SPC_TMASK_CH2 | SPC_TMASK_CH3);
spcm_dwSetParam_i32 (hCard[i], SPC_TRIG_CH_ORMASK0, lAllChannels);
for (j = 0; j < 2; j++)
{
// set all channels to trigger on positive edge crossing trigger level 100
spcm_dwSetParam_i32 (hCard[i], SPC_TRIG_CH0_MODE + j, SPC_TM_POS);
spcm_dwSetParam_i32 (hCard[i], SPC_TRIG_CH0_LEVEL0 + j, 100);
}
}
Run the synchronized cards
Running of the cards is very simple. The star-hub acts as one big card containing all synchronized cards. All card commands have to be
omitted directly to the star-hub which will check the setup, do the synchronization and distribute the commands in the correct order to all
synchronized cards. The same card commands can be used that are also possible for single cards:
Table 101: Spectrum API: star-hub synchronization commands
Register
SPC_M2CMD
M2CMD_CARD_RESET
M2CMD_CARD_WRITESETUP
M2CMD_CARD_START
M2CMD_CARD_ENABLETRIGGER
M2CMD_CARD_FORCETRIGGER
M2CMD_CARD_DISABLETRIGGER
M2CMD_CARD_STOP
All other commands and settings need to be send directly to the card that it refers to.
This example shows the complete setup and synchronization start for our four cards:
spcm_dwSetParam_i32 (hSync, SPC_SYNC_ENABLEMASK, 0x000F); // all 4 cards are masked
// to keep it easy we set all card to the same clock and disable trigger
for (i = 0; i < 4; i++)
{
spcm_dwSetParam_i32 (hCard[i], SPC_CLOCKMODE, SPC_CM_INTPLL);
spcm_dwSetParam_i32 (hCard[i], SPC_SAMPLERATE, MEGA(100));
spcm_dwSetParam_i32 (hCard[i], SPC_TRIG_ORMASK, SPC_TM_NONE);
}
// card 0 is trigger master and waits for external positive edge
spcm_dwSetParam_i32 (hCard[0], SPC_TRIG_ORMASK, SPC_TMASK_EXT0);
spcm_dwSetParam_i32 (hCard[0], SPC_TRIG_EXT0_MODE, SPC_TM_POS);
// start the cards and wait for them a maximum of 1 second to be ready
spcm_dwSetParam_i32 (hSync, SPC_TIMEOUT, 1000);
spcm_dwSetParam_i32 (hSync, SPC_M2CMD, M2CMD_CARD_START | M2CMD_CARD_ENABLETRIGGER);
if (spcm_dwSetParam_i32 (hSync, SPC_M2CMD, M2CMD_CARD_WAITREADY) == ERR_TIMEOUT)
printf ("Timeout occured - no trigger received within time\n")
Using one of the wait commands for the Star-Hub will return as soon as the card holding the Star-Hub has
reached this state. However when synchronizing cards with different memory sizes there may be other cards
that still haven't reached this level.
Error Handling
The Star-Hub error handling is similar to the card error handling and uses the function spcm_dwGetErrorInfo_i32. Please see the example in
the card error handling chapter to see how the error handling is done.
172
Value
Direction
Description
100
write only
Executes a command for the card or data transfer
1h
Performs a hard and software reset of the card as explained further above
2h
Writes the current setup to the card without starting the hardware. This command may be useful if changing some
internal settings like clock frequency and enabling outputs.
4h
Starts the card with all selected settings. This command automatically writes all settings to the card if any of the set-
tings has been changed since the last one was written. After card has been started none of the settings can be
changed while the card is running.
8h
The trigger detection is enabled. This command can be either send together with the start command to enable trigger
immediately or in a second call after some external hardware has been started.
10h
This command forces a trigger even if none has been detected so far. Sending this command together with the start
command is similar to using the software trigger.
20h
The trigger detection is disabled. All further trigger events are ignored until the trigger detection is again enabled.
When starting the card the trigger detection is started disabled.
40h
Stops the current run of the card. If the card is not running this command has no effect.
(c) Spectrum Instrumentation GmbH
Option Star-Hub
Need help?
Do you have a question about the M2p.59 Series and is the answer not in the manual?