# limit fps

**URL:** https://forums.openmv.io/t/limit-fps/1440
**Category:** OpenMV Boards
**Created:** [October 10, 2019, 12:06pm UTC](https://forums.openmv.io/t/limit-fps/1440 "2019-10-10T12:06:28Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Mura](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Mura](https://forums.openmv.io/u/Mura)
#### Post date: [October 10, 2019, 12:06pm UTC](https://forums.openmv.io/t/limit-fps/1440/1 "2019-10-10T12:06:28Z")

</div>

Hi!  
If I run the following program, there will be a 1 second lag in servo startup after receiving data.  
So I would like to lack the limit on the fps output to the screen. please tell me. Thank you.

```python
import time,pyb,sensor,image,micropython
from pyb import Pin,UART,Timer,Servo
from servo import Servos
from machine import I2C
sensor.reset()                      
sensor.set_pixformat(sensor.RGB565) 
sensor.set_framesize(sensor.QVGA)  
sensor.skip_frames(time=4000)    
clock = time.clock()                
####################################################################################################
MotorA=Pin('P1',Pin.OUT_PP,Pin.PULL_NONE)
MotorB=Pin('P2',Pin.OUT_PP,Pin.PULL_NONE)
i2c = I2C(sda=Pin('P5'), scl=Pin('P4'))
servo = Servos(i2c, address=0x40, freq=50, min_us=250, max_us=2800, degrees=180)
uart = UART(1, 115200, timeout=5)
####################################################################################################
#tim = Timer(1, freq=50)
#ch1 = tim.channel(1,Timer.PWM,pin=Pin("P7"),pulse_width_percent=1)
####################################################################################################
x=90
y=90

while(True):
    img = sensor.snapshot()
    print(clock.fps())
    servo.position(7,x)
    servo.position(6,y)
    Data=0;
    Data=uart.readchar()
    if(Data!=0):
      if(Data==1):
        x+=1
      elif(Data==2):
        x-=1
      elif(Data==3):
        y+=1
      elif(Data==4):
        y-=1
      elif(Data==5):
        x=90
        y=90
        MotorA.value(True)
        MotorB.value(False)
      elif(Data==6):
        x=90
        y=90
        MotorA.value(False)
        MotorB.value(True)
    else:
      x=75
      y=90

```

[servo\_1.py](https://forums.openmv.io/uploads/short-url/n5pBiczLAZX1roeRPpwWEipSDiz.py) (1.16 KB)  
[pca9685\_1.py](https://forums.openmv.io/uploads/short-url/n52xU3MyMg9GOXYmPGHuCnQJJXR.py) (1.91 KB)  
[camera\_main.py](https://forums.openmv.io/uploads/short-url/pWIN1jkuWFTZiOAnQ4tKLefZreM.py) (1.91 KB)

---

<div class="post-metadata">

### Author: ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)
#### Post date: [October 10, 2019, 3:08pm UTC](https://forums.openmv.io/t/limit-fps/1440/2 "2019-10-10T15:08:17Z")

</div>

I don’t understand “lack the limit on the fps output to the screen”. Can you elaborate?

---

<div class="post-metadata">

### Author: ![Mura](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Mura](https://forums.openmv.io/u/Mura)
#### Post date: [October 10, 2019, 3:30pm UTC](https://forums.openmv.io/t/limit-fps/1440/3 "2019-10-10T15:30:18Z")

</div>

Well.  
I want to receive data from Arduino and control the servo motor with that data while outputting video on my PC.  
However, with the current program, there is a 1 second lag when moving the servo motor after receiving data from Arduino.  
So,I want to Reduce processing to CPU.

Sorry for the poor English.I am Japanese and don’t understand English well…

---

<div class="post-metadata">

### Author: ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)
#### Post date: [October 10, 2019, 3:35pm UTC](https://forums.openmv.io/t/limit-fps/1440/4 "2019-10-10T15:35:36Z")

</div>

Okay, i don’t see anything that would create the lag in the code. Anyway, what do you mean by reduce processing to the CPU? You can add delay methods that make it run slower.

---

<div class="post-metadata">

### Author: ![Mura](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Mura](https://forums.openmv.io/u/Mura)
#### Post date: [October 10, 2019, 4:03pm UTC](https://forums.openmv.io/t/limit-fps/1440/5 "2019-10-10T16:03:00Z")

</div>

I would like to limit the video fps displayed on my computer as a way to reduce the processing to the CPU.  
I want to move the servo as soon as communication from Arduino comes.

---

<div class="post-metadata">

### Author: ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)
#### Post date: [October 10, 2019, 6:12pm UTC](https://forums.openmv.io/t/limit-fps/1440/6 "2019-10-10T18:12:37Z")

</div>

I see, um, there’s no way to lower the IDE poll rate except to disable the frame buffer such that it doesn’t display anything.

…

You can redo your code loop such that you call snapshot() not each time through the loop. This will reduce the processing on your PC. So, just only call snapshot every 4 times through the loop.

---

<div class="post-metadata">

### Author: ![Mura](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Mura](https://forums.openmv.io/u/Mura)
#### Post date: [October 11, 2019, 3:14am UTC](https://forums.openmv.io/t/limit-fps/1440/7 "2019-10-11T03:14:51Z")

</div>

OK! Thanks!
