Skip to content
Snippets Groups Projects
Commit 352a06ba authored by Gijs Schoonderbeek's avatar Gijs Schoonderbeek
Browse files

Added PPS check

parent 06c46a49
No related branches found
No related tags found
1 merge request!3Apsct production
......@@ -17,6 +17,7 @@ Set APSCT_CLK
import sys
import APSCT_I2C
import time
import RPi.GPIO as gpio
sys.path.insert(0, '.')
import os
if os.name == "posix":
......@@ -39,6 +40,7 @@ class ApsctClass:
self.pll_200 = PllClass("200MHz")
self.pll_160 = PllClass("160MHz")
self.sensors = ApsctSensors()
self.pps = PpsClass()
def read_IO_expanderis(self):
#
......@@ -100,6 +102,7 @@ class ApsctClass:
# Check voltages, temp and lock on APSCT
#
result = self.sensors.check_values()
result = result & self.pps.check_timing()
if self.frequency == "200MHz":
self.pll_200.read_lock()
lock = self.pll_200.lock
......@@ -437,3 +440,48 @@ class ApsctSensors:
else:
self.temperature = 9999
return self.temperature
class PpsClass:
#
# Class to check the PPS signal
#
def __init__(self):
#
# Whats needed to measure the toggle on GPIO24
#
gpio.setmode(gpio.BCM)
gpio.setup(24, gpio.IN)
self.pps_time = 999
def time_pps(self):
gpio.wait_for_edge(24, gpio.RISING)
a = time()
gpio.wait_for_edge(24, gpio.RISING)
b = time()
self.pps_time = (b-a)/2
return self.pps_time
def check_pps(self):
gpio.add_event_detect(24, gpio.RISING)
sleep(5)
pps_ok = gpio.event_detected(24)
gpio.remove_event_detect(24)
return pps_ok
def print_pps(self):
if self.check_pps():
print(f"Time between pps is {self.time_pps():4.2f} s")
else:
print("No PPS found")
def check_timing(self):
print("Check pps timing", end = "" )
self.timing = False
if not self.check_pps():
print(" no pps")
return False
timepps = self.time_pps()
if (0.9 < timepps < 1.1):
print(f", timing is OK: {timepps:4.2f} s")
self.timing = True
return self.timing
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment