Problem with comparison.
/Designs/Measuring_instruments/RMDS02C/SW/Host_controller/start.sh |
---|
0,0 → 1,7 |
ulimit -c unlimited |
~/Bolidozor/frequency_log.py |
jackd -c system -p128 -m -dalsa -dhw:CODEC -r48000 -p4096 -n4 -m -C -i2& |
sleep 3 |
~/Bolidozor/radio-observer -c ~/Bolidozor/uFlu/uFlu-R0.json& |
sleep 3 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/Designs/Measuring_instruments/RMDS02C/SW/Host_controller/stop.sh |
---|
0,0 → 1,7 |
killall frequency_log.py |
killall jackd |
killall qjackctl |
killall waterfall.py |
killall whistle |
killall radio-observer |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/Designs/Measuring_instruments/RMDS02C/SW/Host_controller/frequency_log.py |
---|
0,0 → 1,79 |
#!/usr/bin/python |
# |
# Sample of measuring and frequency correction with ACOUNTER02A |
import time |
import datetime |
import sys |
from pymlab import config |
req_freq = 286.0788 # required local oscillator frequency in MHz. |
#### Sensor Configuration ########################################### |
cfg = config.Config( |
i2c = { |
"port": 1, |
}, |
bus = [ |
{ |
"type": "i2chub", |
"address": 0x70, |
"children": [ |
{ "name":"counter", "type":"acount02", "channel": 2, }, |
{ "name":"clkgen", "type":"clkgen01", "channel": 5, }, |
], |
}, |
], |
) |
cfg.initialize() |
print "RMDS Station frequency management test software \r\n" |
fcount = cfg.get_device("counter") |
fgen = cfg.get_device("clkgen") |
time.sleep(0.5) |
frequency = fcount.get_freq() |
rfreq = fgen.get_rfreq() |
hsdiv = fgen.get_hs_div() |
n1 = fgen.get_n1_div() |
''' |
# sample GPS configuration |
fcount.conf_GPS(0,5) # length of the GPS configurtion sentence |
fcount.conf_GPS(1,ord('a')) # the first byte of GPS configuration sentence |
fcount.conf_GPS(2,ord('b')) # the second byte of GPS configyration sentence |
fcount.conf_GPS(3,ord('c')) |
fcount.conf_GPS(4,ord('d')) |
fcount.conf_GPS(5,ord('e')) |
''' |
fcount.set_GPS() # set GPS configuration |
#### Data Logging ################################################### |
try: |
with open("frequency.log", "a") as f: |
while True: |
now = datetime.datetime.now() |
if (now.second == 15) or (now.second == 35) or (now.second == 55): |
frequency = fcount.get_freq() |
if (len(sys.argv) == 3): |
regs = fgen.set_freq(frequency/1e6, float(req_freq)) |
now = datetime.datetime.now() |
rfreq = fgen.get_rfreq() |
hsdiv = fgen.get_hs_div() |
n1 = fgen.get_n1_div() |
fdco = (frequency/1e6) * hsdiv * n1 |
fxtal = fdco / rfreq |
sys.stdout.write("frequency: " + str(frequency) + " Hz Time: " + str(now.second)) |
sys.stdout.write(" RFREQ: " + str(rfreq) + " HSDIV: " + str(hsdiv) + " N1: " + str(n1)) |
sys.stdout.write(" fdco: " + str(fdco) + " fxtal: " + str(fxtal) + "\r") |
f.write("%d\t%s\t%.3f\n" % (time.time(), datetime.datetime.now().isoformat(), frequency)) |
sys.stdout.flush() |
time.sleep(0.9) |
except KeyboardInterrupt: |
sys.stdout.write("\r\n") |
sys.exit(0) |
f.close() |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/Designs/Measuring_instruments/RMDS02C/SW/Host_controller/setSi570.py |
---|
0,0 → 1,56 |
#!/usr/bin/python |
# |
# Utility for setting frequency of Si570 without a frequency measurement. |
# The factory calibration is used for changing the frequency. |
# This utility reset the Si570 to factory default 10 MHz first and than set a new frequency. |
# |
# This utility use an USBI2C01A module. |
# (c) MLAB 2014 |
import time |
import datetime |
import sys |
from pymlab import config |
import logging |
logging.basicConfig(level=logging.DEBUG) |
#### Script Arguments ############################################### |
if (len(sys.argv) != 3): |
sys.stderr.write("Invalid number of arguments.\n") |
sys.stderr.write("Usage: %s PORT_ADDRESS/0 REQUIERED_MHz\n" % (sys.argv[0], )) |
sys.exit(1) |
port = eval(sys.argv[1]) |
#### Sensor Configuration ########################################### |
cfg = config.Config( |
i2c = { |
"port": port, |
}, |
bus = [ |
{ |
"type": "i2chub", |
"address": 0x70, |
"children": [ |
{ "name":"clkgen", "type":"clkgen01", "channel": 1, }, |
], |
}, |
], |
) |
cfg.initialize() |
fgen = cfg.get_device("clkgen") |
sys.stdout.write("Frequency will be set to " + sys.argv[2] + " MHz.\r\n") |
fgen.route() |
time.sleep(3) |
fgen.recall_nvm() # Reload settings for 10 MHz |
time.sleep(3) |
fgen = cfg.get_device("clkgen") # Reopen CP2112 |
fgen.set_freq(10., float(eval(sys.argv[2]))) # Set frequency |
sys.stdout.write("Done.\r\n") |
sys.stdout.flush() |
sys.exit(0) |
/Designs/Measuring_instruments/RMDS02C/SW/Host_controller/SDR_Record_jack.sh |
---|
0,0 → 1,8 |
#!/bin/bash |
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
#arecord -v --use-strftime -d720 -f dat -t wav -c2 /home/kaklik/Flyover_Svakov_%Y%m%d%H%M%S.wav >> /home/kaklik/record.log |
#arecord -v -f dat -t wav -c2 --max-file-time 3600 --use-strftime /mnt/Svakov/%Y/%m/%d/Radio_%Y%m%d%H%M%S.wav |
recordfile=/media/Radio_zaloha___/Svakov_HG/$(date +Radio_HG_%Y%m%d%H%M%S).wav |
#screen jack_capture -V -d 36 -c 2 -p alsa_in:capture* --filename $recordfile |
#screen jack_capture -V -c 2 -p alsa_in:capture* --filename $recordfile |
jack_capture -V -d 3605 -c 2 -p alsa_in:capture_1 -p alsa_in:capture_2 --filename $recordfile & |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/Designs/Measuring_instruments/RMDS02C/SW/Host_controller/SDR_record_alsa.sh |
---|
0,0 → 1,3 |
#!/bin/bash |
#arecord -v --use-strftime -d720 -f dat -t wav -c2 /home/kaklik/Flyover_Svakov_%Y%m%d%H%M%S.wav >> /home/kaklik/record.log |
arecord -v -D hw:1 -f dat -t wav -c2 --max-file-time 3600 --use-strftime /mnt/Svakov_HG/%Y/%m/%d/Radio_%Y%m%d%H%M%S.wav |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/Designs/Measuring_instruments/RMDS02C/SW/Host_controller/SDR_record.sh |
---|
0,0 → 1,2 |
#!/bin/bash |
pasuspender -- arecord -D hw:1,0 -v --buffer-time=500000 --use-strftime -d600 -f dat -t wav -c2 /mnt/ISS_Praha_%Y%m%d%H%M%S.wav >> /home/kaklik/SDR_record.log |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/Designs/Measuring_instruments/RMDS02C/SW/Host_controller/SiliconLabs.rules |
---|
0,0 → 1,3 |
SUBSYSTEM=="usb", ATTRS{idVendor}=="10c4", MODE="0666" |
SUBSYSTEM=="usb_device", ATTRS{idVendor}=="10c4", MODE="0666" |
/Designs/Measuring_instruments/RMDS02C/SW/Host_controller/plot.gp |
---|
0,0 → 1,12 |
set terminal png size 800,640 |
set output "Frequency_time.png" |
set xdata time |
set timefmt "%s" |
set format x "%H:%M:%S" |
set key under |
set xlabel "Time" |
set ylabel "Freq deviation [Hz]" |
f0=140000000 |
plot "temperature.log" using 1:($3-f0) with linespoints title "CLKGEN01B 140 MHz" |
/Designs/Measuring_instruments/RMDS02C/SW/PIC16F887/main.c |
---|
0,0 → 1,203 |
// Atomic counter with I2C and RS232 output |
// Usage conditions: |
// 1. The first I2C or RS232 readout can be performed minimally 20 s after power up. |
// 2. The I2C internal address 0 has to be read first. |
// 3. An I2C readout can be performed at 15-th, 35-th and 55-th second of UTC. |
// |
// Counter gives 32 bit value: |
// I2C register address 0 = LSB |
// I2C register address 3 = MSB |
#define ID "$Id$" |
#include "main.h" |
#use i2c(SLAVE, Fast, sda=PIN_C4, scl=PIN_C3, force_hw, address=0xA2) |
#include <string.h> |
#define LED PIN_B3 // heartbeat indicator |
#define SEL0 PIN_E0 // external counter division ratio |
#define SEL1 PIN_E1 // external counter division ratio |
#define MR PIN_E2 // external counter master reset |
#define CLKI PIN_C0 // internal counter input |
unsigned int32 count; // count per second |
int1 fire_setup; // flag for sending setup to GPS |
#define BUF_LEN 4 |
int8 buffer[BUF_LEN]; // I2C buffer |
int8 address=0; |
unsigned int16 of=0; // count of overflow |
// 1x 100 us per 10 s UTC synchronised; 40 configuration bytes |
char cmd[50]={40, 0xB5, 0x62, 0x06, 0x31, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x80, 0x96, 0x98, 0x00, 0xE0, 0xC8, 0x10, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0xC6, 0x51}; |
// configure GPS |
void setup_GPS() |
{ |
int n; |
int len; |
len=cmd[0]; |
for (n=1;n<=len;n++) putc(cmd[n]); |
} |
#INT_SSP |
void ssp_interupt () |
{ |
int8 incoming, state; |
state = i2c_isr_state(); |
if(state < 0x80) //Master is sending data |
{ |
incoming = i2c_read(); // Read byte |
if(state == 1) //Second received byte is address of register |
{ |
address = incoming; |
} |
if(state == 2) //Thid received byte are configuration data |
{ |
if ((address==0)&&(incoming==0)) |
{ |
fire_setup = 1; // Write configuration to the GPS if configuration data length is 0 |
} |
else |
{ |
cmd[address] = incoming; // Store byte to configuration sentence |
} |
} |
} |
if(state == 0x80) //Master is requesting data |
{ |
//i2c_read(); // Dummy read of I2C device address |
if(address == 0) // Change buffer atomically at reading of the first byte |
{ |
buffer[0]=make8(count,0); |
buffer[1]=make8(count,1); |
buffer[2]=make8(count,2); |
buffer[3]=make8(count,3); |
} |
if(address <= BUF_LEN) |
{ |
i2c_write(buffer[address]); // Prepare one byte to SSP buffer |
} |
else |
{ |
i2c_write(0x00); // There is nothing to prepare, so zero |
} |
} |
if(state == 0x81) //Master is requesting data |
{ |
i2c_write(buffer[1]); // Prepare next byte to SSP buffer |
} |
if(state == 0x82) //Master is requesting data |
{ |
i2c_write(buffer[2]); // Prepare next byte to SSP buffer |
} |
if(state == 0x83) //Master is requesting data |
{ |
i2c_write(buffer[3]); // Prepare next byte to SSP buffer |
} |
if(state > 0x83) //Master is requesting data |
{ |
i2c_write(0x00); // There is nothing to prepare, so zero |
} |
} |
#int_EXT // Interrupt from 1PPS (RB0) |
void EXT_isr(void) |
{ |
unsigned int16 countH; |
unsigned int8 countL; |
int16 of2; |
of2=of; // read overflow counter |
countH=get_timer1(); // read internal counter |
countL=0; |
output_low(SEL0); |
output_low(SEL1); |
countL=input(CLKI); // read bit 0 of external counter |
output_high(SEL0); |
// output_low(SEL1); |
countL|=input(CLKI)<<1; // read bit 1 of external counter |
output_low(SEL0); |
output_high(SEL1); |
countL|=input(CLKI)<<2; // read bit 2 of external counter |
output_high(SEL0); |
// output_high(SEL1); |
countL|=input(CLKI)<<3; // read bit 3 of external counter |
output_toggle(LED); // heartbeat |
output_low(MR); // External counter Master Reset |
output_high(MR); |
set_timer1(0); // Internal counter reset |
of=0; // Overflow counter reset |
count=((unsigned int32)of2<<20)+((unsigned int32)countH<<4)+(unsigned int32)countL; // concatenate |
// printf("%010Lu\r\n", count); |
} |
#int_TIMER1 // Interrupf from overflow |
void TIMER1_isr(void) |
{ |
of++; |
} |
void main() |
{ |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
setup_adc(ADC_OFF); |
// setup_spi(SPI_SS_DISABLED); //must not be set if I2C are in use! |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
setup_wdt(WDT_2304MS); |
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1); |
setup_timer_2(T2_DISABLED,0,1); |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
restart_wdt(); |
delay_ms(1000); |
restart_wdt(); |
// setup GPS |
setup_GPS(); |
ext_int_edge( L_TO_H ); // set 1PPS active edge |
enable_interrupts(INT_TIMER1); |
enable_interrupts(INT_EXT); |
enable_interrupts(INT_SSP); |
enable_interrupts(GLOBAL); |
buffer[0]=0x0; // Clear I2C output buffer |
buffer[1]=0x0; |
buffer[2]=0x0; |
buffer[3]=0x0; |
//printf("\r\ncvak...\r\n"); |
fire_setup = 0; |
while(true) |
{ |
restart_wdt(); |
delay_ms(1000); |
if (fire_setup) |
{ |
setup_GPS(); // Write configuration to the GPS |
fire_setup = 0; |
} |
output_toggle(LED); // heartbeat |
//printf("%X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]); |
//printf("%010Lu\r\n", count); |
} |
} |
Property changes: |
Added: svn:keywords |
+Id |
\ No newline at end of property |
/Designs/Measuring_instruments/RMDS02C/SW/PIC16F887/main.hex |
---|
0,0 → 1,89 |
:1000000001308A00C2290000FF00030E8301A10015 |
:100010000A08A0008A010408A2007708A300780853 |
:10002000A4007908A5007A08A600831383120B1E8A |
:100030001B288B1838288C308400001C21280C18B1 |
:100040003B288C308400801D27288C193E282208EC |
:1000500084002308F7002408F8002508F900260882 |
:10006000FA0020088A00210E8300FF0E7F0E09008F |
:100070008A110A12BA288A110A1292298A110A12BE |
:100080004E2813087008930014168C118316141848 |
:100090004728F8018312141AF80A08008316941AE4 |
:1000A00059288312E9018316141D59288312E91770 |
:1000B000831683126908E90AEE006E087F3C031C70 |
:1000C0007D2814138C1D622813081416ED006E0B86 |
:1000D0006B286D08B4006E08023C031D7D28B4082F |
:1000E000031D7728ED08031D77282F147D2837304E |
:1000F0003407840083136D0880006E08803C031D64 |
:100100009B28B408031D8C282B08B0002C08B100D4 |
:100110002D08B2002E08B3003408043C031C9928B3 |
:1001200030303407840083130008EF00F0004120D2 |
:100130009B28F00141206E08813C031DA228310854 |
:10014000F00041206E08823C031DA9283208F0000F |
:1001500041206E08833C031DB0283308F000412085 |
:100160006E08833C0318B628F00141208C118A11D7 |
:100170000A1227283608F1003508F0000F08FA00A7 |
:100180000E08F7000F087A02031DBE287708ED005D |
:100190007A08EE00EF018316091083120910831606 |
:1001A0008910831289102814280883168700831267 |
:1001B000EF010718EF0A8316091083120914281497 |
:1001C0002808831687000030831207180130F700D3 |
:1001D0000310F70D7708EF04831609108312091036 |
:1001E000831689108312891428142808831687001F |
:1001F0000030831207180130F700F70DF70DFC30BF |
:10020000F7057708EF0483160910831209142814E0 |
:100210002808831687000030831207180130F70082 |
:10022000F70DF70DF70DF830F7057708EF04831693 |
:10023000861108308312860683160911831209116C |
:1002400083160911831209158F018E01B601B501BC |
:100250008316A301A2017108A1007008A000210863 |
:10026000A3002008A200A001A101A20DA30DA20DD0 |
:10027000A30DA20DA30DA20DA30DF030A205A801A0 |
:10028000A70183126E088316A60083126D088316D9 |
:10029000A500250DF700260DF800270DF900280D03 |
:1002A000FA00F70DF80DF90DFA0DF70DF80DF90D2F |
:1002B000FA0DF70DF80DF90DFA0DF030F705770886 |
:1002C000A00778080318780FA10779080318790F99 |
:1002D000A2077A0803187A0FA3078312F801F9011D |
:1002E000FA016F08831620078312AB0083162108DA |
:1002F0008312AC0078080318780FAC078316220825 |
:100300008312AD0079080318790FAD07831623080F |
:100310008312AE007A0803187A0FAE078B108A1189 |
:100320000A122728B50A0319B60A0C108A110A12F4 |
:1003300027286B308400831300080319AC2906308A |
:10034000F800F701F70BA229F80BA1297B30F70081 |
:10035000F70BA829800B9F2908003708EB00013014 |
:10036000EA006A086B02031CC12937306A0784005F |
:1003700083130008EC006C080C1EBC299900EA0AE3 |
:10038000B1290800840183131F30830583160317E6 |
:10039000871508300313990002309A00A6309800A0 |
:1003A000903083129800A8152808831687008312BE |
:1003B0002816280883168700A2309300363083124F |
:1003C0009400B401B601B501831603170908C039BA |
:1003D000890003131F129F12003003178800831235 |
:1003E0008701880189010313A701FF30A800A90133 |
:1003F000AA012830B700B530B8006230B900063025 |
:10040000BA003130BB002030BC00BD01BE01BF01CD |
:10041000C001C1013230C200C301C401C501803036 |
:10042000C6009630C7009830C800C901E030CA0045 |
:10043000C830CB001030CC00CD016430CE00CF01ED |
:10044000D001D101D201D301D401D501D601D70108 |
:10045000D801D9017330DA00DB01DC01DD01C630DF |
:10046000DE005130DF00E001E101E201E301E401DF |
:10047000E501E601E701E8010330E900831603170F |
:100480000908C039890003131F129F120030031797 |
:100490008800831203131F1083160108C739083818 |
:1004A000810009308312031785000F30F700031312 |
:1004B00081018130840083130008F03907388000FF |
:1004C00064000008F739F719F03977048000073025 |
:1004D00090000030F80092000030831692008312E2 |
:1004E00003178701880189018316031397016400AC |
:1004F00004308312EA00FA30EB009921EA0B7B2AE0 |
:100500006400AD21831601170C1483120B16831699 |
:100510008C15C03083128B04B001B101B201B3015C |
:100520002F1064000430EA00FA30EB009921EA0B46 |
:10053000942A2F1C9D2AAD212F1083168611083076 |
:0805400083128606912A630074 |
:04400E00EA2CFF3F5A |
:00000001FF |
;PIC16F887 |
;CRC=24C8 CREATED="26-Oct-14 00:32" |
/Designs/Measuring_instruments/RMDS02C/SW/PIC16F887/main.h |
---|
0,0 → 1,21 |
#include <16F887.h> |
#device adc=8 |
#FUSES WDT //Watch Dog Timer |
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD) |
#FUSES PUT //Power Up Timer |
#FUSES MCLR //Master Clear pin enabled |
#FUSES NOPROTECT //Code not protected from reading |
#FUSES NOCPD //No EE protection |
#FUSES NOBROWNOUT //No brownout reset |
#FUSES IESO //Internal External Switch Over mode enabled |
#FUSES FCMEN //Fail-safe clock monitor enabled |
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
#FUSES NODEBUG //No Debug mode for ICD |
#FUSES NOWRT //Program memory not write protected |
#FUSES BORV40 //Brownout reset at 4.0V |
#use delay(clock=20000000) |
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,errors) |