max31856 0.1.1 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +1 -69
- data/README.md +15 -4
- data/lib/max31856.rb +54 -11
- data/lib/max31856/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16f3ee8981f76eb1e557cdddcf157c45af6d4a9d4089272fd9d2047f7ad93697
|
4
|
+
data.tar.gz: d933e69b6a4e7639ab973597655913fc67a443035bb2f56338738c7fb27940a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af6f60484be2142230a3e68fe4846f57798b8beb7f06470550711d3c10f6c23261373b9b3db3428afe140c576b777ed2fe7df64e9ccf9a89424b3846c9859b14
|
7
|
+
data.tar.gz: 5c11739f21fe88af3e3f4f266eebd3d8f4ccd29b307087b7821d684a8ee4c3c51d28abc92183554af71a09c8b672f3936b9adf16032192d8d15363443ce69196
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,74 +1,6 @@
|
|
1
1
|
# Contributor Covenant Code of Conduct
|
2
2
|
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
3
|
|
12
4
|
## Our Standards
|
13
5
|
|
14
|
-
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at x@nofxx.com. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: http://contributor-covenant.org
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
6
|
+
Do what the fuck you want to.
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
MAX31856 - Precision Thermocouple to Digital Converter with Linearization
|
4
4
|
|
5
|
-
SPI interface using PiPiper
|
5
|
+
Ruby SPI interface using PiPiper
|
6
6
|
|
7
7
|
|
8
8
|
## Installation
|
@@ -21,11 +21,22 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
$ gem install max31856
|
23
23
|
|
24
|
+
|
24
25
|
## Usage
|
25
26
|
|
26
|
-
m = MAX31856.new(chip = 0, clock = 2_000_000)
|
27
|
-
|
28
|
-
m.
|
27
|
+
m = MAX31856.new(chip = 0, type = :k, clock = 2_000_000)
|
28
|
+
|
29
|
+
m.config # Must be run once (shutdown resets chip)
|
30
|
+
|
31
|
+
m.read # [Cold Junction Temp, Thermocouple Temp] Floats in celsius
|
32
|
+
|
33
|
+
|
34
|
+
## Raspberry v3
|
35
|
+
|
36
|
+
To enable SPI on the Rpi, on `/boot/config.txt`:
|
37
|
+
|
38
|
+
dtparam=spi=on
|
39
|
+
|
29
40
|
|
30
41
|
## Development
|
31
42
|
|
data/lib/max31856.rb
CHANGED
@@ -12,23 +12,24 @@ class MAX31856
|
|
12
12
|
# Cold-Junction Temperature Data Resolution
|
13
13
|
CJ_RES = 0.015625
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
# Read registers
|
16
|
+
REG_CJ = 0x08 # Cold Junction status register
|
17
|
+
REG_TC = 0x0c # Thermocouple status register
|
17
18
|
REG_FAULT = 0x0F # Fault status register
|
18
19
|
|
19
20
|
#
|
20
21
|
# Config Register 1
|
21
22
|
# ------------------
|
22
|
-
# bit 7: Conversion Mode ->
|
23
|
-
# bit 6: 1-shot ->
|
23
|
+
# bit 7: Conversion Mode -> 1 (Normally Off Mode)
|
24
|
+
# bit 6: 1-shot -> 0 (off)
|
24
25
|
# bit 5: open-circuit fault detection -> 0 (off)
|
25
|
-
# bit 4: open-circuit fault detection
|
26
|
-
# bit 3: Cold-junction
|
26
|
+
# bit 4: open-circuit fault detection type k -> 1 (on)
|
27
|
+
# bit 3: Cold-junction sensor disabled -> 0 (default)
|
27
28
|
# bit 2: Fault Mode -> 0 (default)
|
28
29
|
# bit 1: fault status clear -> 1 (clear any fault)
|
29
30
|
# bit 0: 50/60 Hz filter select -> 0 (60Hz)
|
30
31
|
#
|
31
|
-
REG_1 = [0x00,
|
32
|
+
REG_1 = [0x00, 0b10010010].freeze
|
32
33
|
|
33
34
|
#
|
34
35
|
# Config Register 2
|
@@ -44,6 +45,20 @@ class MAX31856
|
|
44
45
|
#
|
45
46
|
REG_2 = 0x01
|
46
47
|
|
48
|
+
#
|
49
|
+
# Config Register 2
|
50
|
+
# ------------------
|
51
|
+
# bit 7: Nil
|
52
|
+
# bit 6: Nil
|
53
|
+
# bit 5: Cold-Junction High Fault Threshold -> 0 (default)
|
54
|
+
# bit 4: Cold-Junction Low Fault Threshold -> 0 (default)
|
55
|
+
# bit 3: Thermocouple Temperature High Fault Threshold -> 0 (default)
|
56
|
+
# bit 2: Thermocouple Temperature Low Fault Threshold -> 0 (default)
|
57
|
+
# bit 1: Over-voltage or Undervoltage Input Fault -> 1 (default)
|
58
|
+
# bit 0: Thermocouple Open-Circuit Fault -> 1 (default)
|
59
|
+
#
|
60
|
+
REG_3 = [0x02, 0b11111100].freeze
|
61
|
+
|
47
62
|
TYPES = {
|
48
63
|
b: 0x00,
|
49
64
|
e: 0x01,
|
@@ -99,14 +114,36 @@ class MAX31856
|
|
99
114
|
end
|
100
115
|
end
|
101
116
|
|
102
|
-
|
117
|
+
#
|
118
|
+
# Run once config
|
119
|
+
#
|
120
|
+
# CR1_AVERAGE_1_SAMPLE 0x00
|
121
|
+
# CR1_AVERAGE_2_SAMPLES 0x10
|
122
|
+
# CR1_AVERAGE_4_SAMPLES 0x20
|
123
|
+
# CR1_AVERAGE_8_SAMPLES 0x30
|
124
|
+
# CR1_AVERAGE_16_SAMPLES 0x40
|
125
|
+
#
|
126
|
+
# define CR1_VOLTAGE_MODE_GAIN_8 0x08
|
127
|
+
# define CR1_VOLTAGE_MODE_GAIN_32 0x0C
|
128
|
+
#
|
129
|
+
# Optionally set samples
|
130
|
+
def config(samples = 0x10)
|
103
131
|
spi_work do |spi|
|
104
|
-
spi.write(
|
105
|
-
spi.write(
|
132
|
+
spi.write(write_reg(REG_1))
|
133
|
+
spi.write(write_reg([REG_2, (samples | type)]))
|
134
|
+
spi.write(write_reg(REG_3))
|
106
135
|
end
|
107
|
-
sleep
|
136
|
+
sleep 0.2 # give it 200ms for conversion
|
108
137
|
end
|
109
138
|
|
139
|
+
# Set 0x80 on first for writes
|
140
|
+
def write_reg(ary)
|
141
|
+
ary[1..-1].unshift(ary[0] | 0x80)
|
142
|
+
end
|
143
|
+
|
144
|
+
#
|
145
|
+
# Read both
|
146
|
+
#
|
110
147
|
def read
|
111
148
|
tc = cj = 0
|
112
149
|
spi_work do |spi|
|
@@ -117,6 +154,9 @@ class MAX31856
|
|
117
154
|
[tc, cj]
|
118
155
|
end
|
119
156
|
|
157
|
+
#
|
158
|
+
# Read cold-junction
|
159
|
+
#
|
120
160
|
def read_cj(raw)
|
121
161
|
lb, mb, _offset = raw.reverse # Offset already on sum
|
122
162
|
# MSB << 8 | LSB and remove last 2
|
@@ -129,6 +169,9 @@ class MAX31856
|
|
129
169
|
temp * CJ_RES
|
130
170
|
end
|
131
171
|
|
172
|
+
#
|
173
|
+
# Read thermocouple
|
174
|
+
#
|
132
175
|
def read_tc(raw)
|
133
176
|
fault, lb, mb, hb = raw.reverse
|
134
177
|
FAULTS.each do |f, txt|
|
data/lib/max31856/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: max31856
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos Piccinini
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pi_piper
|