Problem with comparison.
/Designs/Measuring_instruments/ISMS01A/SW/button_monitor.py |
---|
0,0 → 1,82 |
#!/usr/bin/python |
import hid |
import time |
import datetime |
from time import sleep |
import os, sys |
from mlabutils import ejson |
parser = ejson.Parser() |
#### Script Arguments ############################################### |
if len(sys.argv) != 2: |
sys.stderr.write("Invalid number of arguments.\n") |
sys.stderr.write("Usage: %s CONFIG_FILE\n" % (sys.argv[0], )) |
sys.exit(1) |
value = parser.parse_file(sys.argv[1]) |
path = value['data_upload'] |
stationName = value['origin'] |
def main(): |
while True: |
print "Opening device" |
h = hid.device() |
h.open(0x10C4, 0xEA90) |
print "Manufacturer: %s" % h.get_manufacturer_string() |
print "Product: %s" % h.get_product_string() |
print "Serial No: %s" % h.get_serial_number_string() |
h.write([0x02, 0b00000110, 0x00, 0x00, 0x00]) # setup io pin direction |
sleep( 1.00 ) |
response = h.get_feature_report(0x03,2) |
previous_inputs = response[1] |
try: |
while True: |
response = h.get_feature_report(0x03,2) |
inputs = response[1] |
print bin(inputs) |
now = datetime.datetime.now() |
filename = path + time.strftime("%Y%m%d%H", time.gmtime())+"0000_"+stationName+"_meta.csv" |
if not os.path.exists(filename): |
with open(filename, "a") as f: |
f.write('#timestamp,IO_state \n') |
f.write("%.1f,%s\n" % (time.time(), hex(inputs))) |
if (previous_inputs != inputs): |
with open(filename, "a") as f: |
f.write("%.1f,%s\n" % (time.time(), hex(inputs))) |
previous_inputs = inputs |
if not (inputs & 0b00000001) and (0b00000001): |
h.write([0x04, 0x00, 0xFF]) |
time.sleep(0.8) |
h.write([0x04, 0xFF, 0xFF]) |
time.sleep(0.5) |
time.sleep(0.5) |
except IOError, ex: |
print ex |
except KeyboardInterrupt: |
print "Closing device" |
h.close() |
exit() |
print "Done" |
if __name__ == "__main__": |
main() |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/Designs/Measuring_instruments/ISMS01A/SW/Geozor.json |
---|
0,0 → 1,22 |
{ |
"logging": [ |
{ |
"file_name": "/home/odroid/bolidozor/radio-observer.log", |
"log_level": "debug", |
}, |
], |
"project": "geozor", |
"project_home_folder": "/home/odroid/geozor/station/", |
"storage_hostname": "space.astro.cz", |
"storage_username": "kaklik", |
"storage_stationpath": "/storage/geozor/", |
"raw_sample_interval": 5, |
"data_path": "./station/data/", // path to measured data directory |
"data_archive": "/home/odroid/geozor/station/data_archive/", // path to raw data archive directory |
"data_upload": "/home/odroid/geozor/station/data_upload/", // path to data ready for upload |
"origin": "VRTY-S2", // name of detection station |
} |
/Designs/Measuring_instruments/ISMS01A/SW/ISMS_read.py |
---|
0,0 → 1,135 |
#!/usr/bin/python |
#uncomment for debbug purposes |
#import logging |
#logging.basicConfig(level=logging.DEBUG) |
import time |
import datetime |
import sys |
import os |
import minimalmodbus |
from pymlab import config |
from mlabutils import ejson |
parser = ejson.Parser() |
#### Script Arguments ############################################### |
if len(sys.argv) != 3: |
sys.stderr.write("Invalid number of arguments.\n") |
sys.stderr.write("Usage: %s PORT_ADDRESS CONFIG_FILE\n" % (sys.argv[0], )) |
sys.exit(1) |
port = eval(sys.argv[1]) |
value = parser.parse_file(sys.argv[2]) |
path = value['data_path'] |
interval = value['raw_sample_interval'] |
stationName = value['origin'] |
if (interval<5) or (interval>3600): |
sys.stderr.write("Invalid sample interval arguments.\n") |
sys.stderr.write("The interval has to be in the range from 5 to 3600 seconds\n") |
sys.exit(2) |
#### Sensor Configuration ########################################### |
# I2C |
cfg = config.Config( |
i2c = { |
"port": port, |
}, |
bus = [ |
{ |
"name": "current_sensor1", |
"type": "vcai2c01", |
"address": 0x68, |
}, |
], |
) |
cfg.initialize() |
# modbus |
instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1) # port name, slave address (in decimal) |
instrument.serial.port # this is the serial port name |
instrument.serial.baudrate = 9600 # Baud |
instrument.serial.bytesize = 8 |
instrument.serial.stopbits = 2 |
instrument.serial.timeout = 0.5 # seconds |
instrument.mode = minimalmodbus.MODE_RTU # rtu or ascii mode |
sys.stdout.write("Current loop and modbus sensor example \r\n") |
sys.stdout.write("Time, water-level, temp1, conduc, salinity, tds_kcl, temp2, pH, redox \r\n") |
#sys.stdout.write("Time, channel #1, channel #2, channel #3 , channel #4, channel #5 channel #6 , channel #7, channel #8 \r\n") |
sensor1 = cfg.get_device("current_sensor1") |
#time.sleep(0.5) |
#### Data Logging ################################################### |
while True: |
try: |
before = time.time()-interval |
while True: |
filename = path + time.strftime("%Y%m%d%H", time.gmtime()) +"0000_"+ stationName + "_data.csv" |
now = time.time() |
if (now - before >= interval - 2.5): # 0.5*5 channels= 2.5s |
with open(filename, "a") as f: |
##Measuremment settings |
sensor1.setADC(channel = 1, gain = 1, sample_rate = 3.75); |
instrument.address = 0x1E # this is the slave address number (1E-conductivity) |
instrument.write_register(0x01, 0x1F, 0) # Registernumber, value, number of decimals for storage |
instrument.address = 0x14 # this is the slave address number (14 - pH) |
instrument.write_register(0x01, 0x1F, 0) # Registernumber, value, number of decimals for storage |
time.sleep(0.5) |
##Reading |
## Read data from analog sensors ## |
channel1 = sensor1.readCurrent(); |
channel1 = 0.2488*channel1-0.8892; # transformation from mA to meters |
## Read data from conductivity sensor ## |
instrument.address = 0x1E # this is the slave address number (1E-conductivity) |
temperature1 = instrument.read_float(0x53, 3, 2) # Registernumber, number of decimals |
conductivity = instrument.read_float(0x55, 3, 2) # Registernumber, number of decimals |
salinity = instrument.read_float(0x57, 3, 2) # Registernumber, number of decimals |
tds_kcl = instrument.read_float(0x59, 3, 2) # Registernumber, number of decimals |
## Read data from pH sensor ## |
instrument.address = 0x14 # this is the slave address number (14 - pH) |
temperature2 = instrument.read_float(0x53, 3, 2) # Registernumber, number of decimals |
pH = instrument.read_float(0x55, 3, 2) # Registernumber, number of decimals |
redox = instrument.read_float(0x57, 3, 2) # Registernumber, number of decimals |
sys.stdout.write("%s \t %0.3f \t %0.3f \t %0.3f \t %0.3f \t %0.3f \t %0.3f \t %0.3f \t %0.3f \t \n" % (datetime.datetime.now().isoformat(), channel1, temperature1, conductivity, salinity, tds_kcl, temperature2, pH, redox)) |
f.write("%d;%0.3f;%0.3f;%0.3f;%0.3f;%0.3f;%0.3f;%0.3f;%0.3f\n" % (time.time(), channel1, temperature1, conductivity, salinity, tds_kcl, temperature2, pH, redox)) |
f.flush() |
sys.stdout.flush() |
before = time.time() |
else: |
time.sleep(0.1) |
except KeyboardInterrupt: |
f.close() |
sys.exit(0) |
except Exception as e: |
sys.stdout.write(e) |
time.sleep(5) |
/Designs/Measuring_instruments/ISMS01A/SW/modbus_test.py |
---|
0,0 → 1,32 |
#!/usr/bin/env python |
import minimalmodbus |
import time |
instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1) # port name, slave address (in decimal) |
instrument.serial.port # this is the serial port name |
instrument.serial.baudrate = 9600 # Baud |
instrument.serial.bytesize = 8 |
instrument.serial.stopbits = 2 |
instrument.serial.timeout = 0.5 # seconds |
instrument.address = 0x1E # this is the slave address number |
instrument.mode = minimalmodbus.MODE_RTU # rtu or ascii mode |
instrument.write_register(0x01, 0x1F, 0) # Registernumber, value, number of decimals for storage |
time.sleep(0.5) |
## Read temperature (PV = ProcessValue) ## |
temperature = instrument.read_float(0x53, 3, 2) # Registernumber, number of decimals |
print temperature |
conductivity = instrument.read_float(0x55, 3, 2) # Registernumber, number of decimals |
print conductivity |
salinity = instrument.read_float(0x57, 3, 2) # Registernumber, number of decimals |
print salinity |
tds_kcl = instrument.read_float(0x59, 3, 2) # Registernumber, number of decimals |
print tds_kcl |
## Change temperature setpoint (SP) ## |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/Designs/Measuring_instruments/ISMS01A/DOC/SRC/img/box_base.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/Designs/Measuring_instruments/ISMS01A/DOC/SRC/ISMS01A.html.in |
---|
0,0 → 1,26 |
<html> |
<head> |
<meta charset=utf-8/> |
<link rel="stylesheet" type="text/css" href="/home/ondra6ak/Documents/mlabgen/style.css"> |
<title> |
Mlab|$HumanName |
</title> |
<script type="text/x-mathjax-config"> |
MathJax.Hub.Config({extensions: ["asciimath2jax.js"], |
jax: ["input/AsciiMath", "output/CommonHTML"], |
asciimath2jax: {delimiters: [['$M','M$']]}, |
CommonHTML: {mtextFontInherit: true}, |
showProcessingMessages: false, |
messageStyle: "none", |
showMathMenu: false}); |
</script> |
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script> |
</head> |
</head> |
<body> |
$Text |
</body> |
</html> |
/Designs/Measuring_instruments/ISMS01A/DOC/SRC/ISMS01A.md.in |
---|
0,0 → 1,37 |
$HumanName |
========== |
Brought to you by: $Author |
$Descr |
Specifications |
-------------- |
Specification | Value | Unit | Note |
----------------- | ------------- | ---- | -------------- |
Operating Voltage | | V | |
Power Consumption | | mA | |
Dimensions | $Dimensions | mm | width x length |
Description |
----------- |
!9.9;9.9;287.1;200.1;!(../SCH_PCB/${Module}_SCH.svg) |
Mechanical construction |
----------------------- |
Component placement |
------------------- |
![PCB top](../../CAM_AMA/${Module}_TOP.svg "Top side of a PCB") ![PCB bottom](../../CAM_AMA/${Module}_BOT.svg "Bottom side of a PCB") |
$bom |
First power up |
-------------- |
Programming |
---------- |
/Designs/Measuring_instruments/ISMS01A/AMF/box_base.stl |
---|
0,0 → 1,338 |
solid OpenSCAD_Model |
facet normal -1 0 0 |
outer loop |
vertex 0 0 0 |
vertex 0 90 44.22 |
vertex 0 90 0 |
endloop |
endfacet |
facet normal -1 -0 0 |
outer loop |
vertex 0 90 44.22 |
vertex 0 0 0 |
vertex 0 0 44.22 |
endloop |
endfacet |
facet normal 0 0 1 |
outer loop |
vertex 100 90 44.22 |
vertex 90 80 44.22 |
vertex 100 0 44.22 |
endloop |
endfacet |
facet normal 0 0 1 |
outer loop |
vertex 100 90 44.22 |
vertex 10 80 44.22 |
vertex 90 80 44.22 |
endloop |
endfacet |
facet normal 0 0 1 |
outer loop |
vertex 10 80 44.22 |
vertex 0 90 44.22 |
vertex 10 10 44.22 |
endloop |
endfacet |
facet normal -0 0 1 |
outer loop |
vertex 0 90 44.22 |
vertex 10 80 44.22 |
vertex 100 90 44.22 |
endloop |
endfacet |
facet normal -0 0 1 |
outer loop |
vertex 90 10 44.22 |
vertex 100 0 44.22 |
vertex 90 80 44.22 |
endloop |
endfacet |
facet normal 0 0 1 |
outer loop |
vertex 55 0 44.22 |
vertex 90 10 44.22 |
vertex 55 10 44.22 |
endloop |
endfacet |
facet normal 0 0 1 |
outer loop |
vertex 90 10 44.22 |
vertex 55 0 44.22 |
vertex 100 0 44.22 |
endloop |
endfacet |
facet normal -0 0 1 |
outer loop |
vertex 10 10 44.22 |
vertex 45 0 44.22 |
vertex 45 10 44.22 |
endloop |
endfacet |
facet normal 0 0 1 |
outer loop |
vertex 10 10 44.22 |
vertex 0 0 44.22 |
vertex 45 0 44.22 |
endloop |
endfacet |
facet normal 0 0 1 |
outer loop |
vertex 0 0 44.22 |
vertex 10 10 44.22 |
vertex 0 90 44.22 |
endloop |
endfacet |
facet normal 1 -0 0 |
outer loop |
vertex 100 0 44.22 |
vertex 100 90 0 |
vertex 100 90 44.22 |
endloop |
endfacet |
facet normal 1 0 0 |
outer loop |
vertex 100 90 0 |
vertex 100 0 44.22 |
vertex 100 0 0 |
endloop |
endfacet |
facet normal 0 1 -0 |
outer loop |
vertex 100 90 0 |
vertex 0 90 44.22 |
vertex 100 90 44.22 |
endloop |
endfacet |
facet normal 0 1 0 |
outer loop |
vertex 0 90 44.22 |
vertex 100 90 0 |
vertex 0 90 0 |
endloop |
endfacet |
facet normal 0 0 -1 |
outer loop |
vertex 100 0 0 |
vertex 90 10 0 |
vertex 100 90 0 |
endloop |
endfacet |
facet normal 0 0 -1 |
outer loop |
vertex 100 0 0 |
vertex 10 10 0 |
vertex 90 10 0 |
endloop |
endfacet |
facet normal -0 0 -1 |
outer loop |
vertex 10 10 0 |
vertex 0 0 0 |
vertex 10 80 0 |
endloop |
endfacet |
facet normal 0 0 -1 |
outer loop |
vertex 0 0 0 |
vertex 10 10 0 |
vertex 100 0 0 |
endloop |
endfacet |
facet normal 0 0 -1 |
outer loop |
vertex 90 80 0 |
vertex 100 90 0 |
vertex 90 10 0 |
endloop |
endfacet |
facet normal 0 0 -1 |
outer loop |
vertex 10 80 0 |
vertex 100 90 0 |
vertex 90 80 0 |
endloop |
endfacet |
facet normal 0 0 -1 |
outer loop |
vertex 10 80 0 |
vertex 0 90 0 |
vertex 100 90 0 |
endloop |
endfacet |
facet normal 0 0 -1 |
outer loop |
vertex 0 90 0 |
vertex 10 80 0 |
vertex 0 0 0 |
endloop |
endfacet |
facet normal 0 -1 0 |
outer loop |
vertex 0 0 44.22 |
vertex 45 0 10 |
vertex 45 0 44.22 |
endloop |
endfacet |
facet normal 0 -1 -0 |
outer loop |
vertex 45 0 10 |
vertex 0 0 0 |
vertex 55 0 10 |
endloop |
endfacet |
facet normal 0 -1 0 |
outer loop |
vertex 0 0 0 |
vertex 45 0 10 |
vertex 0 0 44.22 |
endloop |
endfacet |
facet normal 0 -1 0 |
outer loop |
vertex 55 0 10 |
vertex 100 0 44.22 |
vertex 55 0 44.22 |
endloop |
endfacet |
facet normal 0 -1 0 |
outer loop |
vertex 55 0 10 |
vertex 100 0 0 |
vertex 100 0 44.22 |
endloop |
endfacet |
facet normal 0 -1 0 |
outer loop |
vertex 100 0 0 |
vertex 55 0 10 |
vertex 0 0 0 |
endloop |
endfacet |
facet normal 1 -0 0 |
outer loop |
vertex 10 10 44.22 |
vertex 10 80 0 |
vertex 10 80 44.22 |
endloop |
endfacet |
facet normal 1 0 0 |
outer loop |
vertex 10 80 0 |
vertex 10 10 44.22 |
vertex 10 10 0 |
endloop |
endfacet |
facet normal -1 0 0 |
outer loop |
vertex 90 10 0 |
vertex 90 80 44.22 |
vertex 90 80 0 |
endloop |
endfacet |
facet normal -1 -0 0 |
outer loop |
vertex 90 80 44.22 |
vertex 90 10 0 |
vertex 90 10 44.22 |
endloop |
endfacet |
facet normal 0 -1 0 |
outer loop |
vertex 10 80 0 |
vertex 90 80 44.22 |
vertex 10 80 44.22 |
endloop |
endfacet |
facet normal 0 -1 -0 |
outer loop |
vertex 90 80 44.22 |
vertex 10 80 0 |
vertex 90 80 0 |
endloop |
endfacet |
facet normal 0 1 0 |
outer loop |
vertex 90 10 44.22 |
vertex 55 10 10 |
vertex 55 10 44.22 |
endloop |
endfacet |
facet normal 0 1 0 |
outer loop |
vertex 55 10 10 |
vertex 90 10 0 |
vertex 45 10 10 |
endloop |
endfacet |
facet normal 0 1 -0 |
outer loop |
vertex 90 10 0 |
vertex 55 10 10 |
vertex 90 10 44.22 |
endloop |
endfacet |
facet normal 0 1 -0 |
outer loop |
vertex 45 10 10 |
vertex 10 10 44.22 |
vertex 45 10 44.22 |
endloop |
endfacet |
facet normal 0 1 0 |
outer loop |
vertex 45 10 10 |
vertex 10 10 0 |
vertex 10 10 44.22 |
endloop |
endfacet |
facet normal 0 1 0 |
outer loop |
vertex 10 10 0 |
vertex 45 10 10 |
vertex 90 10 0 |
endloop |
endfacet |
facet normal 1 -0 0 |
outer loop |
vertex 45 0 44.22 |
vertex 45 10 10 |
vertex 45 10 44.22 |
endloop |
endfacet |
facet normal 1 0 0 |
outer loop |
vertex 45 10 10 |
vertex 45 0 44.22 |
vertex 45 0 10 |
endloop |
endfacet |
facet normal -1 0 0 |
outer loop |
vertex 55 0 10 |
vertex 55 10 44.22 |
vertex 55 10 10 |
endloop |
endfacet |
facet normal -1 -0 0 |
outer loop |
vertex 55 10 44.22 |
vertex 55 0 10 |
vertex 55 0 44.22 |
endloop |
endfacet |
facet normal -0 0 1 |
outer loop |
vertex 45 10 10 |
vertex 55 0 10 |
vertex 55 10 10 |
endloop |
endfacet |
facet normal 0 0 1 |
outer loop |
vertex 55 0 10 |
vertex 45 10 10 |
vertex 45 0 10 |
endloop |
endfacet |
endsolid OpenSCAD_Model |
/Designs/Measuring_instruments/ISMS01A/CAD/box_base.scad |
---|
0,0 → 1,61 |
module body() { |
color("Red") cube([100,90,44.22]); |
} |
module innerFrame() { |
color("Red") cube([80,70,60]); |
} |
module smallFrame() { |
color("Red") cube([10,20,60]); |
} |
module bushing() { |
cylinder (h = 23.31, r=12.5, center = true, $fn=100); |
} |
module box() { |
color("grey") cube([90.33,120,160.4]); |
} |
module completeBox() { |
union(){ |
box(); |
translate([30,60,-11.65]) bushing(); |
} |
} |
module zip() { |
color("black") cube([2,60,160.4]); |
} |
module boxes() { |
union(){ |
mirror([1,0,0]) translate([-90.33,0,0]) completeBox(); |
translate([90.33,30,0]) zip(); |
mirror([1,0,0]) translate([-182.66,0,0]) completeBox(); |
translate([182.66,30,0]) zip(); |
translate([184.66,0,0]) completeBox(); |
} |
} |
module base(){ |
difference() { |
body(); |
translate([10,10,-5]) innerFrame(); |
translate([45,-5,10]) smallFrame(); |
} |
} |
//translate([15,9,0]) |
base(); |
//translate([169.99,9,0]) |
//base(); |
//translate([0,0,44.22]) |
//translate([0,0,50]) |
//boxes(); |
/Designs/Measuring_instruments/ISMS01A/CAD/small_panel.scad |
---|
0,0 → 1,37 |
height = 1.5; |
module body() { |
translate([2,2,0]) |
minkowski() |
{ |
$fn=30; |
color("Red") cube([110-4,55-4,height/2]); |
cylinder(r=2,h=height/2); |
} |
} |
module bigFrame() { |
color("Red") cube([53,18,10]); |
} |
module smallFrame() { |
color("Red") cube([18,14,10]); |
} |
module hole() { |
color("blue") cylinder($fn=10, h=10, r=1.6); |
} |
module object(){ |
difference() { |
body(); |
translate([10,17,-5]) bigFrame(); |
translate([77,10,-5]) smallFrame(); |
translate([4,4,-5]) hole(); |
translate([4,51,-5]) hole(); |
translate([106,4,-5]) hole(); |
translate([106,51,-5]) hole(); |
} |
} |
object(); |
/Designs/Measuring_instruments/ISMS01A/SCH/Industrial_sensors_Measurement_System.dia |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/Designs/Measuring_instruments/ISMS01A/SCH/Industrial_sensors_Measurement_System.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/Designs/Measuring_instruments/ISMS01A/Makefile |
---|
0,0 → 1,8 |
TARGETS = DOC/$(MODULE).html \ |
DOC/SRC/$(MODULE).md \ |
PrjInfo.txt \ |
DOC/$(MODULE).pdf |
MATHJAX = /home/ondra6ak/Documents/MathJax/MathJax.js |
include mlabgen.mk |
/Designs/Measuring_instruments/ISMS01A/PrjInfo.txt |
---|
0,0 → 1,15 |
[InfoShortDescription.en] |
Industrial Sensors Measurement System |
[InfoShortDescription.cs] |
Měřící systém pro průmyslové senzory |
[InfoLongDescription.en] |
This device can be used for connecting a standard current-loop or analog-voltage output industrial sensors. The instrument contains a computer which digitalizes the measured data and allows transmision over Ethernet interface. |
[InfoLongDescription.cs] |
Zařízení může být využito pro připojení standardních průmyslových čidel s analogovým napěťovým výstupem, nebo proudovou smyčkou. Konstrukce obsahuje počítač, který digitalizuje měřená data a umožňuje jejich přenos přes Ethernet rozhraní. |
[InfoBuyUST] |
[End] |
/Designs/Measuring_instruments/ISMS01A/PrjInfo.txt.in |
---|
0,0 → 1,13 |
[HumanName] |
Human friendly name of the module |
[BuyLinkTindie] |
Link to module's page on Tindie. |
[BuyLinkUST] |
Link to module's page on Universal Scientific Technologies. |
[Dev] |
True |
[End] |