diff --git a/config/PPS.yaml b/config/PPS.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..66d4bd0010e7fe5cc1e17529375902351b14f2e4
--- /dev/null
+++ b/config/PPS.yaml
@@ -0,0 +1,37 @@
+version: "1.0"
+description: "1234"
+
+drivers:
+ - name: pps
+   type: gpio_pps
+   parameters: [24] #PPS pin
+   status: RECVTR_PPS_counter
+
+device_registers:
+ - name: X1 #dummy
+   driver: pps
+   registers:
+   - name: X1
+     address: 0
+
+
+variables:
+   - name: RECVTR_PPS_counter
+     driver: pps
+     rw:  ro
+     dtype: uint64
+     width: 64
+
+   - name: RECVTR_PPS_time
+     driver: pps
+     rw:  rw
+     dtype: uint64
+     width: 64
+
+
+methods:
+   - name: PPS_Init #Called after startup to load. Should have all stored registers  
+     driver: pps
+     debug: True
+     instructions:
+     - RECVTR_PPS_counter : Update
diff --git a/i2cserv/gpio_pps.py b/i2cserv/gpio_pps.py
new file mode 100644
index 0000000000000000000000000000000000000000..b06843b8103dca0117076b61b4b1f1a191e5bde6
--- /dev/null
+++ b/i2cserv/gpio_pps.py
@@ -0,0 +1,85 @@
+from .hwdev import hwdev;
+import logging
+import threading
+from queuetypes import *
+import time;
+import struct
+
+#import signal
+try:
+  import RPi.GPIO as GPIO
+except:
+  GPIO=False;
+  
+class gpio_pps(hwdev):
+  def __init__(self,config):
+    hwdev.__init__(self,config);
+    self.pin=config['parameters'][0];
+    self.cnt=0;
+    self.timesec=None;
+    self.timeid=None;
+    logging.info("PPS on pin %i",self.pin)
+    if GPIO:
+      GPIO.setmode(GPIO.BCM)
+      GPIO.setup(self.pin,GPIO.IN)
+    else:
+      logging.warn("RPi GPIO module not found, PPS input disable!")
+      return
+    self.PPSid=config.get('maskid',None)
+    if self.PPSid is None:
+      logging.warn("PPS cnt variable not linked to driver!")
+      return
+
+    self.thread=threading.Thread(target=self.PPS_wait_loop); 
+    self.thread.start();
+
+  def ppsdata(self):
+    data=struct.pack('>Q',self.cnt)
+    return [d for d in data];
+
+  def incPPS(self):
+      self.cnt+=1;
+      if not(self.timesec is None):
+          self.Qout.put(OPCUAset(self.timeid,InstType.varSet,self.timesec,[]))
+          self.cnt=0;
+          self.timesec=None;
+      logging.debug("PPS cnt=%i" % self.cnt) 
+      self.Qout.put(OPCUAset(self.PPSid,InstType.varSet,self.ppsdata(),[]))
+
+  def PPS_wait_loop(self):
+     time.sleep(3);
+     while True:
+         self.Qout=self.conf.get('Qout',None)
+         if self.Qout is None:
+            logging.warn("PPS thread end (No Qout)")
+            return
+         channel=GPIO.wait_for_edge(self.pin,GPIO.RISING,timeout=2500)
+         if not(channel is None): 
+          self.incPPS();
+         else:
+            logging.debug("PPS not received!") 
+         channel=GPIO.wait_for_edge(self.pin,GPIO.FALLING,timeout=1500)
+         if not(channel is None): 
+          self.incPPS();
+         else:
+            logging.debug("PPS not received!") 
+
+  def OPCUAReadVariable(self,varid,var1,mask):
+      if varid==self.PPSid:
+        return [OPCUAset(self.PPSid,InstType.varSet,self.ppsdata(),[])]
+      else:
+         self.timeid=varid;
+         print("timeid=",varid);
+         return [OPCUAset(self.PPSid,InstType.varSet,[0,0,0,0,0,0,0,0],[])]
+
+  def OPCUASetVariable(self,varid,var1,data,mask):
+      if varid==self.PPSid:
+          logging.warn("Can not set PPS count");
+          return []
+      if self.timeid is None: self.timeid=varid;
+      if not(varid==self.timeid): 
+          logging.warn("Unknown variable");
+          return []
+      logging.info("Set PPS time");
+      self.timesec=data.copy();
+      return []
diff --git a/i2cserv/i2cthread.py b/i2cserv/i2cthread.py
index 62f1c1bfe9641f0ae9b5c0bbf92f1cd991b5b120..7d9675ddaa439bf6e1e83f3b93dc90f3798a926f 100644
--- a/i2cserv/i2cthread.py
+++ b/i2cserv/i2cthread.py
@@ -108,11 +108,16 @@ def I2Cserver(Qin,Qout,name):
         conf=yc.yamlconfig(name)
         conf.linkdevices()
         conf.loaddrivers()
