Servo SG90 control with S7-200

posted in: PLC | 0
  1. Servo SG90 control principle

You guys often use the Arduino library to control the SG90, so sometimes I don’t pay attention to the principle, so did I before.

Its principle is easy to understand:

  • Generate a PWM pulse with a period of 20ms.
  • The angle of the servo will depend on the high pulse time: 0 o – 180 o will correspond to 1ms – 2ms.
  • For example, 0 o is 1ms, 90 o is 1.5ms, 180 o is 2ms, 45 o is 1.25ms. You just need to calculate the ratio. قوانين لعبة القمار

2. Wiring diagram

Please note that only the DC/DC/DC type can generate pulses, and the Relay output type cannot be controlled. S7-200 also only supports 2 pulse generator pins, Q0.0 and Q0.1.

3. Programming

Go to Wizards > Select PTO/PWM.

You choose pins Q0.0 or Q0.1 to generate pulses, here I use Q0.0.

Select the PWM pulse type and the unit is microseconds. 1xbet شرح موقع

After that, go to Call Subroutines and call the PWM function you just created and program it like me. لعبة البوكر




Here Cycle is pulse period 20ms = 20000 microseconds. Pulse is a high pulse time, here I assign it to the VW10 variable for easy adjustment.

Next we will adjust the angle for the servo. Open Chart Status

In principle, here I will put in the values ​​of 1000 – 2000 respectively 0 o – 180 o , the comment will see that the servo runs at an incorrect angle, you continue to try with other values ​​to find 0 o – 180 o , the result I do is 0 o is 300, 90 o is 1300, 180 o is 2300.

Good luck.

Leave a Reply

Your email address will not be published.