Go Down

Topic: Circuit Troubles (Read 5665 times)previous topic - next topic

AWOL

#15
May 18, 2011, 09:18 amLast Edit: May 18, 2011, 09:23 am by AWOL Reason: 1
@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: [Select]
`eye = (HIGH + LOW) - digitalRead(sensorPin);    ` ?

(not trying to make a mountain out of a molehill)
"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.

Grumpy_Mike

#16
May 18, 2011, 10:02 am
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:-
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.

KugarWeb

#17
May 18, 2011, 01:10 pm

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 .

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!

(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).

Grumpy_Mike

#18
May 18, 2011, 01:39 pm
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.

KugarWeb

#19
May 18, 2011, 01:48 pmLast Edit: May 18, 2011, 01:50 pm by KugarWeb Reason: 1

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 . When you say "should go to the arduino", do you mean the "a0" pad you mentioned in your previous post?

Grumpy_Mike

#20
May 18, 2011, 03:14 pm
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.

KugarWeb

#21
May 18, 2011, 04:54 pmLast Edit: May 18, 2011, 04:57 pm by KugarWeb Reason: 1

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?  :~. I'm not sure....I assumed that 56R would be harmless as it's a lot lower than 10k? :~. 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

AWOL

#22
May 18, 2011, 05:20 pm
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.
"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.

KugarWeb

#23
May 18, 2011, 07:06 pm

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?

Grumpy_Mike

#24
May 18, 2011, 07:11 pm
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.

Grumpy_Mike

#25
May 18, 2011, 07:19 pm
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.

KugarWeb

#26
May 18, 2011, 07:57 pm

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:

Grumpy_Mike

#27
May 18, 2011, 09:43 pm
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.

KugarWeb

#28
May 19, 2011, 12:49 am

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

KugarWeb

#29
May 20, 2011, 12:22 am

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

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?

Go Up

Please enter a valid email to subscribe