InaMORAta: Difference between revisions

No edit summary
 
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
<img src="https://user-images.githubusercontent.com/143473/190053690-f692a4cb-119d-4d66-a92c-130aa73bef03.jpg" width=400 height=400 style="float:right"/>
[[File:PXL 20220916 080028177.jpg|right|thumb|the completed apparatus]]
[[InaMORata_2.0|Updated in 2024]]


Let's fuck hard with some fans using an [[Arduino|Arduino MEGA]] and a [https://heltec.org/project/wifi-lora-32/ Heltec LoRa ESP32 v2]. These will be used with my [[MO-RA3]] to collect realtime data (fan RPMs, temperatures, etc.) and provide realtime control (fan PWM/RPM, RGB signals). We will also need a TXS0108E level shifter, a LM2596 buck converter, and three IRLB8721 logic level MOSFETs.
Let's fuck hard with some fans using an [[Arduino|Arduino MEGA]] and a [https://heltec.org/project/wifi-lora-32/ Heltec LoRa ESP32 v2]. These will be used with my [[MO-RA3]] to collect realtime data (fan RPMs, temperatures, etc.) and provide realtime control (fan PWM/RPM, RGB signals). We will also need an LM2596 buck converter and six IRLB8721 logic level MOSFETs, a TXB0108 level shifter, and various resistors.


We use a 12V PWM+DRGB hub for the many fans of the MO-RA3. Only one fan's RPM will be reported (whichever one is plugged into the red fan hookup), so it's important that we use the same model throughout. The hub has a two-wire hookup for tach and PWM (12V and ground are provided through the SATA power hookup). Looking at the hub with the clear side oriented up, the left wire is the PWM input, and the right wire is the tach output.
We use a 12V PWM+DRGB hub for the many fans of the MO-RA3. Only one fan's RPM will be reported (whichever one is plugged into the red fan hookup), so it's important that we use the same model throughout. The hub has a two-wire hookup for tach and PWM (12V and ground are provided through the SATA power hookup). Looking at the hub with the clear side oriented up, the left wire is the PWM input, and the right wire is the tach output.
Line 8: Line 9:


==Communication==
==Communication==
We'll want to report RPMs to the controlling host, and probably take PWM and RGB orders from it. We might use [[LoRa]] for this later. For now, we'll use MQTT over WiFi from the Heltec.
We might use [[LoRa]] for this later; for now, we use MQTT over WiFi from the Heltec. The Heltec exists purely to make the network connection and broker between MQTT and the MEGA; the latter does all the actual work and sensing.
===MQTT topics===
===MQTT topics===
* <tt>mora3/pwm</tt> desired PWM, integer 0–255, published by controller, subscribed by Heltec
* <tt>sensors/mora3.therm</tt> floating-point temperature in celsius
* <tt>mora3/therm</tt> temperature in celsius, published by Heltec, subscribed by controller
** published once per second by Heltec, subscribed by controller
* <tt>mora3/rpm</tt> rpm extrapolated from the most recent second (i.e., multiplied by 60), Heltec->controller
* <tt>sensors/mora3.rpm</tt> integer rpm extrapolated from the most recent second (i.e., multiplied by 60)
** published once per second by Heltec, subscribed by controller
* <tt>control/mora3/rgb</tt> accepts six hex digits BBRRGG specifying the fan color
** published by controller, subscribed by Heltec
* <tt>control/mora3/pwm</tt> accepts an integer 0–255 specifying the fan PWM
** published by controller, subscribed by Heltec
===Recovery===
Currently, the controller sends messages only on change. This doesn't fly if the components can go down. We ought have the Heltec publish two more data, the effective PWM and effective RGB, and it ought get these from the MEGA. That way, the controller can publish whenever the effective values do not equal the desired values.
 
We could have the controller simply regularly publish the desired states, but the protocol above lets the controller know when the MEGA has an incorrect understanding of state (if e.g. the Heltec stops passing along control messages).


==Powering the system==
==Powering the system==
[[File:12vpwmrgbhub.png|right|thumb|Power enters via SATA to a 12V RGB/PWM hub]]
We need 12V for our fans (Arctic P14 RGBs) and their RGB LEDs. This is accomplished with a SHNITPWR 12V AC adapter, plugged into a barreljack switch. This barreljack switch is then adapted to a 12V-only SATA plug (SATA normally carries 3.3V, 5V, and 12V). The SATA plug enters a 12V PWM+RGB hub. All fans are plugged directly into this hub, one port of which carries through tachometer readings.
We need 12V for our fans (Arctic P14 RGBs) and their RGB LEDs. This is accomplished with a SHNITPWR 12V AC adapter, plugged into a barreljack switch. This barreljack switch is then adapted to a 12V-only SATA plug (SATA normally carries 3.3V, 5V, and 12V). The SATA plug enters a 12V PWM+RGB hub. All fans are plugged directly into this hub, one port of which carries through tachometer readings.


A 12V plus ground pair are used from one of the hub's PWM hookups to drive a HiLetgo LM2596 buck converter. The LM2596 is configured to deliver 7.1V by adjusting a potentiometer. The output is displayed on the LM2596's LED. This is a safe output to drive both the Arduino and the Heltec. On the output side, we hook two barreljack pushbutton connectors up to the LM2596. One directly powers the Arduino. The other uses a microUSB adapter to power the Heltec.
A 12V plus ground pair are used from one of the hub's PWM hookups to drive a HiLetgo LM2596 buck converter. The LM2596 is configured to deliver 7.1V by adjusting a potentiometer. The output is displayed on the LM2596's LED. This is a safe output to drive both the Arduino and the Heltec. On the output side, we hook two barreljack pushbutton connectors up to the LM2596. One directly powers the Arduino. The other uses a microUSB adapter to power the Heltec.


