Go Down

Topic: Multiple LDRs detection erratic (Read 3783 times) previous topic - next topic

Paul__B


What's the best way to proceed here?  I need this to be consistent.  It is going to be installed in my fathers Slot Car race track, where they currently have a working (Parallel port -> Win95) solution.

Noted.  This is a somewhat adverse environment, so you do need to get it right.


I am not sure what you mean Paul?  Mike, I get the bit you mentioned about the grounds, and I have amended as shown in the image attached.

Sorry, Still got it wrong!

OK, my first point is that you should not be running your 5V line from the Arduino across your race track board to LDRs (or anything else if you can avoid it).  The LDRs should be connected to ground so that only ground wires (and the inputs themselves) are running around the board.  Now if you use the resistors as pull-ups they should be going to Vcc.  Mike feels that you are better to use 10k resistors, but I am suggesting that the internal pull-up function in the Arduino for each pin (by writing them HIGH using digitalWrite even though they are defined as inputs) should equate to a 10k pull-up.  It may simply have a different linearity - it is not actually a resistor, but for your purpose, it should be OK.  In fact, there is no reason why you should actually need to read them as analog - if they are presently being sensed by a parallel port then they are already being read as digital inputs - you presumably only wish to know whether are shadowed or not.

As to the grounds themselves, the ground from the power supply goes to the Arduino, not somewhere else.  The ground to the LDRs goes to the Arduino.  The ground for your output devices goes to the Arduino (unless you were to use opto-isolators in which case only the grounds from the inputs to the opto-isolators goes to the Arduino).


I am looking to build this fully over the weekend, but will be wanting to have all the bits I need.  So if I need a new power supply (the 9v on here is just for demonstration) for the LDRs


The LDRs consume negligible power.  Your concern may be for how much power the output devices use.

tip2tail

Wow!  Now I am even more confused!  I am totally struggling here!

Is there any chance you could show me what you mean in a diagram?

Let me clarify some things here:
* The Parallel Port/Win95 system is being retired.
* A new PC, using the Arduino and USB will be installed to run the new software I have written.
* The 4x tracks & 4x lights are powered (via the the relays) by a seperate 12v DC supply.
* The Arduino is not plugged into a wall socket, just the USB.

I really don't know what to do next, I just need to be able to detect when a car passes by the LDRs and breaks the beam so I can send a signal back to the PC.  There is plenty of scope for me to plug in another power source if needed, but if someone can show me what you guys mean I would be most appreciative! :-)

Mark

Grumpy_Mike

Quote
Wow!  Now I am even more confused!  I am totally struggling here!

What you need to appreciate is that there is no 100% sure fire way of predicting if you will or will not get some interference in any given situation.

What you can do is to take as many precautions as you can and test it. If you get trouble then you modify and test again.

That last thing you posted was right - ish as far as I could tell although you will not physically have the layout like that will you? The LDRs will be on long wires over to various parts of the track. You reduce the chances if your pull ups are small, 10K is a good start but you might have to go smaller. Then if there is trouble you can put capacitors across the analogue inputs. You have to test first nothing like this works first time.

You started the post with a specific problem and we gave you a solution. What you have not done is to test what we told you to do and report back.

tip2tail


That last thing you posted was right - ish as far as I could tell although you will not physically have the layout like that will you? The LDRs will be on long wires over to various parts of the track. You reduce the chances if your pull ups are small, 10K is a good start but you might have to go smaller. Then if there is trouble you can put capacitors across the analogue inputs. You have to test first nothing like this works first time.

You started the post with a specific problem and we gave you a solution. What you have not done is to test what we told you to do and report back.


Fair comments Mike.  I plan on setting up a test over the weekend.

No, my physical layout will be quite far removed from what you see.  Perhaps I would be better drawing a proper electrical schematic of the circuit.  Need to try and regress to 2002 and Higher (Scottish A Level) Physics.  Once I was out of there that was memory banked never to be used again or so I thought!!!

I do appreciate the help!  The one thing, before I go out testing this on my test track etc that I'm going to build, is the power for the LDRs.

I THINK that I need something like a pin adapter similar to the one on the Arduino itself  (pic attached), then an appropriate wall plug for that.  Although Ive not been able to find such a thing on eBay - perhaps my search terms have been wrong?

Thanks (again)!

Mark

Grumpy_Mike

Quote
I do appreciate the help!  The one thing, before I go out testing this on my test track etc that I'm going to build, is the power for the LDRs.

I would just run 5V from the arduino for that. It takes very little current so there is no need for a separate supply for them.

tip2tail


Quote
I do appreciate the help!  The one thing, before I go out testing this on my test track etc that I'm going to build, is the power for the LDRs.

I would just run 5V from the arduino for that. It takes very little current so there is no need for a separate supply for them.


Brilliant! :)

I think there was maybe 2 conflicting opinions earlier in this thread - will run with this and test over the weekend!

Many thanks!

Mark

tip2tail

To all who assisted me on this...

THANK YOU!
[/size]

As promised, I worked on and tested this today and it's working!!!

I am now able to switch the relays on/off, and detect - consistently - a vehicle passing the sensors on my test track.

Part of the problem was actually a programming error I had made in the delay between detection code.

However separating the power sources was the key it seems.  The relays are powered from the 5V now and the LDRs from the 3.3V via a 10K? resistor.  Works a treat!

Once again - thanks!

Mark

Go Up