Jump to content
THIS IS THE TEST SITE OF EUROBRICKS! ×
THIS IS THE TEST SITE OF EUROBRICKS!

Recommended Posts

Posted

I have struggled a lot with what LEGO train system to choose. We have them (almost) all, from 12V (even some blue and 4.5V sets), to the newest PF trains.

First I wanted to use DCC and I have managed to make some bad 9V motors DCC ready. That was a hard job and I was not totally convinced. Until I came across the Arduino AVR applications. This train uses a special adept of Arduino called the LEGuanO. The board is 8 by 5 studs and has LEGO compatible holes for easy LEGO compatibility.

My first train that totally works with this system is a Dutch classic called the "Sik" locomotor best translated as "Goatty" because it made a Goat like noise. I have put an AVR 2313 in the front. That one is programmed using AVR-GCC and is in fact an i2c slave. The chip makes sure the head and backlights of the locomotor work and also enables the option of a top flashlight. The original "Sik" locomotors had a blue flashlight. I use NEM II era for somewhat realistic scenery etc.

Anyway. The LEGuanO in the train receives PF messages. The last car of the train has a bunch of batteries, the LEGuanO and the driver for the motor. On top of the roof there is a small IR receiver. The LEGuanO board is designed to have a native IR receiver fit.

Below some pictures (the light wasn't very friendly and I didn't have time to get my normal camera, but anyway I might change that later).

The "Sik" locomotor:

sik_forward.jpg

Here with the white headlights and a red backlight (in fact that one should not be lit, on the last car a red lamp should be lit).

While backing up: lights are in reverse mode:

sik_back.jpg

Then the front of the locomotor looks like this:

sik_front_rev.jpg

Pressing (left) STOP on the PF controller twice, will disable the lights including the blinking light. Pressing it twice again will make the flasher blink.

This is the LEGuanO used both for the train and the level crossing:

leguano_board.jpg

It can be programmed using a USB adapter with Arduino and/or AVR-GCC (amongst others).

The level crossing also uses a LEGuanO (could be simpler but just used for showing some possibilities).

The train has some extra strong magnets that activate a read sensor. When the train is past the level crossing, the white "safe" lamp will blink again.

short clip

I have tried to harm as little LEGO as possible, in fact only the to taps were drilled to put the lamps in it. I now and then use hot glue but that could be peeled off without damaging the LEGO.

Posted

Hi JopieK,

your post is very interesting.

did you buy the PCB board or did you design it yourself? :classic:

It appears there is an Atmel micro-controller on the board which is the main component.

The rest looks like it is just there for interfacing. Am I right?

Given the amount of components there appears to be a lot of "empty" space on the board, indicating it can be squeezed on a smaller board.

Regrettably, The video you posted appears up-side-down on my video player. :wacko:

Kind regards,

Teddy

Posted

Well, indeed most of the wires are just interface wires. I designed it myself and I had it professionally made. I'll try to embed it into my LEGOWorld 2010 layout. My autumn holidays fall in the second week (I'm located in Zwolle region). The heart is an Atmega168 or Atmega328 just with the normal Arduinos (see www.arduino.cc) but then adapted to LEGO. It is a mov so quicktime should play it alright (copy paste the url to quicktime). It could indeed be squeezed into a much smaller board but this was my first PCB and I still have a bunch left. Alternative would be to just use an Arduino nano or something like that.

Next step is creating working arm signals and points (using memory wire), should work with LEGuanO, I already did some tests.

Posted

Well, indeed most of the wires are just interface wires. I designed it myself and I had it professionally made. I'll try to embed it into my LEGOWorld 2010 layout. My autumn holidays fall in the second week (I'm located in Zwolle region). The heart is an Atmega168 or Atmega328 just with the normal Arduinos (see www.arduino.cc) but then adapted to LEGO. It is a mov so quicktime should play it alright (copy paste the url to quicktime). It could indeed be squeezed into a much smaller board but this was my first PCB and I still have a bunch left. Alternative would be to just use an Arduino nano or something like that.

