Jump to content

Recommended Posts

Posted
Good morning, I am coding in GXWorks2 and would like to be able to output a sine wave out of a D-to-A conversion card, and I would like to be able to control the frequency, with the highest frequency being 100Hz. Is there an easy way to do this? And/or can you help me finalize my own coding plan. My plan is to set a loop with 360 steps, with a kind of hold timer between steps. I would allow for the frequency to be inputted, then take reciprocal or said frequency and divide that by 360 to get the time between each transition step, use that time in a high speed timer. I would truncate the step time to .00 ms, as that seems to be the limit on the timer (exact frequency is not required). My main concern with this plan is how to change the input to the timer. See pseudo-code below: (note: the amplitude would have already be converted to match the resolution of the output card, ie: 0 to 4095) 1/Freq_In = Period Period/360 = Step While 'Motor_Run = TRUE' for i = 0 to 360 i*(pi/180) = rads sin(rads) = signal signal -> real-to-int -> signal_int signal_int*amplitude=ouput output -> mov -> D0_SP %D0_SP is the alias of the output device Wait Step end end Again, if there is a better way to do this in GXWorks2 the writing the pseudo-code above in structured ladder please let me know, also, what is the best way to allow for changing the input of a High Speed Timer? As always, thanks much for your help, James Kelly

Posted
don't know if there is special card for this (probably not but i may be wrong) but without it, the major problem is scan time. your approach may work but only for much slower output. Q is probably one of the fastest PLCs around, however, depending on your program, there will still be scan limit of some 1-3ms. you don't mention lowest frequency (range is important) or amplitude of the signal but at 100Hz, that means period of 10ms which means output that is practically square wave. if i had to do this, i would probably first look into something dedicated to generate signal and just control it. in your case this could simply be a VCO and let PLC just only set desired frequency (using existing analog output). there is also tons of ready MCU modules that should do this out of box and setting of the frequency could be done through network too.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...