Signal Generators

cancel
Showing results for 
Search instead for 
Did you mean: 

PXI 5406 external triggering VB6.0

Does anybody have any VB code that will allow me to trigger the function generator from an external signal?
 
I want to take an index pulse from an encoder and trigger the function generator to produce a continuous sine wave with an amplitude of 2Vp-p, and a frequency of 100kHz.  All the VB code that was included with the card incorporated only software triggers, not hardware.
 
I know that it can be done because I used the F-Gen softpanel to do exactly what I needed.
 
Any help will be greatly appreciated
0 Kudos
Message 1 of 6
(7,908 Views)
Hi Big Guy,

You can definitely trigger your function generator using hardware. I assume you will be feeding in the external trigger to PFI0. You need to configure the trigger before you initiate the generation. The trigger configuration should look something like this.

niFgen_ConfigureDigitalEdgeStartTrigger(handle, "PFI0", NIFGEN_VAL_RISING_EDGE)

Have a good one.

Regards
Malay Duggar
NI
0 Kudos
Message 2 of 6
(7,888 Views)

Thanks for your quick response.....I actually have a line of code like that in my program.....It doesn't work though....here is my code, maybe you can see where I am screwing up....

 

Waveform = NIFGEN_VAL_WFM_SINE
Amplitude = 2.5
SineFreq = 10000

      (niFgen_init("FunctionGenerator", True, True, handle))

      CheckError (niFgen_ConfigureDigitalEdgeStartTrigger(handle, NIFGEN_VAL_PFI_1, NIFGEN_VAL_RISING_EDGE))
      CheckError (niFgen_ConfigureTriggerSource(handle, "0", NIFGEN_VAL_PFI_1))
      CheckError (niFgen_ConfigureStandardWaveform(handle, "0", Waveform, Amplitude, 0, SineFreq, 0))

      CheckError (niFgen_ConfigureOutputEnabled(handle, "0", True))
      CheckError (niFgen_InitiateGeneration(handle))

0 Kudos
Message 3 of 6
(7,883 Views)
There are two ways to configure a start trigger:
1) Use niFgen_ConfigureTriggerSource with one of the "enum" terminals (like NIFGEN_VAL_PFI_0)
2) Use niFgen_ConfigureDigitalEdgeStartTrigger with one of the "string" terminals (like "PFI0")

Your application appears to be doing both. I would recommend that you remove the "niFgen_ConfigureTriggerSource" line and change your other line to read:

CheckError (niFgen_ConfigureDigitalEdgeStartTrigger(handle, "PFI1", NIFGEN_VAL_RISING_EDGE))

Drew Creel
NI Software Engineer
Signal Generators Group

Drew Creel
NI Software Group Manager
RF and Signal Generators
0 Kudos
Message 4 of 6
(7,877 Views)
Thanks for your quick response.  I tried out your suggestions and they still didn't work.  I am including my whole subroutine.  Please take a look at it and tell me what am I still doing wrong.
 
Many many thanks......
 
 
Waveform = NIFGEN_VAL_WFM_SINE
Amplitude = 1
SineFreq = MotorFrequency
 
CheckError (niFgen_init("FunctionGenerator", True, True, handle))

CheckError (niFgen_AbortGeneration(handle))

CheckError (niFgen_ConfigureDigitalEdgeStartTrigger(handle, NIFGEN_VAL_PFI_1, NIFGEN_VAL_RISING_EDGE))

CheckError (niFgen_ConfigureTriggerMode(handle, "0", NIFGEN_VAL_CONTINUOUS))

CheckError (niFgen_ConfigureStandardWaveform(handle, "0", Waveform, Amplitude, 0, SineFreq, 0))
 
CheckError (niFgen_ConfigureOutputEnabled(handle, "0", True))

CheckError (niFgen_InitiateGeneration(handle))
0 Kudos
Message 5 of 6
(7,867 Views)
Hi Big Guy,

You would need to use the string "PFI1" as the trigger source instead of the ENUM you are using. Please replace the line

CheckError (niFgen_ConfigureDigitalEdgeStartTrigger(handle, NIFGEN_VAL_PFI_1, NIFGEN_VAL_RISING_EDGE))

in your code with

CheckError (niFgen_ConfigureDigitalEdgeStartTrigger(handle, "PFI1", NIFGEN_VAL_RISING_EDGE))

Have a good one.

Malay Duggar
NI
0 Kudos
Message 6 of 6
(7,861 Views)