Next step is creating working arm signals and points (using memory wire), should work with LEGuanO, I already did some tests.

Thanks for your reply! The Arduinos website looks interesting. I had never heard from them.

My experience is in RF design, so with PCB designs I am used to designing them custom for my needs.

I am familiar with design packages such as Eagle, Cadence and Mentor.

I have never heard of a generalized approach as Aduinos, I looked on their website which looks very interesting.

Was it difficult customizing your own board from a standard Aduinos one?

Kind regards,

Teddy

Posted

Well, I'm a teacher in Techn. Informatics and Robotics so familiarity with chips like the AVR come naturally :) I used Eagle for the design actually. Arduino is quite easy (at least if you have suffcient knowledge in electonics and so on like you do). It would be nice to create a LEGO Arduino community, there are more interested people for this.

Posted

Well, I'm a teacher in Techn. Informatics and Robotics so familiarity with chips like the AVR come naturally :) I used Eagle for the design actually. Arduino is quite easy (at least if you have suffcient knowledge in electonics and so on like you do). It would be nice to create a LEGO Arduino community, there are more interested people for this.

Arduino would be interesting, toyed with the Idea to use it in LEGO applications (signalling would be nice, or as a interface between Windows PC and PF Infrared).

I certainly would be interested, but I think my knowledge in electronics would be insufficient. (Got some basics down, and I'm able to code simple C programs or VB Script=.

Posted

Well, I'm a teacher in Techn. Informatics and Robotics so familiarity with chips like the AVR come naturally :) I used Eagle for the design actually. Arduino is quite easy (at least if you have suffcient knowledge in electonics and so on like you do). It would be nice to create a LEGO Arduino community, there are more interested people for this.

Hi JopieK,

that would be a great idea and I would love to toy around with it. :classic:

Currently I am writing my PhD thesis, but after February I should have more time for this.

It would be fantastic if we could combine it with the ideas of Toastie and Mark Bellis.

Get some general platform to combine all the great ideas floating around.

Kind regards,

Teddy

Posted

Hi JopieK,

that would be a great idea and I would love to toy around with it. default_classic.gif

Currently I am writing my PhD thesis, but after February I should have more time for this.

It would be fantastic if we could combine it with the ideas of Toastie and Mark Bellis.

Get some general platform to combine all the great ideas floating around.

Kind regards,

Teddy

Dear All,

I completely agree on what Teddy wrote. (There are a couple of things I'd like to share in the near future, including some RF stuff as well, but that'll take some time. Mark will certainly ground me on my "ideas" - I am a chemist after all - but I will take that as motivation to carry on!)

Talking about "time", Teddy, writing up the PhD thesis - for me that is some years ago, but man, it was good times, don't you agree?

In any case, the Arduino platform could become a fantastic base to operate from - once a couple of people are willing to go with it. I happen to use the microchip PIC family but I don't mind switching at all!

Regards,

Thorsten (Toastie)

Posted

At school we use Atmel, I normally develop my lectures using my LEGuanO. That gives to opportunities:

a. I get my LEGO stuff working

b. I know what bumps there are and what the students will face

Arduino is very nice to start with. I am also developing some highschool materials and in November I will give a masterclass at a teachers conference. The Arduino libraries are very easy to use, but one can also program AVR-GCC (GNU C with AVR extensions) using the same platform. Normal signals are very easy, I actually created a working one as basic test for my LEGuanO. That one has an IR receiver, a red and a green signal and an IR LED. The IR led could give a burst to all approaching trains (e.g. STOP!). Two wire interface (i2c) is also native on the LEGuanO board so that more boards can be connected to eachother. Of course one can also mix LEGuanO's with other Arduinos since they are basically the same. My LEGuanO has a different footprint and that is more or less the only difference with an other Arduino, basic functions include:

a. reverse polarity protection

b. power LED (tiny SMD one)

c. if needed two extra SMD leds (for feedback and debugging)

d. an FTDI programming interface

e. reset function

d. two TWI / i2c headers with possibility for SMD pull up resistors

f. an IR receiver header

It has no power supply, but normally one would just hook one Arduino up to a 5 to 6V supply and then power the others with the i2c interface, so for this application it is more practical to do without an i2c interface.

Posted

Dear All,

I completely agree on what Teddy wrote. (There are a couple of things I'd like to share in the near future, including some RF stuff as well, but that'll take some time. Mark will certainly ground me on my "ideas" - I am a chemist after all - but I will take that as motivation to carry on!)

Talking about "time", Teddy, writing up the PhD thesis - for me that is some years ago, but man, it was good times, don't you agree?

In any case, the Arduino platform could become a fantastic base to operate from - once a couple of people are willing to go with it. I happen to use the microchip PIC family but I don't mind switching at all!

Regards,

Thorsten (Toastie)

At school we use Atmel, I normally develop my lectures using my LEGuanO. That gives to opportunities:

a. I get my LEGO stuff working

b. I know what bumps there are and what the students will face

Arduino is very nice to start with. I am also developing some highschool materials and in November I will give a masterclass at a teachers conference. The Arduino libraries are very easy to use, but one can also program AVR-GCC (GNU C with AVR extensions) using the same platform. Normal signals are very easy, I actually created a working one as basic test for my LEGuanO. That one has an IR receiver, a red and a green signal and an IR LED. The IR led could give a burst to all approaching trains (e.g. STOP!). Two wire interface (i2c) is also native on the LEGuanO board so that more boards can be connected to eachother. Of course one can also mix LEGuanO's with other Arduinos since they are basically the same. My LEGuanO has a different footprint and that is more or less the only difference with an other Arduino, basic functions include:

a. reverse polarity protection

b. power LED (tiny SMD one)

c. if needed two extra SMD leds (for feedback and debugging)

d. an FTDI programming interface

e. reset function

d. two TWI / i2c headers with possibility for SMD pull up resistors

f. an IR receiver header

It has no power supply, but normally one would just hook one Arduino up to a 5 to 6V supply and then power the others with the i2c interface, so for this application it is more practical to do without an i2c interface.

Hi JopieK and Toastie,

In regard to my thesis: well writing is not my favorite hobby and it takes me quite some time to get it right.

Personally, I prefer to do maths and experiments. :classic:

JopieK, those specs sounds pretty cool! The board you build is a nice RCX replacement for implementation of Toastie his system ideas.

I guess if we would like the board to be used in LEGO MOCs and layouts of other users, it might require a voltage converter to allow it to be fed from the Lego Lipo battery.

This can be implemented on a very small separate board, but if you plan a second version of LEGuanO, you might consider adding it to a second version of the board.

Does your board have SMD components on both sides of the board, or only on the top layer?

If you are planning to do an update of the board I am interested to help. Your experience and effort is a valuable resource for anybody attempting a similar project. I have been playing with the idea of using Atmels, but I felt the software interface might be a problem.

The Adruino approach you took solves that.

I would be interested in thinking about board dimensions and casing sizes which are still practical for MOCcing, but large enough to contain the electronics. For footprint reduction one could consider PCB board stacking:

PCB-brochure-image.jpg

I think Toastie has a lot of experience with RCX size and integration into MOCs, with his interesting RCX projects.

For an RF interface, I expect there are standard RF transceiver ICs with i2c interface which operate in an ISM band that can be hooked up to the Adruino system of JopieK. Some RF questions remain such as:

-Strip-line antenna on the PCB or hook up a separate antenna

-Single ended or differential inputs.

-Matching of the RF-PCB strip-lines

-RF and digital isolation/interference

-RF losses in IC footprints.

-Direct soldering to the PCB

-Decoupling caps and pi networks.

But those are mainly implementation issues which affect RF throughput, range, and size.

And these requirements are dictated by the RF-IC layout and content.

Kind regards,

Teddy

Posted

Well Tedler, I'm a little bit confused about what you mean exactly.

I choose to not include a voltage converter / PSU on the board for practical reasons. Adding a shield will allow that (that is what I do). In every train one needs e.g. a 9V to 5V power supply (PSU) of course to feed the logic. In a city however one only needs maybe one or two 5V supplies to power all arduino's / LEGuanO's so including it on the PCB would be not desired.

Connecting Bluetooth, RC, etc. on the board is already very available. Look at sparkfun.com for more idea's and the arduino.cc site of course.

I got my memory wire working yesterday, so now connecting points and arm signals to the memory wires :)

