Biogas is an environmentally friendly and clean, pollution-free fuel. In this paper, biogas generators have been researched in order to study the use of pig farm biogas in China. First, the pig farm biogas components are grouped, tested, and formulated. Since the biogas combustion process is not the same as for gasoline, biogas processing is carried out in a constant volume bomb combustion test, thus, the different components of biogas combustion speed, combustion pressure, and other information become available. The biogas combustion process in the combustion chamber and movement are simulated, and the cylinder pressure, speed, and temperature conditions are obtained. As can be seen from the experimental results, the biogas combustion speed is lower than that of gasoline, the ignition timing generator needs to be adjusted. In order to reduce the possibility of post-combustion occurring in the combustion chamber, certain combustion chamber swirl movements should be organized. The results show that by adjusting the ignition timing, air movement, and other factors, biogas can be used as fuel in generators.