Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_ACR01B11A.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: Jan 25, 2022
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7
8#pragma once
9
10#include <cfg/cs_Boards.h>
11#include <cfg/cs_DeviceTypes.h>
12
13/* ********************************************************************************************************************
14 * Crownstone Plug One
15 * *******************************************************************************************************************/
16
17/*
18 * This plug has not been delivered to customers.
19 *
20 * This design has an improved power design. It has two opamps for both voltage and current.
21 *
22 * Remarks:
23 * - Make sure that pin P0.19 is floating (not listed here). It is a short to another pin (P0.30).
24 * - The pin for the dimmer is accidentally connected to a non-connected pin (A18).
25 * - It has been patched to pin LED red on pin 8.
26 *
27 * Temperature is set according to:
28 * T_0 = 25 (room temperature)
29 * R_0 = 10000 (from datasheet, 10k at 25 degrees Celcius)
30 * B_ntc = 3434 K (from datasheet of NCP15XH103J03RC at 25-85 degrees Celcius)
31 * B_ntc = 3380 K (if we assume it to stay cold at for 25-50 degrees Celcius)
32 * B_ntc = 3455 K (if we assume it to become hot at 25-100 degrees Celcius)
33 * R_22 = 15000
34 * R_ntc = R_0 * exp(B_ntc * (1/(T+273.15) - 1/(T_0+273.15)))
35 * V_temp = 3.3 * R_ntc/(R_22+R_ntc)
36 *
37 * We want to trigger between 76 < T < 82 degrees Celcius.
38 *
39 * | T | R_ntc | V_temp | B_ntc |
40 * | -- | ---- | ------ | ----- |
41 * | 25 | 10000 | 1.32 | |
42 * | 76 | 1859 | 0.3639 | | <- used value
43 * | 82 | 1575 | 0.3135 | | <- used value
44 * | 90 | 1256 | 0.2551 | 3455 |
45 *
46 * Hence, 0.3135 < V_temp < 0.3639 in an inverted fashion (higher voltage means cooler).
47 *
48 * The voltage range with R10 = 36.5k and R6 = 10M (C9 neglectable) is 0.0365/(0.0365+10)*680 = 2.47V.
49 * Thus it is 1.24V each way. A range of 1300 would be fine. Then 1240 would correspond to 240V RMS.
50 * Hence, the voltage multiplier (from ADC values to volts RMS) is 0.19355.
51 */
53 config->pinDimmer = 8; // Actually red LED, but the dimmer pin is N.C.
54 config->pinRelayOn = 15;
55 config->pinRelayOff = 13;
56
57 config->pinAinCurrent[GAIN_LOW] = GpioToAin(2);
58 config->pinAinCurrent[GAIN_HIGH] = GpioToAin(3);
59
60 config->pinAinVoltage[GAIN_LOW] = GpioToAin(31);
61 config->pinAinVoltage[GAIN_HIGH] = GpioToAin(29);
62
63 config->pinAinZeroRef = GpioToAin(5);
64 config->pinAinDimmerTemp = GpioToAin(4);
65
66 config->pinRx = 22;
67 config->pinTx = 20;
68
69 config->pinGpio[0] = 24;
70 config->pinGpio[1] = GetGpioPin(1, 0);
71 config->pinGpio[2] = GetGpioPin(1, 2);
72 config->pinGpio[3] = GetGpioPin(1, 4);
73
74 config->pinLed[LED_RED] = 8;
75 config->pinLed[LED_GREEN] = GetGpioPin(1, 9);
76
77 config->flags.dimmerInverted = true;
78 config->flags.enableUart = false;
79 config->flags.enableLeds = false;
80 config->flags.ledInverted = false;
81 config->flags.dimmerTempInverted = true;
82 config->flags.usesNfcPins = false;
83 config->flags.canTryDimmingOnBoot = false;
84 config->flags.canDimOnWarmBoot = false;
85 config->flags.dimmerOnWhenPinsFloat = true;
86
88
89 // All the values below are just copied from configuration values from other hardware and should be adjusted.
90 config->voltageMultiplier[GAIN_SINGLE] = 0.19355f;
91 config->currentMultiplier[GAIN_SINGLE] = 0.00385f;
92 config->voltageOffset[GAIN_SINGLE] = 0;
93
94 config->currentOffset[GAIN_LOW] = -270;
95 config->currentOffset[GAIN_HIGH] = -270;
96
97 config->powerOffsetMilliWatt = 9000;
98
99 // ADC values [-2048, 2047] map to [REF - 1.8V, REF + 1.8V].
100 config->voltageAdcRangeMilliVolt = 1800;
101
102 // ADC values [-2048, 2047] map to [REF - 0.6V, REF + 0.6V].
103 config->currentAdcRangeMilliVolt = 600;
104
105 config->pwmTempVoltageThreshold = 0.3639;
106 config->pwmTempVoltageThresholdDown = 0.3135;
107
108 config->minTxPower = -20;
109
110 config->scanWindowUs = config->scanIntervalUs;
112}
void asACR01B11A(boards_config_t *config)
Definition: cs_ACR01B11A.h:52
uint8_t GpioToAin(uint8_t gpio)
uint8_t GetGpioPin(uint8_t major, uint8_t minor)
@ LED_GREEN
Definition: cs_Boards.h:133
@ LED_RED
Definition: cs_Boards.h:132
@ GAIN_LOW
Definition: cs_Boards.h:97
@ GAIN_SINGLE
Definition: cs_Boards.h:101
@ GAIN_HIGH
Definition: cs_Boards.h:99
#define DEVICE_CROWNSTONE_PLUG_ONE
Definition: cs_DeviceTypes.h:32
Board configuration.
Definition: cs_Boards.h:169
uint8_t pinDimmer
GPIO pin to control the IGBTs.
Definition: cs_Boards.h:174
int32_t powerOffsetMilliWatt
Measured power when there is no load (mW).
Definition: cs_Boards.h:306
int8_t minTxPower
The minimum radio transmission power to be used.
Definition: cs_Boards.h:326
int32_t currentOffset[GAIN_COUNT]
Offset for current measurement (in ADC values).
Definition: cs_Boards.h:303
struct boards_config_t::@7 flags
Flags about pin order, presence of components, etc.
bool enableUart
True if the board should have UART enabled by default.
Definition: cs_Boards.h:243
uint8_t pinAinDimmerTemp
Analog input pin to read the dimmer temperature.
Definition: cs_Boards.h:201
bool ledInverted
True if LED is off when GPIO is set high.
Definition: cs_Boards.h:250
uint8_t pinAinCurrent[GAIN_COUNT]
Analog input pins to read the current with different gains (if present).
Definition: cs_Boards.h:189
uint32_t scanIntervalUs
Scan interval in μs.
Definition: cs_Boards.h:345
bool canTryDimmingOnBoot
True if the Crownstone can try dimming at boot, because it has an accurate enough power measurement,...
Definition: cs_Boards.h:263
uint8_t pinGpio[GPIO_INDEX_COUNT]
GPIO pins that can be used as GPIO by the user, for example microapps.
Definition: cs_Boards.h:219
float pwmTempVoltageThresholdDown
Voltage of PWM thermometer at which the dimmer is cool enough again.
Definition: cs_Boards.h:332
bool dimmerOnWhenPinsFloat
True if the dimmer can be on when the pins are floating (during boot).
Definition: cs_Boards.h:269
uint32_t currentAdcRangeMilliVolt
Range in mV to be used for the current pin.
Definition: cs_Boards.h:319
float voltageMultiplier[GAIN_COUNT]
Multiplication factor for voltage measurement.
Definition: cs_Boards.h:282
uint32_t scanWindowUs
Scan window in μs.
Definition: cs_Boards.h:353
int8_t tapToToggleDefaultRssiThreshold
Default RSSI threshold, above which tap to toggle will trigger.
Definition: cs_Boards.h:358
uint8_t pinTx
GPIO pin to send UART.
Definition: cs_Boards.h:216
bool dimmerInverted
True if the dimmer is inverted (setting gpio high turns dimmer off).
Definition: cs_Boards.h:240
uint8_t pinLed[LED_COUNT]
GPIO pins of LEDs.
Definition: cs_Boards.h:225
bool enableLeds
True if the board has LEDs that should be enabled by default.
Definition: cs_Boards.h:247
uint8_t deviceType
Device type, e.g.
Definition: cs_Boards.h:276
bool dimmerTempInverted
True if the temperature sensor of the dimmer is inverted (NTC).
Definition: cs_Boards.h:253
bool canDimOnWarmBoot
True if the Crownstone can dim immediately after a warm boot.
Definition: cs_Boards.h:266
float pwmTempVoltageThreshold
Voltage of PWM thermometer at which the dimmer is too hot.
Definition: cs_Boards.h:329
float currentMultiplier[GAIN_COUNT]
Multiplication factor for current measurement.
Definition: cs_Boards.h:294
uint8_t pinRelayOn
GPIO pin to switch the relay on.
Definition: cs_Boards.h:183
uint8_t pinAinVoltage[GAIN_COUNT]
Analog input pins to read the voltage with different gains (if present).
Definition: cs_Boards.h:192
uint8_t pinRelayOff
GPIO pin to switch the relay off.
Definition: cs_Boards.h:186
bool usesNfcPins
True if the NFC pins (p0.09 and p0.10) are used as GPIO.
Definition: cs_Boards.h:256
uint8_t pinAinZeroRef
Analog input pin to read 'zero' / offset (to be used for both current and voltage measurements).
Definition: cs_Boards.h:198
int32_t voltageOffset[GAIN_COUNT]
Offset for voltage measurement (in ADC values).
Definition: cs_Boards.h:297
uint32_t voltageAdcRangeMilliVolt
Range in mV to be used for the voltage pin.
Definition: cs_Boards.h:313
uint8_t pinRx
GPIO pin to receive UART.
Definition: cs_Boards.h:213