I'll keep you guys posted.

@andythenorth: of course this is not limited to trains. Using i2c and an H-bridge together with the arduino / LEGuanO, one can also add e.g. motors to NXT since the sensor ports have i2c possibilities (in fact the NXT also uses AVR µControllers).

Posted

Well Tedler, I'm a little bit confused about what you mean exactly.

I choose to not include a voltage converter / PSU on the board for practical reasons. Adding a shield will allow that (that is what I do). In every train one needs e.g. a 9V to 5V power supply (PSU) of course to feed the logic. In a city however one only needs maybe one or two 5V supplies to power all arduino's / LEGuanO's so including it on the PCB would be not desired.

Connecting Bluetooth, RC, etc. on the board is already very available. Look at sparkfun.com for more idea's and the arduino.cc site of course.

I got my memory wire working yesterday, so now connecting points and arm signals to the memory wires :)

I'll keep you guys posted.

@andythenorth: of course this is not limited to trains. Using i2c and an H-bridge together with the arduino / LEGuanO, one can also add e.g. motors to NXT since the sensor ports have i2c possibilities (in fact the NXT also uses AVR µControllers).

Hi JopieK,

a Bluetooth connection would be brilliant. :classic: And the fact it is already available is just fantastic! :sweet:

The stuff I was contemplating has to do with practical implementation.

