Integrated PeriodicFuncGen frequency control not controllable

4 posts / 0 new
Last post
johnspeth
Offline
Last seen: 2 weeks 4 days ago
Joined: 07/13/2018 - 10:56pm
Integrated PeriodicFuncGen frequency control not controllable

I'm having a problem controlling the PeriodicFuncGen frequency when the module is controlled from my integrated code (AW Designer is not running).  Directly setting the .freq value doesn't change the frequency.  The frequency is controllable using server commands (as expected) when the same layout is running in AW Designer.  My periodic function generator is configured as isTunable = true.  I made a workaround to make it work: I added a DCSource driving a ParamSet for the periodic function generator frequency value.  A peculiar behavior I'm seeing is I can directly control other PeriodicFuncGen parameters (like .amplitude and .functionType) without using my DCSource/ParamSet work around.

That seems like a bug on the surface but I'm wondering if I might have a broken some caveat that is special to the PeriodicFuncGen.freq value.  Can anyone explain why my workaround is necessary?

Integrated code snippet:

status = awe_fwGetObjectByID(&g_AWEInstance,<ID from my generated target files>,&pInstance,&classID);
if((status == E_SUCCESS) && (classID == CLASSID_PERIODICFUNCTIONGEN))
{
    awe_modPeriodicFunctionGenInstance *p = (awe_modPeriodicFunctionGenInstance *)(pInstance);

    p->amplitude = 1.0F;
    p->freq = (FLOAT32)(frequency); // frequency is confirmed to be an integer value of 1000
}

Thanks - John Speth

 

 

Axel Nilsson
Offline
Last seen: 10 hours 43 min ago
Joined: 12/19/2016 - 2:02pm

Hi John,

 

There shouldn't be anything special about the periodic function generator module. Though when you edit module parameters by hand, you should always call ClassModule_Set() afterwards to indicate to the module which value has changed. This set function will update any derived parameters within the module - see this image for the recommended flow while updating module parameters.

Another potential issue could be that you are trying to set the frequency value to something outside of the range specified in the module. The range for the frequency is by default 0:SR/2.

 

Hopefully this helps.

-Axel

johnspeth
Offline
Last seen: 2 weeks 4 days ago
Joined: 07/13/2018 - 10:56pm

Axel, thanks for the help.  The culprit was the lack of ClassModule_Set() function.  I undid my workaround, added the necessary call to ClassModule_Set(), retested, and all is working as I expected.

I regret to have to point out that this function is not documented anywhere that I could find yet it appears to be an important core function.  Your explanation makes perfect sense and ties together several loose ends that I never understood.  I think the ParamSet html help page might describe the topic completely but it never explicitly states that the "set" function is really ClassModule_Set().  Since my workaround did involve the calling of the set function, it was happening behind the scenes.

Axel Nilsson
Offline
Last seen: 10 hours 43 min ago
Joined: 12/19/2016 - 2:02pm

John, 

 

I'm glad this fixed your problem.

Also, thank you for pointing out that this is a gap in our documentation. I've put in a ticket to improve our docs on this front.

 

-Axel