I'm glad you got it behaving
I suggest that you keep the brains for various VFD features in separate files. Once you got every feature working you can redo it in single file, if that's your preferred way.
To set the spindle speed, use the value from "Spin RPM - Ovrden DRO", this DRO contains actual commanded RPM including override. My spindle has max 24000RPM , and max freq 400Hz, so, for each Hz, RPM changes by 24000/400=60 - that's also my user-defined coefficient (p00.05) . To get frequency value from RPM, divide RPM by this coefficient. Frequency value for address/param 2001H can have two decimal places, so desired frequency should be multiplied by 100 to get the value that should be written. If you check my spindle speed brain, you'll see this formula (I think you can actually use that brain, just change the coefficient(60) to a value specific for your spindle).
I do not need to read actual spindle speed/freq from VFD - I've connected digital display to VFD with ribbon cable and mounted it outside the VFD enclosure, so I can see it. When I was thinking about doing it, I remember that there were some "logic" problems, so I just abandoned the whole idea.
I have two hints, first, check the Config/Spindle pulleys..., you can limit min/max RPM there (I have it set to min=4200,max=24000,ratio=1), and second, be careful when using "run from here", this feature does not execute S commands in g-code program (RPM will be read from DRO) and be sure to check "Start spindle" checkbox on "preparation move" form - it is unchecked by default (but once you check it, it stays checked).