This article proposes a real-time optimum control algorithm for Heating, Ventilation, and Air Conditioning (HVAC) units of a commercial building aimed to maximize the ancillary power available for frequency regulation services. First, the prediction of energy consumption of air conditioning zones using long short-term memory (LSTM) is achieved, which helps forecast the aggregated regulation capacity bid of the building in the energy markets. Furthermore, to minimize energy costs and thermal discomfort of building dwellers, an optimization algorithm is designed considering the day-ahead electricity tariffs. Moreover, using installed sensors in a lab-scaled hardware prototype, the proposed algorithm is also shown to be capable of interacting with a Building Energy Management System (BEMS) and investigating the electrical and thermal properties of the HVAC unit. The BEMS controller uses an ethernet protocol to interface with the sensors installed at various operational points throughout the HVAC system. The optimal operation of the HVAC system has been executed with the real-time thermal feedback system, which counterbalances the uncertain thermal load or renewable power availability in the building confronted in real-time operation. The simulation results show the performance of the Artificial Neural Network (ANN) based compressor model in deep learning integrated with the other components of the HVAC unit and thermal model of the air-conditioning zone. Finally, the experimental results display the real-time implementation of multiple thermal and electrical conditions within the proposed control scheme of the HVAC unit. This shows the potential of ancillary services capacity through commercial buildings can be maximized with flexible loads and thereby help in power grid support.