One MAJOR issue with programming MARVIN is NXT to NXT communications. I am putting six NXTs on this next version, so you can see where the issue is at. RobotC allows only one to one communications, while NXT-G allows up to four to communicate with one being the master so the slaves can't communicate directly. I think I have simultaneously solved both problems.
Enter the light sensor. Imagine six light sensors facing each other in a circle inside a dark box. Now imagine one of the sensors sending out a short stream of blinks in a code. The other sensors will pick up the light emitted from the sending sensor. It works, and it works well (so far)! The light doesn't turn on and off as quickly as the LED, but I can get a single blink on and off in less than 50 ms. So in a second, I can send a stream of blinks 20 blinks long. If you use a binary system like I have, you can send an elaborate coded message in a pretty short time. It doesn't compare with the speed of Bluetooth, but with this system, I could possibly leave the Bluetooth function unused. I like that thought.
And possibly the best part of the setup is that I don't have a master and a slave, each NXT can equally send and receive messages! Sweet! This has even got me thinking about throwing my other two RCXs in the picture, but I would likely use them purely as slaves. I have no idea what I would have them doing.
The possibilities are ENDLESS!
Showing posts with label Light. Show all posts
Showing posts with label Light. Show all posts
Wednesday, March 10, 2010
Wednesday, January 13, 2010
Communicating with Light
I just discovered something really cool!
I use RobotC and one of the major drawbacks is that the people at RobotC haven’t released a way for the NXT bricks to communicate with more than one brick at a time. So while I am building this big robot with 4 NXTs, I have to come up with a way to communicate between them. My idea was to use a PF LED as the transmitter in a motor port and a Lego light sensor as a receiver on two bricks. As it turns out, this is a very effective way to communicate.
My first thought was that I could turn the light on for 100 ms and the light sensor could read how long it is on and that time length would be the signal. Then I could string together several blinks as a “code.” For example, one signal with three messages may be 100 ms, 250 ms, and 150 ms. My thought was that it takes time for the LED to come on and turn off, plus the light sensor has some lag time too.
But it turns out that the light sensor and the PF LED can be operated faster - MUCH faster. The LED can be turned ON full strength and completely OFF very quickly and the light sensor can read it nearly instantaneously. I am able to consistently send and receive a five digit code that looks like this: {15, 20, 15, 20, 15}. The message that is typically received is something like {16, 21, 16, 22, 16} I have never had a time reading error of more than 3ms! Not bad! The ON/OFF cycle can't be seen with the naked eye, so all I see from the LED is one short blink that shimmers a little bit.
Each blink is separated by a 15 ms “off” time, so the total send time is 145 ms. So it’s not nearly as fast as Bluetooth, but it’s not far off. Plus I sent 5 messages in that time period.
I use RobotC and one of the major drawbacks is that the people at RobotC haven’t released a way for the NXT bricks to communicate with more than one brick at a time. So while I am building this big robot with 4 NXTs, I have to come up with a way to communicate between them. My idea was to use a PF LED as the transmitter in a motor port and a Lego light sensor as a receiver on two bricks. As it turns out, this is a very effective way to communicate.
My first thought was that I could turn the light on for 100 ms and the light sensor could read how long it is on and that time length would be the signal. Then I could string together several blinks as a “code.” For example, one signal with three messages may be 100 ms, 250 ms, and 150 ms. My thought was that it takes time for the LED to come on and turn off, plus the light sensor has some lag time too.
But it turns out that the light sensor and the PF LED can be operated faster - MUCH faster. The LED can be turned ON full strength and completely OFF very quickly and the light sensor can read it nearly instantaneously. I am able to consistently send and receive a five digit code that looks like this: {15, 20, 15, 20, 15}. The message that is typically received is something like {16, 21, 16, 22, 16} I have never had a time reading error of more than 3ms! Not bad! The ON/OFF cycle can't be seen with the naked eye, so all I see from the LED is one short blink that shimmers a little bit.
Each blink is separated by a 15 ms “off” time, so the total send time is 145 ms. So it’s not nearly as fast as Bluetooth, but it’s not far off. Plus I sent 5 messages in that time period.
Subscribe to:
Posts (Atom)