My PhD is in analog RF-CMOS design. So I was thinking in analog RF circuits and PCB implementation issues. :wink:

I did my Master of Science in wireless channel modeling and digital baseband algorithms for wireless channel estimation.

But if it is already available it can just be used. :classic:

A Bluetooth RF connection will allow train control even when the train is in a cave and one could build the antenna inside the MOC.

Personally, I quite dislike the IR receiver which needs to pop out of the MOC and requires a line of sight connection.

In regard to the LiPo, I am talking about Toastie his power pickup ideas:

Link to topic on EB

Which he is proposing to combine with his RCX ideas published here (page 44 - 62):

Railbrick 3

But I guess you are already quite familiar with the ideas of Toastie. :classic:

I think you are right it is more practical to have the voltage converter on a separate board for footprint reduction.

My thinking was also more along the lines of:

Not all AFOLs are tech savvy, the LEGO PF uses 9V, it would be easy if the power supply can be easily hooked up to the PF.

Kind regards,

Teddy

Posted

Well, I know that the analog and the digital scene in electronics are two worlds in the same universe :)

Maybe this is also a good form factor idea: http://jeelabs.com/

I agree that it is best to have a very good interface. Maybe we could work out a standard LEGuanO interface in the community.

Greetings Johan

Posted (edited)

I too would be interested... my PhD finished over a year ago now and the writing was tough (especially when running department projects simultaneously) - but glad it is over now. So good luck!!

Ive written code for MSP's - but not really dealt with the Arduino's before. C/C++, Labview, Matlab, Simulink (S functions), xPC etc are my background - along with basic PCB layout (Protel / Altium DXP etc). So im likely to follow the thread a lot - but also need to balance work and life...

:knight:

Edited by roamingstudio
Posted (edited)
I too would be interested... my PhD finished over a year ago now and the writing was tough (especially when running department projects simultaneously) - but glad it is over now. So good luck!! Ive written code for MSP's - but not really dealt with the Arduino's before. C/C++, Labview, Matlab, Simulink (S functions), xPC etc are my background - along with basic PCB layout (Protel / Altium DXP etc). So im likely to follow the thread a lot - but also need to balance work and life... default_cycl_shadowknight.gif

Dear All,