We will *not* be powering the fans or LEDs from the Arduino directly. They draw far too much current, and Arduinos can't provide 12V power anyway (well, unless you dump 12V in at the power jack, and then drive from VIN, but you're gonna be voltage regulating that 12 down to 5, and why burn dinosaurs when there's no need?). Everything else is powered by the hub directly. We only need 5V for the tachometer and PWM signals, but we need send 12V PWM to the LEDs. We thus connect another 12V plus ground pair to one side of the breadboard, where we'll feed it into MOSFETs (see below; we can probably eliminate the hub entirely).
We will *not* be powering the fans or LEDs from the Arduino directly. They draw far too much current, and Arduinos can't provide 12V power anyway (well, unless you dump 12V in at the power jack, and then drive from VIN, but you're gonna be voltage regulating that 12 down to 5, and why burn dinosaurs when there's no need?). Everything else is powered by the hub directly. We only need 5V for the tachometer and PWM signals, but we need send 12V PWM to the LEDs. We thus connect another ground to one side of the breadboard, where we'll hook it up to the MOSFETs.


==Rotation count (RPMs)==
==Rotation count (RPMs)==
Line 62: Line 73:


==Wiring==
==Wiring==
All level shifter connections are to the MEGA or Heltec, and are specified there.
[[File:Inamorata bb.png|right|thumb|Fritzing diagram]]
The breadboard has 4 vertical channels. We'll use GND at 0 (the leftmost), 5V at 1, and 3.3V at 2. Both MCUs will be tied to channel 0 for ground. The Arduino will supply our 5V, and the Heltec our 3.3V.


===MEGA===
===MEGA===
* 5V pin goes to 10kΩ resistor, goes to tach signal, goes to level shifter VB
* 5V goes to breadboard channel 1
* GND goes to breadboard channel 0
* Pin 2 goes to hub's tach output
* Pin 2 goes to hub's tach output
* Pin A0 goes to thermistor signal
* Pin 8 goes to hub's PWM input
* Pin 8 goes to hub's PWM input
* 3.3V pin goes to 10kΩ resistor, goes to thermistor signal, goes to AREF
* Pin 16 goes to level shifter B3
* Pin 16 goes to level shifter B7
* Pin 17 goes to level shifter B6
* Pin 17 goes to MEGA pin 17
* Pins 9, 10, and 11 go to MOSFET controls (dynamic fan RGB)
* Pins 9, 10, and 11 go to MOSFET controls
* Pins 7, 6, and 5 go to a second set of MOSFET controls (static reservoir RGB)
* Pin 20 goes to tach of first pump
* Pin 21 goes to tach of second pump


===Heltec===
===Heltec===
* 5V pin goes to level shifter OE
* Pin 37 goes to level shifter A3
* 3.3V pin goes to level shifter VA
* Pin 17 goes to level shifter A6
* Pin 36 goes to level shifter A7
* Pin 38 goes to thermistor signal
* Pin 17 goes to MEGA pin 17
* 3.3V goes to breadboard channel 2
* GND goes to breadboard channel 0


===MOSFETs===
===MOSFETs===
* Gate is connected to appropriate MEGA pin 9, 10, or 11
* Gate is connected to appropriate MEGA pin 9, 10, or 11
* Drain is connected to appropriate hub R/G/B pin
* Drain is connected to appropriate hub R/G/B pin
* Source is connected to ground
* Source goes to breadboard channel 0
 
===Level shifter===
* Va goes to breadboard channel 2
* Vb goes to breadboard channel 1
* GND goes to breadboard channel 0
* OE goes to breadboard channel 2
 
===Thermistor===
* Source goes to 10kΩ resistor, goes to breadboard channel 2


==Protocol==
==Protocol==
Line 91: Line 115:


===UART===
===UART===
We can transmit from the Heltec to the Arduino directly; the 3.3V high logic level of the Heltec registers as high on the MEGA. Sending from the 5V MEGA directly to the Heltec will damage the latter. We instead go through a TXS0108E level shifter. The 5V line is taken to VB, while the 3.3V line is taken to VA. TX2 (pin 16) on the MEGA is taken to B7 on the level shifter. A7 goes to pin 36 on the Heltec, which is configured as RX2. The Heltec transmits from 17 directly to RX2 (pin 17) on the MEGA. Finally, the Heltec's 5V output is connected to OE on the level shifter.
We can transmit from the Heltec to the Arduino directly; the 3.3V high logic level of the Heltec registers as high on the MEGA. Sending from the 5V MEGA directly to the Heltec will damage the latter. We instead go through a 1kΩ+2kΩ voltage divider from MEGA pin 16 to Heltec pin 36. The Heltec transmits from 17 directly to RX2 (pin 17) on the MEGA.


==Future work==
==Future work==
* This needs to get cleaned up, obviously. at a bare minimum, wires need be soldered into the Heltec.
* This needs to get cleaned up, obviously. at a bare minimum, wires need be soldered into the Heltec.
* I think I can remove the 12V hub and just drive things off the 12V/ground lines on the breadboard. This would also remove the barreljack-to-SATA adapter (I'd just take the barreljack to a 2-way screwpost, and from there to the breadboard). That would probably let me move everything to the side of the MO-RA3, which would be great.
* I ought power the Heltec through the 5V pin rather than the USB. In this case, it moves to the LM2596, and the only thing drawing 5V is the CODI6 (for ARGB LEDs).
* I think I can eliminate the MEGA2560 entirely? We only need move the three tachometer inputs and three RGB outputs at this point. Eliminating it would also (probably) eliminate the level shifter.


[[CATEGORY:Projects]]
[[CATEGORY:Projects]]
[[CATEGORY:Hardware]]
[[CATEGORY:Hardware]]