"The Cool Magnet Man" provides an excellent tutorial on the practical aspects of the design and winding of your own electromagnets here
This is a summary of his procedure:
Before you can start with the construction of an electromagnet, you first need to figure out the following:
- What will the core be made of
- What magnetic flux density are you trying to achieve
- How many turns will be required for this along with
- How many amps will be flowing through the wire
- How big will the wire have to be to handle the current
- How much surface area will you have for cooling the coil
- How big will the electromagnet be due to the above
- What voltage rating will the insulation of the wire have to withstand
- What will be the inductance of the electromagnet
- Obtain the core, wire, bobbin (form for the winding)
- Wind the coil
- Test the electromagnet
____________________________________
Superb Surrey University inductor winding page here
____________________________________________
This page cites the CMM's tutorial and provides my commentary on the use of electromagnets with a Raspberry Pi.