Two linked gear wheels in a micromachine can be simultaneously rotated in opposite directions by using a laser beam that has in its section areas the spin angular momentum (SAM) of the opposite sign. However, for instance, a cylindrical vector beam has zero SAM in the focus. We alter a cylindrical vector beam so as to generate areas in its focus where the SAM is of opposite signs. The first alteration is adding to the cylindrical vector beam a linearly polarized beam. Thus, we study superposition of two rotationally symmetric beams: those with cylindrical and linear polarization. We obtain an expression for the SAM and prove two of its properties. The first property is that changing superposition coefficients does not change the shape of the SAM density distribution, whereas the intensity changes. The second property is that maximal SAM density is achieved when both beams in the superposition have the same energy. The second perturbation is adding a spatial carrier frequency. We study the SAM density of a cylindrical vector beam with a spatial carrier frequency. Due to periodic modulation, upon propagation in space, such a beam is split into two beams, having left and right elliptic polarization. Thus, in the beam transverse section, areas with the spin of different signs are separated in space, which is a manifestation of the spin Hall effect. We demonstrate that such light beams can be generated by metasurfaces, with the transmittance depending periodically on one coordinate.