Pages: 1 [2] 3   Go Down
Author Topic: Circuit Troubles  (Read 3100 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26452
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Grumpy Mike,
still having difficulties understanding your antipathy towards what, to me, looks to be a perfectly mathematically-correct inversion.

Would you be happier if it were written:
Code:
eye = (HIGH + LOW) - digitalRead(sensorPin);    
?

(not trying to make a mountain out of a molehill)
« Last Edit: May 18, 2011, 02:23:42 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

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

Quote
looks to be a perfectly mathematically-correct inversion.
Yes it does produce a result. My problem with it is that is just making something a lot more complicated than it needs to be and at the same time shows that the writer of it doesn't know what they are doing. If it were me I would have simply put:-
eye = digitalRead(sensorPin);
And then when I used it put:-
If(!eye) {
Well actually if it were me I would have wired up the sensor correctly and so there would have been no need to invert it anyway.  smiley
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
can phototransistors also be known as resistors
No a photo transistor and resistor are two different thing. Also a photo transistor and a photo resistor are two very different things.

Okay, thank you for that explanation smiley.

Quote
is there anything particularly wrong with the code?
Yes the photo transistor is never read, that line is commented out.

I have been thinking about this and your best bet is to swap the resistor and photo transistor round like I said. Use a 100K resistor and connect it to an analogue input, say A0.
Then read it with a line
eye = analogRead(0);    // set eye to the light value we "see"
Serial.println(eye);    // look at the value
Then try it and look at the range of numbers you get when you cover the light. Pick a number in the middle of this range and assign it to a variable call threshold at the start of your code. For example if 200 is the middle number you would put:-
int threshold = 200; Then remove the Serial.println(eye); line.
Just before the void setup();
Then change the line:-
  if (eye) {
to
  if ( eye < threshold ) {

So, from my understanding of your posts, I will need to produce one of the following circuits? Please excuse the crude drawings! smiley

(Version 4)


(Version 5)


Please note that on the Version 4 drawing, the positive from the RGB LED is to go to the positive on the LiPo board (left-most board).
Logged

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

It is almost impossible to follow something like that but it does look wrong.
Where is the 56R resistor, it wasn't on the original schematic from the first post. I can't make that bit out. It seems to say on the photographs emitter positive and emitter negative. An emitter is the name of one of the pins on a transistor so it does not make much sense.

The photo transistor circuit is also wrong. The junction of the 100K resistor and the photo transistor should go to the arduino with the other end of the 100K going to +5 and the other end of the photo resistor going to ground.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is almost impossible to follow something like that but it does look wrong.
Where is the 56R resistor, it wasn't on the original schematic from the first post. I can't make that bit out. It seems to say on the photographs emitter positive and emitter negative. An emitter is the name of one of the pins on a transistor so it does not make much sense.


The Emitter circuit drawn above is exactly the same as before (although admittedly I have made a mistake on the Version 5 drawing - the resistor connected to the Emitter should be a 56R (ohm) not a 56K).

Should I keep the Emitter circuit as it is at the moment? GND >> Emitter >> 56R >> Pin 6?

The photo transistor circuit is also wrong. The junction of the 100K resistor and the photo transistor should go to the arduino with the other end of the 100K going to +5 and the other end of the photo resistor going to ground.

Right okay, thank you for clearing that up smiley. When you say "should go to the arduino", do you mean the "a0" pad you mentioned in your previous post?
« Last Edit: May 18, 2011, 06:50:29 am by KugarWeb » Logged

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

Quote
do you mean the "a0" pad
Yes.

Are you using the word 'emitter' to mean LED? If so then are you sure that 56R does not exceed the maximum current of 40mA of the arduino output pins. Even 40mA will damage the arduino if you run it for too long.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
do you mean the "a0" pad
Yes.

Are you using the word 'emitter' to mean LED? If so then are you sure that 56R does not exceed the maximum current of 40mA of the arduino output pins. Even 40mA will damage the arduino if you run it for too long.

Okay thanks.

The "Emitter" is an IR Emitter...I assume it's also known as an LED?  smiley-confuse. I'm not sure....I assumed that 56R would be harmless as it's a lot lower than 10k? smiley-confuse. Is the current setup of the IR Emitter correct for it to work or will I also need to reposition this? How long is "too long"?

The Instructable I am working from states that I needed a 10KOhm and a 56Ohm resistor. Full details can be seen here: http://www.instructables.com/id/Arduino-Lilypad-Interactive-Passion-Sensing-Scarf
« Last Edit: May 18, 2011, 09:57:13 am by KugarWeb » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26452
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
....I assumed that 56R would be harmless as it's a lot lower than 10k?
That's a really bad assumption if the resistor is acting as a current limiter.
Whilst 10k may be too high to allow enough current to flow to light a LED, at least it won't cause damage, but 56R may be too low, allowing too much current to flow, potentially damaging both the output and the LED.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
....I assumed that 56R would be harmless as it's a lot lower than 10k?
That's a really bad assumption if the resistor is acting as a current limiter.
Whilst 10k may be too high to allow enough current to flow to light a LED, at least it won't cause damage, but 56R may be too low, allowing too much current to flow, potentially damaging both the output and the LED.

Do you have any suggestions as to what may be a suitable resistor value please? smiley
Logged

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

You need to know the current limit of your LED and the voltage it drops when on. Form this you can work things out properly.
If you don't know what these are then do not go lower than 100R.
Logged

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

Quote
The Instructable I am working from states that I needed a 10KOhm and a 56Ohm resistor.

From the Instructable it says:-
The emitter and detector each get hooked up from POWER to RESISTOR to LILYPAD PIN to IR LED to GROUND.

You are wiring your LED up to an output pin of the arduino. That means the current will come from the arduino pin not direct from the battery! It is fine if you wire it up like it is described in the Instructable with a 56R resistor but NOT if you source the power through an arduino pin.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The Instructable I am working from states that I needed a 10KOhm and a 56Ohm resistor.

From the Instructable it says:-
The emitter and detector each get hooked up from POWER to RESISTOR to LILYPAD PIN to IR LED to GROUND.

You are wiring your LED up to an output pin of the arduino. That means the current will come from the arduino pin not direct from the battery! It is fine if you wire it up like it is described in the Instructable with a 56R resistor but NOT if you source the power through an arduino pin.

The problem is, that setup is what I had in the first place and the circuit didn't work (see picture below).



I'm completely confused as to how this circuit is meant to be wired if it is to actually work, as the instructable instructions appear to be completely wrong, at least according to the results I have gathered from the above setup.

I will hopefully be sourcing a number of 100K resistors tomorrow so will try your suggestion with the analog pin.

As for the Emitter (IR LED), I am still unsure of how to set it up. Directly from the IR Emitter LED Datasheet from Rapid:


The entire datasheet for the Emitter can be downloaded from: http://www.rapidonline.com/netalogue/specs/58-0442.pdf
Logged

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

Quote
As for the Emitter (IR LED), I am still unsure of how to set it up
The way the Instructable has it wired up will damage your arduino, I have just put a note on the site to warn people.

Take the code from the site again as you have messed up your code and make this change:-
eye = 1 - digitalRead(sensorPin);    // set eye to 1 if we "see" any IR light
should become:-
eye = digitalRead(sensorPin);    // set eye to 1 if we "see" any IR light

Then wire it up as shown in this circuit.


* LiliPad circuit.png (19.28 KB, 480x467 - viewed 23 times.)
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
As for the Emitter (IR LED), I am still unsure of how to set it up
The way the Instructable has it wired up will damage your arduino, I have just put a note on the site to warn people.

Take the code from the site again as you have messed up your code and make this change:-
eye = 1 - digitalRead(sensorPin);    // set eye to 1 if we "see" any IR light
should become:-
eye = digitalRead(sensorPin);    // set eye to 1 if we "see" any IR light

Then wire it up as shown in this circuit.

I see. No wonder the guy that made the Instructable wasn't returning my messages then, he'd probably received quite a few regarding this problem!

Thank you very much for the advice and also for the clear diagram and code. I will be sure to try this out tomorrow when I'm a little more awake  smiley-wink smiley
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
As for the Emitter (IR LED), I am still unsure of how to set it up
The way the Instructable has it wired up will damage your arduino, I have just put a note on the site to warn people.

Take the code from the site again as you have messed up your code and make this change:-
eye = 1 - digitalRead(sensorPin);    // set eye to 1 if we "see" any IR light
should become:-
eye = digitalRead(sensorPin);    // set eye to 1 if we "see" any IR light

Then wire it up as shown in this circuit.

I see. No wonder the guy that made the Instructable wasn't returning my messages then, he'd probably received quite a few regarding this problem!

Thank you very much for the advice and also for the clear diagram and code. I will be sure to try this out tomorrow when I'm a little more awake  smiley-wink smiley

Okay, I've managed to get the circuit up and working, but the RGB is now changing straight to red and will not change colour even after covering the Phototransistor or moving the IR LED and Phototransistor apart.

The instructable states that the RGB should change from blue to red depending on the proximity of the IR LED. I assume this is a problem with sensitivity which I need to adjust within the code?
Logged

Pages: 1 [2] 3   Go Up
Jump to: