Jump to content

Recommended Posts

Posted

After seeing some AFOL having success with train automation using this sensor thought I would give it a try.  First, I am not familiar with TLG's coding so took a bit to understand what all the symbols mean.  Got it after a bit.  Stumbling a bit in these areas, if anyone has had some success would appreciate some tips.

1) Mounting the sensor in 60197.  To me the only place it could go was in the square hole in the 20 something stud by six stud base.  Senor unable to read colors when mounted above this base (senor in the cab).  Relocated below the base, but not a lot down there to connect it too.  Its mounted but not very secure.  Sure someone smarter then me figure out a good way to mount this thing.  

2) Color reading.  My sensor picking up the colors was very inconsistent.  The lighting is not the best for my city, that may affect things.  Get the most false trips with Blue and Yellow selected for sensor.  I have green felt down under my tracks and got a few false Blue color reading when no color present.  When Yellow selected senor would read yellow if it saw yellow, lt gray, white and red.  If might have read more then this i just kinda gave up on yellow after that.  What colors work best for you?

3) The proximity sensor, my dreams of having chasing trains came to a crash literally.  Mounted the sensor to the front of my 60197 engine (front yellow piece removed).  Out of the box it tripped on anything I had close to my tracks, buildings, RR signals, etc (sensitivity set at 5).  I had to turn down the setting to level 2 to get it around my layout.  I set another train on the track (PF  1) and let 60197 chase it.  Running around 50% power.  Could not stop 60197 fast enough before it would hit the other train.  Believe if I removed the RR signs and pushed my building back from the RR could increase sensitivity of sensor.  Concerned as I cannot stop it fast enough the trains will still hit each other.  Not that I don't enjoy a good train smashing another train action, but when I put carriages on concerned going to get some derailments with this crashing.  

4) Coding,  Is there a way to code the app that it can react to colors without following the loop?  My simple loop code  could only react to what the next color in the code was looking for.  I could work around this by listing each color the train would see as it traveled the track (say white, black, red, red, white, black. etc.) but if it missed one (say one of the second red) then it would not look for the next color till it saw this missed color again (for my example I would miss my two white/black color actions).

Any help greatly appreciated.  

 

 

Posted

Regarding the wrong color readings: make sure that the sensor has the right distance to the bottom. I don't know the exact value out of my head, but it should be somewhere near 2 studs. Maybe someone else here knows the exact value. Also, you can make it drive slower over the colors. That way it has more time to react. You can also put more plates behind each other (so that it has 6 studs time to detect the color, not just 4 or 2).

To your second question: you can make a trigger for each color. That way it acts like the duplo train base. But make sure to make a normal "start" block that runs one to start the train ;)

SyLC2gv.png

Posted

Some people are not using tiles but normal plates: the shadows cause the sensor to detect anomalies. The sensor itself is probably very simple: a colored LED and a light sensitive transistor. It quickly alternates between the different colors and can thus create a reflection profile. Certain colors are too close in the spectrum to perfectly differentiate between them. Also the speed of the train influences the process. Apart from that is does work well enough to make it usable. Look at the Duplo train that has this functionality out-of-the box.

Posted

I stuck sensor up through the square hole from the bottom of the train base plate.  I held it in place with right angle bracket and a modified 1x2 plate with door rail.

To help diag issues, you can use the report current color seen by sensor block in the app to show you what color the sensor is seeing as you roll your sensored locomotive along the track. 

 

Posted
5 hours ago, Tcm0 said:

Regarding the wrong color readings: make sure that the sensor has the right distance to the bottom. I don't know the exact value out of my head, but it should be somewhere near 2 studs. Maybe someone else here knows the exact value. Also, you can make it drive slower over the colors. That way it has more time to react. You can also put more plates behind each other (so that it has 6 studs time to detect the color, not just 4 or 2).

To your second question: you can make a trigger for each color. That way it acts like the duplo train base. But make sure to make a normal "start" block that runs one to start the train ;)

SyLC2gv.png

