how can convert a electrical motor in a generator?
A permanent magnet DC motor with a commutator can be used as a DC generator simply by connecting an electrical load to the terminals and turning the shaft. Very small motors of that type are sold as toy and hobby items. Somewhat larger motors of that type are used for such things as electric windows in cars. Motors that are called brushless DC motors are similar to permanent magnet synchronous motors. They can be used as AC generators simply by connecting a load and turning the shaft. However, some such motors have an electronic commutator inside that will probably prevent using the motor as a generator. Other types of motors can be used as generators, but each type of motor has its own specific requirements. There is a wide range of difficulty and complexity involved. Many DC motors that have a field winding can be operated as generators, but the field winding connection may need to be changed and/or a separate field excitation circuit may need to be added. Three phase synchronous AC motors can be operated as generators with the appropriate field excitation control system. Three phase induction motors can be used as generators to supply additional AC power to a live AC source by operating them a few percent faster than their normal speed for motor operation. They can be used as generators under other conditions with the use of a complex electronic control system. Some types of single phase induction motors can be used as generators under the right circumstances.
You can't, they are built differently. If you have a 240v motor and you drive it at it's rated speed by something mechanical and test the leads for an output voltage, there will be a small voltage due to residual magnetism in the rotor, but nothing of any use.
If you turn the shaft on an electrical motor, it will create a voltage across the power leads. Then you just need to connect those leads to whatever you want to power. There's no actual conversion necessary.
Retired E.E. below is 100% correct. Wish he would contact me. Always good to talk to Brothers of The clothe!