NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Project Help and Ideas » iRobot Roomba Virtal Wall
August 14, 2010 by carlhako |
Hi Today i have been trying to reproduce a virtual wall. Its basically an ir transmitter that stops the irobot from passing the virtual wall. The beam flashes at 500hz on a 35khz carrier signal. I have successfully got it working using an atmega168 but i want to use the same code on a smaller MCU, its a bit of a waste of pins, flash etc. I have a ATTINY44-20PU which only has 4k of flash. Using the code here When i write this to the atmega168 i get the following output avrdude: input file led_blink.hex auto detected as Intel Hex avrdude: writing flash (7778 bytes): I need to reduce that to < 4000 bytes. Any ideas how i can accomplish this? Thanks Carl |
---|---|
August 14, 2010 by carlhako |
I have managed to get it down 6kb by chaning the make file to this GCCFLAGS=-g -Os -Wall -mmcu=attiny44 LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm vw.hex: vw.c make -C ../libnerdkits avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o vw.o vw.c avr-objcopy -j .text -O ihex vw.o vw.hex and getting this as output from avr-size C:Codeirobot_VW>avr-size vw.hex text data bss dec hex filenam 0 6056 0 6056 17a8 vw.hex only 2kb to go |
August 14, 2010 by carlhako |
I think my answer is in LINKFLAGS after deleting most of it, I have a 260byte output from avr-size. I think this is a little too small tho. Will post outcome of researching LINKFLAGS and figuring our what it does. |
August 16, 2010 by hevans (NerdKits Staff) |
Hi carlhako, Removing the LINKFLAGS is actually what you might want to do. The first part of the flags link in the printf and scanf functions that make it easy to print stuff out to the serial port and the LCD.
the
links in the floating point math libraries. Since you are using none of these in your code you can just blow them away and your code should still work fine (and be tiny!). Let us know if it works. Humberto |
August 25, 2010 by carlhako |
Thanks Humberto I have eventually got it working 100%. These chips run off their internal 8mhz clock out of the box and have some sort of clock divider turned on to divide by 8. These were fixed by figuring out what fuses to set. If anyone else is trying to do something similar i found this site http://www.engbedded.com/fusecalc/ it will generate your fuse settings for you. I ended up with the following, which are probably strictly for the ATTINY44 lfuse:w:0xdf:m hfuse:w:0xdf:m efuse:w:0xff:m |
August 25, 2010 by carlhako |
Forgot to mention final size 212bytes :) |
November 09, 2010 by carlhako |
Hi I am redoing this project as im not getting good range/reliability out of current design. Im trying to simplify it using phase and frequency correct PWM. Google searches has taught me is IR transmission uses a 50% duty cycle? My second questions is the irobot requires 500hz signal over the 35khz what would be the best way to achieve this? I have come up with 2 ideas, first run a second timer at 1khz and have it switching the first timer on and then off. The other idea i have is still running a second timer but use a second pin set to low as a ground for the led and setting it to high then low at 1khz achieving a 500hz signal over the 35khz. Am i on the right track? |
November 09, 2010 by mrobbins (NerdKits Staff) |
Hi Carl, Are you sure it's 35kHz? I'd guess that it's 38kHz or so, because that's what remote controls use and therefore it'd be cheaper for Roomba people to buy receiver modules already designed to filter for that modulation frequency. One site suggests that it's 38kHz modulated on-off at 2kHz. Then again, at 38kHz, it'd interfere with remote controls... Of course, I can find other sites that suggest that it's 35kHz, so who knows. Anyway, 50% duty cycle is a good place to start (to get the most power into the modulated signal). I think you're on the right track with your two ideas about generating the signal you want. Both of those ideas are fine. I'd personally probably go with the first one (one timer for 35kHz generation, switched on and off by a 2nd timer at 1kHz). Also make sure you consider the electronics and optics part of things. You can use multiple IR LEDs in series/parallel arrays to emit more light (see our 10 LEDs switched by one MOSFET for an example). And finally, infrared is not one monolithic thing -- it's a band of wavelengths. The IR receiver inside your Roomba is designed not to allow any visible light into the sensor, but that means it actually has a narrow range of wavelengths that it will accept without being dimmed by the plastic. If your IR LEDs are spitting out IR on a different frequency, then a lot of that energy will be wasted before it even gets to the sensor. If you can buy IR LEDs that match the wavelength that the receiver expects, you might easily double your range. Mike |
November 10, 2010 by carlhako |
Thanks for your reply Mike I also came across the site you linked to. its the only one i found that referred to 38khz. I will test both frequencies and do some research on which wavelengh is best to use, may need some testing here too, IR leds are cheap enough. Is there a way to work out what kind of resistor to use when driving the led with pulses? I am running my circuit at 5v and 50% duty cycle to the led. When using ohms law to work out my resistor value should i double the amperage going into the led? e.g. 2v led @ 20ma without PWM this would be (5-2)/.02 = 150ohms should i instead do (5-2)/.04 = 75ohm? |
November 10, 2010 by mrobbins (NerdKits Staff) |
Your math (2V LED @ 20mA -- 150 ohm resistor in series) is right if you want the on-current to be 20mA. It does ignore the fact that the microcontroller pin itself presents an effective resistance of roughly 25-30 ohms, so you could actually go down to a 120 ohm resistor to actually get your 20mA. I think you are asking a more detailed question about whether it's OK to temporarily (i.e. for the duration of a pulse) exceed the rated current of an LED if you let it "cool down" afterwards. So that gets to the idea that there are two possible mechanisms that could kill a LED: heat-based failure (which is relatively "slow", and the thermal mass of the object would be able to average out), or other semiconductor-based failure (which might be relatively "fast", like exceeding some critical voltages and causing the semiconductor to blow out). I think the official answer is that you should stick to the rated current at all times. But parts intended for this purpose, such as the OSRAM SFH 484 IR LED that we used for our IR-based Theremin video, will actually have curves on the datasheet to show "permissible pulse handling capability" -- see page 6 of the datasheet. Even though it's nominally a 100mA IR LED, this graph shows that it's OK to use almost 3 amps of current for a short enough pulse when it's done infrequently enough! For whatever reason, many IR LEDs seem to be built to handle higher currents (at least for short duty cycles). In your application, the LED is on for roughly 25% of the time. Say that you had IR LEDs with a forward voltage of about 1.5V @ 100mA. (FYI, IR LEDs tend to have a lower on-voltage than visible LEDs because there's less energy per photon emitted.) I'd probably take 2 of the LEDs in series with a 20 ohm resistor, and use a 2N7000 MOSFET to switch them. Mike |
November 13, 2010 by carlhako |
Hi Mike thanks again for your details reply. I ended up using a single LED i pulled out of an old tv remote. Using a 68ohm resistor i had laying around this gives 1.5v @ 80ma, since i dont know what sort of led it is i have no idea what its rating are. This seems to give out a fairly bright light when looking at it via my phone camera. Here is a vid of it working http://www.youtube.com/watch?v=JVpKb1UeIQs can see the breadboard and the led lit up before i start up the roomba. and code here http://nerdkits.pastebin.com/63NkNrxa The proper virtual wall flashed the led when i look at it through my phone i suspect its going into some sort of sleep mode and turning the led off momentarily to save battery. I am now working on reproducing this so i can run it also off batteries. Now to work out how the power saving modes work on the MCU. More and updated code to come soon :) |
Please log in to post a reply.
Did you know that you can make a huge, multi-panel LED display? Learn more...
|