I was unaware can run multiple coded run sequence at a time.  This helps.  Have some experimenting to do.  Thank you.

39 minutes ago, dr_spock said:

I stuck sensor up through the square hole from the bottom of the train base plate.  I held it in place with right angle bracket and a modified 1x2 plate with door rail.

To help diag issues, you can use the report current color seen by sensor block in the app to show you what color the sensor is seeing as you roll your sensored locomotive along the track. 

 

Currently I have two headlight bricks on the sensor and suspending it thru the square hole.  With the motor cable in there too just not enough room.  I have the bricks you referenced will attempt some thing similar.  

I was unfamiliar with the report color code.  Will experiment.  Thank you.

2 hours ago, JopieK said:

Some people are not using tiles but normal plates: the shadows cause the sensor to detect anomalies. The sensor itself is probably very simple: a colored LED and a light sensitive transistor. It quickly alternates between the different colors and can thus create a reflection profile. Certain colors are too close in the spectrum to perfectly differentiate between them. Also the speed of the train influences the process. Apart from that is does work well enough to make it usable. Look at the Duplo train that has this functionality out-of-the box.

I was using plates not tiles.  Will change.  Thank you.

Posted

Played  around a little more with the code and sensor.  Still getting sensor color errors. Not sure what block is "report a color".  I just put in code to have if any color seen, a different sound goes off.  Can see the code change too when a color is seen.  Going to try lowering the sensor closer to the track.

Is there a block for the train stop slowly?  The only way I have found is to just use a motor block with speed setting.  For a stop, just set the speed to 0.  This makes a very sudden stop.  Would prefer a nice stop that takes a few seconds. Also nice if could ramp up the speed vs the engine just taking off full blast.

Posted

You can use this block to display what the color sensor is detecting.  It shows a dot of the color detected in the upper right hand of the block if I recall. 

color-sensor-report-block.jpg

 

Posted (edited)

Another thing you can do is after detecting a color, check the distance reported. That way you can try to check that the color reported is actually from a tile you want it to be triggered from rather than the surface under the track.

So if the distance from your sensor to the table is 20mm, but the distance from your sensor to the top of one of the colored tiles you want to use is 10mm, you could check to see if the distance is also <10mm when the color is detected.

Edited by Mr Hobbles
Posted
On 3/9/2020 at 6:48 PM, LegoDW said:

Is there a block for the train stop slowly?  The only way I have found is to just use a motor block with speed setting.  For a stop, just set the speed to 0.  This makes a very sudden stop.  Would prefer a nice stop that takes a few seconds. Also nice if could ramp up the speed vs the engine just taking off full blast.

There is a motor stop block

039.png

and a motor float block

037.png

In theory you would want the second since the motor would coast to a stop, but it probably does not coast enough for what you are looking for. You can code up a slow start/stop by progressively stepping up/down the motor speed though.

 

On 3/9/2020 at 6:48 PM, LegoDW said:

Played  around a little more with the code and sensor.  Still getting sensor color errors. Not sure what block is "report a color".  I just put in code to have if any color seen, a different sound goes off.  Can see the code change too when a color is seen.  Going to try lowering the sensor closer to the track.

So far I have only used plates and found red to be reliable and green also appears to be. I haven't tried all the colors but yellow, gray, black and white all gave poor performance for me.

Though the fact that some physical colors are detected by multiple "sensor colors" could work to be an advantage, effectively providing a logical "AND" or "OR" for the layout.

 

On 3/9/2020 at 8:56 PM, Mr Hobbles said:

Another thing you can do is after detecting a color, check the distance reported. That way you can try to check that the color reported is actually from a tile you want it to be triggered from rather than the surface under the track.

Might be difficult, a plate is 3.2 mm tall and the sensor is probably less than 10 mm from the top of the rail to begin with, so it might work, but it might not. As for relying on successive sensors, as it is, I needed 8-10 studs of red plate to get a reliable color read from a passing train at half power, so you would need another 6+ studs of "high" tiles to allow for the second sensor read.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...