node-red-contrib-periph-adc-dac 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,158 @@
1
+ [
2
+ {
3
+ "id": "tab-cs43l22-demo",
4
+ "type": "tab",
5
+ "label": "CS43L22 Headphone Demo",
6
+ "disabled": false,
7
+ "info": "Headphone amplifier bring-up with a CS43L22 stereo DAC. The audio stream (MCLK, SCLK, LRCK, SDIN) comes from the board's I2S master; Node-RED only drives the control port. An Inject node sends {start: true} once (MCLK must already be running), a second Inject ticks every 5 s into a Function node that steps the master volume 0 -> -30 dB -> 0 in 2 dB steps, a third sends a single-beep command, and a Debug node shows the volume and the status register read back (reading the status clears its flags). A fourth Inject sends {stop: true} for the power-down sequence."
8
+ },
9
+ {
10
+ "id": "inj-start",
11
+ "type": "inject",
12
+ "name": "Start (once)",
13
+ "topic": "",
14
+ "payload": "{\"start\":true}",
15
+ "payloadType": "json",
16
+ "repeat": "",
17
+ "crontab": "",
18
+ "once": true,
19
+ "onceDelay": 0.5,
20
+ "z": "tab-cs43l22-demo",
21
+ "x": 150,
22
+ "y": 60,
23
+ "wires": [
24
+ [
25
+ "cs43l22-node"
26
+ ]
27
+ ]
28
+ },
29
+ {
30
+ "id": "inj-tick",
31
+ "type": "inject",
32
+ "name": "Volume tick (5 s)",
33
+ "topic": "",
34
+ "payload": "",
35
+ "payloadType": "date",
36
+ "repeat": "5",
37
+ "crontab": "",
38
+ "once": false,
39
+ "onceDelay": 0.5,
40
+ "z": "tab-cs43l22-demo",
41
+ "x": 150,
42
+ "y": 120,
43
+ "wires": [
44
+ [
45
+ "fn-ramp"
46
+ ]
47
+ ]
48
+ },
49
+ {
50
+ "id": "fn-ramp",
51
+ "type": "function",
52
+ "name": "volume ramp",
53
+ "func": "// 0, -2 ... -30 dB, then back up, then wrap.\nlet i = context.get('step') || 0;\ncontext.set('step', (i + 1) % 30);\nconst db = i <= 15 ? -i * 2 : -(30 - i) * 2;\nmsg.payload = { volume: db };\nreturn msg;",
54
+ "outputs": 1,
55
+ "noerr": 0,
56
+ "z": "tab-cs43l22-demo",
57
+ "x": 350,
58
+ "y": 120,
59
+ "wires": [
60
+ [
61
+ "cs43l22-node"
62
+ ]
63
+ ]
64
+ },
65
+ {
66
+ "id": "inj-beep",
67
+ "type": "inject",
68
+ "name": "Beep",
69
+ "topic": "",
70
+ "payload": "{\"beep\":{\"frequency\":1,\"onTime\":2,\"offTime\":0,\"volume\":-6,\"mode\":1}}",
71
+ "payloadType": "json",
72
+ "repeat": "",
73
+ "crontab": "",
74
+ "once": false,
75
+ "onceDelay": 0.5,
76
+ "z": "tab-cs43l22-demo",
77
+ "x": 150,
78
+ "y": 180,
79
+ "wires": [
80
+ [
81
+ "cs43l22-node"
82
+ ]
83
+ ]
84
+ },
85
+ {
86
+ "id": "inj-read",
87
+ "type": "inject",
88
+ "name": "Read back",
89
+ "topic": "",
90
+ "payload": "",
91
+ "payloadType": "date",
92
+ "repeat": "",
93
+ "crontab": "",
94
+ "once": false,
95
+ "onceDelay": 0.5,
96
+ "z": "tab-cs43l22-demo",
97
+ "x": 150,
98
+ "y": 240,
99
+ "wires": [
100
+ [
101
+ "cs43l22-node"
102
+ ]
103
+ ]
104
+ },
105
+ {
106
+ "id": "inj-stop",
107
+ "type": "inject",
108
+ "name": "Stop",
109
+ "topic": "",
110
+ "payload": "{\"stop\":true}",
111
+ "payloadType": "json",
112
+ "repeat": "",
113
+ "crontab": "",
114
+ "once": false,
115
+ "onceDelay": 0.5,
116
+ "z": "tab-cs43l22-demo",
117
+ "x": 150,
118
+ "y": 300,
119
+ "wires": [
120
+ [
121
+ "cs43l22-node"
122
+ ]
123
+ ]
124
+ },
125
+ {
126
+ "id": "cs43l22-node",
127
+ "type": "periph-cs43l22",
128
+ "z": "tab-cs43l22-demo",
129
+ "name": "CS43L22",
130
+ "bus": "1",
131
+ "address": "0x4A",
132
+ "gpioChip": "0",
133
+ "resGpio": "",
134
+ "format": "i2s",
135
+ "x": 580,
136
+ "y": 150,
137
+ "wires": [
138
+ [
139
+ "dbg-out"
140
+ ]
141
+ ]
142
+ },
143
+ {
144
+ "id": "dbg-out",
145
+ "type": "debug",
146
+ "z": "tab-cs43l22-demo",
147
+ "name": "volume + status",
148
+ "active": true,
149
+ "tosidebar": true,
150
+ "console": false,
151
+ "tostatus": false,
152
+ "complete": "payload",
153
+ "targetType": "msg",
154
+ "x": 820,
155
+ "y": 150,
156
+ "wires": []
157
+ }
158
+ ]
@@ -0,0 +1,158 @@
1
+ [
2
+ {
3
+ "id": "tab-ds1881-demo",
4
+ "type": "tab",
5
+ "label": "DS1881 Volume Demo",
6
+ "disabled": false,
7
+ "info": "Stereo volume control with a DS1881 dual audio potentiometer. An Inject node ticks every 200 ms into a Function node that ramps the attenuation from 0 dB to 40 dB in 2 dB steps and back; the periph-ds1881 node sets both channels and returns {position0, position1, db0, db1}, which a Debug node shows. Two more Inject nodes send {mute: true} and {mute: false} (the last volume is restored on unmute), a third reads back both channels with the configuration, and a fourth sends {store: true} to persist the positions to EEPROM (the chip is rated for only 50 000 writes, so leave that one alone unless needed). The wipers are volatile by default, so after a power cycle both channels start muted until the ramp runs."
8
+ },
9
+ {
10
+ "id": "inj-ramp",
11
+ "type": "inject",
12
+ "name": "Ramp tick (200 ms)",
13
+ "topic": "",
14
+ "payload": "",
15
+ "payloadType": "date",
16
+ "repeat": "0.2",
17
+ "crontab": "",
18
+ "once": true,
19
+ "onceDelay": 0.5,
20
+ "z": "tab-ds1881-demo",
21
+ "x": 150,
22
+ "y": 100,
23
+ "wires": [
24
+ [
25
+ "fn-ramp"
26
+ ]
27
+ ]
28
+ },
29
+ {
30
+ "id": "fn-ramp",
31
+ "type": "function",
32
+ "name": "volume ramp",
33
+ "func": "// 0, 2 ... 40 dB, then back down to 2 dB, then wrap.\nlet i = context.get('step') || 0;\ncontext.set('step', (i + 1) % 40);\nconst db = i <= 20 ? i * 2 : (40 - i) * 2;\nmsg.payload = { db: db };\nreturn msg;",
34
+ "outputs": 1,
35
+ "noerr": 0,
36
+ "z": "tab-ds1881-demo",
37
+ "x": 350,
38
+ "y": 100,
39
+ "wires": [
40
+ [
41
+ "ds1881-node"
42
+ ]
43
+ ]
44
+ },
45
+ {
46
+ "id": "inj-mute",
47
+ "type": "inject",
48
+ "name": "Mute",
49
+ "topic": "",
50
+ "payload": "{\"mute\":true}",
51
+ "payloadType": "json",
52
+ "repeat": "",
53
+ "crontab": "",
54
+ "once": false,
55
+ "onceDelay": 0.1,
56
+ "z": "tab-ds1881-demo",
57
+ "x": 160,
58
+ "y": 180,
59
+ "wires": [
60
+ [
61
+ "ds1881-node"
62
+ ]
63
+ ]
64
+ },
65
+ {
66
+ "id": "inj-unmute",
67
+ "type": "inject",
68
+ "name": "Unmute",
69
+ "topic": "",
70
+ "payload": "{\"mute\":false}",
71
+ "payloadType": "json",
72
+ "repeat": "",
73
+ "crontab": "",
74
+ "once": false,
75
+ "onceDelay": 0.1,
76
+ "z": "tab-ds1881-demo",
77
+ "x": 160,
78
+ "y": 240,
79
+ "wires": [
80
+ [
81
+ "ds1881-node"
82
+ ]
83
+ ]
84
+ },
85
+ {
86
+ "id": "inj-read",
87
+ "type": "inject",
88
+ "name": "Read back",
89
+ "topic": "",
90
+ "payload": "",
91
+ "payloadType": "date",
92
+ "repeat": "",
93
+ "crontab": "",
94
+ "once": false,
95
+ "onceDelay": 0.1,
96
+ "z": "tab-ds1881-demo",
97
+ "x": 160,
98
+ "y": 300,
99
+ "wires": [
100
+ [
101
+ "ds1881-node"
102
+ ]
103
+ ]
104
+ },
105
+ {
106
+ "id": "inj-store",
107
+ "type": "inject",
108
+ "name": "Store to EEPROM",
109
+ "topic": "",
110
+ "payload": "{\"store\":true}",
111
+ "payloadType": "json",
112
+ "repeat": "",
113
+ "crontab": "",
114
+ "once": false,
115
+ "onceDelay": 0.1,
116
+ "z": "tab-ds1881-demo",
117
+ "x": 160,
118
+ "y": 360,
119
+ "wires": [
120
+ [
121
+ "ds1881-node"
122
+ ]
123
+ ]
124
+ },
125
+ {
126
+ "id": "ds1881-node",
127
+ "type": "periph-ds1881",
128
+ "name": "DS1881",
129
+ "bus": "1",
130
+ "option": "1",
131
+ "zerocrossing": true,
132
+ "nonvolatile": false,
133
+ "z": "tab-ds1881-demo",
134
+ "x": 560,
135
+ "y": 140,
136
+ "wires": [
137
+ [
138
+ "dbg-ds1881"
139
+ ]
140
+ ],
141
+ "address": "0x28"
142
+ },
143
+ {
144
+ "id": "dbg-ds1881",
145
+ "type": "debug",
146
+ "name": "positions / dB",
147
+ "active": true,
148
+ "tosidebar": true,
149
+ "console": false,
150
+ "tostatus": false,
151
+ "complete": "payload",
152
+ "targetType": "msg",
153
+ "z": "tab-ds1881-demo",
154
+ "x": 780,
155
+ "y": 140,
156
+ "wires": []
157
+ }
158
+ ]
@@ -0,0 +1,137 @@
1
+ [
2
+ {
3
+ "id": "tab-ds3502-demo",
4
+ "type": "tab",
5
+ "label": "DS3502 Voltage Setter Demo",
6
+ "disabled": false,
7
+ "info": "VCOM-style voltage setter on one DS3502 high-voltage digital potentiometer with RH = 15 V and RL = 0 V. An inject node sends {voltage: 5} on deploy; a second inject ticks every 500 ms into a function node that sweeps {code: n} through 16 steps (0, 8, ... 120); a debug node shows code, ratio and voltage; a button inject sends {store: true} to persist the last setting in the EEPROM (power-up value)."
8
+ },
9
+ {
10
+ "id": "inj-sweep",
11
+ "type": "inject",
12
+ "name": "Sweep tick (500 ms)",
13
+ "topic": "",
14
+ "payload": "",
15
+ "payloadType": "date",
16
+ "repeat": "0.5",
17
+ "crontab": "",
18
+ "once": true,
19
+ "onceDelay": 0.5,
20
+ "z": "tab-ds3502-demo",
21
+ "x": 150,
22
+ "y": 100,
23
+ "wires": [
24
+ [
25
+ "fn-sweep"
26
+ ]
27
+ ]
28
+ },
29
+ {
30
+ "id": "fn-sweep",
31
+ "type": "function",
32
+ "name": "sweep wiper",
33
+ "func": "// 16 steps of 8 codes: 0, 8, ... 120, then wrap.\nlet i = context.get('step') || 0;\ncontext.set('step', (i + 1) % 16);\nmsg.payload = { code: i * 8 };\nreturn msg;",
34
+ "outputs": 1,
35
+ "noerr": 0,
36
+ "z": "tab-ds3502-demo",
37
+ "x": 350,
38
+ "y": 100,
39
+ "wires": [
40
+ [
41
+ "ds3502-node"
42
+ ]
43
+ ]
44
+ },
45
+ {
46
+ "id": "inj-rheo",
47
+ "type": "inject",
48
+ "name": "Set 5 V",
49
+ "topic": "",
50
+ "payload": "{\"voltage\":5}",
51
+ "payloadType": "json",
52
+ "repeat": "",
53
+ "crontab": "",
54
+ "once": true,
55
+ "onceDelay": 0.1,
56
+ "z": "tab-ds3502-demo",
57
+ "x": 160,
58
+ "y": 180,
59
+ "wires": [
60
+ [
61
+ "ds3502-node"
62
+ ]
63
+ ]
64
+ },
65
+ {
66
+ "id": "inj-sd-on",
67
+ "type": "inject",
68
+ "name": "Store wiper in EEPROM",
69
+ "topic": "",
70
+ "payload": "{\"store\":true}",
71
+ "payloadType": "json",
72
+ "repeat": "",
73
+ "crontab": "",
74
+ "once": false,
75
+ "onceDelay": 0.1,
76
+ "z": "tab-ds3502-demo",
77
+ "x": 160,
78
+ "y": 300,
79
+ "wires": [
80
+ [
81
+ "ds3502-node"
82
+ ]
83
+ ]
84
+ },
85
+ {
86
+ "id": "inj-read",
87
+ "type": "inject",
88
+ "name": "Read wiper",
89
+ "topic": "",
90
+ "payload": "",
91
+ "payloadType": "date",
92
+ "repeat": "",
93
+ "crontab": "",
94
+ "once": false,
95
+ "onceDelay": 0.1,
96
+ "z": "tab-ds3502-demo",
97
+ "x": 160,
98
+ "y": 240,
99
+ "wires": [
100
+ [
101
+ "ds3502-node"
102
+ ]
103
+ ]
104
+ },
105
+ {
106
+ "id": "ds3502-node",
107
+ "type": "periph-ds3502",
108
+ "name": "DS3502",
109
+ "bus": "1",
110
+ "z": "tab-ds3502-demo",
111
+ "x": 560,
112
+ "y": 140,
113
+ "wires": [
114
+ [
115
+ "dbg-ds3502"
116
+ ]
117
+ ],
118
+ "address": "0x28",
119
+ "vhigh": "15",
120
+ "vlow": "0"
121
+ },
122
+ {
123
+ "id": "dbg-ds3502",
124
+ "type": "debug",
125
+ "name": "code / ratio / voltage",
126
+ "active": true,
127
+ "tosidebar": true,
128
+ "console": false,
129
+ "tostatus": false,
130
+ "complete": "payload",
131
+ "targetType": "msg",
132
+ "z": "tab-ds3502-demo",
133
+ "x": 780,
134
+ "y": 140,
135
+ "wires": []
136
+ }
137
+ ]
@@ -0,0 +1,109 @@
1
+ [
2
+ {
3
+ "id": "tab-mcp3422-demo",
4
+ "type": "tab",
5
+ "label": "MCP3422 Two-Channel Demo",
6
+ "disabled": false,
7
+ "info": "Inject node (every 2 s) into periph-mcp3422 (16 bit, x1); a function node splits payload.channels into two messages with topics ch1 and ch2 for the chart / debug nodes. A second inject sends gain = 8 and resolution = 18 for a bridge-sensor measurement."
8
+ },
9
+ {
10
+ "id": "inj-scan",
11
+ "type": "inject",
12
+ "name": "Scan every 2 s",
13
+ "topic": "",
14
+ "payload": "",
15
+ "payloadType": "date",
16
+ "repeat": "2",
17
+ "crontab": "",
18
+ "once": true,
19
+ "onceDelay": 1,
20
+ "z": "tab-mcp3422-demo",
21
+ "x": 140,
22
+ "y": 100,
23
+ "wires": [
24
+ [
25
+ "mcp3422-node"
26
+ ]
27
+ ]
28
+ },
29
+ {
30
+ "id": "inj-bridge",
31
+ "type": "inject",
32
+ "name": "Bridge: x8, 18 bit",
33
+ "topic": "",
34
+ "payload": "",
35
+ "payloadType": "date",
36
+ "repeat": "",
37
+ "crontab": "",
38
+ "once": false,
39
+ "onceDelay": 0.1,
40
+ "z": "tab-mcp3422-demo",
41
+ "x": 150,
42
+ "y": 180,
43
+ "props": [
44
+ {
45
+ "p": "gain",
46
+ "v": "8",
47
+ "vt": "num"
48
+ },
49
+ {
50
+ "p": "resolution",
51
+ "v": "18",
52
+ "vt": "num"
53
+ }
54
+ ],
55
+ "wires": [
56
+ [
57
+ "mcp3422-node"
58
+ ]
59
+ ]
60
+ },
61
+ {
62
+ "id": "mcp3422-node",
63
+ "type": "periph-mcp3422",
64
+ "name": "MCP3422",
65
+ "bus": "1",
66
+ "address": "0x68",
67
+ "resolution": "16",
68
+ "gain": "1",
69
+ "z": "tab-mcp3422-demo",
70
+ "x": 380,
71
+ "y": 140,
72
+ "wires": [
73
+ [
74
+ "fn-split"
75
+ ]
76
+ ]
77
+ },
78
+ {
79
+ "id": "fn-split",
80
+ "type": "function",
81
+ "name": "split channels",
82
+ "func": "// One message per channel with a chart topic.\nconst v = msg.payload.channels;\nreturn [[{ topic: 'ch1', payload: v[0] }, { topic: 'ch2', payload: v[1] }]];",
83
+ "outputs": 1,
84
+ "noerr": 0,
85
+ "z": "tab-mcp3422-demo",
86
+ "x": 590,
87
+ "y": 140,
88
+ "wires": [
89
+ [
90
+ "dbg-mcp3422"
91
+ ]
92
+ ]
93
+ },
94
+ {
95
+ "id": "dbg-mcp3422",
96
+ "type": "debug",
97
+ "name": "ch1 / ch2 (V)",
98
+ "active": true,
99
+ "tosidebar": true,
100
+ "console": false,
101
+ "tostatus": false,
102
+ "complete": "payload",
103
+ "targetType": "msg",
104
+ "z": "tab-mcp3422-demo",
105
+ "x": 800,
106
+ "y": 140,
107
+ "wires": []
108
+ }
109
+ ]
@@ -0,0 +1,79 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('periph-ad5251', {
3
+ category: 'Peripheral',
4
+ color: '#C084FC',
5
+ defaults: {
6
+ name: { value: '' },
7
+ bus: { value: '1', required: true, validate: RED.validators.number() },
8
+ address: { value: '0x2C', required: true },
9
+ rab: { value: '50000', required: true },
10
+ rwiper: { value: '75', required: true, validate: RED.validators.number() }
11
+ },
12
+ inputs: 1,
13
+ outputs: 1,
14
+ icon: 'font-awesome/fa-sliders',
15
+ label: function() { return this.name || 'AD5251'; },
16
+ paletteLabel: 'AD5251'
17
+ });
18
+ </script>
19
+
20
+ <script type="text/html" data-template-name="periph-ad5251">
21
+ <div class="form-row">
22
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
23
+ <input type="text" id="node-input-name" placeholder="AD5251">
24
+ </div>
25
+ <div class="form-row">
26
+ <label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
27
+ <input type="number" id="node-input-bus" min="0" style="width:80px"> &nbsp;(Linux /dev/i2c-N)
28
+ </div>
29
+ <div class="form-row">
30
+ <label><i class="fa fa-at"></i> I²C address</label>
31
+ <select id="node-input-address" style="width:100px">
32
+ <option value="0x2C">0x2C</option>
33
+ <option value="0x2D">0x2D</option>
34
+ <option value="0x2E">0x2E</option>
35
+ <option value="0x2F">0x2F</option>
36
+ </select> &nbsp;(AD1, AD0 pins)
37
+ </div>
38
+ <div class="form-row">
39
+ <label for="node-input-rab"><i class="fa fa-sliders"></i> RAB</label>
40
+ <select id="node-input-rab" style="width:120px">
41
+ <option value="50000">50 kΩ</option>
42
+ </select>
43
+ </div>
44
+ <div class="form-row">
45
+ <label for="node-input-rwiper"><i class="fa fa-sliders"></i> Wiper RW</label>
46
+ <input type="number" id="node-input-rwiper" min="0" style="width:80px"> &nbsp;Ω (typ. 75 Ω)
47
+ </div>
48
+ </script>
49
+
50
+ <script type="text/html" data-help-name="periph-ad5251">
51
+ <p>Sets and reads the two 64-position wipers of an AD5251 dual I²C digital potentiometer. Both channels power up from their stored EEMEM value (midscale, 32, until a value is stored).</p>
52
+
53
+ <h3>Inputs</h3>
54
+ <dl class="message-properties">
55
+ <dt>payload.channel <span class="property-type">number</span></dt>
56
+ <dd>Channel to act on: <code>0</code> or <code>1</code>.</dd>
57
+ <dt>payload.code <span class="property-type">number</span></dt>
58
+ <dd>With <code>channel</code>: wiper position 0–63 (clamped).</dd>
59
+ <dt>payload.ohms <span class="property-type">number</span></dt>
60
+ <dd>With <code>channel</code> (and no <code>code</code>): target W–B resistance in ohms, set to the nearest code.</dd>
61
+ <dt>payload.store <span class="property-type">boolean</span></dt>
62
+ <dd>If <code>true</code>: store both wipers in EEMEM (restored at power-on); replies <code>{ stored: true }</code>.</dd>
63
+ <dt>payload <span class="property-type">any</span></dt>
64
+ <dd>Any other message reads back both channels.</dd>
65
+ </dl>
66
+
67
+ <h3>Outputs</h3>
68
+ <dl class="message-properties">
69
+ <dt>payload.channel, payload.code, payload.resistance <span class="property-type">number</span></dt>
70
+ <dd>After a set: the channel, the wiper code read back, and the resulting W–B resistance in ohms.</dd>
71
+ <dt>payload.wiper <span class="property-type">number[2]</span></dt>
72
+ <dd>After any other message: wiper codes of channels 0 and 1.</dd>
73
+ <dt>payload.resistance <span class="property-type">number[2]</span></dt>
74
+ <dd>After any other message: W–B resistances (Ω) of channels 0 and 1.</dd>
75
+ </dl>
76
+
77
+ <h3>Configuration</h3>
78
+ <p>Set the Linux I²C bus number, the part's end-to-end resistance RAB (50 kΩ), the I²C address (0x2C–0x2F) and the wiper resistance RW. Absolute resistance is only accurate to the part's tolerance (±20 %); ratios are exact.</p>
79
+ </script>