11-23-2015 09:17 AM
Hi,
I'm using a NI PCI-6562 with a script to generate a continuous stream of data of 192 bits which contains two packets of data separated by a pre-defined delay. My script is defined below:
script Script1
generate TxRxWaveform subset(0,192)
clear scriptTrigger0
repeat forever
wait until scriptTrigger0
generate TxRxWaveform subset(0,192)
end repeat
end script
This script is run by a user press of a command button on from a GUI panel within my software application. I also have an abort command button which terminates the script and hence can be selected at any time. When the user decides to press the Abort button the script will more than likely be in the 'repeat forever' loop.
My concern is that when the script is aborted during the 'generate TxRxWaveform subset(0,192)', will the script complete output of 'TxRxWaveform' before aborting or will it abort instantly, and hence not complete transfer of all the 192 bits of data? I need all 192 bits to complete transfer before the script is aborted.
Any help would be appreciated.
Thanks,
Graham.
11-27-2015 03:29 AM
Hi Gabby666,
I'm curious about what kind of scripting language you are using, since you talk about using an Abort button. Is it LabVIEW coding, or some other language? I take it that the defined script a pseudo-code?
If it is LabVIEW, I would suggest using a Property Node that removes the toolbar in the VI, thus making the Abort button unavailable - the short-key command for aborting might still work, though. If you generate the 192 bits of data in a subVI, and place that in a While Loop, that whole signal generating node will have to be completed before a Stop Button (on the front panel) can exit that While Loop and shut down the VI.
If it is not LabVIEW, could you clarify what kind of script you are using? Do you have a screen shot that you can share?
11-27-2015 04:52 AM
Hi,
Thanks for your response and apologies for the initial lack of detail.
My application had been developed in 'C' under the NI LabWindows/CVI 2010 development environment. I have a grapical user interface which has two command buttons 'Init' and 'Abort'.
My design was such that when the 'Init' command button was selected, the callback function would then call the following HS-DIO driver functions:
Initialise Digital Controlling Script Generation Session
niHSDIO_InitGenerationSession() // Initialise Digital Controlling Script Generation Session
niHSDIO_AssignDynamicChannels() // Assign Channels For Dynamic Generation
niHSDIO_ConfigureSampleClock() // Configure Clocking Parameters
niHSDIO_ExportSignal() // Export Sample Clock To DDC CLK OUT Terminal
niHSDIO_CommitDynamic()
niHSDIO_ConfigureInitialState() // Configure Initial Channel State
niHSDIO_ConfigureDigitalEdgeScriptTrigger() // Configure Hardware Script Trigger ("scriptTrigger0", NIHSDIO_VAL_RISING_EDGE)
niHSDIO_ConfigureGenerationMode() // niHSDIO_ConfigureGenerationMode (NIHSDIO_VAL_SCRIPTED)
Generate And Transfer 192-Bit Command Waveform And Hardware Script
niHSDIO_WriteNamedWaveformU16() // Write 192-Bit Command Waveform To Device
niHSDIO_WriteScript() // Write Script #1 To Device
niHSDIO_ConfigureScriptToGenerate() // Select Script To Generate ("Script1")
Initiate Generation Of 192-Bit Command Waveform Upon Hardware Trigger
niHSDIO_Initiate() // Initiate Generation Of Script
The script was created under the NI Script Editor. "scriptTrigger0" is connected to an Agilent 81104A Pulse/Pattern Generator output. The script runs as expected, transfer an initial
192-bit command then continually transfer the same 192-bit command upon detection of a rising edge from the Pulse/Pattern Generator output. Upon selection of the 'Abort' command
button, the callback function would then call the following HS-DIO driver functions:
niHSDIO_Abort() // Abort Generation Of Script
niHSDIO_DeleteNamedWaveform() // Delete 192-Bit Command Waveform From Device
niHSDIO_ExportSignal() // Unexport Sample Clock
niHSDIO_CommitDynamic()
niHSDIO_close() // Close Digital Controlling Script Generation Session
Again, the script correctly aborts but my concern is, if the user selects the 'Abort' command button during the script processing the "generate TxRxWaveform subset(0,192)" instruction,
will this instruction complete instantly upon reception of the 'niHSDIO_Abort()' command or wait until control has returned to the script from the "generate ..." instruction? My design
requires completion of the 192-bit command message transfer before aborting.
Hope this helps,
Graham.
11-27-2015 07:37 AM
Hi again,
From the name of the abort function, I would assume that this is a function that you have created yourself? If so, I'm not sure if I can give you a concrete answer to how this would affect your code. To be sure that all of the 192 data points are being sent without being cut, the loop that continuously sends out these packages of data should "wait graciously" for the trigger sent by the Abort button. It could check whether or not the button has been pushed only after each data package has been sent (ie. once every iteration of the loop). A producer-consumer loop would be a good design pattern for such a system.
Of course, to be sure that what you send is in fact a serie of 192 data points, you could add a function that counts the data sent from the loop, which runs in parallell. If it at some point should receive less than 192 points, it could provide a warning stating that the package was cut short, like when you stop the program.
To me, by the way, the name "Abort" implies that it cuts the operation without closing references, etc. I would probably have called it "Stop" intead, so that it would be easier to understand how it stops the system. But that's me.
12-02-2015 04:55 AM
Hi,
The "niHSDIO_Abort()" function is contained within the device driver DLL supplied with the NI PCI-6562 card to allow he user to control features of this particular card.
As you have stated a "Stop" function may have been more appropriate so that references are closed elegantly, I'll contact NI to see if they can clarify my query.
Thanks very much for your time and help.
Cheers,
Graham.