For Mega 2560.
I am attaching a generalized “schematic” of my project so far. I am not including 3 parts: an encoder (connected to interrupts 2 and 3 / 20 21, GND and 5V from Arduino), the 16x2 LCD I use on top of all the boards, and the 12V fan pushing air into the custom refrigerator (which is the project.)
I will provide code if need be, but this is more an electrical question than anything.
The way the ground lines are connected in the schematic is exactly how I have them wired on the board.
From the bottom - I power all the components with 12V, and the Arduino is regulated down to 5V.
I have a Trinamic TOS-100 Stepper motor controller on top of it, powered by the 12V (wherein the onboard TMC2660 chip requires 9V to operate.)
On top of the Trinamic is a custom board with 4 resistors, 1 transistor, and 2 capacitors.
For the point of this topic, I would like to focus on 1 analog output, and 2 analog inputs.
The two analog inputs are used for the LM35 sensors I am using to monitor air temperature and plate temperature. Their power and ground pins are wired to the same 5V and GND pin on the Arduino. Their output goes through a low pass filter (R = 26.7kOhm, C = 0.1uF) into A2 and A3. Each capacitor is wired to a ground pin separate of the one used for the sensors themselves.
The transistor (IRL530NS) is used to either allow or disallow the cool side of the Peliter sensor from receiving voltage (if that doesn’t sound right, lingo-wise, could you reword it so I know how to voice it properly for the future, thanks!) I have a 10k resistor acting as a pull-down for when the transistor goes into high impedance mode.
Finally, I’m using the PID looping method to, for example, bring ambient temperature of 22 degrees Celsius down to setpoint of 4 degrees. When the PID reaches the equivalent output (produced using analogWrite(PIN_28)) in relation to the setpoint, the transistor goes into the high impedance…“turning off” the cool side.
Here’s my issue. When the PID is in the aggressive state, whereby it’s driving its output down to the setpoint, my entire current draw from the 12V supply by the whole board is around 4.25 A. When the transistor goes into high impedance, the current draw goes down to 0.4 A.
As a result, the Trinamic board becomes inoperable (which is something I will hopefully address myself in the future) AND the LM35 analog input readings drop significantly.
Here’s what happens to the sensor that is reading the air temperature (which I’m using as the Input factor for the PID):
- Read about 4 degrees C - gets closer to mark
- Reads a little below (~3.8) - passes setpoint, expectantly
- Then the transistor goes to high impedance - current draw goes from 4.25 A to 0.4 A
- The sensor then starts reading around 1.2 degrees C
- PID algorithm now takes a long time to get back up to Setpoint - about 5 minutes of stepper motor inactivity.
Any thoughts as to why this happens, or how it can be fixed? I have checked all the wiring on the board, and it checks out. Is the transistor switching affecting all the other parts/pins?