+        for c in conf.conf['drivers']:
+             c['Qout']=Qout;
         conf.linkdrivers()
         statusid=conf.getvarid(name+"_translator_busy");
         while True:
            item = Qin.get()
-           if item is None: break;
+           if item is None: 
+              for c in conf.conf['drivers']:
+                  c['Qout']=None;
+              break;
 #           print("TODO: Set busy")
 #           self.statevar.set_value("busy");
            #print("SetVar",item)#,self.conf.variables[item.id])
diff --git a/opcuaserv/yamlreader.py b/opcuaserv/yamlreader.py
index 4653f335ed6554eb788e2e33e24469c24c72f8f9..3033ae876e6257862f317e851de76a004f572f23 100644
--- a/opcuaserv/yamlreader.py
+++ b/opcuaserv/yamlreader.py
@@ -117,9 +117,9 @@ class yamlreader(yamlconfig):
     def setvar(self,id1,data=[]):
         v=self.conf['variables'][id1];
         if v['rw']=='variable': 
-          var1=v.get('OPCR')
+          var1=v.get('OPCR',None)
 #          if not(var1): var1=v.get('OPCW')
-          if not(var1):
+          if var1 is None:
              logging.warn("OPCR variable not found!!");
              return;
           logging.info("Update variable")
@@ -235,9 +235,9 @@ class yamlreader(yamlconfig):
                 if convert: data2=[eval("convert_unit."+convert)(d) for d in data2]
                 for x in range(cnt): 
                     if notvalid[x]: data2[x]=float('nan')
-        var1=v.get('OPCR')
-        if not(var1): var1=v.get('OPCW')
-        if not(var1):
+        var1=v.get('OPCR',None)
+        if var1 is None: var1=v.get('OPCW',None)
+        if var1 is None:
            logging.warn("OPC variable not found!!");
            return;
         data3=var1.get_value();
diff --git a/scripts/pps_test.py b/scripts/pps_test.py
index c1d966830e650d2654fdc268f25791e7bfc26721..76209d1f7d4bb62fa4a80b605a4a270f44ea8c79 100644
--- a/scripts/pps_test.py
+++ b/scripts/pps_test.py
@@ -1,6 +1,6 @@
 import RPi.GPIO as GPIO
 import time
-PIN=23
+PIN=24
   
 GPIO.setmode(GPIO.BCM)
 GPIO.setup(PIN,GPIO.IN)
@@ -8,3 +8,5 @@ GPIO.setup(PIN,GPIO.IN)
 for x in range(3):
   channel=GPIO.wait_for_edge(PIN,GPIO.RISING,timeout=1500)
   print("Timeout!" if channel is None else "PPS")
+  channel=GPIO.wait_for_edge(PIN,GPIO.FALLING,timeout=1500)
+  print("Timeout!" if channel is None else "PPS")
diff --git a/scripts/testpps.py b/scripts/testpps.py
new file mode 100644
index 0000000000000000000000000000000000000000..da785f0ee5834681c7f66189bc068014a5d42677
--- /dev/null
+++ b/scripts/testpps.py
@@ -0,0 +1,20 @@
+from test_common import *
+connect("opc.tcp://localhost:4850/")
+import time
+
+var1="RECVTR_PPS_counter_R"
+vart="RECVTR_PPS_time"
+#  for x in range(20):#
+for x in range(4):
+  time.sleep(0.5);
+  print("PPS=",get_value(var1)," time=",get_value(vart+"_R"));
+for y in range(5):
+  print("Set time");
+  set_value(vart+"_RW",10+y)
+  time.sleep(0.1);
+  print("PPS=",get_value(var1)," time=",get_value(vart+"_R"));
+  for x in range(5):
+    time.sleep(0.5);
+    print("PPS=",get_value(var1)," time=",get_value(vart+"_R"));
+
+disconnect();
diff --git a/start.sh b/start.sh
index 87a13ec1614c73dc9927d4dfec3e13fee2076935..d77fcf3333a4e901df31160406dc72c374e6bde2 100755
--- a/start.sh
+++ b/start.sh
@@ -1,4 +1,4 @@
-tmux new -s translators  'cd ~/pypcc;python3 pypcc2.py -p 4840 -c RECVTR'  \; \
+tmux new -s translators  'cd ~/pypcc;python3 pypcc2.py -p 4840 -c RECVTR,PPS'  \; \
   new-window 'cd ~/pypcc;python3 pypcc2.py -p 4841 -c UNB2TR' \; \
   new-window 'cd ~/pypcc;python3 pypcc2.py -p 4842 -c APSPUTR' \; \
   new-window 'cd ~/pypcc;python3 pypcc2.py -p 4843 -c APSCTTR' \; \