I believe this is catching up some good momentum. There is a lot of diverse knowledge, there are visions, first tries, serious implementations, creative ideas, and most importantly, there is "drive" - in a very positive sense. And yes, there needs to be a smooth balance; name it work and life. For me this means we don't need to power this through - instead let's try to render this into an attractive approach for the numerous train heads around. Wow, big words eh?

Whatever. I'd like to share a couple of very vague ideas before moving in, and I think we should agree on some fundamentals; if you don't agree, give my flak. Here we go:

- The thing we are dreaming about seems to be a "train PBrick", right? There were/are LEGO PBricks but they do not really resonate with LEGO trains, they are more like "robot PBricks".

- Regardless what we dream up, it should be compatible in some way with what LEGO is giving us, e.g., the PF hardware, PF message protocols, IR communication, all the works, right? We may want (I do!) RF communication, but that should not translate to: "If you want to go with what is dreamed up here you are screwd" (I am trying to say that the RF should not be hardwired to the PBrick but rather an external option ...)

- And then we all have our preferences. What should such a "Train PBrick" be capable of? What about ...

  1. Large ID space. Which translates to "many trains", "many automated switch points", many "whatever devices" are trackside ...
  2. It should be small. Do we need full battery power on board? Or just for the the flash memory?
  3. How about optional bi-directional communication? RF is one-way. What about hand-shaking?
  4. Anything else? There must be a million more ideas ...

If we can agree on - or better come-up with - a list of what is central, what is less important, and how do we keep compatibility at max, I am willing to spend some considerable time here. Not 24/7 but more persistently ... Don't get me wrong: I am new here, it was not my idea to start this activity, I am just having a lot of fun. Others may have well thought about similar things in the past!!!

My PhD thesis is some 17 years ago, now I am running a PChem department and still do play with LEGOs and I tell you what: It feels (very) good to be here!

All the best,

Thorsten

Edited by Toastie
Posted

Dear All,

I believe this is catching up some good momentum. There is a lot of diverse knowledge, there are visions, first tries, serious implementations, creative ideas, and most importantly, there is "drive" - in a very positive sense. And yes, there needs to be a smooth balance; name it work and life. For me this means we don't need to power this through - instead let's try to render this into an attractive approach for the numerous train heads around. Wow, big words eh?

Whatever. I'd like to share a couple of very vague ideas before moving in, and I think we should agree on some fundamentals; if you don't agree, give my flak. Here we go:

I think this is a good approach, especially remaining as compatible with the existing PF devices from Lego as possible. I also agree keeping RF modular, since there may be times we want to use RF, but others where the existing PF/IR is sufficient. Also the more widely useful we can make the device, the more likely it becomes a de-facto standard.

I think the basic things we need to address are

1) motor control, with options of multiple motors being safely controlled from one controller.

2) mechanical devices such as points/switches and semaphore signals

3) train and signal lights, these should be flexible in numbers and type to accommodate the many national signal standards and also both Lego LEDs and possibly third parties such as lifelites.

a further refinement that would be nice

4) position detection and PC control

BTW I have no PhD. I do have a Physics degree and another in Computing and Instrumentation, and have worked 10 years as a professional programmer including a couple of years doing embedded work for controllers of fruit sorting machines. My electronics is pretty dated now, but I worked for a year as a repair tech for IBM 486 motherboards, so I should be able to at least try and understand.

Posted

Well, memory wire tests have failed so I have bought me some servos for 8€ per piece. I'll post more if I have two arm signals and a point working with those servo motors.

Posted

Well, memory wire tests have failed so I have bought me some servos for 8€ per piece. I'll post more if I have two arm signals and a point working with those servo motors.

Initial tests were done. Servos seem to be very neat for powering signals and points. The only problem I had was a software problem: the IR messages are not being read together with the Servo motors. Problem is that they both want to use timer1 of the AVR. I should really make sure IR works using interrupts then that problem is solved.

Posted

I'll post images this weekend of the working point and arm signals. Currently working on my PF remote. Hope to finish that before tuesday, (start of LW 2010 in Zwolle, Netherlands), but we'll see. Servos work very well and it was a very good decision to move from memory wire to servos. They are cheap and accurate.

