Skip to content

Commit 3f3d6eb

Browse files
jktjktsde1000
authored andcommitted
Add support for DT5 (0-10V conversion) devices
Tested with Lunatone 86458508-AN. This one only appears to support switching between linear and logarithmic dimming curves, and some (undocumented) manufacturer's extensions. Support for pullup handling as well as switching between the 0-10V and 1-10V ranges is not there.
1 parent 95eac0a commit 3f3d6eb

File tree

4 files changed

+187
-2
lines changed

4 files changed

+187
-2
lines changed

README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This library has been written with reference to the following documents:
2121
- IEC 62386-201:2009 (fluorescent lamps)
2222
- IEC 62386-202:2009 (self-contained emergency lighting)
2323
- IEC 62386-205:2009 (supply voltage controller for incandescent lamps)
24+
- IEC 62386-206:2009 (conversion from digital signal into DC voltage)
2425
- IEC 62386-207:2009 (LED modules)
2526
- IEC 62386-301:2017 (particular requirements for push button input devices)
2627
- IEC 62386-303:2017 (particular requirements for occupancy sensor input devices)

dali/gear/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
import dali.gear.general
88
import dali.gear.emergency
99
import dali.gear.incandescent
10+
import dali.gear.converter
1011
import dali.gear.colour
1112
import dali.gear.led # noqa: F401

dali/gear/converter.py

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
"""Commands and responses from IEC 62386 part 206.
2+
3+
This part covers conversion from digital signal into DC voltage.
4+
"""
5+
6+
from dali import command
7+
from dali.gear.general import _StandardCommand, QueryExtendedVersionNumberMixin
8+
9+
10+
class _ConversionCommand(_StandardCommand):
11+
devicetype = 5
12+
13+
14+
class _ConversionConfigCommand(_ConversionCommand):
15+
"""An incandescent lighting configuration command as defined in
16+
section 11.3.4.1 of IEC 62386-206:2009.
17+
"""
18+
sendtwice = True
19+
20+
21+
###############################################################################
22+
# Commands from IEC 62386-206 section 11.3.4.1
23+
###############################################################################
24+
25+
class SetOutputRange1To10V(_ConversionConfigCommand):
26+
"""Set the output range to 1V - 10V
27+
28+
Converters without this feature shall not react.
29+
"""
30+
_cmdval = 224
31+
32+
33+
class SetOutputRange0To10V(_ConversionConfigCommand):
34+
"""Set the output range to 0V - 10V
35+
36+
Converters without this feature shall not react.
37+
"""
38+
_cmdval = 225
39+
40+
41+
class SwitchOnInternalPullUp(_ConversionConfigCommand):
42+
"""Switch on the internal pull-up resistor at the control voltage output
43+
44+
Converters without this feature shall not react.
45+
"""
46+
_cmdval = 226
47+
48+
49+
class SwitchOffInternalPullUp(_ConversionConfigCommand):
50+
"""Switch off the internal pull-up resistor at the control voltage output
51+
52+
Converters without this feature shall not react.
53+
"""
54+
_cmdval = 227
55+
56+
57+
class StoreDtrAsPhysicalMinimum(_ConversionConfigCommand):
58+
"""The physical minimum level shall be changed to the value given in the DTR"""
59+
_cmdval = 228
60+
61+
62+
class SelectDimmingCurve(_ConversionConfigCommand):
63+
"""Select Dimming Curve
64+
65+
If DTR0 is 0 then selects the standard logarithmic curve
66+
67+
If DTR0 is 1 then selects a linear dimming curve
68+
69+
Other values of DTR0 are reserved and will not change the dimming
70+
curve. The setting is stored in non-volatile memory and is not
71+
cleared by the Reset command.
72+
"""
73+
_cmdval = 229
74+
75+
76+
class ResetConverterSettings(_ConversionConfigCommand):
77+
"""Reset parameters which are not affected by RESET
78+
79+
All converter settings not influenced by the RESET command shall be set to the
80+
default values given in clause 10 of IEC 62386-206:2009.
81+
"""
82+
_cmdval = 230
83+
84+
85+
###############################################################################
86+
# Commands from IEC 62386-205 section 11.3.4.2
87+
###############################################################################
88+
89+
class QueryDimmingCurve(_ConversionCommand):
90+
"""Query Dimming Curve
91+
92+
0 = standard logarithmic
93+
1 = linear
94+
2-255 = reserved for future use
95+
"""
96+
_cmdval = 238
97+
response = command.Response
98+
99+
100+
class OutputLevelResponse(command.NumericResponse):
101+
def __str__(self):
102+
if isinstance(self.value, int):
103+
if self.value == 254:
104+
return "10.16V or more"
105+
elif self.value == 255:
106+
return "unknown"
107+
else:
108+
return f"{self.value * 0.04} V"
109+
return self.value
110+
111+
112+
class QueryOutputLevel(_ConversionCommand):
113+
"""Query the output level
114+
115+
The answer shall be the analog output level in units of 0.04V, fiving a range of 0V to 10.16V.
116+
117+
Raw value 254 maps to 10.16V or higher.
118+
Raw value of 255 means "the output level is not known".
119+
120+
Converters without this feature shall not react.
121+
"""
122+
_cmdval = 239
123+
response = OutputLevelResponse
124+
125+
126+
class QueryConverterFeaturesResponse(command.BitmapResponse):
127+
bits = [
128+
"0V - 10V output selectable",
129+
"internal pull-up selectable",
130+
"detection of output fault selectable",
131+
"mains relay",
132+
"output level can be queried",
133+
"non-logarithmic dimming curve supported",
134+
"physical selection / lamp fail detection by loss out output supported",
135+
"physical selection switch supported",
136+
]
137+
138+
139+
class QueryConverterFeatures(_ConversionCommand):
140+
"""Query hardware features of the converter"""
141+
_cmdval = 240
142+
response = QueryConverterFeaturesResponse
143+
144+
145+
class QueryFailureStatusResponse(command.BitmapResponse):
146+
bits = [
147+
"output fault detected",
148+
]
149+
150+
151+
class QueryFailureStatus(_ConversionCommand):
152+
"""Query failure status register"""
153+
_cmdval = 241
154+
response = QueryFailureStatusResponse
155+
156+
157+
class QueryConverterStatusResponse(command.BitmapResponse):
158+
bits = [
159+
"0-10V operation",
160+
"internal pull-up on",
161+
"non-logarithmic dimming curve active",
162+
]
163+
164+
165+
class QueryConverterStatus(_ConversionCommand):
166+
"""Query the current status of the converter"""
167+
_cmdval = 242
168+
response = QueryConverterStatusResponse
169+
170+
171+
class QueryExtendedVersionNumber(QueryExtendedVersionNumberMixin,
172+
_ConversionCommand):
173+
pass

