Problem with comparison.
/Designs/Measuring_instruments/ISMS01A/SW/ISMS_read.py
0,0 → 1,113
#!/usr/bin/python
 
#uncomment for debbug purposes
#import logging
#logging.basicConfig(level=logging.DEBUG)
 
import time
import datetime
import sys
import os
 
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 ###########################################
 
cfg = config.Config(
i2c = {
"port": port,
},
bus = [
{
"name": "current_sensor1",
"type": "vcai2c01",
"address": 0x68,
},
{
"name": "current_sensor2",
"type": "vcai2c01",
"address": 0x6a,
},
],
)
cfg.initialize()
 
sys.stdout.write("Current loop sensor example \r\n")
sys.stdout.write("Time, channel #1, channel #2, channel #3 , channel #4, channel #5 \r\n")
sensor1 = cfg.get_device("current_sensor1")
sensor2 = cfg.get_device("current_sensor2")
#time.sleep(0.5)
 
#### Data Logging ###################################################
 
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:
 
sensor1.setADC(channel = 1, gain = 1, sample_rate = 3.75);
time.sleep(0.5)
channel1 = sensor1.readCurrent();
sensor1.setADC(channel = 2, gain = 1, sample_rate = 3.75);
time.sleep(0.5)
channel2 = sensor1.readCurrent();
sensor1.setADC(channel = 3, gain = 1, sample_rate = 3.75);
time.sleep(0.5)
channel3 = sensor1.readCurrent();
sensor1.setADC(channel = 4, gain = 1, sample_rate = 3.75);
time.sleep(0.5)
channel4 = sensor1.readCurrent();
sensor2.setADC(channel = 1, gain = 1, sample_rate = 3.75);
time.sleep(0.5)
channel5 = sensor2.readCurrent();
 
sys.stdout.write("%s \t %0.3f \t %0.3f \t %0.3f \t %0.3f \t %0.3f \n" % (datetime.datetime.now().isoformat(), channel1, channel2, channel3, channel4, channel5))
 
f.write("%d;%0.3f;%0.3f;%0.3f;%0.3f;%0.3f\n" % (time.time(), channel1, channel2, channel3, channel4, channel5))
f.flush()
 
sys.stdout.flush()
before = time.time()
else:
time.sleep(0.1)
 
except KeyboardInterrupt:
f.close()
sys.exit(0)
 
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/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/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/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]