Bluetooth Robot Controller

download Bluetooth Robot Controller

of 26

Transcript of Bluetooth Robot Controller

  • 8/12/2019 Bluetooth Robot Controller

    1/26

    Bluetooth Robot Controller

    Neven Skoro

    Mentor: Janusz Zalewski

    CEN !"# Co$%uter Networks

    &ate Modified: Nove$'er ()t*())#

    http://satnet.fgcu.edu/~nskoro

    mailto:[email protected]:[email protected]
  • 8/12/2019 Bluetooth Robot Controller

    2/26

    Table Of Content

    1. Introduction and Overview......................................................................................................

    "." +ur%ose.........................................................................................................................".( Sco%e............................................................................................................................"., -er$s /cron0$s and /''reviations...........................................................................". +ro'le$ &escri%tion.....................................................................................................".! +ro'le$ Solution..........................................................................................................

    2. Specific Requirements..............................................................................................................

    (." 1luetoot* 2e3uire$ents...............................................................................................(."." 1luetoot* Co$$unication +rotocols...........................................................(.".( 1luetoot* 4unctional 2e3uire$ents.............................................................(."., 1luetoot* Non54unctional 2e3uire$ents.....................................................

    (.".,." 2elia'ilit0........................................................................(.".,.( /vaila'ilit0 .....................................................................(.".,., Securit0............................................................................

    (.". 1luetoot* Constraints...................................................................................(.( 2o'ot 2e3uire$ents.....................................................................................................

    (.(." 2o'ot 4unctional 2e3uire$ents...................................................................(.(.( 2o'ot Non54unctional 2e3uire$ents...........................................................

    (.(.(." 2elia'ilit0........................................................................(.(.(.( /vaila'ilit0 .....................................................................(.(.(., Securit0............................................................................

    (.(., 2o'ot Constraints66666666.........................................................(.(. 2S(,( Co$$unication +rotocol.................................................................

    (., 7ser 8nterface 2e3uire$ents........................................................................................(.,." S%ecific 7ser Control 2e3uire$ents............................................................

    (.,.( Jo0stick Control 2e3uire$ents....................................................................(.,., 9e0'oard Control 2e3uire$ents..................................................................

    . Bac!"round Information..........................................................................................................

    ,." 8ntelli1rain 1ot 8nfor$ation........................................................................................,.( Jo0stick 8nfor$ation....................................................................................................

    #. References..................................................................................................................................

    $. %ppendi&....................................................................................................................................

    !." Jo0stick Code Ea$%le...............................................................................................!.( 2o'ot Code Ea$%le...................................................................................................!., Co$%uter Code Ea$%le.............................................................................................

    (

  • 8/12/2019 Bluetooth Robot Controller

    3/26

    %bstract'

    8n t*e world of auto$ation we want t*ings to 'e to work inde%endentl0 wit*out an0

    *u$an interaction. ;e want co$%uter servers to run wit*out *u$an control we want our

    cars co$%uters %*one %lanes and ot*er co$%licated s0ste$s 'uilt auto$aticall0 wit*out

    too much hassle. +er*a%s 0ou would want 0our lawn $oved '0 a ro'ot or $a0'e 0ou would

    want to re$otel0 $ow t*e lawn using 0our co$%uter to control t*e lawn $ower. -*is

    %roect will infor$ 0ou t*e reader *ow a secure 1luetoot* co$$unication 'etween a ro'ot

    and a user is designed and i$%le$ented and $ost i$%ortantl0 w*0 it works.

    Mac*ines are a 'ig %art of t*e world=s %roduction trans%ortation and e%loration.

    Most of t*e %eo%le toda0 are unaware of *ow $uc* work is done '0 ro'ots ever0da0 for

    ea$%le in car $anufacturing facilities and $ilitar0 o%erations. Mo'ile ro'ots s*all

    %ro'a'l0 'e t*e $ost i$%ortant $ac*ines in t*e future. /lread0 $o'ile ro'ots are 'eing

    used to e%lore distant %lanets as well as for ust si$%le *ouse *old work suc* as $owing

    t*e lawn or vacuu$ing. -*is re%ort focuses on a 1luetoot* Co$$unication w*ic* was

    esta'lis*ed 'etween t*e 8ntelli'rain 2o'ot and a +ersonal Co$%uter. -*is s%ecific design

    and i$%le$entation would work wit* $ost two5w*eel differential ro'ots t*at *ave a serial

    %ort availa'le on t*eir $ain 'oards and can run Java irtual Mac*ine.

    ,

  • 8/12/2019 Bluetooth Robot Controller

    4/26

    ". Introduction and Overview

    ".".+ur%ose

    -*e $ain %ur%ose of t*is %roect is to develo% a re$ote user interface to control a

    ro'ot via a wireless tec*nolog0. -*ere is a need to co$$unicate wit* t*e ro'ot re$otel0 in

    order to control t*e ro'ot $ove$ents and %ass critical data 'ot* wa0s. -*e current 82

    controls are not good enoug* 'ecause t*e ro'ot does not *ave an 82 trans$itter 'ut onl0 a

    receiver $eaning t*at t*e co$$unication is one wa0. -*e 82 co$$unication works onl0 in

    line of direct sig*t and an0 o'ects in t*e wa0 will o'struct t*e co$$unication.

    1luetoot* co$$unication will ena'le us to control t*e ro'ot u% to ")) $eters

    wit*out t*e need for direct sig*t w*ic* $eans t*at t*e ro'ot could 'e located 'e*ind a wall

    or so$e ot*er o'ect and t*e co$$unication would not 'e lost.

    ".(.Sco%e

    -*is s0ste$ will deal wit* t*e 'asic ro'ot $ove$ent functions as well as user

    interface 1luetoot* co$$unication serial 2S(,( co$$unication 'etween t*e ro'ot and t*e

    1luetoot* $odule and 2S(,( co$$unication 'etween t*e +C and t*e 1luetoot* $odule.

    4ull i$%le$entation of t*e code 'ot* for t*e ro'ot and t*e co$%uter s*all 'e

    develo%ed in t*is %roect.

    ".,.-er$s /cron0$s ? /''reviations

    5 82 5 8nfra 2ed

    5 2S(,( 5 Serial Co$$unication Standard

    5 /C 5 /s0nc*ronous connection link

    5 A4S9 5 Aaussian 4re3uenc0 s*ifting

  • 8/12/2019 Bluetooth Robot Controller

    5/26

    5 &-E 5 &ata -er$inal E3ui%$ent

    5 &CE B &ata Carrier E3ui%$ent

    5 C-S B Clear to Send

    5 &-2 B &ata -er$inal 2ead0

    5 &C& 5 &ata Carrier &etect

    5 2-S B 2e3uest -o Send

    5 AN& 5 Around

    5 &S2 B &ata Set 2ead0

    5 28 B 2ing 8ndicator

    5 /SNCD2N7S B a co$$unications s0ste$ in w*ic* data trans$ission $a0 start at

    an0 ti$e and is indicated '0 a start 'it

    5 SNCD2N7S B a co$$unications s0ste$ in w*ic* sending and receiving of data

    is fied '0 ti$e5clock intervals

    5 21- B 8ntelli1rain51ot 2o'ot

    5 17E--D M&7E B 4irefl0 Serial 1luetoot* Module Class "

    "..+ro'le$ &escri%tion

    -*ere is a need for a re$ote ro'ot controller t*at will ena'le t*e two wa0 co$$unication

    'etween t*e user and t*e ro'ot. -*is controller $ust 'e wireless in order to give t*e ro'ot its

    $ove$ent freedo$. -*e current 82 controller works onl0 one wa0 'ecause t*e ro'ot does not *ave

    its own trans$itter. -*e 82 co$$unication is ver0 li$ited 'ecause t*e trans$itter *as to 'e directl0

    %ointed to t*e receiver. ;it* t*e 1luetoot* tec*nolog0 we can *ave a two wa0 co$$unication

    w*ic* works on radio fre3uenc0 u% to ")) $eters in distance. 4urt*er$ore we want to control t*e

    !

    http://dictionary.reference.com/search?q=start%20bithttp://dictionary.reference.com/search?q=start%20bit
  • 8/12/2019 Bluetooth Robot Controller

    6/26

    ro'ot wit* a user interface suc* as a o0stick and ke0'oard. -*e ro'ot could t*en %ass t*e data suc*

    as distance s%eed 'atter0 %ower etc. 'ack to t*e user. -*e user could t*en decide w*at *e wants to

    do wit* t*e ro'ot according to t*e data received. -*e navigation s0ste$ s*all 'e relativel0 accurate

    wit* no deviation *ig*er t*an two centi$eters. No ro'ot is %erfect and it s*all $ost likel0 never 'e

    error free. So$eti$es in ro'otics 0ou *ave to acce%t close enoug* to 'e %erfect.

    ".!.+ro'le$ Solution

    -*e s0ste$ s*all 'e co$%osed of , $aor co$%onents. -*e first one is t*e software t*at

    defines t*e $ain ro'ot $ove$ents navigation and sensor s0ste$s. -*e second %art is t*e 7ser

    8nterface w*ic* will i$%le$ent a o0stick as t*e $ain user controller. -*e o0stick used is an

    /nalog 2aider +ro Jo0stick w*ic* will 'e connected via a Male "! %in ca'le t*roug* a ga$e

    %ort. 1ot* t*e serial co$$unication 'etween t*e +C and t*e 1luetoot* and t*e co$$unication

    'etween t*e ro'ot and t*e 1luetoot* $odule will 'e i$%le$ented. 4ro$ t*e contet diagra$ 5

    "." we can see w*ic* co$$unication %rotocols are needed for t*is design.

    #

  • 8/12/2019 Bluetooth Robot Controller

    7/26

    4ig "." Contet &iagra$

    -*e s%oofing of t*e serial ca'les is re3uired to $ake t*e connection 'etween t*e ro'ot

    and t*e co$%uter work. 1ellow we can see t*e colors used in a regular serial ca'le for

    corres%onding %in. -*e standard 2S(,( ca'le *as F %ins w*ic* we can see fro$ t*e ta'le ".,.

    Most &CE devices onl0 use %ins ( , ! w*ic* are 2eceive trans$it and ground res%ectivel0.

    -*is $akes at %ro'le$ for t*e 1luetoot* 'ecause it re3uires an active C-S and 2-S signals in

    order to know if t*e data was re3uested. -o solve t*is %ro'le$ 8 *ave connected %ins G and F to

    G

  • 8/12/2019 Bluetooth Robot Controller

    8/26

    eac* ot*er on t*e ro'ot=s 1luetoot* $odule so it alwa0s t*inks data is read0 to 'e received and

    trans$itted.

    4ig ".( 2S(,( Serial Connections HSource: Z0tra.co$I

    /'ove we can see t*e solution to t*e %ro'le$. ;e can si$%l0 wire %ins " and #

    toget*er so t*at t*e co$%uter t*ings it found t*e device loo%ing 'ack &-S &-2 and &C& 'ack

    to itself. n t*e co$%uter %art of t*e connection 8 *ad to wire %ins " and # toget*er 'ecause

    t*e 1luetoot* $odules onl0 use %ins ( , ! G F and t*erefore it does not tell t*e co$%uter if a

    &C& device was detected on t*e ot*er end. -*is ter$ is know as s%oofingK t*e connection and

    s*ould 'e done ver0 carefull0.

    n t*e ro'ot side 8 *ave connected t*e 'rown wire to t*e send %in red to t*e receive

    %in 0ellow to t*e ground %in and gra0 to t*e %ower %in. -*e corres%onding %in to t*e colors

    can 'e found in t*e coloring ta'le 'ellow 4igure ".!.

    L

  • 8/12/2019 Bluetooth Robot Controller

    9/26

    4ig "., 2S(,( ca'le %inout

    (in

    )o.

    )ame )otes*+escription

    " &C& &ata Carrier &etect( 2& 2eceive &ata

    , -& -rans$it &ata

    &-2 &ata -er$inal 2ead0

    ! SAN& Around

    # &S2 &ata Set 2ead0

    G 2-S 2e3uest -o Send

    L C-S Clear -o Send

    F 28 2ing 8ndicator

    4ig ". 2S(,( %inout ta'le

    4ig ".! 2S(,( ca'le colors HSource: $astrea$.netI

    F

  • 8/12/2019 Bluetooth Robot Controller

    10/26

    1ot* 1luetoot* $odules *ave to 'e %re5%rogra$$ed 'efore use in order to set t*e

    correct 'aud rate sto% 'its %arit0 encr0%tion and w*et*er t*e device is $aster or a slave. -*ere

    are $an0 $ore o%tions w*ic* can 'e found in figure ".#.

    4ig ".# 1luetoot* $odule o%tions Hsource: Aridconnect.co$I

    / 1luetoot* $odule can 'e %rogra$$ed '0 connecting it to t*e co$%uter via a serial

    ca'le and running a co$$unication %rogra$ suc* as D0%er-er$inal on ;indows S or

    MiniCo$ on inu S. -o %ut t*e 1luetoot* $odule into t*e configuration state it needs to 'e

    %lugged into t*e co$%uter and t*en %owered. /fter %owering a ti$e count down will initiate

    giving 0ou #) seconds to %ut it into configuration $ode. -0%ing K into t*e ter$inal window

    will access t*e 1luetoot* configuration co$$ands listed in ta'le ".# and ".G. Eiting t*e

    configuration $ode is done '0 t0%ing . -*e ta'le ".G si$%l0 s*ows t*e advance

    ")

  • 8/12/2019 Bluetooth Robot Controller

    11/26

    configuration o%tions for t*e res%ective $odules.

    4ig ".G /dvance %tions HSource: AridConnect.co$I

    -*e 1luetoot* $odules re3uired so$e furt*er *ardware $odifications. -*e %lace$ent of

    t*e inner u$%ers was c*anged to acco$$odate t*e co$$unication needs. 1ecause eac*

    1luetoot* device re3uires C-S and 2-S signals 8 u$%ed %ins " and , ( and ! and # G and L

    F and ") res%ectivel0 on t*e fe$ale $odule on t*e co$%uter end. n t*e ro'ot H$aleI 1luetoot*

    $odule 8 *ave u$%ed %ins " and ( , and F and ") res%ectivel0.

    (. Specific Requirements

    (.".1luetoot* 2e3uire$ents

    (.".".1luetoot* Co$$unication +rotocols

    ""

  • 8/12/2019 Bluetooth Robot Controller

    12/26

    -*e 1luetoot* $odule use Aaussian 4re3uenc0 s*ifting A4S9 and work at t*e 8SM

    'and of (. ADz. -*e $odules are divided into Master and Slave. -*e $aster $odule looks

    for an0 slave $odules in range and saves t*eir address and connects to it. -*e $aster is in

    c*arge of setting t*e fre3uenc0 *o%%ing se3uence w*ic* insures t*at no ot*er wireless

    devices are distur'ed. 1ot* devices need to agree on t*e 1/7& rate %arit0 sto% 'its and

    flow control in order to send 'its fro$ t*e +C to t*e 2o'ot and 'ack. 8n t*is design t*e

    1luetoot* $odules are si$%l0 etending t*e serial ca'le wirelessl0. -*e 1luetoot* devices

    used in t*is %roect are Class " w*ic* use "))$; H() d1$I and *ave a $ai$u$ range of

    ")) $eters.

    1luetoot* co$$unication is $uc* different t*an t*e 2S(,( co$$unication 'ut it

    can rese$'le one. 8t uses /s0nc*ronous Connectionless links H/CI for its data

    co$$unications. /C link sends data at irregular intervals w*enever data is availa'le.

    So$e of t*e /C link ensures data accurac0 '0 c*ecking for errors and re sending data if

    needed.

    -*e /ccess code *eader and a %a0load are e$'edded into a %acket w*ic* is

    trans$itted. -*erefore t*e slave device will $atc* its access code to t*e inco$ing %acket.

    -*e control infor$ation is contained in t*e *eader %art of t*e %acket and t*e actual data

    $essage is contained in t*e %a0load %art of t*e %acket. 1luetoot* %rotocol uses four different

    access codes suc* as C*annel /ccess Code HC/CI &evices /ccess Code H&/CI Aeneral

    8n3uir0 /ccess Code HA8/CI and &edicated 8n3uir0 /ccess Code H&8/CI. C/C is used '0

    all devices t*at are ec*anging data. &/C is used for %aging a device A8/C is used for t*e

    in3uir0 %rocedures and &8/C is used for used for s%ecified range of t*e in3uir0 access code.

    "(

  • 8/12/2019 Bluetooth Robot Controller

    13/26

    4ig (." &ata +rotocol

    -*e a'ove figure s*ows t*e 1luetoot* stack %rotocol co$%ared to t*e S8 reference

    $odel. -*e 1luetoot* can 'e in $an0 different states suc* as t*e stand'0 in3uir0 state

    in3uir0 scan %age state %age scan active connection connection *old connection stiff and

    connection %ark. Eac* 1luetoot* device can onl0 'e in one state at one ti$e.

    ",

  • 8/12/2019 Bluetooth Robot Controller

    14/26

  • 8/12/2019 Bluetooth Robot Controller

    15/26

    4ig (., 1luetoot* +aging

    -*e figure (., s*ows t*e $essage se3uence c*art w*en %aging and %age scanning.

    ;e can see t*e $essages 'eing ec*anged 'etween two devices w*en t*e0 are connected.

    -*e $aster is on t*e left side and it sends t*e slave=s access code %revious $essage

    se3uence. ;*en t*e slave gets t*e code it re%lies wit* t*e sa$e code 'ack after t*at t*e

    $aster sends t*e 4DS again and t*e slave res%onds again to acknowledge t*e 4DS. /fter

    t*at t*e /C %ackets are sent as well as t*e M+ link configuration.

    "!

  • 8/12/2019 Bluetooth Robot Controller

    16/26

    (.".(.1luetoot* 4unctional 2e3uire$ents

    5 1luetoot* fe$ale $odule s*all receive a '0te fro$ t*e Co$%uter Serial %ort and trans$it

    it to t*e $ale $odule connected to t*e ro'ot serial %ort

    5 1luetoot* connection s*all work 'ot* wa0s

    (.".,.1luetoot* Non54unctional 2e3uire$ents

    (.".,.".2elia'ilit0

    5 -*e 1luetoot* connection s*all not e%erience an0 s0ste$ $aor cras*es or errors

    (.".,.(./vaila'ilit0

    5 -*e 1luetoot* connection s*all 'e availa'le "))O of t*e ti$e if in range of ")) $eters.

    (.".,.,.Securit0

    5 -*e 1luetoot* connection s*all not allow an0 ot*er slave devices to connect to t*e

    $aster and receive data.

    5 -*e 1luetoot* connection s*all use data encr0%tion.

    (."..1luetoot* Constraints

    5 -*e 1luetoot* $odules are li$ited to $ai$u$ transfer rate of ""!())9'Ps and to t*e

    distance of ")) $eters.

    (.(. Robot Requirements

    (.(.".2o'ot 4unctional 2e3uire$ents

    5 2o'ot $oves s*all res%ond to o0stick %ositions

    5 2o'ot s*all 'e a'le to detect o'ects in its %at*wa0

    5 2o'ot s*all store t*e %at* and 0 coordinates in a dou'le arra0 varia'le

    "#

  • 8/12/2019 Bluetooth Robot Controller

    17/26

    5 2o'ot s*all 'e a'le to follow its %revious $e$orized %at*

    (.(.(.2o'ot Non54unctional 2e3uire$ents

    (.(.(.".2elia'ilit0

    5 2o'ot s*all res%ond to o0stick $ove$ent wit*in fewer t*an !)) $illiseconds

    5 2o'ot s*all not *it an0 o'ects in its %at*wa0

    5 2o'ot s*all not $iss its destination wit*in $ore t*an ( inc*es

    (.(.(.(./vaila'ilit0

    5 2o'ot s*all res%ond to user=s co$$ands at all ti$es

    (.(.(.,.Securit0

    5 2o'ot s*all not allow access to its co$$ands to $ore t*an one 1luetoot* $odule

    (.(.,.2o'ot Constraints

    5 2o'ot cannot run $ore t*an ") t*reads successfull0

    5 2o'ot runs on an Micro controller t*at *as ".G MDz %rocessing %ower

    5 2o'ot *as "(L flas* %rogra$ $e$or0

    5 2o'ot *as ",(9 2/M availa'le

    5 2o'ot *as 9 '0tes of EE+2M availa'le

    (.(..2S(,( co$$unication %rotocols

    -*e serial connection used in t*is %roect to connect t*e +C and t*e 1luetoot*

    $odule is /s0nc*ronous Serial -rans$ission H7/2-I. -*e sender and t*e receiver do

    not agree on t*e ti$ing signals 'etween t*e 'its of data 'eing send rat*er t*e0 use a

    "G

  • 8/12/2019 Bluetooth Robot Controller

    18/26

    start 'it and a sto% 'it. -*e start 'it tells t*e receiver w*ere t*e data 'egins using t*e

    little endian order $eaning t*at t*e least significant 'it is sent first. -*e ti$e 'etween

    eac* 'it is t*e sa$e for all t*e 'its and t*e receiver ust deter$ines w*et*er t*e 'it is "

    or ). -*e sender c*ecks t*e clock to see if it is ti$e to send t*e net word 'ut it does

    not *owever know w*en t*e receiver *as gotten t*e data. +arit0 $a0 'e used for si$%le

    c*ecking and flow control 'ut t*e0 will not 'e used in t*is %roect 'ecause t*e

    1luetoot* $odules do not su%%ort flow of control.

    /n i$%ortant t*ing to notice is t*at w*en t*e co$$unication is idle

    $eaning t*at no data is 'eing sent t*e 2S(,( will 'e trans$itting continuous " values.

    -*erefore a start 'it alwa0s *as a value of ) and a sto% 'it *as a value of ". -*e

    standard voltage 'eing sent is Q"(&C or 5"(&C 'ut so$e low %ower devices allow

    Q!&C and 5!&C w*ic* are still acce%ta'le 'ut in t*is case t*e ca'le lengt* s*ould

    'e s*ort. 8n case t*at t*ere is no electricit0 %resent in t*e circuit a signal called a 'reak

    is 'eing sent. -*is signal needs to 'e longer t*an t*e co$%lete '0te 'eing sent %lus t*e

    start sto% and %arit0 'its.

    -*e 2S(,( s%ecification descri'es two t0%es of connection ends: &ata

    -er$inal E3ui%$ent H&-EI and t*e &ata Carrier E3ui%$ent H&CEI. 10 standard

    convention &-E is usuall0 t*e co$%uter and &CE is a $ode$. 1ut it=s i$%ortant to

    re$e$'er t*e 1luetoot* $odule does not work wit* $ode$s. Mode$ *ere is ust a

    reference to a device 'eing connected to t*e %c.

    2..,ser Interface Requirements

    (.,.".S%ecific 7ser Control 2e3uire$ents

    5 -*e user s*all 'e a'le to control t*e ro'ot $ove$ents via a o0stick

    "L

  • 8/12/2019 Bluetooth Robot Controller

    19/26

    5 -*e user s*all 'e a'le to give co$$ands to t*e ro'ot via a ke0'oard

    5 -*e user s*all 'e a'le to switc* 'etween o0stick and ke0'oard controls

    5 -*e user s*all 'e a'le to start and ter$inate a connection

    5 -*e user s*all 'e a'le to receive 'atter0 c*arge infor$ation fro$ t*e ro'ot

    5 -*e user s*all not 'e a'le to run t*e ro'ot into an o'ect

    (.,.(.Jo0stick Control 2e3uire$ents

    5 -*e o0stick s*all send and 0 coordinates to t*e co$%uter

    5 -*e o0stick s*all send t*e states of ( of its 'uttons

    5 -*e o0stick $ai$u$ and $ini$u$ 0 coordinates s*all 'e F and 5F res%ectivel0

    5 -*e o0stick $ai$u$ and $ini$u$ coordinates s*all 'e F and 5F res%ectivel0

    (.,.,.9e0'oard Control 2e3uire$ents

    5 -*e user s*all 'e a'le to enter and 0 coordinates fro$ t*e ke0'oard w*ic* s*all 'e sent

    to t*e ro'ot

    5 -*e user s*all 'e a'le to control ro'ot $ove$ent '0 %ressing letters w s a d and 3 for

    forward 'ackwards left rig*t and sto% res%ectivel0

    . Bac!"round Information

    .1.IntelliBrain Bot Information

    Most of t*e ro'ots 'uilt toda0 are two5w*eel differential $eaning t*at all of t*e ro'ots

    $ove$ent is acco$%lis*ed wit* ust one set of w*eels. -*e 8ntelli1rain 'ot is co$%osed of t*e

    8ntelli1rain $ain 'oard t*at takes t*e energ0 fro$ // 'atteries to %ower t*e two servo $otor

    %orts as well as ot*er sensor %orts. -*is ro'ot *as t*e following co$%onents attac*ed to it=s $ain

    "F

  • 8/12/2019 Bluetooth Robot Controller

    20/26

    'oard: an C& dis%la0 a cou%le of %us* 'uttons a 'ee%er an S24) sonar range sensorR two

    w*eels t*at are attac*ed to t*e servo $otors a set of A+(&"( range sensors and two 21"",

    infrared %*oto reflector sensors used for w*eel encoding as well as line sensing. /ll of t*is

    *ardware sits on a well5'uilt 1oe51ot c*assis develo%ed '0 +aralla.

    -*e ro'ot runs on ava virtual $ac*ine t*at su%%orts $ulti t*reading w*ic* is essential for

    t*is %roect 'ecause we need to *ave $ulti%le o'ects running at t*e sa$e ti$e. -*is 8ntelli1rain 'ot

    uses 2o'oJ&E Java develo%$ent environ$ent software t*at is used to design 'uild and u%load t*e

    %rogra$ to t*e $ain 'oard of t*e ro'ot. -*is software co$es wit* t*e /+8 s%ecification of classes

    and $et*ods t*at *ave alread0 'een develo%ed for %u'lic use. -*e %rogra$ is u%loaded to t*e ro'ot

    via a serial ca'le. -*e ro'ot=s $ain 'oard consists of ") &igital in%uts and out%uts an infrared

    receiver , 8C %orts a 'uzzer a "#( C& dis%la0 ( servo %orts G analogPdigital in%uts a %ower

    switc* ( %us* 'uttons a t*u$'w*eel a *ost 8nterface H2S5(,( ""!.(9 'audI and a wall 'rick

    %ower connector.

    -*e ro'ot runs on an /t$el /t$ega"(L Micro controller t*at *as ".G MDz "(L flas* %rogra$

    $e$or0 ",(9 2/M and 9 '0tes of EE+2M. -*e /+8 s%ecification notes t*at t*e flas* $e$or0

    *as a li$ited life of ")))) writes and t*erefore s*ould 'e used s%aringl0 w*ile t*e 9 of

    EE+2M is esti$ated to *ave a lifeti$e of "))))) writes. -*e Java irtual Mac*ine and t*e

    'ootstra% loader use 9 '0tes of 2ando$ /ccess Me$or0 H2/MI. -*e infrared receiver works at

    ,L kDz and is co$%ati'le wit* $ost television re$otesR t*is receiver could also 'e used for

    co$$unication 'etween two ro'ots. -*e 'ootstra% leader is software on t*e ro'ot res%onsi'le for

    downloading t*e virtual $ac*ine to t*e ro'ot and c*anging t*e *ost %ort 'aud rate.

    .2.-ostic! Information

    ()

  • 8/12/2019 Bluetooth Robot Controller

    21/26

    -*e o0stick used in t*is %roect was an older o0stick t*at used a ga$e %ort rat*er

    t*an 7S1. Modern co$%uters do not co$e wit* ga$e %ort an0$ore t*erefore to overco$e

    t*is %ro'le$ 8 *ave installed a $idi sound card Hw*ic* *as a "! %in in%ut on itI into t*e

    co$%uter +C8 %ort. -*e o0stick can 'e connected to t*e $idi card w*ic* is t*en recognized

    '0 t*e %erating S0ste$ as a ga$e %ort.

    H$ale connector on o0stick ca'leI

    .///////////////////////.

    0 3 $ # 2 1 *

    0 1$ 1# 1 12 11 14 5 *

    6666666666666666666

    " T" HQ!vI( Switc* "

    , T" Around Hfor switc* "I! Around Hfor switc* (I

    # "G Switc* (

    L N.C.F T( HQ!vI

    ") Switc* ,"" T(

    "( Around Hfor switc* ,?I U", (

    " Switc* "! N.C. U

    4ig (. o0stick %inout

    -*e o0stick %ort is located on t*e 8S/ 'us 8P address ()"* and can 'e accessed '0

    t*e C+7 to read and write to t*e %ort. ;*en data is sent to t*e %ort t*e o0stick initializes its

    %osition $easure$ents 'ut t*e data sent to t*e o0stick is not relevant and it is not saved

    an0w*ere.

    ("

  • 8/12/2019 Bluetooth Robot Controller

    22/26

    #. References

    V"WJulia a0ton andCurt 4ranklin Dow 1luetoot* ;orksK

    72: *tt%:PPelectronics.*owstuffworks.co$P'luetoot*.*t$

    V(W Dac /nna Mo'ile -eleco$$unications +rotocols for &ata NetworksK +u'lication:

    C*ic*ester ;est Susse Do'oken NJ Jo*n ;ile0 ? Sons td. H79I ()),

    V,W 2idgesoft C 8nc 8ntelli1rain AuideK + 1T L( +leasanton C/

    72: *tt%:PPridgesoft.co$Pintelli'rainP8ntelli1rainAuide.%df

    VW Arid Connect 4irefl0 1luetoot* Serial ManualK June (Gt*())# "L" Centre +oint

    Circle Suite ", Na%erville 8 #)!#,

    72: *tt%:PPsite.gridconnect.co$PdocsP+&4P4irefl0XL)),"Xc.%df

    V!W 4rank &urda Serial and 7/2- -utorialK -anuar7 1th 1553

    72: *tt%:PPwww.free'sd.orgPdocPenX7S.8SLL!F5"ParticlesPserial5uartPinde.*t$l

    $. %ppendi&

    $.1 -ostic! pro"rammin" e&ample

    8N- "! 5 18S 5 JS-8C9 S7++2- HT- after ""PLPL(/-T-(L#+SI /D Y L* &T Y su'function ))))* read o0stick switc*es 2eturn: / 'its G5 Y switc* settings )))"* read %ositions of o0sticks 2eturn: /T Y T %osition of o0stick / 1T Y %osition of o0stick / CT Y T %osition of o0stick 1 &T Y %osition of o0stick 12eturn: C4 set on error /D Y status L)* invalid co$$and H+C+CrI L#* function not su%%orted Hot*erI C4 clear if successful

    Notes: if no ga$e %ort is installed su'function ))))* returns /Y))* Hall switc*es o%enI and su'function )))"* returns /TY1TYCTY&TY))))* a (!)k*$ o0stick t0%icall0 returns ))))*5)"/)*

    ((

    http://electronics.howstuffworks.com/about-author.htm#laytonhttp://electronics.howstuffworks.com/contact.php?s=hsw&ct=feedbackhttp://electronics.howstuffworks.com/bluetooth.htmhttp://www.freebsd.org/doc/en_US.ISO8859-1/articles/serial-http://electronics.howstuffworks.com/about-author.htm#laytonhttp://electronics.howstuffworks.com/contact.php?s=hsw&ct=feedbackhttp://electronics.howstuffworks.com/bluetooth.htmhttp://www.freebsd.org/doc/en_US.ISO8859-1/articles/serial-
  • 8/12/2019 Bluetooth Robot Controller

    23/26

    $.2 Robot/Code e&ample

    PP setting u% connection tr0 Serial+ort co$+ort Y 8ntelli1rain.getCo$(HIR

    PPSerial +ara$eters co$+ort.setSerial+ort+ara$sH""!())Serial+ort.&/-/18-SXLSerial+ort.S-+18-SX"Serial+ort.+/28-XNNEIR

    8n%utStrea$ in%utStrea$ Y co$+ort.get8n%utStrea$HIR ut%utStrea$ out%utStrea$ Y co$+ort.getut%utStrea$HIR

    PP clear screendis%la0.%rintH) [[IRdis%la0.%rintH" [[IR

    PP Setting 'uffer'0te VW 'uf Y new '0teV"(LWR\

    %u'lic static void $ove2o'otHint i int i(I

    $eftMotor.set+owerHiIR PP -urn left $otor$2ig*tMotor.set+owerHi(IR PP -urn rig*t $otor

    \

    $. Computer/Code e&ample

    PUU /ut*or: Neven Skoro

    U &ate Modified: Nove$'er "Lt* ())#U 428&/ A74 C/S- 7N8E2S8-U *tt%:PPsatnet.fgcu.eduP]nskoroUUUP

    PP SerialCo$$.ava

    %ackage co$.centralneus.in%utR

    i$%ort ava.co$$.Co$$+ort8dentifierRi$%ort ava.co$$.+ort8n7seEce%tionRi$%ort ava.co$$.Serial+ortRi$%ort ava.co$$.7nsu%%ortedCo$$%erationEce%tionRi$%ort ava.io.URi$%ort ava.util.Enu$erationR

    %u'lic class SerialCo$$

    static 'oolean %ort4oundR static StringVW default+ortsR static Enu$eration %ortistR static Co$$+ort8dentifier %ort8dR

    static String default+ortR static Serial+ort serial+ortR static 8n%utStrea$ in%utStrea$R static ut%utStrea$ out%utStrea$R static 1uffered2eader inR

    (,

  • 8/12/2019 Bluetooth Robot Controller

    24/26

    static Jo0stick o0(Rstatic final int /T8SXT Y )R

    PUU Constant for aisalues UP static final int /T8SX Y "R PUU Constant for aisalues UP

    %u'lic SerialCo$$HI

    tr0%ort8dY Co$$+ort8dentifier.get+ort8dentifierH[CM,[IR

    \ catc*HEce%tion eIS0ste$.out.%rintlnH[ no %ort [ Q eIR \ S0ste$.out.%rintlnH[found %ort [IR

    tr0 serial+ort Y HSerial+ortI %ort8d.o%enH[serial[ !)IR \

    catc* H+ort8n7seEce%tion eI S0ste$.out.%rintlnHeIR\

    tr0 serial+ort.setSerial+ort+ara$sH""!()) Serial+ort.&/-/18-SXL Serial+ort.S-+18-SX" Serial+ort.+/28-XNNEIR

    \catc* H7nsu%%ortedCo$$%erationEce%tion eI \

    S0ste$.out.%rintlnHserial+ort.get4lowControlModeHIIR

    PPut%utStrea$ tr0 out%utStrea$ Y serial+ort.getut%utStrea$HIR \ catc* HEce%tion eI \

    PP8$%utStrea$ tr0 in%utStrea$ Y serial+ort.get8n%utStrea$HIR \ catc* H8Ece%tion eI \

    \

    %u'lic static '0te VW c*ar-o10te/rra0H c*ar c I

    '0te VW two10tes Y H'0teIHc ? )ffI H'0teIHc >> L ? )ffI \R S0ste$.out.%rintlnH[c*ar to '0te [ Q two10tesV)W Q [ [ Q two10tesV"WIR return two10tesR\

    %u'lic static void %us*8tH'0te 'I

    tr0 out%utStrea$.writeH'IR

    PP out%utStrea$.flus*HIR\ catc* H8Ece%tion eI

    S0ste$.out.%rintlnHe.toStringHIIR \\

    %u'lic static void %us*8tH'0teVW 'I

    tr0 out%utStrea$.writeH'IR

    PP out%utStrea$.flus*HIR\ catc* H8Ece%tion eI

    S0ste$.out.%rintlnHe.toStringHIIR \ \

    %u'lic static void %us*8tH'0te ' '0te '(I

    tr0 out%utStrea$.writeH'IR

    (

  • 8/12/2019 Bluetooth Robot Controller

    25/26

  • 8/12/2019 Bluetooth Robot Controller

    26/26

    else if Ho0(.getHI > ).LI PP 'ackwards %us*8tHH'0teILIR

    else if Ho0(.getTHI < 5).LI PP left

    %us*8tHH'0teIL,IR else if Ho0(.getTHI > ).LI PP rig*t

    %us*8tHH'0teIL(IRelsePP sto%

    %us*8tHH'0teILFIR\

    if Ho0(.is1utton&ownH"IIS0ste$.out.%rintlnH[Connection ter$inated...[IR

    serial+ort.closeHIR 'reakR\

    if Ho0(.is1utton&ownH(II'oolean flag YtrueRPP 2eading data fro$ ke0'oardS0ste$.out.%rintlnH[+lease in%ut a co$$and: [IR

    w*ile HflagItr0

    i Y S0ste$.in.readHIR

    \ catc* H8Ece%tion eI\ if HHc*arIi YY ^w^I %us*8tHH'0teIL!IR if HHc*arIi YY ^s^I %us*8tHH'0teILIR if HHc*arIi YY ^a^I %us*8tHH'0teIL,IR if HHc*arIi YY ^d^I %us*8tHH'0teIL(IR if HHc*arIi YY ^3^I %us*8tHH'0teILFIR if Hi YY^_t^I flag Y falseR

    \

    \

    tr0S0ste$.out.%rintlnH[in%ut strea$ e3uals: [ Qin%utStrea$.availa'leHIIR

    if Hin%utStrea$.availa'leHI > )I S0ste$.out.%rintlnH[in%utstrea$ is availa'le[IR '0te VW 'uffer Y new '0teV"(LWR int lengt* Y in%utStrea$.readH'ufferIR S0ste$.out.%rintlnH[lengt* of in%ut is [ Q lengt*IR S0ste$.out.%rintlnH[8n%ut 'uffer is [ Q 'uffer.toStringHIIR \\catc* H8Ece%tion eI S0ste$.out.%rintlnH[error reading in%ut[ Q eIR\

    tr0 -*read.slee%HG!IR \

    catc* H-*rowa'le tI\ \ \\PP EN& 4 48E