examples/async-dalitest.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import dali.gear.general as gg
88
import dali.device.general as dg
99
import dali.device.sequences as ds
10-
from dali.gear import emergency
11-
from dali.gear import led
10+
from dali.gear import emergency, led, converter
1211
from dali.sequences import QueryDeviceTypes, DALISequenceError
1312
from dali.driver.hid import tridonic, hasseb
1413
from dali.memory import *
@@ -48,6 +47,17 @@ async def scan_control_gear(d):
4847
print(f" -E- battery charge: {r}")
4948
r = await d.send(emergency.QueryRatedDuration(addr))
5049
print(f" -E- rated duration: {r} * 2")
50+
if 5 in device_types:
51+
r = await d.send(converter.QueryConverterFeatures(addr))
52+
print(f" -0-10V- {r}")
53+
r = await d.send(converter.QueryConverterStatus(addr))
54+
print(f" -0-10V- {r}")
55+
r = await d.send(converter.QueryFailureStatus(addr))
56+
print(f" -0-10V- {r}")
57+
r = await d.send(converter.QueryDimmingCurve(addr))
58+
print(f" -0-10V- dimming curve: {r.raw_value.as_integer}")
59+
r = await d.send(converter.QueryOutputLevel(addr))
60+
print(f" -0-10V- output level: {r}")
5161
if 6 in device_types:
5262
r = await d.send(led.QueryGearType(addr))
5363
print(f" -LED- {r}")

0 commit comments

Comments
 (0)