Small Virtual Wall for iRobot Roomba



The Virtual Wall is a circuit to mimic the behaviour of the iRobot Virtual Wall/Lighthouse, provided with the robot. It produces the same infrared pattern and the robot sees it as another virtual wall, blocking its path, while vacuuming.

This circuit was built mostly using SMD components to reduce its size, nearly to the size of a 9V battery (PP3/6F22/6LF22/etc).


Design Considerations

After examining the original virtual wall, with a webcam, I was able to see that it emits infrared light from its top round transparent ring and from a small hole above the switches. The light coming from the top ring prevents the robot from colliding with the virtual wall, if it comes from its sides or from behind. The front hole emits light as a beam. This beam of light is directional and stops at the nearest obstacle, probably a real wall, preventing the robot from crossing it to the other side.


The pattern emitted by the virtual wall is a form of PWM, modulated with a carrier frequency around 38KHz. Below is a picture of the pattern captured using a TSOP1238 and an oscilloscope.


It consists of a sequence of eight bits, encoded as:

Bit 0

Bit 1


So the byte being emitted is 0xA2 or 0b10100010. The pattern repeats itself after a few tenths of milliseconds later.

A circuit to emit a similar pattern will need to output the same 0xA2 pattern, generate the 38KHz carrier frequency and mix the two together. Using a PIC microcontroller it is possible to output the pattern and generate the carrier frequency. Mixing is accomplished by connecting the LED between the PWM output and the carrier output.

A great solution is to use the PIC's master clock oscillator output to produce the carrier frequency. This is the solution proposed by the circuit below. The PIC clock runs at 160KHz (FOSC) using an RC oscillator and the carrier frequency is available on CLKOUT pin as FOSC/4, at 40KHz.



From left to right we see the main switch, the power supply based on a MIC5205-5, 5V/150mA regulator, the microcontroller, two LEDs, one emitting visible light and an infrared one. Connected to the microcontroller's pin 2 (CLKIN) are R1 and C6 that form the RC pair for the PIC oscillator. There's also a 5 pin header to connect the programmer (an ICD2 or another compatible one). Click the image to enlarge.

Schematic - Click to enlarge

The power supply's MIC5205 is a low dropout voltage, low noise, low quiescent current, regulator very good for battery powered circuits and powerful enough to deliver 150mA. The circuit consumes 3.5mA on average and the IR LED peak current is 25mA mostly because the PIC cannot drive more than 25mA on its pins. The input voltage should be between 5.2V and 16V and I suggest a 9V battery to which you may hold the circuit using velcro or any double sided sticky tape.

As referred above, the PIC's master clock should be adjusted to FOSC=160KHz using R1. Connecting a frequency counter to pin 3 (CLKOUT) and adjusting R6 until 39KHz or 40KHz are displayed. This adjustment is not critical.

The visible LED should be a high brightness model because it is driven with less than 1 mA.


List of Components


Quantity Part Description
1 S1 Micro slide switch (RS #712-2567)
1 IC1 MIC5205-5 SOT-23 (RS #453-158)
2 C1, C4 10uF/16V Aluminum electrolytic capacitors (RS #628-4018)
1 C6 22pF 1206 capacitor (RS #264-4040)
1 C5 100nF 1206 capacitor (RS #391-214)
2 R2, R4 4K7 resistor 1206 (RS #223-2350)
1 R3 150R resistor 1206 (RS #223-2142)
1 LED1 Any 5mm infrared LED (preferebly a narrow beam one)
1 LED2 Any high brightness 1206 LED (visible)
1 ICD2 SIL header 5 pin female
1 J1 Molex connector, 2 pin, male, 90º
1   PCB
1   9V battery plug
1   9V battery



The PCB and Schematic were created using Eagle from Cadsoft. The PCB is about the same width as a 9V battery so it may be attached/glued/velcro'd to it. The blue line (replace with a wire jumper) and the ICD2 connector are only required for for programming the microcontroller. There's no need to add them to the PCB if the PIC was previously programmed.

PCB - Click to enlarge (even more)

Both tracks and silk screen are available for download in two separate PDF files. Both files have mirror images suitable for photographic or toner transfer methods.

The PCBs after etching with the solder bath applied:

pcbs unpopulated

And after being assembled:

pcbs assembled



This is my first attempt to write an assembly program on my own. It uses 89 bytes of FLASH and 8 bytes of RAM! There are no interrupts and all timings for the PWM are created by counting the instructions' time.

The PWM routine gets the pattern byte 0xA2 and rotates it through the C flag. Then the correct bit pattern (see above) is produced, wating the correct amount of time and another bit is shifted through C. The process repeats itself 8 times, for each bit of the pattern byte.

flow diagram

Besides generating the virtual wall pattern, it will also read pins GP0 and GP1 to generate the Clean and Spot IR patterns on demand (when they are pulled down). This feature is from the Tiny Remote Project and, unless someone shorts those pins to GND, it won't transmit those patterns. As is it will transmit the Wall 0x82 pattern and thus the software can be shared between both projects. GP0 and GP1 pins are available at the ICD2 connector:

While on Spot or Clean pattern, breaking/releasing  the connection to ground, stops the IR emission. When breaking/releasing the connection to ground of both pins simultaneously, the circuit will keep emitting the virtual wall pattern.

The following tables contain the infrared commands that the robot understands. You may use them to further expand this project:

Command/Pattern Binary representation  Hexadecimal 
Power 1000 1010  0x8A 
Spot  1000 0100  0x84 
Clean  1000 1000  0x88 
Max  1000 0101  0x85 
Left  1000 0001  0x81 
Left/Forward  1000 1011  0x8B 
Forward  1000 0010  0x82 
Right/Forward  1000 1100  0x8C 
Right  1000 0011  0x83 
Pause  1000 1001  0x89 
VirtualWall/Lighthouse  1010 0010  0xA2 


There are other patterns emitted by the docking/charging station, their job is to let the robot position itself in line with the front side of the dock and recharge automatically.

Docking Station Patterns Binary representation Hexadecimal
Behind 1111 0010 0xF2
Left 1111 1010 0xFA
Slightly Left 1111 1011 0xFB
Middle 1111 1110 0xFE
Slightly Right 1111 0111 0xF7
Right 1111 0110 0xF6


The firmware for pic12F629 is available for download below.



After programming the PIC, the master clock needs to be adjusted to 160KHz. Then start your irobot vacuum cleaner and place the circuit board near its IR ring. The robot should move away from the circuit as if it was an original virtual wall.

pcb running



Files available for download:



  1. PWM (Wikipedia)
  2. MIC5205 datasheet
  3. PIC12F629 datasheet
  4. iRobot Create Open Interface (PDF)
  5. iRobot Serial Command Interface (PDF)


Published on Tuesday 2011/04/05, last modified on Monday 2013/06/10