Yes, you can collect and store data from previous time steps.
Either create a new state variable using the DELAY run-time function. Then your subroutine can get the data from that variable using the SYSFNC call as long as the ID of that variable is passed as a parameter to the subroutine.
An alternative is to use a SENSUB (or REQSUB) that collects the data and stores them in a common block (Fortran) or global variable (C). Difference is that REQSUBS are only called at output steps while SENSUBS are called at every converged integration step.
But how you would get the frequency from that I don't understand. Unless you know that the motion of the force is a single, clear sine wave, without noise, disturbances, overtones you will have a hard time getting the instantaneous frequency of the excitation of the force element.
Thank you very much @Jesper Slattengren for this helpful reply !
I am also not sure about calculating the frequency accurately but what I thought is to track the zero crossing of displacement/velocity and get something out of it if that works.
It will be very helpful if there is any other approach for this kind of simulation.