LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Rapport cyclique variable - Labwindows CVI - PXI 5411

Bonjour Madame, Monsieur,

 

Je développe actuellement une application sous Labwindows CVI permettant de faire varier en fréquence 3 signaux déphasés de 120° entre eux . Pour cela je dispose de 3 cartes PXI 5411.

 

Cependant, le rapport cyclique est fixé à 50% par défaut. Mes signaux doivent avoir un rapport cyclique Th=75%.

 

Je ne sais pas comment programmer cela sous CVI.

 

Voici mon bout de code (dans moin exemple j'ai fixé la fréquence à 500Hz) :

 

int CVICALLBACK COMMANDBUTTON (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
 ViReal64 DC=75.00; 
 

 ViReal64 frequence=500.00;
 ViChar GBF1[256]="DAQ::3";
 ViChar ChannelGBF1[256]="0";
 ViReal64 Amplitude1=5;
 ViReal64 DCOffset1=2.5;
 ViInt32  Waveform1=NIFGEN_VAL_WFM_SQUARE;
 
 ViChar GBF2[256]="DAQ::5";
 ViChar ChannelGBF2[256]="0";
 ViReal64 Amplitude2=5;
 ViReal64 DCOffset2=2.5;
    ViInt32  Waveform2=NIFGEN_VAL_WFM_SQUARE;
 
 ViChar GBF3[256]="DAQ::7";
 ViChar ChannelGBF3[256]="0";
 ViReal64 Amplitude3=5;
 ViReal64 DCOffset3=2.5;
    ViInt32  Waveform3=NIFGEN_VAL_WFM_SQUARE;

 switch (event)
 {
  case EVENT_COMMIT:


   /* Ressource 1 maître, ressource 2 et 3 esclaves*/  
 if(vi1 != VI_NULL) { niFgen_close(vi1);}  
 if(vi2 != VI_NULL) { niFgen_close(vi2);}
 if(vi3 != VI_NULL) { niFgen_close(vi3);}  
 
 niFgen_init(GBF1, VI_TRUE,1, &vi1);
 niFgen_init(GBF2, VI_TRUE, 1, &vi2);  
 niFgen_init(GBF3, VI_TRUE,1, &vi3);  

 

  /* Configuration du maître*/
 niFgen_ConfigureRefClockSource(vi1, NIFGEN_VAL_RTSI_CLOCK);
 niFgen_RouteSignalOut(vi1, "0", NIFGEN_VAL_OUT_START_TRIGGER,NIFGEN_VAL_RTSI_1);
 niFgen_RouteSignalOut(vi1, "0", NIFGEN_VAL_SYNCHRONIZATION,NIFGEN_VAL_RTSI_0);   
 
   /* Configuration esclave 1*/
 niFgen_ConfigureRefClockSource(vi2, NIFGEN_VAL_RTSI_CLOCK);
    niFgen_ConfigureTriggerSource(vi2, "0", NIFGEN_VAL_RTSI_1);
    niFgen_ConfigureSynchronization (vi2, "0", NIFGEN_VAL_RTSI_0);  

   /* Configuration esclave 2*/
 niFgen_ConfigureRefClockSource(vi3, NIFGEN_VAL_RTSI_CLOCK);
    niFgen_ConfigureTriggerSource(vi3, "0", NIFGEN_VAL_RTSI_1);
    niFgen_ConfigureSynchronization(vi3, "0", NIFGEN_VAL_RTSI_0);   


 
  /* Configuration et generation forme d'onde esclave 1*/
    niFgen_ConfigureOutputMode(vi2, NIFGEN_VAL_OUTPUT_FUNC); 
 niFgen_ConfigureStandardWaveform(vi2, ChannelGBF2, Waveform2, Amplitude2, DCOffset2, frequence,120);
 niFgen_InitiateGeneration(vi2);
    niFgen_ConfigureOutputEnabled(vi2, "0", VI_TRUE);     
 niFgen_SetAttributeViReal64 (vi2, ChannelGBF2, NIFGEN_ATTR_FUNC_DUTY_CYCLE_HIGH, DC); 

 

  /* Configuration et generation forme d'onde esclave 2*/
    niFgen_ConfigureOutputMode(vi3, NIFGEN_VAL_OUTPUT_FUNC); 
 niFgen_ConfigureStandardWaveform(vi3, ChannelGBF3, Waveform3, Amplitude3, DCOffset3, frequence,-120);
 niFgen_InitiateGeneration(vi3);
    niFgen_ConfigureOutputEnabled(vi3, "0", VI_TRUE);
 niFgen_SetAttributeViReal64 (vi2, ChannelGBF2, NIFGEN_ATTR_FUNC_DUTY_CYCLE_HIGH, DC); 
 
 /* Configuration et generation forme d'onde maître*/
    niFgen_ConfigureOutputMode(vi1, NIFGEN_VAL_OUTPUT_FUNC);
    niFgen_ConfigureStandardWaveform(vi1, ChannelGBF1, Waveform1, Amplitude1, DCOffset1, frequence,0);   
    niFgen_InitiateGeneration(vi1);
    niFgen_ConfigureOutputEnabled(vi1, "0", VI_TRUE); 
    niFgen_SetAttributeViReal64 (vi2, ChannelGBF2, NIFGEN_ATTR_FUNC_DUTY_CYCLE_HIGH, DC); 

    break;
 }
 return 0;
}

 

Naturellement, je me connecte sur la sortie SYNC OUT des cartes PXI. Aussi, j'ai essayé à l'aide du Front Panel NiFgen et là j'arrive à faire varier le rapport cyclique (quelque soit le signal généré sur la sortie ARB OUT).

 

Pourriez-vous m'aider??

La fonction ; niFgen_SetAttributeViReal64(vi2,ChannelGBF2,NIFGEN_ATTR_FUNC_DUTY_CYCLE_HIGH, DC);

ne fonctionne pas.

 

Cordialement,

 

Eric

0 Kudos
Message 1 of 4
(4,555 Views)

Bonjour Eric,

 

Tu as posté ta question sur la partie internationale du forum.

 

Si tu souhaites avoir plus de chance d'avoir une réponse je te conseille soit d'y poser ta question en anglais soit de la poser sur le forum francophone : French forum

 

Nevertheless, you should be able to change the duty cycle with the following function:

 

ViStatus niFgen_SetAttributeViReal64 (ViSession vi, ViConstString Channel_Name, ViAttr Attribute_ID, ViReal64 Attribute_Value);

 

You can take a look at CVI examples and especially to the 5404ClockGeneration. cws example which change dynamically the duty cycle with the function above. (Help>>Find Examples)

 

Regards,

Valentin
Certified LabVIEW Architect
Certified TestStand Architect
Certified LabWindowsCVI Developer
National Instruments France

0 Kudos
Message 2 of 4
(4,521 Views)

Bonjour Valentin,

 

Excusez moi, je ne savais pas que j'étais sur le forum international.

 

Well if you check in my previously posted code, I have used the "niFgen_SetAttributeViReal64" function but with no result. Furthermore, I have already tried to use the "5404ClockGeneration" example but changing the duty cycle dynamically doesn't work with my PXI 5411 card. It returns a "unknown parameter" error.. 

 

Could you help me more?

 

Thank you for you reply. 

 

Regards,

 

Eric

0 Kudos
Message 3 of 4
(4,514 Views)

Bonjour Eric,

 

As mentionned in my last post the niFgen_SetAttributeViReal64 should be able to do it.

 

What's the duty cycle you set as parameter, because valid settings are from 20% to 80% duty cycle:

 

Can I Adjust the Duty Cycle of a Square Wave Output on the NI 5411

 

Bonne journée,

 

 

 

 

 

 

Valentin
Certified LabVIEW Architect
Certified TestStand Architect
Certified LabWindowsCVI Developer
National Instruments France

0 Kudos
Message 4 of 4
(4,500 Views)