Pages: [1]   Go Down
Author Topic: Guidance needed on this schematic  (Read 1076 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 2
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

newb here with a few questions...
so here's a quick schematic i did of what im trying to accomplish. First and foremost, im trying to control a regular 120v, 75w light fixture from both a 3 way switch and the arduino simultaneously. Furthermore, the serial monitor will be used to send on/off commands to the light, as well as receive the status of the light (light is on/ light is off). My question is; will this schematic function for my intended purpose?
thanks!
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Urm yes. with a little bit of programming yeah.
Logged

SW Scotland
Offline Offline
Edison Member
*
Karma: 17
Posts: 1385
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't ned the 100ohm resistor - the 10k to ground is all you need
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 619
Posts: 33961
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Change the +5V to be a ground, and enable the internal pull up resistors and you don't need any resistors at all.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
s well as receive the status of the light (light is on/ light is off).

As designed, it detects whether the line is energized nor not, not if the light is on or off. For example, it would not detect if a light bulb is not present, or if it has been burned out.
Logged

Florida USA
Offline Offline
Newbie
*
Karma: 2
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would at a minimum put a diode across the relay coil to protect the Arduino chip..
jolphil
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As for RELAY 1, how would i compose the sketch where a single character is used to toggle both the HIGH and LOW positions. For example, if i type in '1' on the serial monitor, pin2 will go from HIGH to LOW; if i type in the same character '1' again, pin2 will go from LOW to HIGH. In other words; one command triggers either a HIGH or LOW position on RELAY 1.

Can someone compose a sketch of the code required for my whole operation corresponding to the schematic?  smiley-grin
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

try to adapt what in this page to your application http://arduino.cc/en/Tutorial/SwitchCase2
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As for RELAY 1, how would i compose the sketch where a single character is used to toggle both the HIGH and LOW positions. For example, if i type in '1' on the serial monitor, pin2 will go from HIGH to LOW; if i type in the same character '1' again, pin2 will go from LOW to HIGH. In other words; one command triggers either a HIGH or LOW position on RELAY 1.
This part is trivial in assembly language so a competent C programmer (which I am not) should be able to come up with something for you.

The PINx register is where you normally read digital input data so writing to that register is not something one would normally do.  However, if you do write to that register the result is that the corresponding output bit(s) in PORTx is (are) toggled.

It's spelled out this way in the datasheet:
... writing a logic one to a bit in the PINx Register, will result in a toggle in the corresponding bit in the Data Register.


Don
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 98
Posts: 3569
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to make a coded latch.
Psudocode:
If button1 == high && latch == false {
Output high;
Latch ==true;
}

If button1 == high && latch == true{
Output low;
Latch == false;
}

In your case,
If SerialRead== 1 && latch == false
.
.
.
.....................&& latch ==true
.
.
.
Done
« Last Edit: December 11, 2012, 11:41:33 pm by HazardsMind » Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 619
Posts: 33961
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What current does relay 1 take? You normally need a transistor to drive a relay, you also need a diode across the coil.
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to make a coded latch.
Psudocode:
If button1 == high && latch == false {
Output high;
Latch ==true;
}

If button1 == high && latch == true{
Output low;
Latch == false;
}

In your case,
If SerialRead== 1 && latch == false
.
.
.
.....................&& latch ==true
.
.
.
Done
hum.. do i need additional hardware to operate the latch function? What is a latch command?
What current does relay 1 take? You normally need a transistor to drive a relay, you also need a diode across the coil.
i will be purchasing a relay board/shield from ebay which i believe comes ready to receive signals from the arduino without any additional components/hardware. As for relay2, what should the polarity direction be when attaching the diode to the circuit on the relay? where do i attach the diode?

so... can anyone compose an IDE sketch of the code necessary to operate my project?
« Last Edit: December 16, 2012, 09:35:02 pm by RobV15 » Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 98
Posts: 3569
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No extra hardware that I am aware of.

Also, you can simplify the latch code with this.

Code:
boolean latch= false;
If( button1 == HIGH) {
~latch; // latch = !latch;

digitalWrite(relayPin, latch ? HIGH : LOW);
}
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
As for relay2, what should the polarity direction be when attaching the diode to the circuit on the relay? where do i attach the diode?

Your original post states that you want to "receive the status of the light (light is on/ light is off)"

You should carefully reread reply #4 and consider another technique.

Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First up, I assume you realize the relays are going to have to be different - one is triggering on DC the other on AC. Relay 1 needs a diode fitted opposite to the current flow across the coil terminals if it isn't otherwise protected. I don't know if the relay shield has this protection, but I would assume so. In fact I'm pretty sure the relays will be transistor driven in the shield.

Relay 2 doesn't need a diode since the coil is isolated from the arduino, and in any case you would need a snubber since you're dealing with AC.

Smarter people than me have given you some good code snippets.
Logged

Pages: [1]   Go Up
Jump to: