Solid State Relay not working w/ Teensy

Status
Not open for further replies.
Hi,

I have some questions about my first ever project using a Teensy. This is also my time trying to build anything really so sorry if I ask any really basic question.

I'm trying to control a fan and a solenoid valve using solid state relays and a Teensy 3.2.

Here's my code:

int relayFan = 5; //Setting the pin of the fan
int relaySol = 10 //Setting the pin of the solenoid valve


void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(relaySol, OUTPUT); //Sets pin mode to output
pinMode(relayFan, OUTPUT);

}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(relaySol, HIGH); //Turns solenoid on

digitalWrite(relayFan, HIGH); //Turns solenoid on
delay(5000); //Delays for 5000ms (5s)
CircuitDiaTemplate.jpg
digitalWrite(relaySol, LOW);
digitalWrite(relayFan, LOW);
delay(5000);
}

I attached a really rough circuit diagram in case my hardware setup is incorrect.

After I uploaded the code to the Teensy and plugged in the power, for some reason, the fan and solenoid stayed on constantly regardless of if the pin output was high or low. I'm extremely new to this so any help would be grreatly appreciated. Let me know if there is anything else that could be helpful.
 
The power supply is 12v as well as the fan and solenoid. I used a step-down transistor to supply the teensy with power.
 
The CX240D5 as shown in the diagram is rated for 3--15V, its just an AC relay using SCRs and with zero-crossing switch-on, so can't work for DC loads.

Is this the one you have?
 
Hi Kevin,

Mark is right, read this for more background.
Using an N-channel logic-level MOSFET like the affordable IRLZ44N is a much better option to switch 12Vdc by a Teensy. More info here.

Paul
 
The SSR won't work because it's specified for AC. It may turn on but probably won't turn off.

Your wiring is wrong. You need a common ground for the teensy, fan, pump and power supply to start with. Your diagram shows no connection from the power supply. Secondly, I'd be surprised if the EMI from the motors didn't mess up the teensy.
 
What you called a step-down transistor is a voltage regulator. If you really are using a L7812CV, as shown in your diagram, it is the wrong one and would probably have burned out the T3.2 instantly. That outputs 12V from a higher DC input voltage. You would need L7805CV.

Pete
 
The SSR in the picture is incorrect. The one I'm using is a CPC1219Y. The input voltage is 3.5v. Is this too high for a Teensy?
 
It is really a good idea to have accurate information when asking for help.

That SSR is normally closed. Is that what you want?

Your wiring is still incorrect. Everything must have a common ground. And your voltage reg needs to have capacitors - read the datasheet for details (or look at one of the about 1M www pages talking about it).
 
So should the power supply also be connected to the ground pin on the Teensy? Sorry for the simple questions, this is my first project.
 
Electricity needs 2 wires to work: a + and a -. Without those, the electrons won't flow. That's why we call it a circuit. We often call minus ground or 0V. So yes, you need the ground too.

Start small. Load a blink sketch into the teensy, disconnect it from USB and power it via your power supply. If it blinks, it worked. If not, figure out what's wrong. Then start adding other pieces. Don't just throw parts at it. Read up on how the part is used and what other parts it needs to work correctly. For example, that 7805 you say you have, it needs 2 capacitors, one on input and one on output. It may sort of work without them but it also may not.

Also, if you want to continue, some tasks for you:
  • Get a multimeter - even a cheapo $5 harbor freight one is better than nothing. Measure various outputs. You will soon get a sense of what works and what doesn't.
  • Get a solderless breadboard and some jumper wires. The SBB holds your parts securely and avoids accidental shorts. Plus a picture is easy to understand than a snarl of wires.
  • Instead of driving SSRs, start with LEDs (and a resistor) to see if your signals are getting sent. I always have a couple of LEDs with resistors that I can touch to outputs to see if they are working. It's a great and incredibly cheap diagnostic tool.
  • Learn how to read datasheets. They have (almost) everything you need to know about using a part. Even if 95% of it is over your head, the 5% that you do get will soon become 10%. and then 20% and then... And if you ask questions, a link to the data sheet will encourage people to help you.
 
Status
Not open for further replies.
Back
Top