I am a beginner in the field of electronics, please bear with me if something is wrong. Below is a schematic and the code for my implementation. I am using a nano(clone) as a logic control for a solid state relay. I have tested my sketch(code) while the nano was powered via 5V usb and it works as intended.
With my basic programming skill, I wrote a simple code which runs around an analogRead value. The nano reads between a range of 2.5-5V voltage(analog pin) from a control board, and activates the solid state relay.
For my final setup, I am using a DC-DC adjustable step-down power module(LM2596) with an input of 24VDC. Since then, the range for the analogRead value has shrink and the code does not execute as required.
I have done a few tests, as follows:
LM2596 to nano VIN(pin30) and GND at 4.8V, 5V, 6.5V and 7.5V
LM2596 to nano 5V(pin27) and GND at 5V
These have not solved the issue.
But, I tried USB to VIN(pin30) / 5V(pin27) and GND, the code works as suppose.
Does anyone have an idea what can be causing this?
int PSON = A3; // 5V PSON to analog pin 3
int SSR = 8; // 5V to digital pin 8
int psState = 0; // PSON status
int ssState = 0; // SSR status
void setup() {
pinMode(PSON, INPUT); // analog pin 3 as input
pinMode(SSR, OUTPUT); // digital pin 8 as output
}
void loop() {
psState = analogRead(PSON); // read analog input status
ssState = digitalRead(SSR); // read digital output status
if (psState > 850) {
digitalWrite(SSR, HIGH); // sets digital output HIGH
}
else if (psState < 850 && ssState == HIGH) {
delay(10000); // wait for 10 seconds
psState = analogRead(PSON); // read analog input status
if (psState > 850){
digitalWrite(SSR, HIGH); // sets digital output HIGH
}
else if (psState < 850){
digitalWrite(SSR, LOW); // sets digital output LOW
}
}
else {
digitalWrite(SSR, LOW); // sets digital output LOW
}
}
According to the specification of LM2596, it can supply up to 3A. I measured the current at the input side of the nano, its consuming around 20mA at idle and around 30mA when the digital output pin is activated(solid state relay is engaged).
Do not apply 5V to Vin. Apply the 5V to the 5V pin. The Vin input requires a minimum of 7V. Less than 7V and the on board 5V regulator can not regulate property.
@groundFungus I read about this and had a go at both options; 5V to 5V pin and 7.5V to Vin pin. AnalogRead behaviour did not change in comparison when powered by 5V USB.
@TomGeorge the component circled in red is a 3-pin KK connector located on a DUET3D board(3d printer control board). There is a 5V pin, PS_on pin and a GND pin, the combination of 5V pin and PS_on pin can used to control an atx-style power supply or a solid state relay.
Below is a description from the DUET3D documentation.
Open drain mosfet output for controlling an ATX-style power supply or a SSR. The +5V pin can also be used to provide external 5V power. A small amount of 5V power can be drawn from this pin (through an internal 220 ohm resistor), so that the control terminals of an SSR can be connected directly between the +5V and PS_ON pins.
I am measuring voltage across pin A3 and GND using a multimeter. When the PS_on pin is active(closed circuit) I measure around 4.8VDC. And when the PS_on pin is inactive(floating) I measure around 2.5VDC.
@TomGeorge I guess I found the culprit, it is my AC/DC SMPS. I think there is significant ripple noise in the 24VDC output hence its passing on to the LM2596 power module.
I tried powering the LM2596 using a 30VDC wall wart power supply, and it works perfectly.
Do you have any idea how I can reduce the ripple noise in the 24VDC?