How to achieve a variable frequency AC voltage source

I want to achieve a variable frequency AC voltage source with the frequency variation of ± 0.5Hz frequency, but there is no block for me to realize that. Should I use C-script or this function cannot be achieved in plecs?

Do you have a predefined set of voltage source data? Or how do you want to change the frequency? Is the frequency variation random or follows a pattern?

You can use a Trigonometric Function and a Voltage Source (Controlled) component to create a voltage source of arbitrary phase and frequency.

For the time/angle input, you can use a Clock component for offline simulations and for real-time simulations you’ll want to use a wrapping integrator. There is an example of a C-Script based wrapping integrator in the C-Script documentation in the PLECS Manual (see: Event Handling - Wrapping Integrator) and variations in several of the demo models (Look in the PLL’s of the STATCOM Cascaded H-Bridge Converter, Three-Phase Grid-Connected PV Inverter, and Z-Source Inverter, among others).