DIY Virtual Wall for Roomba – Part One

本文介绍了一位爱好者如何使用PIC12F683微控制器自制Roomba机器人虚拟墙的过程,通过红外线发射特定频率的信号阻止机器人进入指定区域,有效解决了原装虚拟墙数量不足的问题。

Last weekend, we finally decided it was time to get a Roomba robotic vacuum.  This decision was made easier by the relatively good price and availability of the iRoomba 585 at Sam’s Club.  While this isn’t a product review, I’ll take a moment to say that so far the results are excellent.

Included with the unit was one “virtual wall“, a little black box that shoots out an infrared beam, creating an invisible line you don’t want the robot to cross.  This allows you to keep it from going somewhere you don’t want it to go without physically placing some obstruction in its path.  The virtual wall works great, but one just isn’t enough in our case.  Luckily, it took just a bit of Googling before I was ready to build my own.

Circuit

It turns out that the virtual wall isn’t too complex.  Basically, it sends out a repeating pattern of ON/OFF infrared signals, each one a millisecond long.  These signals ride on a 38kHz carrier frequency, just like most infrared remote controls, meaning that an ON signal is actually being pulsed ON/OFF about 38,000 times per second.  I won’t go into more detail here, especially because it’s beyond the scope of my expertise, but please see the references for more information on carrier frequencies.

Only a few parts were required to start building my own virtual wall, all of which I was lucky enough to have on-hand.  Here I’ll put out my standard disclaimer that my electronics knowledge is pretty limited, and anything that I cobble together runs mostly on dreams and good intentions.  I did my best to throw some math into this circuit, but I’m always open to helpful hints as to how to improve things.

 

I used a PIC12F683 microcontroller because I have a bunch of them.  They’re inexpensive and pretty robust, so I bought a pack of ten a while back on eBay.  In this simple circuit, I use the PIC’s pulse-width modulation (PWM) capabilities to generate the 38kHz carrier frequency.  The PWM pulses are output through the GP2 pin, which turns on the transistor, letting current flow through the infrared LED, thus generating the required signals.

Circuit Diagram

Components

  • PIC12F683 Microcontroller
  • R1 – 330 ohm 1/4-watt
  • R2 – 12 ohm, 1/4-watt
  • Q1 – 2N3904 (Datasheet)
  • L1 – Infrared LED (Datasheet)

 

Source Code

The source code is written for the HI-TECH C compiler, which is included in the older version of the MPLAB IDE I’m still using.  I first tested sending a steady stream ON/OFF pulses, which had the desired effect of making the robot stop and turn.  In an attempt to extend battery life, however, I’ve settled on sending out a blast of pulses, then putting the microcontroller to sleep for a couple hundred milliseconds.  My assumption is that the robot won’t travel too far in that time.  So far, the results look positive.

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

#include <htc.h>

 

__CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_OFF & CP_OFF &

    CPD_OFF & BOREN_OFF & IESO_OFF & FCMEN_OFF);

 

#ifndef _XTAL_FREQ

 #define _XTAL_FREQ 2000000

#endif

 

#define PWM_OFF CCP1CON = 0x10

#define PWM_ON CCP1CON = 0x1c

 

#define BURST_COUNT 10                  // How many IR bursts to send

 

// GP2 - PWM output

void main() {

 

    int i;

 

    OSCCON = 0x51;                      // Internal 2MHz osc.

 

    ADCON0 = 0;                         // all pins digital

    ANSEL = 0;                          // all pins digital

    CMCON0 = 7;                         // Comparators off.

    TRISIO = 0;                         // all output

    GPIO = 0;                           // all pins low

 

    PR2 = 0b00001100 ;                  // Set up PWM for roughly 38kHz

    T2CON = 0b00000100 ;

    CCPR1L = 0b00000110 ;

    PWM_OFF;

 

    PSA = 0;                            // Don't use Timer0 prescalar

    WDTCON = 0b00010000;                // Prescalar = 1000 = 8192 = 272ms

 

    while (1){

 

        // Send a few IR bursts

        i = BURST_COUNT;

        while( i-- )

        {

            // Virtual wall is 1ms on, and 1ms off

            PWM_ON;

            __delay_us(1000);

            PWM_OFF;

            __delay_us(1000);

        }

 

        // Then sleep for a moment

        SWDTEN = 1;     // Enable watch dog timer

        asm("sleep");

        SWDTEN = 0;     // Disable watch dog timer

    }

}

Next Step

I’ve got the microcontroller programmed and the components permanently soldered onto a perma-proto board.  I’ve tested it using a CR2032 coin cell battery as the 3-volt source, and positioning it just right in a doorway with a small piece of a drinking straw over the infrared LED to make it more directional.  The next step, and the one most likely to confound me, will be finding a suitable enclosure, especially one pretty enough to be left out in the open and not look like I made it.

References

http://www.enide.net/webcms/index.php?page=virtual-wall-for-roomba
https://sites.google.com/site/irobotcreate2/createanirbeacon
http://www.micro-examples.com/public/microex-navig/doc/097-pwm-calculator.html
http://led.linear1.org/1led.wiz

 

Update 8/9/2014:  I posted a second part to this article here that includes the final product.

http://misc.ws/2014/02/27/diy-virtual-wall-for-roomba/

【四旋翼无人机】具备螺旋桨倾斜机构的全驱动四旋翼无人机:建模与控制研究(Matlab代码、Simulink仿真实现)内容概要:本文围绕具备螺旋桨倾斜机构的全驱动四旋翼无人机展开研究,重点探讨其系统建模与控制策略,结合Matlab代码与Simulink仿真实现。文章详细分析了无人机的动力学模型,特别是引入螺旋桨倾斜机构后带来的全驱动特性,使其在姿态与位置控制上具备更强的机动性与自由度。研究涵盖了非线性系统建模、控制器设计(如PID、MPC、非线性控制等)、仿真验证及动态响应分析,旨在提升无人机在复杂环境下的稳定性和控制精度。同时,文中提供的Matlab/Simulink资源便于读者复现实验并进一步优化控制算法。; 适合人群:具备一定控制理论基础和Matlab/Simulink仿真经验的研究生、科研人员及无人机控制系统开发工程师,尤其适合从事飞行器建模与先进控制算法研究的专业人员。; 使用场景及目标:①用于全驱动四旋翼无人机的动力学建模与仿真平台搭建;②研究先进控制算法(如模型预测控制、非线性控制)在无人机系统中的应用;③支持科研论文复现、课程设计或毕业课题开发,推动无人机高机动控制技术的研究进展。; 阅读建议:建议读者结合文档提供的Matlab代码与Simulink模型,逐步实现建模与控制算法,重点关注坐标系定义、力矩分配逻辑及控制闭环的设计细节,同时可通过修改参数和添加扰动来验证系统的鲁棒性与适应性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值