Posted

I'll post images this weekend of the working point and arm signals. Currently working on my PF remote. Hope to finish that before tuesday, (start of LW 2010 in Zwolle, Netherlands), but we'll see. Servos work very well and it was a very good decision to move from memory wire to servos. They are cheap and accurate.

Hi JopieK,

sounds all very good.

Lets wait for the servo (and actualy switch point setup) story. But then - if we want to go further towards a more general "LEGO train PBrick" - lets first talk about what do people really want (i.e. what is generally featured in the guts of that PBrick), and how do we want to implement that. Currently I don't think that many people are really interested in such a device, given the number of replies in this thread. That is perfectly ok with me, maybe we are discussing a topic that is not very much appealing to the general public.

Rock on,

Thorsten

Posted

I have been following this thread with interest and am very interested in a "Lego train brick".

Or maybe even a more general PF brick. Unfortunately I don't have the time to help develop it right now and it seems several of you have much more experience with this stuff than me so I think you will do better without me!

What functions do you have in mind for this brick? I have some ideas. Maybe I am just stating the obvious and then you can ignore me...

In a layout you can have several small hubs that can take commands from a central point, perhaps with Bluetooth from a computer?

The hubs can:

1. control PF much like the IR-receiver today (operate for example a train motor).

2. control servos or something to operate switches.

3. forward signals from external sensors (pressure, position? ...)

What protocol is used in Mindstorm NXT? Can that be used to communicate with sensors and servos? Then we already have several peripherals to use and we can make some more.

To know the location of a train RFID can be used with tags on the rail and a RFID reader in the train.

If this would be possible to implement in a small brick I think it would be very useful for trains and even more for Mindstorms and Technics.

I said that I don't have the time but this would be so interesting so I don't think I can keep away. I am a programmer so maybe I can help with the PC software?

Posted

I have been following this thread with interest and am very interested in a "Lego train brick".

Or maybe even a more general PF brick. Unfortunately I don't have the time to help develop it right now and it seems several of you have much more experience with this stuff than me so I think you will do better without me!

What functions do you have in mind for this brick? I have some ideas. Maybe I am just stating the obvious and then you can ignore me...

In a layout you can have several small hubs that can take commands from a central point, perhaps with Bluetooth from a computer?

The hubs can:

1. control PF much like the IR-receiver today (operate for example a train motor).

2. control servos or something to operate switches.

3. forward signals from external sensors (pressure, position? ...)

What protocol is used in Mindstorm NXT? Can that be used to communicate with sensors and servos? Then we already have several peripherals to use and we can make some more.

To know the location of a train RFID can be used with tags on the rail and a RFID reader in the train.

If this would be possible to implement in a small brick I think it would be very useful for trains and even more for Mindstorms and Technics.

I said that I don't have the time but this would be so interesting so I don't think I can keep away. I am a programmer so maybe I can help with the PC software?

That is a good idea, there are a lot of RFID applications for Arduino and I did some successful tests. The NXT has i2c at its sensor ports so that way it can be hooked up to an Arduino / LEGuanO. But an Arduino costs about 20€ and an NXT costs a lot more and has more or less the same possibilities (actually less).

Posted

That is a good idea, there are a lot of RFID applications for Arduino and I did some successful tests. The NXT has i2c at its sensor ports so that way it can be hooked up to an Arduino / LEGuanO. But an Arduino costs about 20€ and an NXT costs a lot more and has more or less the same possibilities (actually less).

Hi JopieK,

do you have an estimate/idea of the cost breakdown of the LEGuanO and its cost bottlenecks?

Although 20 Euro is already a very good price point.

Kind regards,

Teddy

Posted

Anyway. The LEGuanO in the train receives PF messages. The last car of the train has a bunch of batteries, the LEGuanO and the driver for the motor. On top of the roof there is a small IR receiver. The LEGuanO board is designed to have a native IR receiver fit.

How is the LEGuanO connected to the PF elements?

Do you have a shematic of pictures?

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