When viewing the signal on the oscilloscope, where do you connect the ground clip of the scope probe?
Also, note that if a linear regulator has to drop the voltage from 24V to 5V, that is a 19V drop and the regulator will run very hot when supplying any appreciable amount of current.
Also, note that if a linear regulator has to drop the voltage from 24V to 5V, that is a 19V drop and the regulator will run very hot when supplying any appreciable amount of current.