Skip to content
Snippets Groups Projects
Commit 4bc28405 authored by Paulus Kruger's avatar Paulus Kruger
Browse files
parents d96bc365 37bef031
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ Set CCD
'''
import sys
import time
import math
sys.path.insert(0,'.')
import os
if os.name =="posix":
......@@ -31,8 +32,8 @@ READ_LOCK = True
READ_ALL = False
CHECK_EEPROM = True
PWR_RST = False
READ_SENSOR = True
READ_SENSOR = False
READ_SET_FAN = True
CLK_FREQ = '200MHz'
dev_i2c_eeprom = I2C(0x50)
dev_i2c_eeprom.bus_nr = I2CBUSNR
......@@ -121,16 +122,16 @@ def setup_pll() :
I2C_device = I2C(0x20, BUSNR=I2CBUSNR) #clock selection
I2C_device.write_bytes(0x07, 0x00)
Write_byte_PLL(0x03, 0x08, PLL_addr)
Write_byte_PLL(0x04, 0xCF, PLL_addr) # CF disable not used outputs, 00 enable all
Write_byte_PLL(0x05, 0xF0, PLL_addr)
Write_byte_PLL(0x06, 0x40, PLL_addr) # cp inv = 0xF4 other 0xE4
Write_byte_PLL(0x04, 0xFF, PLL_addr) # CF disable not used outputs, 00 enable all
Write_byte_PLL(0x05, 0xD7, PLL_addr)
Write_byte_PLL(0x06, 0xE0, PLL_addr) # cp inv = 0xF4 other 0xE4
Write_byte_PLL(0x07, 0x04, PLL_addr) # Divider R = 1 dec
Write_byte_PLL(0x08, 0x01, PLL_addr)
Write_byte_PLL(0x07, 0x00, PLL_addr)
Write_byte_PLL(0x09, 0x04, PLL_addr)
Write_byte_PLL(0x09, 0x10, PLL_addr)
Write_byte_PLL(0x0A, 0x01, PLL_addr)
Write_byte_PLL(0x09, 0x00, PLL_addr)
Write_byte_PLL(0x0B, 0x40, PLL_addr)
Write_byte_PLL(0x0B, 0x00, PLL_addr)
Write_byte_PLL(0x0D, 0x01, PLL_addr)
Write_byte_PLL(0x0E, 0x00, PLL_addr)
Write_byte_PLL(0x0F, 0x01, PLL_addr)
......@@ -251,6 +252,71 @@ def read_temp():
else:
print("Error reading tempeature")
def set_fan_off():
#
# Switch CCD fan off
#
print("Switch fan off")
MAX6620 = 0x29
fanmonitor_dev = I2C(MAX6620)
fanmonitor_dev.bus_nr = 3
fanmonitor_dev.write_bytes(0x00, 0x10)
fanmonitor_dev.write_bytes(0x02, 0x08)
fanmonitor_dev.write_bytes(0x28, 0x00)
fanmonitor_dev.write_bytes(0x29, 0x00)
def set_fan_speed(speed):
#
# Set control voltage of fan PNP
#
stri = "Set fan to {} %".format(speed)
print(stri)
MAX6620 = 0x29
reg_a = ((0xFF*speed)/100) & 0xFF
fanmonitor_dev = I2C(MAX6620)
fanmonitor_dev.bus_nr = 3
fanmonitor_dev.write_bytes(0x00, 0x00)
fanmonitor_dev.write_bytes(0x02, 0x08)
fanmonitor_dev.write_bytes(0x01, 0x0F)
fanmonitor_dev.write_bytes(0x06, 0x60)
fanmonitor_dev.write_bytes(0x28, reg_a)
fanmonitor_dev.write_bytes(0x29, 0x80)
def read_tacho():
#
# Read the fan speed
#
MAX6620 = 0x29
REG_TACH_MSP_REGS = [ 0x10, 0x12, 0x14]
REG_TACH_LSP_REGS = [ 0x11, 0x13, 0x15]
TACH_PERIODS = 16
TACH_COUNT_FREQ = 8192
FAN_TACHS = 1
DEBUG=1
fanmonitor_dev = I2C(MAX6620)
fanmonitor_dev.bus_nr = 3
fan_nr=0
ret_ack, ret_value = fanmonitor_dev.read_bytes(1)
if ret_ack < 1:
stri = " Device {0} at address 0x{1:X} not found".format("MAX6620", MAX6620)
print(stri)
status = False
ret_ack, tach_msb = fanmonitor_dev.read_bytes(REG_TACH_MSP_REGS[0], 1)
tach_msb = int(tach_msb, 16) & 0xFF
if tach_msb > 254:
if DEBUG :
tach_lsb = 255
tach = 99999
rpm = 0
else:
ret_ack, tach_lsb = fanmonitor_dev.read_bytes(REG_TACH_LSP_REGS[0], 1)
tach_lsb = int(tach_lsb, 16) & 0xE0
tach = tach_msb*16 + tach_lsb/8
rpm = float((TACH_COUNT_FREQ*TACH_PERIODS*60))/(FAN_TACHS*tach)
if DEBUG:
stri = "MSP: {0}, LSB: {1}, TACH : {2}, RPM : {3:6.2f}".format(tach_msb, tach_lsb, tach, rpm)
print(stri)
if CHECK_EEPROM :
wr_rd_eeprom()
......@@ -272,6 +338,13 @@ if READ_LOCK:
print("Not Locked --> No 10 MHz ref")
else:
print("Not locked --> PLL Error")
if READ_SET_FAN :
read_tacho()
set_fan_off()
sleep(10)
set_fan_speed(75)
sleep(10)
read_tacho()
if READ_SENSOR:
ccd_sensors()
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment