Commit b850a594 authored by Matthieu Cattin's avatar Matthieu Cattin

Add test22 to repdo, temperature measurment.

parent d2edb4c4
#! /usr/bin/env python
# coding: utf8
# Copyright CERN, 2011
# Author: Matthieu Cattin <matthieu.cattin@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
import sys
import rr
import time
import os
from ptsexcept import *
import csr
import fmc_adc
import spec_fmc_adc
"""
test13: Test FMC temperature stability
"""
def load_firmware(default_directory):
print('Load firmware to FPGA')
path_fpga_loader = '../../../gnurabbit/user/fpga_loader';
path_firmware = '../firmwares/spec_fmcadc100m14b4cha_test.bin';
firmware_loader = os.path.join(default_directory, path_fpga_loader)
bitstream = os.path.join(default_directory, path_firmware)
print firmware_loader + ' ' + bitstream
os.system( firmware_loader + ' ' + bitstream )
time.sleep(2);
def main (default_directory='.'):
# Load firmware
load_firmware(default_directory)
# Objects declaration
spec = rr.Gennum() # bind to the SPEC board
fmc = fmc_adc.CFmcAdc100Ms(spec)
spec_fmc = spec_fmc_adc.CSpecFmcAdc100Ms(spec)
# Read SPEC unique ID and print to log
spec_unique_id = spec_fmc.get_unique_id()
if(spec_unique_id == -1):
raise PtsError ("Can't read DS18D20 1-wire thermometer on SPEC board.")
else:
print('SPEC Unique ID: %.12X') % spec_unique_id
# Read FMC unique ID and print to log
fmc_unique_id = fmc.get_unique_id()
if(fmc_unique_id == -1):
raise PtsError ("Can't read DS18D20 1-wire thermometer on SPEC board.")
else:
print('FMC Unique ID: %.12X') % fmc_unique_id
# Read SPEC temperature and print to log
spec_temp = []
spec_temp.append(spec_fmc.get_temp())
print('SPEC temperature: %3.3f°C') % spec_temp[-1]
# Read FMC temperature and print to log
fmc_temp = []
fmc_temp.append(fmc.get_temp())
print('FMC temperature: %3.3f°C') % fmc_temp[-1]
fmc_temp_sum = 0
fmc_temp_cnt = 0
MAX_DIFF = 0.2
start_time = int(time.time())
while True:
#spec_temp.append(spec_fmc.get_temp())
fmc_temp.append(fmc.get_temp())
fmc_temp_cnt += 1
if fmc_temp_cnt < 50:
fmc_temp_sum += fmc_temp[-1]
fmc_temp_avg = (fmc_temp_sum/fmc_temp_cnt)
else:
fmc_temp_sum = sum(fmc_temp[-50:])
fmc_temp_avg = (fmc_temp_sum/50)
temp_diff = abs(fmc_temp_avg - fmc_temp[-1])
print "%4d fmc temp:%3.3f°C average:%3.3f°C temp diff:%3.3f°C"%(fmc_temp_cnt, fmc_temp[-1], fmc_temp_avg, temp_diff)
if fmc_temp_cnt > 20:
if temp_diff < MAX_DIFF:
pass#break
time.sleep(2)
end_time = int(time.time())
time_diff = end_time - start_time
print "FMC temperature is stable after %ds"%time_diff
if __name__ == '__main__' :
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment