Recommended Posts

Awesome, had some time to play last night. It's working perfectly! I was able to use my arduino to put a train into extra space mode and control it just like normal. Confirmed by the fact that the train ignored a normal remote. So now I've got lots of extra channels for a train layout.

Once I get things a little more polished, I'll be publishing the code so others can do it too...

Share this post


Link to post
Share on other sites

Im sure there is three way switches you can hook up by lego or non lego things. or perhaps you can make one

A DPDT swich can reverce a DC motor.

With a NXT brick you can program pin 1 to do one function , pin2 to do another, etc these pins can be connected to the PLAIN side of a switch, do not connect two paths that have a outputting line together. such as if one is controlling a motor and one is controlling a color sensor.

They have to go to a path that has nothing going through it electrically prior to the switch being closed , the only thing that should go through it is the data from that path when the switch is closed.

If you want even more fun you can use microswitches inside of a microcontroller in the NXT brick, these things are SMALL.

Again you just have to set the instructions right and hook the lego electronic components to the right pins of the port of the NXT brick.

the NXT brick needs to use the H bridge aswell in order to reverce the polatiry

with functions, the NXT can do lots of things such as flash an LED when it hears a sound that is a certain decibel, or spin a motor and play a preloaded sound but alter the pitch of it (possibly)

it can turn an digital inputed light signal into a digital electrical signal with the ADC then play it through the speakers like a CD player basicaly does

when you increase the resistance in the motor axis in the NXT brick the amperage raises so if you stop the motor axis the motor will behave like a short, say if the robot was driven into a wall it would cut the motor.

these are simple ideas and it can get much complex than this.

Three buttons can turn off three functions individually too, a button is a switch.

Id like if if lego could make a LCD screen that can easily be mounted to a model and looks good, and id like some LEGO magnetic reed switches

Edited by SNIPE

Share this post


Link to post
Share on other sites

Awesome, had some time to play last night. It's working perfectly! I was able to use my arduino to put a train into extra space mode and control it just like normal. Confirmed by the fact that the train ignored a normal remote. So now I've got lots of extra channels for a train layout.

Once I get things a little more polished, I'll be publishing the code so others can do it too...

Congrats! That's good to hear, looking forward to that! One question though, are you repeating all commands 5 times like LEGO states on the last pages of their PF Specs or your sent a command only once? I am currently sending the switch "hypersapce" command only once, no repetitions.

Share this post


Link to post
Share on other sites
Im sure there is three way switches you can hook up by lego

it can be done with an nxt brick and two touch sensors, but that's a pricey solution. a simple dual-switch, 3-way cuircuit harness shouldn't cost more than $8 - $10. add the motor and the battery box, and the whole thing should come in for around $25 - $30.

KEvron

Share this post


Link to post
Share on other sites

Congrats! That's good to hear, looking forward to that! One question though, are you repeating all commands 5 times like LEGO states on the last pages of their PF Specs or your sent a command only once? I am currently sending the switch "hypersapce" command only once, no repetitions.

The main IR code that I'm using, I didn't write. I've just made adjustments as needed to it (to add extra space ability, for example). Looking at it, it doesn't appear to send the command 5 times.

Share this post


Link to post
Share on other sites

The main IR code that I'm using, I didn't write. I've just made adjustments as needed to it (to add extra space ability, for example). Looking at it, it doesn't appear to send the command 5 times.

I have made it a while back, a custom remote control

My link

Ill refresh the links, they don't work anymore

Share this post


Link to post
Share on other sites

Thanks - it's your code that I'm using. I found it over on the arduino site, but didn't realize you visited over here too :)

I've modified it now so that the extra address space works. I'll post it soon, just need to clean some things up.

On your remote, what LED specs are you using? Is it a 940nm or 850? how much power? I'm currently using a 940nm w/ 200ma, and the range just sucks.

Share this post


Link to post
Share on other sites

Thanks - it's your code that I'm using. I found it over on the arduino site, but didn't realize you visited over here too :)

I've modified it now so that the extra address space works. I'll post it soon, just need to clean some things up.

On your remote, what LED specs are you using? Is it a 940nm or 850? how much power? I'm currently using a 940nm w/ 200ma, and the range just sucks.

I used a normal 940nm ir led.

But i made a booster to boost it up to 200ma. An arduino/atmega pin only delivers maximum 20ma.

arduino-joystick.jpg

I also made an Lego IR reviver using all 8 addresses. I still have to modify my remote control :P

Share this post


Link to post
Share on other sites

But i made a booster to boost it up to 200ma. An arduino/atmega pin only delivers maximum 20ma.

Hi SuperCow,

now this is very nice, just what I was looking for. Sweet!!!

Just in case: Further up people were also discussing RF as range extension or "line of sight problem" buster. In this thread in the Train forum I have posted one idea of how to get RF and PF get along quite well. The RF thingies tie into the IR bit stream so you don't have to get nasty on the LEGO stuff.

The thread discussion is also very interesting. JopieK has a project going on where he uses 2.4 GHz stuff at breathtakingly low prices(!), see links in posts. That seems to be the way to go with respect to RF, if you'd ask me.

Regards,

Thorsten

Share this post


Link to post
Share on other sites

Thanks supercow. I've got something similar - an arduino w/ some pots and switches set up as inputs to control speed, and an output w/ transistor to boost the IR power to 200ma. I'm guessing either I've got some dud LEDs or something else is wrong. I'm getting only a few feet of range, pointed straight at the PF receiver from above.

Share this post


Link to post
Share on other sites

On your remote, what LED specs are you using? Is it a 940nm or 850? how much power? I'm currently using a 940nm w/ 200ma, and the range just sucks.

The LED topic is nearly worth a seperate thread...

I have the luck that I've got a big components store in my town so I have a bunch of different LEDs.

It is not only the wattage of the LED that matters, but also the directional output of the LED. Usually you find this in the datasheet, but some electronic components let you search also for a specific angle. The angle defined here is usually where there is 50% of power left.

For my case, I want to use stationary transmitters, so I am looking for wide-angle LEDs to cover as much space as possible. Currently I have got 45° ones (that's the most I could get over the counter) but I want to try also 120°. There are LEDs as narrow as 15° , so here you have to aim pretty well!

Share this post


Link to post
Share on other sites

The LED topic is nearly worth a seperate thread...

I have the luck that I've got a big components store in my town so I have a bunch of different LEDs.

It is not only the wattage of the LED that matters, but also the directional output of the LED. Usually you find this in the datasheet, but some electronic components let you search also for a specific angle. The angle defined here is usually where there is 50% of power left.

For my case, I want to use stationary transmitters, so I am looking for wide-angle LEDs to cover as much space as possible. Currently I have got 45° ones (that's the most I could get over the counter) but I want to try also 120°. There are LEDs as narrow as 15° , so here you have to aim pretty well!

my range is better then the lego control, doesn't matter where i point. I use a normal irled 20ma ;D

My range wasn't good first because it didn't oscillate on 38KHz but on 28Khz (read my comment in sourcecode)

Share this post


Link to post
Share on other sites

Thanks for that tip about the oscillation freq. I saw the note in your code. I might try tweaking that a bit - don't have an oscilloscope, so can't measure, but I can try adjusting it just a bit to see if that makes a difference. I'm running on a arduino duemilanove and a teensy, both 16mhz processors. It'd only take a few minutes, so worth trying...

Share this post


Link to post
Share on other sites

my range is better then the lego control, doesn't matter where i point. I use a normal irled 20ma ;D

My range wasn't good first because it didn't oscillate on 38KHz but on 28Khz (read my comment in sourcecode)

Thanks for that tip about the oscillation freq. I saw the note in your code. I might try tweaking that a bit - don't have an oscilloscope, so can't measure, but I can try adjusting it just a bit to see if that makes a difference. I'm running on a arduino duemilanove and a teensy, both 16mhz processors. It'd only take a few minutes, so worth trying...

Hello SuperCow, mostlytechnic,

My name is Steffen and I'm new to eurobricks and have read the topics about all the activities around the IR PF with great interest. Based on SuperCow's Code found on the arduino forum I also build a PF IR remote. Thank you for sharing your code! I did not know about the updated code, but will have a closer look at this. (I also have range problems, but I guess I do not have the proper resistors in my amplifier circuit).

My application is a bit different. I do not want to build a manual remote but want to control the different LEGO motors from my PC. So I added a simple parser to the arduino. Commands can be sent over the serial interface using the USB connection and the virtual serial port. I implemented commands to set the velocity, halt a motor, toggle the extra address bit and output an "impulse". The impulse command sets one motor to maximum velocity and then floats it - useful for train switches. The state of digital input channels can also be queried. With this I'm now able to control up to 16 PF motors with my mouse.

I'm planning to have some kind of feedback, where the trains are, so I can implement a simple train control system. Probably the feedback may not be built with LEGO (reed sensors, light barriers, ...?)

To test all this I have a simple GUI where I can add motors on the fly:

post-8965-132251332511.jpg

post-8965-132251333936.jpg

(currently this is implemented in python, but providing modules in other languages should be easy, since the protocol is simple ASCII over a serial interface)

Of course this also can be used to build some colorful GUI for the 8043 excavator, ...

What about collecting all this code on sourceforge or some other code hosting platform? I think other people might find this also interesting.

best,

Steffen

Share this post


Link to post
Share on other sites

Ok, hopefully you can help me... Still working on the hardware for my remote. I've got an arduino running basically SuperCow's code to generate the IR signals. From the pin on the arduino, I have a simple transistor amplifier circuit (pin - > resistor -> base, emitter to ground, and collector to the IR led w/ a 22R resistor from 5V) In theory that should be giving me 200ma thru the LED.

I've tried a couple different LEDs (one from radio shack, and a couple from a pack I ordered off ebay). No matter what, I only get about 4 feet of range, even pointed directly at the receiver.

I also tried changing the values in the code to adjust the freq (in case it wasn't right at 38KHz). No improvement at all, and if I changed it too far, it quit working all together.

Any ideas?

Share this post


Link to post
Share on other sites
From the pin on the arduino, I have a simple transistor amplifier circuit (pin - > resistor -> base, emitter to ground, and collector to the IR led w/ a 22R resistor from 5V) In theory that should be giving me 200ma thru the LED.

Maybe the transistor can't provide that current. What transistor have you used? Base resistor value?

Share this post


Link to post
Share on other sites

The transistor is a basic pn2222 (think that's the right # - it's the super common one NPN one. Rated for like 600ma or something like that)

Base resistor is a 10K. Is that the problem?

edit: lemme see if I'm right (I know little about electronics; I'm more of a software guy. But I can google well!). I want 200ma out of the transistor, right? So assuming a gain of 100, I need 2ma into the base. Using V=IR, that'd mean a 2500ohm resistor with the 5V circuit. So swapping the 10k out and putting in something around 2-3K would be better? Not able to test it at the moment, but I can later tonight hopefully...

edit 2: So I did some calculations and ended up trying a 1.8K resistor instead of the 10k base resistor. It does help - range is better, but still not as good as the real remote. But, my final design uses 7 LEDs in series, so I think it'll be ok. Still debating though on whether to put the LEDs on the table pointed up (to bounce off the white ceiling) or mount them on the ceiling pointed down. The first would look better (can probably even hide them in buildings w/ a hole in the roof, or put them behind things since only one side of the layout will be accessible) but the second more reliable I'd think.

Edited by mostlytechnic

Share this post


Link to post
Share on other sites

edit: lemme see if I'm right (I know little about electronics; I'm more of a software guy. But I can google well!). I want 200ma out of the transistor, right? So assuming a gain of 100, I need 2ma into the base. Using V=IR, that'd mean a 2500ohm resistor with the 5V circuit. So swapping the 10k out and putting in something around 2-3K would be better? Not able to test it at the moment, but I can later tonight hopefully...

Yes, that's what I meant. And your current gain of 100 is IMHO optimistic for this kind of transistor. If you look at this datasheet you see that saturation voltage is specified for a 150mA collector current... at a 15 mA base current! If you base current is too low there is a large voltage drop in the transistor, reducing LED current. I'd also suggest a transistor better suited for high current such as BC337

edit 2: So I did some calculations and ended up trying a 1.8K resistor instead of the 10k base resistor. It does help - range is better, but still not as good as the real remote. But, my final design uses 7 LEDs in series,

What voltage do you intend to use, 12V?

Share this post


Link to post
Share on other sites

Thanks for your input.

I also tried going to a 330R as the base resistor, and that didn't seem to change anything.

Yes, the final design will use a 12V supply to run the 7 LEDs. For now, I'm just trying to get the circuits working with a single LED off the 5V supply from the USB connection. I'll probably switch to my 5v/12v supply this weekend if I get a chance...

What about the BC337 makes it better? Looking at the datasheets, the 2222 is rated for 600ma continuous, 1100ma peak. The BC337 is 500/1000. So what else should one be looking at to pick a transistor? (in my case, I picked these cause I got a bag of them for cheap at a local store...)

Edited by mostlytechnic

Share this post


Link to post
Share on other sites

What about the BC337 makes it better? Looking at the datasheets, the 2222 is rated for 600ma continuous, 1100ma peak. The BC337 is 500/1000. So what else should one be looking at to pick a transistor? (in my case, I picked these cause I got a bag of them for cheap at a local store...)

Current gain at high current/low collector voltage, and saturation voltage. Both are better for BC337.

Share this post


Link to post
Share on other sites

PF fridge magnets....

KEvron

haha that is certainly a very original idea, but...what would they do :grin: ?

tim

Share this post


Link to post
Share on other sites

PF fridge magnets....

KEvron

haha that is certainly a very original idea, but...what would they do :grin: ?

tim

Pf attach /disattach?:look:

So what other great technic power functions stuff should we get?................................................................ah yes,

cup holders.

KEvron

:look:

Edited by Alasdair Ryan

Share this post


Link to post
Share on other sites
what would they do?

well, aside from adding immeasurable kitsch value to my home, they'd be handy in affixing A+ school papers to where everyone could admire them.

So what other great technic power functions stuff should we get?

seems a silly idea until you find yourself without one.

you know, i was wondering if these comments would go unnoticed. the thread had strayed a bit, so i thought i'd apply a little kidding-on-the-square.

KEvron

Edited by KEvron

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.