A method for machining ribs or grooves on a workpiece intended to be rotated about a longitudinal axis (A-A) of a centrifugal compressor (1), the workpiece comprising a shaft (7), on which or in which a rotor structure (16) with at least one permanent magnet (16a) of an electric motor is mounted or attached in order to drive the shaft such that it rotates, and/or an air or gas axial bearing (24) attached to one end of the shaft (7) or forming a part of the shaft (7), the centrifugal compressor (1) further comprising a casing (2) with a fluid inlet (5) and a compressed fluid outlet (6), a first compressor wheel (8) of the workpiece and a second compressor wheel (10) of the workpiece mounted at two ends of the shaft (7) in the casing (2), a front air or gas radial bearing (18) mounted on a first end of the shaft (7), and a rear air or gas radial bearing (22) mounted on a second end of the shaft (7), the machining method being carried out in a machining unit (100) adapted to receive the workpiece and comprising a tool holder (110) with a machining tool for machining the ribs or grooves on at least one portion of the workpiece,
- wherein all of the ribs or grooves (24a;
- 32) are obtained at once by the machining tool on a workpiece portion of the shaft (7) rotatably driven, by moving the shaft (7) of the workpiece or the tool holder (110) in a longitudinal machining direction, said machining tool moving back and forth with a machining position in contact with the workpiece and a position wherein it is not in contact with the workpiece from a beginning to an end of the workpiece portion,
- wherein reciprocating motions of the machining tool are synchronised with a sinusoidal program set up in the machining unit, as well as with a desired, programmed arrangement of the ribs or grooves to be produced on the workpiece portion,
- wherein all of the ribs or grooves (32) are obtained at once on a first workpiece portion of the first end of the shaft (7) from the beginning of the first portion to the end of the first portion, by the reciprocating motions of the machining tool and a displacement in a longitudinal machining direction of the rotating shaft (7) according to how the machining unit (100) was programmed, and
- wherein all of the ribs or grooves (32) are obtained at once on a second workpiece portion of the second end of the shaft (7) from the beginning of the second portion to the end of the second portion, by the reciprocating motions of the machining tool and the displacement in a longitudinal machining direction of the rotating shaft (7) or tool holder (110).