Let a pendulum of length $\ell$ be connected to a rod that rotates with constant angular velocity $\omega$. $\theta$ is the angle of the pendulum wrt $z$ axis ($z$ axis is parallel to the rod).
I have found the Hamiltonian and the Lagrangian already, the fact is that the Hamiltonian is not the energy of the system, even though it is still conserved:
Constraint: $$r - \ell = 0.$$ Lagrangian: $$L = \frac{m\ell^2((\theta \dot)^2+w^2 \sin^2(\theta))}{2} + mg\ell\cos(\theta).$$ Hamiltonian = $$H = \frac{p_\theta ^2}{2m\ell^2} - \frac{m\ell^2w^2\sin^2(\theta)}{2} - mg\ell\cos(\theta).$$
The constraint is holomonic and time independent.
The lagrangian is not time dependent.
The Hamiltonian is also not time dependent.
The potential is not velocity dependent.
So what is the matter? What i mean is, suppose the hamiltonian and the lagrangian and, also, the constraint was given to us, and the question be: "Is this hamiltonian the energy of a system?" without revealing to us the system itself, how could i be able to answer that? That is, how could we conclude this hamiltonian is not the energy? Where is the problem? something i missed?
Of course, what i want is to know when the hamiltonian is the energy just by sight, not doing any calculation.