Vous êtes sur la page 1sur 130

 

 
 
This   project   consists   of   developing   a  differential   sprinter   for   beginners   and   low   cost   (less   than 
100   euros).   For   beginners   because   it   is   the   first   time   that   I  put   myself   with   a  sprinter   of   this   type, 
so   I  have   everything   to   learn.   "Robot   Zero"   is   a  project   with   which   I  intend   to   build   a  series   of 
robots   from   scratch   so   that   everyone   who   wants   to   do   it   can   follow.  
 
The   aim   of   every   robot   sprinter   is   to   travel   a  circuit   in   the   shortest   possible   time,   in   Spain   we   find 
several   competitions   with   this   test   (Cosmobot,   CRJET,   ALcabot,   etc   ...),   the   objective   is   to   build 
a   robot   that   can   participate   in   those   competitions   in   the   That   we   find   limitations   for   the   robot   20 
cm   wide   by   30   cm   long,   and   13   cm   maximum   height.   The   robots   that   dominate   these   tests   are 
usually   about   2  m  /  s,   for   this   robot   as   the   first   robot   of   initiation   that   is   and   low   cost,   the 
objective   will   be   to   reach   a  speed   of   1  m  /  s  with   which   we   can   present   ourselves   to   any   test   And 
we   will   not   be   very   bad.  
 
The   first   thing   is   to   select   all   the   components   to   create   the   robot,   nowadays   you   can   buy 
everything   directly.   For   a  first   robot   attempt,   if   it   does   not   reach   the   speed   of   1  m  /  s  it   will   be 
redesigned   (every   sprinter   robot   below   this   speed   will   finish   between   two   sumos)   I  bought   the 
following   components   in   Pololu.com:  
 
Engines.   2x   $  16   =  $  32.   Link.  
Wheel.   $  7.   Link.  
Motor   support.   $  5.   Link.  
Crazy   wheel.   $  4.   Link   .  
Sensor   board.   $  15.   Link   .  Replaced   by   its   analog   version   QTR­8A   .  
Electronics.   $  30.   Link   .  
 
  
 
A   total   of   $  93,   about   70   euros   to   change,   that   next   to   the   battery   that   we   select   and   some   more 
component   will   put   us   in   the   initial   budget.   With   the   engines   I  have   serious   doubts   if   they   are 
going   to   arrive   at   1  m  /  s,   but   hey   with   this   he   is   going   to   make   the   first   attempt   to   see   that   it 
leaves.   I  bought   the   sensor   board   and   electronics   (microcontroller   and   bridge   in   h)   to   make   the 
project   as   simple   as   possible,   and   because   it   really   costs   me   more   to   do   it   than   to   buy   it,   we 
gain   in   time   and   comfort   but   we   limit   ourselves   to   a  series   of   options   .  
 
If   anyone   interested   in   this   test   of   sprinters   and   differential   robots   wants   to   talk   about   this   project 
and   share   ideas   I  have   opened   a  forum   for   it,   that   comments   on   the   page   when   there   are 
several   are   difficult   to   follow.   Forum.  
 
 
 
 
 
 
 
Original   Spanish   text: 
El   objetivo   de   todo   robot   velocista   es   recorrer   un   circuito   en   el   menor   tiempo   posible,   en   España 
encontramos   varios   concursos   con   esta   prueba   (Cosmobot,   CRJET,   ALcabot,   etc..),   el   objetivo 
es   construir   un   robot   que   pueda   participar   en   esos   concursos   en   los   que   encontramos   unas 
limitaciones   para   el   robot   de   20   cm   de   ancho   por   30   cm   de   largo,   y  13   cm   de   altura   máxima. 
  Contribute   a  better   translation 
 
 
++++++++++ 
 
 
 

First   basic   idea.  

  
 
With  the  selected  components  the  first  thing  is  to  assemble  a  base,  the  process is quite simple 
since  the  motors  and  the  wheels  are  designed  to  fit  directly, and the brackets to fix the motor to 
the  base  of  the  robot  also  sell  it  made  to  measure,  so  Which  is  simply  cut  a  piece  of  plastic, 
wood,   etc.   with   the   desired   shape   and   fix   the   components.  
 
To  make  the  base  I  use  a  sheet  of  foamed  PVC,  4mm,  usually  sold  in  many  sites  of  various 
sizes.  In  this  case  I  had  a  20  cm  x  20  cm  and  I  will  use  it  to  make  a  basic  idea  first.  The 
advantages  of  this  material  is  that  it  is  very  light  and  very  easy  to  work  and  aesthetically  it  is 
better   than   wood,   disadvantages   its   flexibility   in   long   pieces.  
 
The  robot  must  have  dimensions  less  than  30  cm  long and 20 cm wide, and can not exceed 13 
cm  in  height.  To  design  the  base  would  have  to do a mechanical analysis of how they influence 
the  different  dimensions  in  the  movement  of  the  robot,  for  example  the  larger  the  robot  the 
greater  the  difference  in  speed  of  the  motors  will  have  to  turn  with  an  angle,  the  longer  More 
space  will  have  between  the  center  of  gravity  and  the  sensor  plate  so  we  can  anticipate  the 
curve,  but  also  the  weight  or  inertia  will  be  greater,  the  greater  the  derivative  of  the error of the 
sensors  for  a  speed  of  rotation,  etc.  There  are  many  variables  to  analyze,  and  at  first  I  do  not 
know  the  mechanics  to  be  able  to  do  it,  so  in  a first design I will only follow 3 criteria: first make 
the  robot  as  light as possible since the engines are not very powerful. Second, that the center of 
gravity  of  the  robot  is  on  the  axis  of  the  wheels,  in  this  way  we will have maximum traction and 
facilitate  the  rotation  of  the  robot,  and  third  that  the  center  of  gravity  of  the  robot  is  as  far  as 
possible   from   the   sensor   board   to   Anticipate   the   curves.  
 
With  these  ideas I will use the maximum length of the iron that I have, 20 cm long, and the width 
in  principle  the  minimum  possible  to  remove  7.5  cm  base  weight,  which  is  necessary  to  fit  the 
battery  well,  would  have  to  study  As  it  influences  the  wheelbase  since  it  is  quite  important  in 
these   robots.  
 
The first thing is to take measurements and draw a template of the robot base design that will be 
used  to  cut,  it  is  best  to do it with any drawing program to be totally accurate, or draw it by hand 
with   enough   care.  
 
The   components   used   are:  
 
Engines.   2x   $  16   =  $  32.  L   ink.  
Wheel.   $  7.  L
  ink.  
Motor   support.   $  5.  L   ink.  
Crazy   wheel.   $  4.  L  ink   .  
Sensor   board.   $  15.  L   ink   .  
Electronics.   $  30.  L   ink   .  
 
From  its  page  we  can  remove  the  dimesiones  of  several  of  them,  reason  why  we  avoid having 
to   measure   by   hand   with   the   consequent   error.  
 
Images   of   www.pololu.com  
 
Engine   support.  

 
 
 
Wheel.  
 
 
Crazy   wheel.  

 
 
Sensor   board.  

 
 
Dimensions   in   inches   and   centimeters.  
 
With   these   dimesiones   we   draw   the   template   of   our   base   that   later   we   will   use   to   cut   the   robot. 
Click   on   the   images   for   a  higher   resolution.  

  
 
We   place   the   template   on   top   of   the   PVC   with   the   marked   holes   and   proceed   to   mark   on   the 
PVC   the   cutting   lines   with   a  knife   and   a  punch.  
  
 
Once   marked   we   proceed   to   cut   the   piece   with   another   blade,   PVC   is   a  very   soft   material   that   is 
cut   easily,   we   will   not   need   any   type   of   tool.  

  
 
And   we   make   the   drills   that   we   have   marked.  Y
  ou   do   not   need   a  drill,   a  drill   bit   or   a  screwdriver 
and   turning   it   by   hand   is   usually   enough.  

  
 
The   final   result   of   the   assembly   is   thus.  

  
 
If  we  have  done  well  the  calculations  (in  this  case  making  the  part  between  the  motors  and 
sensors  wider  or  less  wide  will  be  the  solution  of  the  calculation  to  place  the  center  of  gravity) 
the  center  of  gravity  for  the  base  will  be  on  the  center  of  the  axis of The engines, and the base 
will  need  to  be  able  to  stand on both wheels without having the crazy wheel set or third fulcrum. 
There  are  still  missing  components  to  add  and  they  will  be  balanced afterwards, the main ones 
that   add   more   weight   are   those   of   the   base.  

  
 
Finally  we  place  the  crazy  wheel,  making  a  hole  through the base starting from the initial drill (it 
is  advisable  to  draw  the  diameter  of  this  wheel  in  the  template  and mark it with the blade at the 
base),  the  height  is  more  or  less  similar  To  the  one  of  the  wheels  and  does  not  need to adjust. 
The  front part is trimmed slightly to remove the connectors from the sensors. With metallic tubes 
like  the  one  seen  in  the  photo  that  on  one  side  have  a  male  screw and on the other the female 
part,   it   will   be   used   to   place   a  second   platform   with   electronics,   pushbuttons,   leds,   etc   ...  
  
 
Bottom   view.  

  
 
A  screw  is  mounted  a  little  high  to  avoid  that  the  sensors  hit  the  ground,  being  the  PVC  quite 
flexible  we  can  have  some  ooscilación,  with  the  screw of this form also we guarantee that there 
is  a  minimum  distance  always  of  the  sensor  to  the  ground,  since  if  Was  totally  stuck  could  not 
read,  the  light  coming  out  of  the  photodiode  has  to  reach the photo transistor, and for this there 
must   be   a  minimum   distance   between   the   sensor   and   the   ground.  

  
 
The   total   weight   of   the   base   is   124   gr,   which   results   a  fairly   light   sprinter.  T
  he   engines   are   200 
gr­cm   with   1.6   cm   wheel   radius,   so   you   will   have   to   see   on   the   track   how   fast   we   get.  I n   a 
differential   robot   the   acceleration   of   the   engines   is   important,   because   we   decrease   and 
increase   the   speed   of   each   wheel   to   make   the   turns.  
  
 
For   last   we   have   to   solder   the   connectors   that   come   with   the   electronics   that   we   have   bought.  

  
 
For   small   welds   the   14S   of   JBC   with   tip   of   0.5   mm   is   ideal.  
  
 
The   microcontroller   board   +  bridge   in   h  has   the   dimensions   to   be   punctured   on   a  protoboard, 
which   will   come   very   well   for   testing.  

  
 
So   that   the   base   of   the   complete   robot   would   be   this   way,   to   hold   the   battery   have   been   put   a 
pair   of   flanges.  

  
 
The   next   thing   is   to   analyze   in   detail   the   electronics,   the   sensor   board   and   the   microcontroller 
board,   of   which   we   have   libraries   and   example   code   of   the   robots   of   pololu,   once   done   this   will 
realize   a  plate   in   which   to   punch   the   plate   of   the   microcontroller   ,  With   jumpers,   leds,   etc   ...  
 
For   any   comment,   doubt,   idea:  F   orum.  
 
+++++++ 
 
 
Electronics,   sensor   board   and   control.  
 
Baby   Orangutan   B­328   Robot   Controller.   Link.  
As   robot   brain   and   for   the   control   of   the   motors   we   will   use   this   plate   that   sells   pololu,   its   price   is 
$   30   (  $  42   with   its   programmer   )  and   consists   of   a  microcontroller   with   its   corresponding   pins   to 
the   outside   world   and   a  bridge   in   h  to   control   Two   motors,   together   with   sensors,   these   are   the 
main   components   of   all   robots,   sensors,   control,   and   actuators.  
 
The   first   thing   is   to   weld   the   connectors   that   comes   with   the   plate   as   shown   in   the   image:  
 
Pictures   of   pololu.com  
 
The   connector   on   the   top   is   the   connector   that   will   be   used   to   program   the   board   (more   on   this 
when   you   get   to   the   programming   part)   and   should   be   welded   on   top   with   that   type   of   connector. 
The   other   connectors   are   the   outputs   to   the   motors   and   pins   of   the   microcontroller,   can   be 
soldered   as   you   like   or   use   the   connector   you   like,   welding   it   with   the   connectors   of   the   photo   in 
that   position   is   quite   accurate   because   we   can   punch   the   board   on   a  protoboard   Perform   tests, 
or   on   a  plate   of   moles   to   solder   and   make   a  circuit   if   we   do   not   want   to   make   a  pcb.  
 
The   components   of   the   plate   are   as   follows:  
 
 
 
The   microcontroller,   in   this   case   an   ATmega328P   ,  which   is   good   news   and   decisive   in   my   case 
when   selecting   the   board,   because   probably   in   8  bits   the   AVR   are   the   best   microcontrollers 
available,   and   another   good   news   is   that   the   compiler   C  /  c  ++   is   good   and   free.  
 
The   other   integrated   TB6612FNG   is   an   H­bridge,   its   mission   is   to   control   the   motor   in   speed   and 
direction   depending   on   the   inputs   given   by   the   microcontroller.   A  motor   can   not   be   controlled 
directly   from   the   pin   of   a  microcontroller   since   the   motor   requires   much   more   intensity   for   its 
operation   than   it   is   able   to   provide   the   port   of   the   micro.   When   I  get   to   the   programming   part   I 
will   go   into   detail   with   its   operation,   and   the   peripherals   of   the   micro   (PWM)   necessary   for   its 
control.   The   bridge   is   MOS   technology   so   the   voltage   drop   in   this   will   be   much   lower   than   in   the 
bipolar   alternatives,   like   the   L293   and   L298   that   are   usually   seen   here   for   the   control   of   small 
motors,   which   will   ultimately   allow   us   to   take   better   advantage   of   the   Battery   and   give   more 
voltage   to   the   motor.   The   connections   of   the   bridge   inputs   go   to   the   PWM   outputs   of   the 
microcontroller,   of   course.  
 
The   other   components   to   highlight   is   a  led   that   can   be   turned   on   and   off   during   programming 
and   a  potentiometer   on   the   board   that   reads   through   an   ADC.   The   input   voltage   of   the   plate   is 
from   5  to   13.5V,   it   already   has   its   regulator.  
 
Before   entering   with   the   available   pins   of   the   microcontroller   that   is   what   really   interests   a  look 
at   the   scheme:  
 
 
 
The   design   is   simple,   starting   from   above   to   the   left   we   see   the   input   voltage   that   we   will 
connect   to   the   battery,   a  mosfet   to   avoid   inversion   of   polarity   and   a  dissipative   regulator   that 
provides   a  voltage   of   5V   to   logic   of   the   integrated.   The   input   voltage   of   the   battery   is   also   taken 
to   the   bridge   in   H  (Vbat   label),   it   is   the   voltage   that   reaches   the   motors,   so   with   this   plate   we   can 
control   motors   from   6  to   12V   (common   ratings)   and   up   to   1.2A   in   stall   (motor   powered   and 
stopped),   because   we   have   the   limit   of   the   input   voltage   between   5  and   13.5.  
 
After   the   regulator   is   observed   capacitors   to   eliminate   noise,   a  led   to   indicate   that   the   plate   is 
working   and   an   LC   filter   to   give   a  clean   tension   to   the   ADC   part   (converts   analog   voltage   values 
 into   digital   values)   of   the   micro,   reference   V  Of   the   ADC   is   connected   to   this   voltage   of   5  volts,   ie 
5/1024   resolution   for   our   ADCs.   Then   we   have   the   H­bridge   connected   to   the   corresponding 
pins   of   the   micro   for   its   control.   The   reset   signal   brought   to   Vcc   through   a  resistor,   to   enable   a 
reset   button   we   will   only   have   to   ground   this   pin   through   a  pushbutton.   A  user   LED   and   a 
potentiometer   also   user,   if   they   bother   us   for   our   application   and   we   want   to   use   that   pin   for 
something   else   could   be   removed.  
 
But   the   most   interesting,   what   microcontroller   pins   we   can   use   and   what   is   in   those   pins.  
 
 
 
PB0:   ICP1   /  CLKO   /  PCINT0.  
ICP1:   input   capture   pin   timer1,   would   serve   to   capture   an   external   signal   and   calculate   for 
example   its   frequency,   duty   cycle,   etc   ...   medianet   the   timer1.  
PCINT0:   interrupt   on   change,   when   the   port   status   changes   (from   1  to   0  or   vice   versa)   an 
interrupt   is   triggered,   a  button   is   connected,   digital   distance   sensor,   etc.  
CLK0:   to   output   the   clock   signal.   Little   applicable   on   the   sprinter.  
 
PB1:   OC1A   /  PCINT1.  
OC1A:   output   compare   match   output   timer1,   is   used   to   generate   an   output   by   means   of   timer1 
(a   pwm   for   example),   when   it   matches   the   account   of   the   latter   with   a  value   stored   in   a  register. 
Little   applicable   on   the   sprinter.  
PCINT0:   interrupt   on   change,   when   the   port   status   changes   (from   1  to   0  or   vice   versa)   an 
interrupt   is   triggered,   a  button   is   connected,   digital   distance   sensor,   etc.  
 
PB2:   SS   /  OC1B   /  PCINT2.  
SS:   slave   select,   for   SPI   protocol   that   is   not   available   on   this   board.   Without   use.  
OC1B:   output   compare   match   output   timer1.   Same   as   in   the   previous   one.  
PCINT2:   external   interruption   like   the   previous   ones.  
 
PB4:   MISO   /  PCINT4.  
MISO:   master   input   slave   output,   signal   from   spi   protocol,   not   used   since   it   is   not   available   on 
the   board.  
PCINT4:   external   interruption   as   in   previous   cases.  
This   pin   is   used   for   serial   programming,   so   be   careful   not   to   connect   anything   that   may   influence 
it   (such   as   high   capacitance)   or   in   which   it   may   influence.  
 
PB5:   SCK   /  PCINT5.  
SCK:   I2C   bus   clock,   not   available   on   the   board.  
PCINT5:   external   interruption   like   the   previous   ones.  
This   pin   is   used   for   serial   programming,   so   be   careful   not   to   connect   anything   that   may   influence 
it   (such   as   high   capacitance)   or   in   which   it   may   influence.  
 
In   this   port   we   lack   PB3   that   goes   to   the   bridge   in   H  of   the   plate,   PB3   contains   the   line   MOSI   of 
the   protocol   SPI,   reason   why   without   it   we   lose   this   protocol   series.  
 
PD0:   RXD   /  PCINT16.  
RXD:   receive   data,   the   data   entry   for   the   USART.   Important   as   it   will   allow   us   to   establish   a 
serial   communication   with   the   outside.  
PCINT16:   external   interruption.  
 
PD1:   TXD   /  PCINT17.  
TXD:   transmit   data,   the   data   output   of   the   USART.   Along   with   the   previous   two   pins   required   to 
mount   a  serial   communication   via   the   UART.  
PCINT17:   external   interruption.  
In   this   port   also   we   have   a  user   led   connected,   which   can   be   a  problem   if   we   want   to   use   the 
port   as   input,   if   the   device   that   provides   the   input   is   not   able   to   supply   the   necessary   current   that 
requires   the   led,   the   voltage   that   the   micro   May   be   below   the   threshold   of   1,   so   we   can   not   read. 
In   the   worst   case   the   LED   is   removed.  
 
PD2:   INT0   /  PCINT18.  
PCINT18:   external   interruption   as   above,   when   the   voltage   level   changes   from   low   to   high   or 
upside   down   it   is   triggered.  
INT0:   it   is   also   an   external   interrupt,   the   difference   if   I  remember   correctly   (I   would   have   to   look 
at   it   in   the   datasheet)   is   that   this   interrupt   has   its   own   interrupt   vector,   whereas   all   of   the   above 
usually   have   a  vector   every   8  interrupt   sources,   Once   it   is   fired,   it   is   necessary   to   detect   who 
has   fired   it.   With   INT0   it   would   be   entered   directly,   also   in   the   INT0   I  think   it   can   be   selected   if   it 
is   fired   by   a  falling   edge   (from   1  to   0)   or   of   rising   (from   0  to   1),   or   both.,   While   in   the   other   any 
He   shoots   it.  
 
PD4:   XCK   /  T0   /  PCINT20  
XCK:   is   the   external   clock   for   usart,   we   will   not   use   it.  
T0:   it   is   used   to   capture   a  rising   or   falling   edge   that   incremenet   or   decrement   the   count   of   the 
timer0,   for   example   serves   to   capture   an   encoder.   But   we   can   not   use   it   since   it   is   used   for   the 
pwm   of   the   bridge   in   h.  
PCINT20:   external   interruption   when   the   pin   changes.  
 
PD7:   AIN1   /  PCINT23  
AIN1:   analog   comparator   negative   input.   The   positive   we   do   not   have   available.  
PCIN23:   external   interruption   as   above.  
 
PC0   to   PC3:   ADCx   /  PCINTx  
In   all   we   find   an   input   to   convert   an   analog   value   into   digital   and   an   external   interrupt.  
 
PC4:   SDA   /  ADC4   /  PCINT12  
ADC   +  interruption   as   in   the   previous   ones.  
SDA:   2­wire   serial   interface   data,   ie   the   I2C   serial   protocol   data   line.   Protocol   very   important   to 
communicate   with   other   integrated   circuits   and   that   is   probably   used   in   the   robot.  
 
PC5:   SCL   /  ADC5   /  PCINT13  
ADC   +  interruption   as   in   the   previous   ones.  
SCL:   2­wire   serial   interface   clock,   the   clock   line   of   the   I2C   protocol,   which   together   with   the 
previous   port   add   what   is   necessary   to   mount   this   protocol.  
 
PC6:   RESET   /  PCINT14.  
PCINT14:   external   interruption   as   above.  
Reset:   here   we   have   one   of   the   sources   of   reset   of   the   microcontroller,   in   the   plate   has   a  pull­up 
resistor   and   a  capacitor   to   ground,   if   we   want   to   use   the   external   reset   we   just   have   to   carry   this 
pin   to   ground.   We   also   have   the   option   to   disable   the   external   reset   and   use   the   pin   as   a  normal 
input   and   output   pin,   for   this   we   have   to   take   into   account   the   pull­up   resistance   that   is   already 
set   and   if   it   bothers   to   remove   it,   just   like   the   condensate.  
 
ADC6   and   ADC7.  
These   two   ADC   inputs   are   not   multiplexed   with   any   port,   in   the   ADC7   we   already   have   a 
potentiometer   connected,   in   the   schematic   the   value   does   not   come   out,   but   we   must   always 
keep   in   mind   if   we   want   to   use.  
 
When   a  port   is   said   to   be   multiplexed,   it   means   that   in   addition   to   the   hardware   needed   to   make 
it   work   as   an   input   or   output,   there   is   also   other   hardware   available   such   as   an   ADC   input,   a 
timer,   etc.   and   we   can   only   choose   one   of   the   options   At   the   same   time,   in   program   execution 
can   be   reconfigured.  
 
In   summary,   we   have   17   ports   +  2  ADCs,   one   port   has   a  green   LED   connected,   another   is   the 
reset   signal   with   pull­up   resistor   and   ground   capacitor   and   one   of   the   ADCs   has   a  voltage 
divider   connected,   is   Say,   a  potentiometer.  
 
So   we   can   choose   between   the   combination   of   the   following   options   (in   total   have   to   add   19):   16 
digital   inputs   +  1  reset   if   we   want   to   use   it   as   such,   8  ADCs   (two   of   them   without   multiplexing 
with   ports),   2  pins   for   Mount   a  serial   protocol   using   the   UART   (PD0   and   Pd1),   2  pins   to   mount   a 
serial   protocol   using   I2C   (PC4   and   PC5).   And   a  16­bit   timer   (timer1)   available,   which   we   can   not 
use   to   count   some   event   since   we   do   not   have   the   necessary   pin   available   (it's   on   the   bridge   in 
h),   but   it   can   be   used   to   create   a  pair   of   pwm   signals   (PB1   And   PB2).  
 
Of   the   3  timers   that   have   the   micro   available   16­bit,   the   two   8­bit   are   used   to   control   the   bridge 
in   h  of   the   plate   and   generate   its   pwm   control   signals   (more   on   this   when   used),   and   the   16   bits 
we   are   going   to   have   to   use   it   for   the   derivative   part   of   the   control   of   the   robot   or   to   read   the 
sensors.   So   the   3  timers   we   have   are   busy.  
 
 
M1B,   M1A,   M2B   and   M2A,   are   connected   to   the   two   motors,   can   supply   a  continuous   1.2A 
current   and   3A   peaks.  
VIN   is   the   input   of   the   battery   together   with   GND   (negative   battery).  
Also   we   have   a  Vcc   connection,   it   would   be   a  5V   output   of   the   regulator   of   the   plate,   but   we   can 
not   get   almost   intensity   (50   mA   max)   because   if   we   try   to   pull   out   more   we   load   the   internal 
regulator.   So   if   you   have   to   use   additional   electronics   (the   sensors)   it   is   best   to   use   another 
external   regulator.  
 
All   previous   protocols   and   concepts   will   be   viewed   as   they   are   used.  
 
Sensor   board.   Link.  
Pololu   gives   us   two   possible   options   when   buying   a  sensor   board,   one   to   read   the   analog   value 
of   the   sensors   and   another   to   read   a  digital   value,   the   result   of   using   one   or   the   other   is   the 
same,   is   to   do   the   same   thing   Two   different   ways.   In   this   case   the   digital   has   been   chosen   since 
it   is   the   one   that   implements   its   3pi   robot   and   we   can   find   available   code   to   look   at.  
 
 
The   plate   is   formed   by   8  sensors   and   can   be   divided   into   one   plate   of   six   and   in   another   of   two.  
 
 
In   our   case   we   are   going   to   use   the   8  sensors,   since   we   have   leftover   entries   in   the 
microcontroller   and   with   the   8  sensors   we   cover   more   space   for   reading   the   line.  
 
The   sensor   consists   of   a  photodiode   and   a  photo   transistor.   The   diode   is   a  light   emitter   and   the 
transistor   a  receiver,   it   is   necessary   to   detect   a  white   or   black   surface   to   follow   the   circuit.   If   the 
surface   underneath   the   sensor   is   black,   the   light   emitted   by   the   diode   is   absorbed   by   the   black 
color,   and   the   phototransistor   receives   almost   no   light.   If   the   surface   is   white   the   light   emitted   by 
the   diode   is   reflected   by   the   surface   and   the   phototransistor   gets   light.   When   the   phototransistor 
receives   light,   a  current   is   created   that   passes   through   this   (the   current   is   proportional   to   the 
amount   of   light   received),   and   we   must   detect   the   effect   that   generates   that   current   with   the 
microcontroller,   for   that   we   must   add   a  component   to   the   Circuit   as   a  resistance.  
 
 
This   would   be   the   simplest   case,   the   transistor   receives   light   and   generates   a  current   passing 
through   it,   this   current   circulation   causes   a  voltage   drop   in   the   resistor   (V   =  I  *  R)   that   will   be   of 
sufficient   value   to   have   a  Value   close   to   0V   when   the   transistor   is   over   white   and   therefore 
receiving   light.   When   the   sensor   is   black   on   the   transistor   it   does   not   reach   almost   light   and   the 
current   that   it   generates   is   practically   zero,   so   in   the   resistance   there   is   no   voltage   drop   and   the 
voltage   at   the   output   is   close   to   Vin   (5V).   With   a  microcontroller   connected   to   the   output   we   can 
read   the   high   and   low   states   by   reading   in   digital   and   detecting   only   1  or   0.   When   the   sensor   is 
not   completely   black   or   white,   for   example   it   is   half   black   and   white,   the   Value   of   the   output   will 
be   between   0  and   5V,   and   here   we   can   use   an   ADC   to   read   the   value   of   the   actual   output, 
which   will   give   us   a  much   more   precise   idea   of   the   distance   of   the   sensor   to   the   black   line. 
Detecting   one   and   zero   is   sufficient   in   most   cases   and   does   not   need   to   read   analog.  
 
This   is   how   the   QTR­8A   plate   works,   which   might   have   been   a  better   choice   than   the   other 
option   I'm   going   to   use   Link   ,  since   the   direct   reading   of   one   or   zero   is   very   simple,   if   it 
complicates   the   thing   I  will   change   to   this   plate,   but   at   the   moment   my   interest   is   to   analyze   the 
plate   that   I  am   going   to   use   that   apparently   gives   very   good   results.  
 
On   the   chosen   plate   the   sensor   is   mounted   as   follows:  
 
Instead   of   a  resistor   we   have   a  capacitor   and   a  resistance   at   the   output,   and   instead   of 
measuring   a  voltage   value,   we   measure   the   time   it   takes   to   change   the   voltage   from   one   to 
zero,   as   explained   in   the   page   of   the   sequence.   Reading   would   be   as   follows.  
 
The   OUT   output   is   connected   to   a  microcontroller   port   that   will   be   configured   as   an   input   or   as 
an   output   to   do   the   reading   process,   when   a  port   is   configured   as   an   input   it   is   said   to   be   in   high 
impedance,   ie   the   current   it   absorbs   is   very   high   Small,   so   seen   from   the   sensor   circuit   could   be 
seen   as   an   open   circuit.  
 
Translation   of   pololu:  
1.   Set   the   I  /  O  line   to   an   output   and   drive   it   high.   //   Set   the   microphone   pin   as   output   and   set   it 
to   one.  
2.   Allow   at   least   10   us   for   the   10   nF   capacitor   to   charge   //   Wait   at   least   10   us   for   the   capacitor   to 
charge.  
3.   Make   the   I  /  O  line   an   input   (high   impedance)   //   Set   the   microphone   pin   as   input   (high 
impedance).  
//   Measure   the   time   the   capacitor   takes   to   download,   ie   when   we   read   a  0  in   the   input   because 
the   voltage   in   out   is   Less   than   logical   1.  
 
What   I  understand   about   how   this   works,   I  think   it's   going   to   touch   me   to   take   pen   and   paper 
x_x.  
1.   Set   the   micro   output   and   set   it   to   one.  
2.   Wait   10   us   for   the   capacitor   to   discharge   instead   of   being   charged,   it   would   be   at   the   same 
voltage   on   the   two   terminals,   so   explain   to   me   what   direction   the   capacitor   is   charging.  
3.   Put   the   microcontroller   pin   as   input.  
4.   Measure   the   time   it   takes   the   capacitor   to   charge   ,  as   it   charges   the   voltage   in   Vout   will 
decrease.  
 
Paying   attention   to   what   he   puts   on   the   page   and   summarizing   the   subject   is   to   measure   the 
time   it   takes   to   "discharge"   the   capacitor   (by   putting   the   pin   of   the   micro   as   an   output   or   as   input 
we   cause   the   capacitor   to   be   charged   or   discharged),   and   this   Time   will   be   proportional   to   the 
current   that   flows   through   the   transistor,   this   current   in   turn   depends   on   the   light   that   arrives,   that 
is   to   say,   the   time   it   takes   the   pin   of   the   micro   to   go   from   reading   one   to   reading   zero   will   be   a 
function   of   the   Far   away   from   the   black   line   of   the   sensor,   is   like   doing   a  reading   with   an   ADC 
but   using   a  digital   port   and   counting   time.   So   we   get   a  good   idea   of   the   distance   from   the   sensor 
to   the   black   line   and   we   will   probably   get   better   resolution   than   with   the   ADC.  
 
This   circuit   is   more   complex   than   the   previous   one,   but   I  have   decided   to   use   it   to   evaluate   it 
since   it   is   the   one   used   in   robots   3pi,   but   for   those   who   do   not   want   to   complicate   the   other   plate 
is   read   in   digital,   1  or   0,   passing   Of   the   ADC   and   probably   do   not   need   more.   But   then   to   be   able 
to   make   the   derivative   of   the   error   we   have   to   count   time,   while   doing   it   through   ADC   or 
capacitor   we   can   apply   the   values   read   directly,   but   to   get   here   there   is   still   enough.  
 
The   complete   scheme   of   the   plate   is   as   follows:  
 
You   can   see   the   previous   phototransistor   and   capacitor   assembly   multiplied   by   8,   photo   diodes 
are   placed   two   by   two   to   reduce   consumption.   We   have   an   entrance   to   the   board   called 
LEDON,   which   serves   to   turn   the   light­emitting   diodes   on   and   off,   and   can   be   used   in   two   cases: 
the   first   one   serves   to   save   battery,   turn   them   on   reading   and   turn   them   off   until   Next   time   we 
want   to   re­read.   The   second   use   we   can   give   is   to   control   the   light   emitted   by   the   gods   by 
applying   a  signal   pwm,   making   more   or   less   the   work   cycle   we   can   make   the   transistors   reach 
more   or   less   light.   In   the   case   of   the   sprinter   robot   with   always   leaving   them   on   is   enough.  
 
The   consumption   of   the   plate   says   that   it   is   100   mA,   the   previous   plate   of   the   micro   could   give 
those   100   mA   but   we   risk   to   burn   it,   a  good   rule   is   always   to   dimension   the   components   for 
twice   the   theory.  
 
We   also   note   how   there   is   a  connector   for   short­circuiting   the   47   ohm   resistors   of   the   diodes, 
this   is   in   case   we   are   going   to   feed   the   board   with   3.3V,   since   that   resistance   is   calculated   for   a 
value   of   5V.   If   you   feed   with   5V   you   do   not   have   to   touch   anything,   if   you   feed   with   3.3V   join 
those   points.  
 
The   connectors   of   the   board   can   be   soldered   in   two   ways:  
 
Using   a  connectors   that   would   fit   the   large   yellow   rectangle,   or   with   a  connector   in   a  row:  
 
Anyway,   according   to   tastes.  
 
The   sensor   board   comes   with   its   pin   strip   to   put   it   as   we   like,   the   resistance   is   in   case   we   decide 
to   split   the   plate   in   two   and   it   would   go   in   the   plate   of   the   two   sensors,   in   our   case   is   useless.  
 
In   order   to   be   able   to   read   these   sensors   with   a  capacitor   it   is   necessary   to   use   a  timer   of   the 
microcontroller,   since   we   must   count   time,   so   it   is   no   choice   but   to   use   the   timer1   that   we   were 
left   free   for   the   task,   luckily   we   will   be   able   to   read   them   all   to   the   Instead   of   detecting   when   the 
input   pin   changes   due   to   an   interrupt.   So   we   will   surely   have   to   choose   a  pin   of   the   micro   with 
external   interruption   for   each   sensor,   luckily   we   have   to   spare.   We   have   a  lot   of   code   to   look   at, 
since   the   3pi   robot   that   uses   this   form   of   ller   sensors   also   carries   the   ATmega328p,   so   we   will 
probably   be   able   to   reuse   its   libraries   for   the   control   of   motors   and   for   reading   and   calibration   Of 
the   sensors,   or   at   least   notice   how   they   have   been   made.  
 
A   final   point   on   the   sensors   is   that   they   must   be   at   a  minimum   distance   from   the   ground,   the 
further   we   move   away   the   less   light   will   reach   the   transistor   coming   from   the   diode,   so   we   must 
worry   about   placing   them   about   3  mm   from   the   ground   approximately.  
 
The   next   step   would   be   to   create   a  board   using   pcb   or   a  tops   board,   to   punch   the   board   of   the 
micro,   and   cable   the   whole   robot,   add   a  led,   a  push   button.   The   sensor   board   requires   8  or   9 
pins   of   the   microcontroller,   so   we   would   have   enough   with   the   baby   orangutan,   sensors   and 
anything   else   we   want   to   add.   But   that   for   the   next   weekend,   if   the   miniz   leaves   me.   With   this, 
the   introduction   of   the   electronics   selected   for   the   robot   is   done,   and   each   point   will   be   defined 
as   it   is   used.  
 
For   any   doubt,   idea,   comment:   forum   .  
 
 
 
 
 
 

Electronics,   sensor   board   and   control.  
 
Baby   Orangutan   B­328   Robot   Controller.  L   ink.  
As   robot   brain   and   for   the   control   of   the   motors   we   will   use   this   plate   that   sells   pololu,   its   price   is 
$   30   ( $
    42   with   its   programmer   )  and   consists   of   a  microcontroller   with   its   corresponding   pins   to 
the   outside   world   and   a  bridge   in   h  to   control   Two   motors,   together   with   sensors,   these   are   the 
main   components   of   all   robots,   sensors,   control,   and   actuators.  
 
The   first   thing   is   to   weld   the   connectors   that   comes   with   the   plate   as   shown   in   the   image:  
 
Pictures   of   pololu.com  
 
The  connector  on  the  top  is  the  connector  that  will  be  used  to  program the board (more on this 
when  you get to the programming part) and should be welded on top with that type of connector. 
The  other  connectors  are  the  outputs  to  the  motors  and  pins  of  the  microcontroller,  can  be 
soldered  as  you  like  or  use  the connector you like, welding it with the connectors of the photo in 
that  position  is  quite  accurate  because  we  can  punch  the  board  on a protoboard Perform tests, 
or   on   a  plate   of   moles   to   solder   and   make   a  circuit   if   we   do   not   want   to   make   a  pcb.  
 
The   components   of   the   plate   are   as   follows:  
 

 
 
The  microcontroller,  in  this  case  an   ATmega328P , which is good news and decisive in my case 
when  selecting  the  board,  because  probably  in  8  bits  the  AVR  are  the  best  microcontrollers 
available,   and   another   good   news   is   that   the   compiler   C  /  c  ++   is   good   and   free.  
 
The other integrated  TB6612FNG is an H­bridge, its mission is to control the motor in speed and 
direction  depending  on  the  inputs  given  by  the  microcontroller.  A  motor  can  not  be  controlled 
directly  from  the  pin  of  a  microcontroller  since  the  motor  requires  much  more  intensity  for  its 
operation  than  it  is  able  to  provide  the  port  of  the  micro.  When  I  get  to  the  programming  part  I 
will  go  into  detail  with  its  operation,  and  the  peripherals  of  the  micro  (PWM)  necessary  for  its 
control.  The  bridge  is  MOS  technology  so  the voltage drop in this will be much lower than in the 
bipolar  alternatives,  like  the  L293  and  L298  that  are  usually  seen  here  for  the  control  of  small 
motors,  which  will  ultimately  allow  us  to  take  better  advantage  of  the  Battery  and  give  more 
voltage  to  the  motor.  The  connections  of  the  bridge  inputs  go  to  the  PWM  outputs  of  the 
microcontroller,   of   course.  
 
The  other  components  to  highlight  is  a  led  that  can  be  turned  on  and  off  during  programming 
and  a  potentiometer  on  the  board  that  reads  through  an  ADC.  The  input  voltage  of  the  plate  is 
from   5  to   13.5V,   it   already   has   its   regulator.  
 
Before  entering  with  the  available  pins  of  the  microcontroller  that  is  what  really  interests  a  look 
at   the   scheme:  
 
 
 
The  design  is  simple,  starting  from  above  to  the  left  we  see  the  input  voltage  that  we  will 
connect  to  the  battery,  a  mosfet  to  avoid  inversion  of  polarity  and  a  dissipative  regulator  that 
provides  a  voltage  of  5V  to  logic  of  the  integrated.  The input voltage of the battery is also taken 
to  the  bridge in H (Vbat label), it is the voltage that reaches the motors, so with this plate we can 
control  motors  from  6  to  12V  (common  ratings)  and  up  to  1.2A  in  stall  (motor  powered  and 
stopped),   because   we   have   the   limit   of   the   input   voltage   between   5  and   13.5.  
 
After  the  regulator  is  observed  capacitors  to  eliminate  noise,  a  led  to  indicate  that  the  plate  is 
working  and  an  LC  filter  to give a clean tension to the ADC part (converts analog voltage values 
 into digital values) of the micro, reference V Of the ADC is connected to this voltage of 5 volts, ie 
5/1024  resolution  for  our  ADCs.  Then  we  have  the  H­bridge  connected  to  the  corresponding 
pins  of  the  micro  for  its  control.  The  reset  signal  brought  to  Vcc  through  a  resistor,  to  enable  a 
reset  button  we  will  only  have  to  ground  this  pin  through  a  pushbutton.  A  user  LED  and  a 
potentiometer  also  user,  if  they  bother  us  for  our  application  and  we  want  to  use  that  pin  for 
something   else   could   be   removed.  
 
But   the   most   interesting,   what   microcontroller   pins   we   can   use   and   what   is   in   those   pins.  
 

 
 
PB0:   ICP1   /  CLKO   /  PCINT0.  
ICP1:  input  capture  pin  timer1,  would  serve  to  capture  an  external  signal  and  calculate  for 
example   its   frequency,   duty   cycle,   etc   ...   medianet   the   timer1.  
PCINT0:  interrupt  on  change,  when  the  port  status  changes  (from  1  to  0  or  vice  versa)  an 
interrupt   is   triggered,   a  button   is   connected,   digital   distance   sensor,   etc.  
CLK0:   to   output   the   clock   signal.   Little   applicable   on   the   sprinter.  
 
PB1:   OC1A   /  PCINT1.  
OC1A:  output  compare  match  output  timer1,  is  used  to  generate  an  output  by  means of timer1 
(a  pwm  for  example),  when  it  matches  the  account  of the latter with a value stored in a register. 
Little   applicable   on   the   sprinter.  
PCINT0:  interrupt  on  change,  when  the  port  status  changes  (from  1  to  0  or  vice  versa)  an 
interrupt   is   triggered,   a  button   is   connected,   digital   distance   sensor,   etc.  
 
PB2:   SS   /  OC1B   /  PCINT2.  
SS:   slave   select,   for   SPI   protocol   that   is   not   available   on   this   board.   Without   use.  
OC1B:   output   compare   match   output   timer1.   Same   as   in   the   previous   one.  
PCINT2:   external   interruption   like   the   previous   ones.  
 
PB4:   MISO   /  PCINT4.  
MISO:  master  input  slave  output,  signal  from  spi  protocol,  not  used  since  it  is  not  available  on 
the   board.  
PCINT4:   external   interruption   as   in   previous   cases.  
This pin is used for serial programming, so be careful not to connect anything that may influence 
it   (such   as   high   capacitance)   or   in   which   it   may   influence.  
 
PB5:   SCK   /  PCINT5.  
SCK:   I2C   bus   clock,   not   available   on   the   board.  
PCINT5:   external   interruption   like   the   previous   ones.  
This pin is used for serial programming, so be careful not to connect anything that may influence 
it   (such   as   high   capacitance)   or   in   which   it   may   influence.  
 
In  this  port  we  lack  PB3  that  goes  to  the  bridge in H of the plate, PB3 contains the line MOSI of 
the   protocol   SPI,   reason   why   without   it   we   lose   this   protocol   series.  
 
PD0:   RXD   /  PCINT16.  
RXD:  receive  data,  the  data  entry  for  the  USART.  Important  as  it  will  allow  us  to  establish  a 
serial   communication   with   the   outside.  
PCINT16:   external   interruption.  
 
PD1:   TXD   /  PCINT17.  
TXD:  transmit  data,  the  data  output  of  the  USART.  Along  with  the previous two pins required to 
mount   a  serial   communication   via   the   UART.  
PCINT17:   external   interruption.  
In  this  port  also  we  have  a  user  led  connected,  which  can  be  a  problem  if  we  want  to  use  the 
port  as input, if the device that provides the input is not able to supply the necessary current that 
requires  the  led, the voltage that the micro May be below the threshold of 1, so we can not read. 
In   the   worst   case   the   LED   is   removed.  
 
PD2:   INT0   /  PCINT18.  
PCINT18:  external  interruption  as  above,  when  the  voltage  level  changes  from  low  to  high  or 
upside   down   it   is   triggered.  
INT0:  it  is  also  an  external  interrupt,  the  difference  if  I  remember correctly (I would have to look 
at  it  in  the  datasheet)  is  that  this  interrupt  has  its  own  interrupt  vector, whereas all of the above 
usually  have  a  vector  every  8  interrupt  sources,  Once  it  is  fired,  it  is  necessary  to  detect  who 
has  fired  it.  With  INT0  it  would  be  entered  directly,  also  in the INT0 I think it can be selected if it 
is  fired  by  a  falling  edge  (from  1  to  0)  or  of  rising  (from  0  to  1),  or  both.,  While  in  the  other any 
He   shoots   it.  
 
PD4:   XCK   /  T0   /  PCINT20  
XCK:   is   the   external   clock   for   usart,   we   will   not   use   it.  
T0:  it  is  used  to  capture  a  rising  or  falling  edge  that  incremenet  or  decrement  the  count  of  the 
timer0,  for  example  serves  to  capture  an  encoder.  But  we  can  not  use  it  since  it is used for the 
pwm   of   the   bridge   in   h.  
PCINT20:   external   interruption   when   the   pin   changes.  
 
PD7:   AIN1   /  PCINT23  
AIN1:   analog   comparator   negative   input.   The   positive   we   do   not   have   available.  
PCIN23:   external   interruption   as   above.  
 
PC0   to   PC3:   ADCx   /  PCINTx  
In   all   we   find   an   input   to   convert   an   analog   value   into   digital   and   an   external   interrupt.  
 
PC4:   SDA   /  ADC4   /  PCINT12  
ADC   +  interruption   as   in   the   previous   ones.  
SDA:  2­wire  serial  interface  data,  ie  the  I2C  serial  protocol  data  line.  Protocol  very important to 
communicate   with   other   integrated   circuits   and   that   is   probably   used   in   the   robot.  
 
PC5:   SCL   /  ADC5   /  PCINT13  
ADC   +  interruption   as   in   the   previous   ones.  
SCL:  2­wire  serial  interface  clock,  the  clock  line  of  the  I2C  protocol,  which  together  with  the 
previous   port   add   what   is   necessary   to   mount   this   protocol.  
 
PC6:   RESET   /  PCINT14.  
PCINT14:   external   interruption   as   above.  
Reset:  here  we  have  one of the sources of reset of the microcontroller, in the plate has a pull­up 
resistor  and  a  capacitor  to  ground, if we want to use the external reset we just have to carry this 
pin  to  ground.  We  also have the option to disable the external reset and use the pin as a normal 
input  and  output  pin,  for  this  we  have  to  take  into  account  the  pull­up  resistance that is already 
set   and   if   it   bothers   to   remove   it,   just   like   the   condensate.  
 
ADC6   and   ADC7.  
These  two  ADC  inputs  are  not  multiplexed  with  any  port,  in  the  ADC7  we  already  have  a 
potentiometer  connected,  in  the  schematic  the  value  does  not  come  out,  but  we  must  always 
keep   in   mind   if   we   want   to   use.  
 
When  a  port  is  said  to be multiplexed, it means that in addition to the hardware needed to make 
it  work  as  an  input  or  output,  there  is  also  other  hardware  available  such  as  an  ADC  input,  a 
timer,  etc.  and  we  can  only  choose  one  of  the  options  At  the  same  time,  in  program  execution 
can   be   reconfigured.  
 
In  summary,  we  have  17  ports  +  2  ADCs,  one  port  has  a  green  LED  connected,  another  is the 
reset  signal  with  pull­up  resistor  and  ground  capacitor  and  one  of  the  ADCs  has  a  voltage 
divider   connected,   is   Say,   a  potentiometer.  
 
So  we can choose between the combination of the following options (in total have to add 19): 16 
digital  inputs  +  1  reset  if  we  want  to  use  it  as  such,  8  ADCs  (two  of  them  without  multiplexing 
with  ports),  2  pins  for  Mount  a  serial protocol using the UART (PD0 and Pd1), 2 pins to mount a 
serial  protocol  using I2C (PC4 and PC5). And a 16­bit timer (timer1) available, which we can not 
use  to  count  some  event  since  we  do  not  have  the necessary pin available (it's on the bridge in 
h),   but   it   can   be   used   to   create   a  pair   of   pwm   signals   (PB1   And   PB2).  
 
Of  the  3  timers  that  have  the  micro  available  16­bit,  the  two  8­bit  are used to control the bridge 
in  h  of  the  plate  and  generate  its  pwm control signals (more on this when used), and the 16 bits 
we  are  going  to  have  to  use  it  for  the  derivative  part  of  the  control  of  the  robot  or  to  read  the 
sensors.   So   the   3  timers   we   have   are   busy.  

 
 
M1B,  M1A,  M2B  and  M2A,  are  connected  to  the  two  motors,  can  supply  a  continuous  1.2A 
current   and   3A   peaks.  
VIN   is   the   input   of   the   battery   together   with   GND   (negative   battery).  
Also  we  have  a  Vcc  connection, it would be a 5V output of the regulator of the plate, but we can 
not  get  almost  intensity  (50  mA  max)  because  if  we  try  to  pull  out  more  we  load  the  internal 
regulator.  So  if  you  have  to  use  additional  electronics  (the  sensors)  it  is  best  to  use  another 
external   regulator.  
 
All   previous   protocols   and   concepts   will   be   viewed   as   they   are   used.  
 
Sensor   board.  L   ink.  
Pololu  gives  us  two  possible  options  when  buying a sensor board, one to read the analog value 
of  the  sensors  and  another  to  read  a  digital  value,  the  result  of  using  one  or  the  other  is  the 
same,  is  to  do  the same thing Two different ways. In this case the digital has been chosen since 
it   is   the   one   that   implements   its   3pi   robot   and   we   can   find   available   code   to   look   at.  

 
 
The   plate   is   formed   by   8  sensors   and   can   be   divided   into   one   plate   of   six   and   in   another   of   two.  
 
 
In  our  case  we  are  going  to  use  the  8  sensors,  since  we  have  leftover  entries  in  the 
microcontroller   and   with   the   8  sensors   we   cover   more   space   for   reading   the   line.  
 
The  sensor  consists  of  a  photodiode  and  a  photo  transistor.  The diode is a light emitter and the 
transistor  a  receiver,  it  is  necessary  to  detect  a  white  or  black surface to follow the circuit. If the 
surface  underneath  the  sensor  is  black,  the  light  emitted  by  the  diode  is  absorbed  by the black 
color,  and  the  phototransistor  receives  almost no light. If the surface is white the light emitted by 
the  diode  is  reflected  by the surface and the phototransistor gets light. When the phototransistor 
receives  light,  a  current  is  created  that  passes  through  this  (the  current  is  proportional  to  the 
amount  of  light  received),  and  we  must  detect  the  effect  that  generates  that  current  with  the 
microcontroller,   for   that   we   must   add   a  component   to   the   Circuit   as   a  resistance.  
 

 
This  would  be  the  simplest  case,  the  transistor  receives  light  and  generates  a  current  passing 
through  it,  this  current  circulation  causes  a  voltage  drop  in  the  resistor  (V  =  I * R) that will be of 
sufficient  value  to  have  a  Value  close  to  0V  when  the  transistor  is  over  white  and  therefore 
receiving  light.  When  the  sensor  is  black  on  the  transistor it does not reach almost light and the 
current  that  it  generates  is  practically  zero,  so  in the resistance there is no voltage drop and the 
voltage  at  the  output  is  close  to  Vin (5V). With a microcontroller connected to the output we can 
read  the  high  and  low  states  by  reading  in  digital  and  detecting  only 1 or 0. When the sensor is 
not  completely  black  or  white,  for  example  it  is  half  black  and  white,  the Value of the output will 
be  between  0  and  5V,  and  here  we  can  use  an  ADC  to  read  the  value  of  the  actual  output, 
which  will  give  us  a  much  more  precise  idea  of   the  distance  of  the  sensor  to  the  black  line. 
Detecting   one   and   zero   is   sufficient   in   most   cases   and   does   not   need   to   read   analog.  
 
This  is  how  the   QTR­8A  plate  works,  which  might  have  been  a  better  choice  than  the  other 
option  I'm  going  to  use   Link  ,  since  the  direct  reading  of  one  or  zero  is  very  simple,  if  it 
complicates  the  thing  I  will  change  to  this  plate,  but  at the moment my interest is to analyze the 
plate   that   I  am   going   to   use   that   apparently   gives   very   good   results.  
 
On   the   chosen   plate   the   sensor   is   mounted   as   follows:  

 
Instead  of  a  resistor  we  have  a  capacitor  and  a  resistance  at  the  output,  and  instead  of 
measuring  a  voltage  value,  we  measure  the  time  it  takes  to  change  the  voltage  from  one  to 
zero,   as   explained   in   the   page   of   the   sequence.   Reading   would   be   as   follows.  
 
The  OUT  output  is  connected  to  a  microcontroller  port  that  will  be  configured  as  an  input  or as 
an  output  to  do  the  reading process, when a port is configured as an input it is said to be in high 
impedance,  ie  the  current  it  absorbs is very high Small, so seen from the sensor circuit could be 
seen   as   an   open   circuit.  
 
Translation   of   pololu:  
1.  Set  the  I  /  O  line  to  an  output  and  drive  it  high.  // Set the microphone pin as output and set it 
to   one.  
2.  Allow  at  least  10 us for the 10 nF capacitor to charge // Wait at least 10 us for the capacitor to 
charge.  
3.  Make  the  I  /  O  line  an  input  (high  impedance)  //  Set  the  microphone  pin  as  input  (high 
impedance).  
//  Measure  the  time  the  capacitor  takes  to  download,  ie  when  we  read  a 0 in the input because 
the   voltage   in   out   is   Less   than   logical   1.  
 
What  I  understand  about  how  this  works,  I  think  it's  going  to  touch  me  to  take  pen  and  paper 
x_x.  
1.   Set   the   micro   output   and   set   it   to   one.  
2.  Wait  10  us  for  the  capacitor  to   discharge  instead  of  being  charged,  it  would  be  at the same 
voltage   on   the   two   terminals,   so   explain   to   me   what   direction   the   capacitor   is   charging.  
3.   Put   the   microcontroller   pin   as   input.  
4.  Measure  the  time  it  takes  the  capacitor  to   charge  ,  as  it  charges  the  voltage  in  Vout  will 
decrease.  
 
Paying  attention  to  what  he  puts  on  the  page  and  summarizing  the  subject  is  to  measure  the 
time  it  takes  to  "discharge"  the capacitor (by putting the pin of the micro as an output or as input 
we  cause  the  capacitor  to  be  charged  or  discharged),  and  this  Time  will  be  proportional  to  the 
current that flows through the transistor, this current in turn depends on the light that arrives, that 
is  to  say,  the  time  it  takes  the  pin  of  the  micro  to  go  from  reading  one  to  reading  zero  will  be a 
function  of  the  Far  away  from  the  black  line  of  the  sensor,  is  like  doing  a  reading  with  an  ADC 
but  using a digital port and counting time. So we get a good idea of  the distance from the sensor 
to   the   black   line   and   we   will   probably   get   better   resolution   than   with   the   ADC.  
 
This  circuit  is  more  complex  than  the  previous  one,  but  I  have  decided  to  use  it  to  evaluate  it 
since  it  is the one used in robots 3pi, but for those who do not want to complicate the other plate 
is read in digital, 1 or 0, passing Of the ADC and probably do not need more. But then to be able 
to  make  the  derivative  of  the  error  we  have  to  count  time,  while  doing  it  through  ADC  or 
capacitor   we   can   apply   the   values   read   directly,   but   to   get   here   there   is   still   enough.  
 
The   complete   scheme   of   the   plate   is   as   follows:  
 
You  can  see  the  previous  phototransistor  and  capacitor  assembly  multiplied  by  8, photo diodes 
are  placed  two  by  two  to  reduce  consumption.  We  have  an  entrance  to  the  board  called 
LEDON,  which  serves to turn the light­emitting diodes on and off, and can be used in two cases: 
the  first  one  serves  to  save  battery,  turn  them  on  reading  and  turn  them  off  until  Next  time  we 
want  to  re­read.  The  second  use  we  can  give  is  to  control  the  light  emitted  by  the  gods  by 
applying  a  signal  pwm,  making  more  or  less  the  work  cycle  we  can  make  the  transistors reach 
more   or   less   light.   In   the   case   of   the   sprinter   robot   with   always   leaving   them   on   is   enough.  
 
The  consumption  of  the  plate  says  that  it  is  100  mA,  the  previous  plate  of  the  micro  could give 
those  100  mA  but  we  risk  to  burn  it,  a  good  rule  is  always  to  dimension  the  components  for 
twice   the   theory.  
 
We  also  note  how  there  is  a  connector  for  short­circuiting  the  47  ohm  resistors  of  the  diodes, 
this  is  in  case  we  are  going  to  feed  the  board with 3.3V, since that resistance is calculated for a 
value  of  5V.  If  you  feed  with  5V  you  do  not  have  to  touch  anything,  if  you  feed  with  3.3V  join 
those   points.  
 
The   connectors   of   the   board   can   be   soldered   in   two   ways:  
 
Using   a  connectors   that   would   fit   the   large   yellow   rectangle,   or   with   a  connector   in   a  row:  

 
Anyway,   according   to   tastes.  

 
The  sensor  board comes with its pin strip to put it as we like, the resistance is in case we decide 
to   split   the   plate   in   two   and   it   would   go   in   the   plate   of   the   two   sensors,   in   our   case   is   useless.  
 
In  order  to  be  able  to  read  these  sensors  with  a  capacitor  it  is  necessary  to  use  a  timer  of  the 
microcontroller,  since  we  must  count  time,  so  it  is  no  choice  but  to  use  the timer1 that we were 
left  free  for  the  task,  luckily  we  will  be  able to read them all to the Instead of detecting when the 
input  pin  changes  due  to  an  interrupt.  So  we  will  surely  have  to  choose  a  pin  of  the  micro  with 
external  interruption  for  each  sensor,  luckily  we  have  to  spare. We have a lot of code to look at, 
since  the  3pi  robot  that  uses  this  form  of  ller  sensors  also  carries  the  ATmega328p,  so  we  will 
probably  be  able  to  reuse its libraries for the control of motors and for reading and calibration Of 
the   sensors,   or   at   least   notice   how   they   have   been   made.  
 
A  final  point  on  the  sensors  is  that  they  must  be  at  a  minimum  distance  from  the  ground,  the 
further  we  move  away  the  less  light  will  reach  the transistor coming from the diode, so we must 
worry   about   placing   them   about   3  mm   from   the   ground   approximately.  
 
The  next  step  would  be  to  create  a  board  using  pcb  or  a  tops  board,  to  punch  the board of the 
micro,  and  cable  the  whole  robot,  add  a  led,  a  push  button.  The  sensor  board  requires  8  or  9 
pins  of  the  microcontroller,  so  we  would  have  enough  with  the  baby  orangutan,  sensors  and 
anything  else  we  want  to  add.  But  that  for  the  next  weekend,  if  the  miniz  leaves  me.  With  this, 
the  introduction  of  the  electronics  selected  for  the  robot  is  done,  and  each  point  will be defined 
as   it   is   used.  
 
For   any   doubt,   idea,   comment:  f orum   .  
 
 
 
 
++++++ 
 
 
 
 
 

Electronics.  
 
A  first  design  of  electronics  for  the  robot  (   not  yet  tested  )  and  first  idea  of  complete base, they 
leave   the   robot   finished   at   100%   ready   to   start   with   programming.  
 
 
The  first  thing  is  to  connect  the  control  board  to  the  motors and to the sensor board, in addition 
we  need  to  give  a  5V  or  3.3V  supply  to  the  sensor  board,  so  we  will  have  to  add  some  kind of 
regulator  that  will  provide  the  required  voltage  From  the  battery  constantly.  For  all  this  I  have 
assembled  a  plate  with  which  to  join  the  different  parts  of  the  robot  and  add  additional 
components   like   the   regulator   of   5  V,   leds,   buttons,   etc   ...  
 
Last   week   the   robot   ended   up   like   this.  

  
 
A  basic  idea  with  a  weight  of  124  grams.  The  top platform is still missing, where the electronics 
and  buttons  are  placed.  It  can  be  done  in  many  ways,  by  making  a  hard  printed  circuit  board 
using  a  tops  board  to  make  the  welds,  I  have  decided to use another piece of plastic and a thin 
printed  circuit  board  that  almost  does  not  weigh  all  The  options  are  more  or  less  equivalent  in 
weight.  
 
If   you   do   not   have   experience   making   printed   circuit   boards   it   is   easiest   to   resort   to   a  top   plate.  
 

  
 
It  is  a  way  of  joining  the different electronic components, they are fixed to the plate and they are 
united  by  means  of  cables  or  the  tracks  are made joining the islands with tin. If you do not have 
experience  in  electronics  this  is  the  easiest  option,  since  you  do  not  have  to  design  and  make 
the  printed  circuit  board.  Although  it  seems  faster  than  making  a  printed  circuit,  it  is  quite  the 
opposite,  it  takes  much  longer  than  when  you  have  experience  designing  and  creating  printed 
circuit   boards.  
 
If  we are going to use a plate of these then we will make the holes to dock to the 3 screws of the 
robot  and  we  will  punch  the  pololu  plate  of  the  microcontroller  (in  the  connector that we will put 
in  the  plate  of  topos  for  that  purpose)  to  make  the  different  connections  with  the  Rest  of  the 
components.  An  easy  way  to  cut  and  shape  these  tops  plates  is  with  cutting  pliers  (the  ones 
typical  of  cutting  cables)  to  cut  one  by  one  the  material  between  two  holes.  If  you  have  never 
done  a  pcb  as  this  is  the  best  option  to  mount  a  first  robot,  in  any  electronics  store  they  sell 
these   plates,   of   different   sizes,   and   its   price   is   a  few   euros.  
 
Another  option  would  be  to  make  a printed circuit board that is screwed to the robot on which to 
mount  the  components,  this  may  be  the  best  option,  the only difficulty is to cut the pcb and give 
it  shape,  that  if  no  tool  is  available  Adequate  (as  is  my  case)  since  it  usually  takes  quite  some 
time.  
 
The  option  that  I  have  decided  is  to  use  a  very  thin  and  flexible  plate,  which  can  be  cut  with 
simple  scissors  with  the  desired  shape  and  drilled  with  a  punch.  If  we  want  to  mount 
components  such  as  buttons,  switches,  you  will  have to think about a surface on which to place 
this  thin  plate.  Although  it  could  be  screwed  directly  to  the  robot  the  thin  plate  and  work 
perfectly,  but  does  not give the feeling of stiffness of the previous ones, although we would save 
some   reels.  
 
Using   PVC   like   the   previous   one   creates   a  piece   that   will   be   the   top   of   the   robot.  
  
 
This  material  weighs  little  and  can  be  worked  without  any special tools, it is drilled to fit with the 
screws  of  the  base  and  a  hole  is  made  to  incorporate the switch that lights the robot, according 
to  the  rules  of  many  competitions  the  robot  is  left  On  the  track  totally  off,  and  to  start  simply 
lights  up.  So  taking the main switch in an accessible area is logical, although the regulations are 
to  skip  them  and  then  in  the  contests  it  is  seen  as  the robots 3 pi make the previous calibration 
of  sensors  on  the  track  they  need  before  starting  To  walk,  starting  the  race  by  means  of  a 
pushbutton.   But   in   principle   it   is   necessary   to   design   according   to   the   regulation.  
 
  
Set  the  switch  to  which  we  will  weld a pair of cables to connect in series with the battery. And in 
thin  plate  we  create  the printed circuit to connect the necessary electronics. With a scissors and 
a   punch   and   bits   we   give   the   desired   shape   and   adjust   it   to   the   upper   base.  
 

  
 
The  plate  on  the  right  is  where  we  click  the  control electronics (baby orangutan), the scheme is 
as   follows:   (schematic  s  till   to   be   tested   )  
 
 
In  the  center  is  the Baby Orangutan, with its pins with their corresponding names. For a minimal 
robot  design  the  only  thing  we  would  need  to  do  is  connect  the  motors  and  sensors  with  the 
microcontroller   board   and   add   a  regulator   that   feeds   to   the   sensor   board.  
 
The  regulator  part  is  on  top  left,  in  X1­1  and  X1­2  the  battery is connected, then X1­1 is seen a 
connector,  there  goes  the  switch  in  series  with  the  battery,  thereafter  a  cable  That  goes  to  Vin 
(battery  voltage  to  the  microplate)  and  a  protection  diode,  behind  the  diode  we  find  a  regulator 
7805  with  its  corresponding  capacitors  to  filter  noise,  and  we  will  use  it  to  power  all electronics 
other   than   the   Baby   Orangutan   that   are   Add   to   the   robot.  
 
The  pin  assignment  of  the  microcontroller  has  been  made  to  facilitate  the  layout  of  the  printed 
circuit,  leaving  the  Reset  without  external  connection,  like  the  ADC7  and  the  user  LED  (PD1). 
PB4  and  PB5  are  pins  that  are  also  used  for  the  serial  programming  connector,  so  they  have 
been  connected  to  the  sensors,  if  they  bother  programming  with  removing  the  connector  from 
the  sensor  board  is  enough.  In  PB1  and  PD0  have  been  added  LEDs,  instead  of  a  led  by  pin 
three  have  been  added,  since  it  will  be  easier  to  see  them  when  the  robot  is  on  the  track, they 
are  lit  by  a  transistor  and  the  power  is  taken  from  the  7805.  In  PB0  and  PB2  we  have a pair of 
switches,  which  serve  to  select  different  strategies  of  the  robot  program,  it  is  advisable  to  add 
them,  since  in  the  contest  there  is  usually  no  time  to  reprogram  between  races  and  take  them 
and   to   be   able   to   decide   between   different   programs   or   parameters   is   an   advantage.  
 
In  ADC6  the  battery  is read by means of a voltage divider, in this case the resistances are equal 
dividing  the  voltage  of  the  battery  (7.4V)  between  two,  since values  greater than 5V we can not 
read,  the  resistances  must  be  of  the  order of 10K , We could add a capacitor in parallel with the 
earth  resistance  to  avoid  the  effect  of  loading  the  adc, but in this case we will as this is enough. 
In  PC4  and  PC5  a  connector  for  the  I2C  protocol  has  been  installed,  which  will  be  used  to 
connect  an  interface  to  the  robot  and  to  read  the  registers  of  the  microcontroller,  such  as  the 
reading  value of the sensors for example, so we can check their operation. The missing pins are 
used  to  read  the  sensor  board.  Finally  the  connectors  for  the  motors  in  M1  and  M2  have  been 
put.  
 
I  still  have  not  tried  this  sensor  board  but  seeing  the  pins  there,  the  way  to  read  it  probably  is 
through  the  external  interrupt,  so  that  is  the  only  thing  we should ask the pin, which has one. In 
principle  if  there  is  no  subsequent  incompatibility  between  the  assignment  of  pins  and  the 
peripherals  used  as  this  design  could  be  worth  and  if  I  have  not  been wrong in anything will be 
the   definitive.  
 
Once  you  have  the  schematic  you  go to make the circuit using a program like Eagle, Orcad, etc 
...   I  like   Eagle   although   probably   the   most   accurate   is   to   use   some   of   the   free   alternatives.  
 
 
 
The  components  chosen  by  space  topics  are  usually  SMD  over  DIP,  welding  SMD  is  quite 
simple  although  it  seems  quite  the  opposite,  it  only  requires  a  little  practice,  so  there  is  no 
reason  to  continue  using SMD DIP components in most of the Cases. The final photolitre is this: 
pcb  .  To  make  the  plate  there  are  several  techniques,  I  use  insolator  plus  ferric  chloride,  to 
insulate  you  have  to  make sure that you have a good photolithography, that you do not pass the 
light,  I  use  a  cheap  laser  printer  and  transparency  paper  to  make  them,  you  do  not  get  good 
Results   and   the   plates   are   a  bit   ugly,   but   it   is   enough.  
 
Once  we  remove  the  plate  from  the  acid  we  proceed  to  weld  it,  for  small  components  the  best 
welder  I  have  found  is  the JBC 14s with a tip of 0.5 mm, together with a clamp (JBC also) and a 
support   for   the   plate   is   all   that   needed.  
  
 
Once   soldered   the   plate   looks   like   this:  
 

  
Regarding  the  values   of  the  components,  the  resistance  of  the  LEDs  depends  on  the  chosen 
color:  130  for  green  and  180  for  red.  The  resistors  of the transistors are of 100k and they serve 
to  give  a  value  of  0  V  in  the  door  in  the  case  that  we  configure  the  pin  like  entrance,  it  can  be 
removed.  The  resistors  of  the  12k  and 12k switches are those that go to Vcc and 220 which are 
in  series  with  the  pin  of  the  micro,  and  serve  to  protect  the  latter  from configuration errors. The 
electrolytic   capacitor   is   0.47   uF   and   the   other   0.1   uF.   The   resistors   of   the   voltage   divider   of   12k.  
 
The  Baby  Orangutan  paca  is  inserted  in  the  connectors that have been put for that purpose (be 
careful  not  to  put  it  upside  down),  thus  we  have  the  option  to  remove  it,  to  change  it  without 
having  to  desolder.  The  top  connector  goes  to  the  sensor  board,  the  two  smaller  connectors in 
the  middle  are  for  the  motors,  and  the  large  connector  next  to  the  letters  is  the  one  for  the 
battery,  the  two  connectors  on  the  underside  are  for  the  Bus  I2C  and  a  5V  output  in  case  we 
want  to  add  an additional board to the robot. The I2C bus has not been fitted with the necessary 
resistors  for  its  operation,  so  it  must  be  taken  into  account  to  provide them externally when it is 
to  be  used.  The  plate  has  a  pair  of  bridges,  you  see  in  the  photo  of  the  tracks  and  the 
components,  the  two  yellow  lines  we  must  join  them  by  making  a bridge with a cable, there are 
4  green  circles  that  is  where  these  cables  should  go.  Next  to  the  battery  connector are the two 
holes   where   the   switch   wires   are   to   be   soldered.  
 
So   the   plate   mounted   on   the   robot   would   look   like   this:  

  
 
If  you  have  never  done  a  pcb  or  media  is  available,  the  option  is  to  use  the  board  of  all  of  the 
principle   and   assemble   it   all   there   with   dip   components.  
 
With  this  we would already have all the electronics needed to make the robot work, but a plaque 
has  been  made  with  the  sole  purpose  of  making  the  robot  more  attractive,  since  although  it  is 
not  a  requirement  it  is  a  good  idea  to  try  to  make  beautiful  robots  to  see,  already  That  in  the 
contests  a  great  part  of  the  people  is  the  public,  (we  go  is  an  excuse  to  be  able  to put the leds 
that   I  sell   the   ebay   Chinese   that   I  like   XD   so   much).  
 
The   other   plaque   that   has   been   made   is   this:  

  
 
The   scheme   is   very   simple,   they   are   only   LEDs   with   their   resistance   leds.  

 
And   his   photo   is   here:  l eds   .  
 
And   so   they   remain   in   the   robot.  
 
  
 
Yes,  I  know,  there  is  still  a  line  of  pink LEDs between the motors and the sensors, if they do not 
make   a  lot   of   noise   in   the   latter   they   will   be   there.  
 
The  electronics  are  already  made,  so  you  just  have  to wire everything. The first thing is to put a 
cable   to   the   engines   that   come   with   nothing:  
  
A  pair  of  wires  are  soldered  to  each terminal, and at least one capacitor is placed between both 
0.1  uF  terminals  to  remove  noises,  if desired one can also weld a pair of further capacitors from 
each  terminal  to  a  common point of the housing Of the motor, but with the first initial capacitor is 
sufficient.  
 
Once   wired   and   mounted   on   the   robot   are   as   follows:  
  
 
It  is  done  to  the  cable  that  joins  the  sensor  board  with  the  plate  that  we  made  of  the 
microcontroller  and the cable that carries the power to the LEDs. I used all these types of cables 
to   do   the   following:  
 
Based   on   the   following   components:   female   connector,   pc   bus   cable   and   heat   shrink.  
  
 
It  peels  and  separates  the  cable  of  the  pc  and  cuts  the desired length of pins for the connector, 
in   each   cut   a  pin   is   sacrificed,   if   we   need   11   we   have   to   cut   by   12.  

  
 
Once  peeled  and  cut  the  connector  are  given  flux  and  tin  both,  so  that  to  join  them  then  only 
have   to   use   the   welder   without   providing   tin.  

  
 
Once   they   have   been   welded   all   is   placed   and   heats   the   heat   shrink.  
 

  
 
Finally   you   can   give   a  little   thermocouple   to   the   connectors   to   make   sure   they   do   not   move.  
  
 
We   make   the   other   connector   in   the   same   way:  

  
 
With  this  would  be  the  complete  robot,  regarding  the  base  has  been  made  a  change  and  has 
added   a  second   crazy   wheel.  

  
 
Due  to  the  flexibility  of  the  PVC  the  part  of  the  sensors  almost  touched  the  ground,  so  the 
friction  with  the  screws  was  going  to  be  constant,  so I prefer to put another crazy wheel smaller 
which  adds  weight  and  makes  the  robot  always  go  At  that  height.  The  variable height can be a 
problem  since  it  will  read  analog  values   (in  this  case  counting  time),  so  that  the variable height 
would   affect   the   reading.  
 
  
 
The  ideal  is  3  points  of  support,  which  are  those  that  are  needed  for  the  plane  and  that  way 
never  a  wheel  is  going  to  be  able  to  remain  in  the  air.  In  this  case  the  center  of gravity is on or 
behind  the  axis,  so  the  case  of  losing  the  contact of a wheel with the ground on a flat surface is 
impossible.  S   econd   wheel   crazy   .  
 
I  will  start  to  try  with  this  basic  idea  to  see  what  result  I  get,  and  above  all  to  see  how  the 
engines  go  since  I  have  serious  doubts about passing the meter per second with them. Anyway 
I  have  the  same  10:  1  more  current  motors,  1.6  A  in stall that could burn the Baby Orangutan if 
the  robot  gets  blocked,  but  I  have  tried  them  and  I  was  surprised  the  speed  and  the  strength 
they   have.  
 
The   base   yet   assembled   and   ready   to   run   gives   the   next   weight.  
 

  
166   grams,   I  think   I  remember   the   3  pi   weigh   it   and   it   was   about   155   grams.  
 
 

  
 
So  the  robot  is  ready  to  program  and  test  the  electronics  that  have  been  assembled,  which  is 
still  not  sure  that  it  works.  Riding a robot takes a couple of evenings as you can see, the difficult 
thing  is  now  to  program  it  in  the  best  way  possible  and  what  requires  most  of  the  time  to  test 
and  develop  a  robot.  But  good  that  for  later,  that  now  I  will  see  if  I  return  a  little  with  the  miniz 
that   are   a  little   abandoned.  
 
For   any   doubt,   comment,   idea,   correction   ...  F
  orum   .  
 
++++++ 
 
 
 

QTR­8RC   Sensors.  

 
 
Test  of  the   QTR­8RC  sensor   board  of  pololu  which  is  characterized  by  reading the line through 
the  charge  time  (through  the  phototransistor)  of  a  capacitor,  and  looking  at  the  results it seems 
to me that I have made a mistake choosing this option for a robot Initiation, being able to choose 
a   plate  of  sensors  with  resistance  to  read  directly  in digital, 1 or 0, that if it works is the simplest 
thing   for   the   robot.  
 
For  the  tests black insulating tape is used on a white surface, write the program that is in charge 
of  configuring  the  pins  of  the  micro  that  go  to  the  sensors  like  inputs  and  outputs  to  be  able  to 
realize   the   reading,  c  ode   .  
 
To  start  a  first  reading  with  all  the  sensors  on  black,  to  see  the  result  of  the  reading  is  used  a 
logic   analyzer   that   is   connected   to   the   8  sensors.  

  
 
The  pulse  width  gives  us  the  distance  from  the  sensor  to  the  line,  the  shorter  it  is  the  sensor 
gets  more  light  and  therefore  means  that  it  is  over  white,  when  it  gets  less  light  the  sensor  is 
over  black  and  the  pulse  is  more  long.  The  pulses  are  generated  and  the  sensors  are  read 
every  4  ms,  the  image  below  shows  the  pulse  duration  of  the  8  sensors  when  they  are  over 
black.  
 
 
The  pulses  of  each  sensor  when they are over black are not the same, the lowest is about 1 ms 
and  the  greater  about  1.37  ms,  this  pulse  width  in  addition  to  the  line  situation  with  respect  to 
the  sensor,  also  depends  on  factors  such  as  height,  Positioning,  the  voltage  thresholds  of  the 
microcontroller  pins,  or  the  sensor  itself.  Therefore  it  is  necessary  an  individual  calibration  of 
each  sensor to be able to have a precise reading. And this is a problem for a robot that pretends 
to   be   simple   and   easy   to   do.  

 
 
For   the   reading   of   the   sensors   a  logic   analyzer   is   used,   which   distinguishes   between   voltage 
levels   of   one   and   zero   according   to   their   thresholds:   input   low   voltage:   ­0.5   to   0.8   V  and   input 
high   voltage:   2  to   5.25   V.   In   the   ATmega328p   the   Threshold   for   the   low   input   level   would   be   at 
­0.5V   to   1.5V   and   the   high   from   3V   to   5.5V.  A
  ll   this   means   that   if   the   micro   read   the   input,   being 
detecting   the   low   level   and   being   the   micro   threshold   higher   than   the   analyzer,   we   could   have 
slightly   shorter   times   in   the   pulse   width.  
 
If  you  observe  on  the  oscilloscope what happens in the sensor, you do not see a constant pulse 
in  its  output,  you  see  how  the  output  voltage  of the sensor decreases as the capacitor charges. 
The  pulse  would  remain  at  one  until  the  sensor  output  reaches  a voltage level that the micro or 
analyzer  interprets  as  zero.  So  the  times  measured  in  this  test  are  not  exact,  the  only  way  to 
know  them  accurately  is  by  a  pin  of  the micro that is activated to record the time when the input 
pin  reads  zero,  and  it  should  be  done  for  all  sensors,  Which  does  not  make  sense  since  they 
also   affect   other   external   and   variable   factors.  
 

 
 
The   robot   3  pi   solves   this   problem   by   making   a  calibration   of   the   sensors   at   the   beginning,   to   do 
so   before   starting   to   run   turns   on   itself,   in   such   a  way   that   all   sensors   go   through   the   line   and 
write   down   and   save   the   maximum   and   minimum   values   read   by   Each   sensor   and   for   each 
sensor   assigns   the   value   0  to   the   lowest   value   read   and   the   value   1000   to   the   maximum   of   each 
sensor   and   in   the   readings   returns   an   amount   between   these   values.  
 
Continuing   with   the   tests,   the   sensors   are   placed   on   white   and   the   output   is   observed   on   the 
analyzer.  
 
 
As  soon  as  the  pulse  starts,  there  is  a  delay  of  40  us  to  discharge  the  capacitor,  so the sensor 
that  takes  more  time  to  load  does  it  in  just  55us.  The  difference  between  the  minimum  black 
value  and the maximum white value is about 1 ms, which in principle will allow us to obtain good 
precision   with   a  timer.  
 
It   does   a  test   by   sticking   a  bit   of   ambient   light,   (in   the   picture   3  table   lamps   are   lit   although   only 
one   is   seen,   it   is   not   sunlight   that   would   be   good   for   testing)   and   it   goes   on   to   turn   off   the   diodes 
of   the   plate   Sensors   to   see   if   it   affects   in   some   way   the   external   illumination   that   we   can   find   in 
the   contests.  
  
 
The   next   measurement   is   taken   on   the   analyzer.  

 
 
The  capacitor  does  not  receive  light  and  never  gets  charged in the period of 4 ms, the low level 
pulse  that  is  seen  in  the  analyzer  has  a  width  less  than  1  us  and  has  been  set  to  trigger  the 
trigger  of  the  analyzer,  corresponds  with  Enabling  the  own  pull­up  resistor  of  each  pin  of  the 
port,  when  making  the  change  to  configure  the  pin  as  output  to  input.  This resistance would be 
in  parallel  with  the  capacitor,  and  its  value  is  sufficient  so  that  with  the  minimum  intensity  that 
circulates   by   the   phototransitor   puts   low   to   the   collector   of   this   one.  
 
_delay_us   (40);  / /   The   capacitor   is   discharged.  
 
DDRD   =  (1   <<   S0)   (1   <<   S1)   (1   <<   S2));  / /   The   sensors   are   configured   as   input.  P
  ull­up   enabled.  
DDRB   =  (1   <<   S3)   (1   <<   S4));  
DDRC   =  (1   <<   S5)   |  (1   <<   S6)   |  (1   <<   S7));  
 
PORTD   &  =  ~  ((1   <<   S0)   |  (1   <<   S1)   |  (1   <<   S2));  / /   Pull­up   off,   Hi­Z  
PORTB   &  =  ~  ((1   <<   S3)   |  (1   <<   S4));  
(1   <<   S5)   |  (1   <<   S6)   |  (1   <<   S7));  
 
_delay_ms   (4);  
 
Pulse   start.  

 
 
PORTD   |  =  ((1   <<   S0)   |  (1   <<   S1)   |  (1   <<   S2));  / /   The   output   is   set   to   1  
PORTB   |  =  ((1   <<   S3)   |  (1   <<   S4));  
PORTC   |  =  ((1   <<   S5)   |  (1   <<   S6)   |  (1   <<   S7));  
 
This   image   just   out   of   curiosity   to   observe   how   the   sensors   are   set   to   1  as   its   instruction   is 
executed   at   different   times.  
 
 
Finally,   a  test   is   performed   with   the   robot   on   the   line,   with   the   central   sensors   on   it,   and   the 
measurements   are   taken   with   the   lamps   on   and   off.  
  
 
Lamps   off,   central   sensors   on   the   line.  

 
The   enormous   time   difference   between   the   sensors   on   black   (S3   and   S4)   and   the   rest   on   white 
is   observed.  
 
Lamps   on.  
 
It  is  observed  the  same  as  in  the  previous  case,  the  time  has  decreased  a  few  microseconds, 
which  is  totally  negligible,  and  at  the height of the sensors can be said that the noise created by 
the   artificial   lighting   that   I  have   here   is   negligible.  
 
The   ideal   solution   to   the   problem   of   the   different   values   that   each   sensor   can   record   when   they 
are   on   the   line   is   to   perform   a  calibration   before   running   as   3  pi,   thus   solving   the   problem   of 
external   and   internal   conditions   to   the   sensor.  B   ut   it   goes   against   the   rules   of   the   competitions:  
 
The   start   up   of   the   robot   will   be   done   by   means   of   a  switch   or   "rope".  I n   no   case  w
  ill   the   robots 
be   allowed   to   operate   before   the   start   of   the   operation.  
 
Normative  of  the  Cosmobot,  according  to  that  the  robot  could  not  perform  a  calibration  before 
starting  to run, although in recent competitions has been done, if we do not take into account we 
can   find   the   robot   disqualified.  
 
Output   sensors   on   black.  
 
 
Looking  at  the  times  of  the  sensors  on  black  it  is  seen  that  all  pass  a  minimum  amount,  what 
could  be  done  to  solve  the  problem  of  calibration,  is to set a maximum value, in this case 1 ms, 
and  that  maximum  value  is  modified  from  Individual  way  if  any  sensor  exceeds  it  in  any  of  its 
readings.  The  calibration  would  be  done  on  the  track and at the speed of the readings, let's say 
that  the  main  loop  is  done  every  10  ms, as it would not affect the behavior of the robot. Another 
option  is  to  calibrate  the  homologation  wheels  and  store  the data in the eeprom, once recorded 
change   the   switches   in   such   a  way   that   they   will   not   be   done   again.  
 
The  RC  sensor  board  is  better  option  than  the  analog  alternative  because  we  get  higher 
resolution,  but  I  think  it  is  not  suitable  for  the  intentions  of  this  project,  when  there  is  an 
alternative  that  reading  simply  one  or  zero  can  work.  I'm  going  to  buy  one  of  the  analog plates 
and   once   the   two   have   been   tested   and   seen   the   results,   I'll   see   which   one   stays   in   the   robot.  
 
For   anything:  f orum   .  
 
++++++++ 
 
 
 
 

Controlling   the   speed   of   the   motors.  
 
In  a  differential  robot  the  turns  are  realized  when  the  wheels  of  one  side are moved to different 
speed  than  the  wheels  of  the  other  side.  To  do  this  we  can  stop  the  wheels  on  one  side  while 
moving  the  other,  or  you  can  have  the  wheels  on  each  side  turn  in  one  direction,  which  will 
cause   the   robot   to   turn   on   itself.  
 
The  most  practical  thing  is  that  the  wheels  on  each  side  can  move  in  the  same  direction but at 
different  speeds,  the  greater  the  difference  between  the  speed  of  the  wheels  of  each  side,  the 
greater  the  angle  of  rotation  of the robot. For example, if you want to turn left, the wheels on the 
right   side   should   move   faster   than   the   left   wheels.  
 
To  control  the  speed  of  a  motor  is  usually  used  what  is  called  PWM  (Pulse  Width  Modulation), 
which  consists  of  putting  a  train  of  pulses  of  a  certain  frequency  to  the  driver  that  controls  the 
motor,  and  depending  on  the  time  the  pulse  is  To  1  within  the  period, the motor moves more or 
less   fast.  
 
To  control  a  motor  the  Baby  Orangutan  as  driver  takes  two  bridges  in h, a bridge in h is formed 
by   4  transistors:  

 
Turning  the  transistors  on  and  off  can control the direction and speed of the motor. For example 
when  the  two  transistors  of  the  image  above  are  lit  by  the  arrow,  which  represents  the  current, 
the  motor rotates in one direction. When these two transistors are off and the other two switches 
on,  the  motor  turns  in  the  reverse  direction.  Turning  on  only  the  two  transistors  below,  we  get 
the   engine   to   brake.  
 
The  microcontroller  is  responsible  for  providing  the  integrated  circuit  with  the  j­jumpers  the 
signals   for   controlling   the   speed   and   direction   of   the   motors,   according   to   the   following   table:  
 
 
 
If  we leave M1A to zero and put a 1 in M1B, the motor turns in one direction. If instead of putting 
a   1  (5V)   we   put   a  signal   of   this   type   (signal   pwm):  

 
The  motor  rotates  at  a  speed  that  is  a  function  of  time  within  the  period in which the pulse is at 
1,  ie  by varying the pulse width of the square signal that we provide in M1B we get the engine to 
rotate  slower  or  faster.  The  higher  the  frequency  of  the  square  signal  that  we  put  in  M1B,  the 
closer  it  is  to  a  constant  value  the  intensity  that  the  motor  crosses,  having  as  limit  a  maximum 
frequency   at   which   we   begin   to   have   losses.  
 
If  the  microcontroller  had  to  be  set  to  1  M1B,  counting  the  time  it  takes  to  1  to  generate  the 
pulse  width  and  then  to  zero  it  and  also  keep  track  of the time elapsed before entering the next 
period,  as  it  would  involve  consuming a lot of time Of the microcontroller in performing this task, 
which  could  prevent  us  from  doing  other  things.  For  this  the microcontroller has up to 6 outputs 
pwm.  They  are  hardware  modules  that  we  should  only  activate,  indicate  the  frequency  of  the 
square  signal  and its pulse width, and these modules will automatically generate the pwm signal 
by  a  pin  of  the  microcontroller,  freeing  him  from such a task so that he can devote Its time to do 
other   things.  
 
I  will  not  enter  with  the  registers of the microcontroller in charge of the task of pwm, nor with the 
different  modes  of pwm that we can generate since it is out of the purpose of this robot, but I will 
do  it  for  the  section  of  Arduino  /  AVR  of  the  page, Because pwm signals are used quite often in 
robotics.  
 
I  will  take  advantage  of  the  code  made  for  the  Baby  Orangutan  in  the  Pololu  page,  where  we 
find the functions to initialize the hardware of the microcontrollers to create the pwm signals, and 
the  functions  to  change  the  pulse  width  of  each  pwm  signal  generated  by  the  modules,  And 
therefore  to  be  able  to  regulate  in  speed  the  motors.  Just  note  that  the  selected  pwm  mode  is 
called  Fast  PWM among those available in the microcontroller, which is not the most suitable for 
motor  control,  having  other  modes  available  that  correct  the phase of the signal when the pulse 
width  changes.But  it  is  the  one  used  by  the  robot  3pi  and  for  which  the  code  is  available,  and 
therefore   the   one   that   is   going   to   be   used.  
 
On  the  following  page:  http://www.pololu.com/docs/pdf/0J15/motor_driver_application_note.pdf 
we  find  the  code  to  control  the  motors  that  we  connect  to  the  Baby  Orangutan.  The  functions 
that   interest   us   are   the   following:  
 
#include   <avr   /  io.h>  
//   Motor   Control   Functions   ­  pwm   is   an   8­bit   value  
//   (ie   ranges   from   0  to   255)  
Void   M1_forward   (unsigned   char   pwm)  
{  
OCR0A   =  0;  
OCR0B   =  pwm;  
}  
Void   M1_reverse   (unsigned   char   pwm)  
{  
OCR0B   =  0;  
OCR0A   =  pwm;  
}  
Void   M2_forward   (unsigned   char   pwm)  
{  
OCR2A   =  O;  
OCR2B   =  pwm;  
}  
Void   M2_reverse   (unsigned   char   pwm)  
{  
OCR2B   =  O;  
OCR2A   =  pwm;  
}  
 
Including  these functions in our code we can control the speed and direction of the engines. The 
functions  Mx_forward  and  Mx_reverse  cause  the  motor  to  rotate  in  one  direction  or  in  the 
reverse  direction,  to  the  function  we  pass  a  value  in  the  variable  pwm,  that  value  is  between  0 
and   255   and   corresponds   to   the   speed   of   rotation   of   the   motor.  
 
//   Engine   Initialization   routine   ­  this   function   must   be   called  
//   before   you   use   any   of   the   above   functions  
Void   motors_init   ()  
{  
//   configure   for   inverted   PWM   output   on   motor   control   pins:  
//   set   OCxx   on   compare   match,   clear   on   timer   overflow  
//   Timer0   and   Timer2   count   up   from   0  to   255  
TCCR0A   =  TCCR2A   =  0xF3;  
//   use   the   system   clock   /  8  (=   2.5   MHz)   as   the   timer   clock  
TCCR0B   =  TCCR2B   =  0x02;  
//   initialize   all   PWMs   to   0%   duty   cycle   (braking)  
OCR0A   =  OCR0B   =  OCR2A   =  OCR2B   =  O;  
//   set   PWM   pins   as   digital   outputs   (the   PWM   signals   will   not  
//   appear   on   the   lines   if   they   are   digital   inputs)  
DDRD   |  =  (1   <<   PORTD3)   | (  1   <<   PORTD5)   | (  1   <<   PORTD6);  
DDRB   |  =  (1   <<   PORTB3);  
}  
 
Motors_init  ()  is  in  charge  of  initializing  the  microcontroller  hardware  that  will generate the pwm 
signals,  the  frequency  of  the  pwm  signal  is  set  to 9.8 kHz. The H­bridge of the Baby Orangutan 
plate  supports  up  to  80  KHz  frequencies,  so  we  may  be  interested  in  changing  this 
configuration,  to  put  a  higher  frequency  out  of  the  range we hear and that will probably improve 
the  performance  of  the  motors.  At  the  moment  it  is  going  to  leave  like  this  because  it  is  as  it 
comes.  
 
A   code   is   written   in   the   AVR   Studio   to   check   the   operation   of   all   of   the   above:  
 
#define   F_CPU   20000000UL   //   Baby   Orangutan   frequency   (20MHz)  
#include   <avr   /  io.h>  
#include   <util   /  delay.h>  
 
//   Leds.  D  epartures.  
#define   LEDP   PORTD1  
#define   LEDV   PORTB1  
#define   LEDR   PORTD0  
//   Switches.  T   ickets.  
#define   SW1   PORTB0  
#define   SW2   PORTB2  
//   Sensors.  I nputs   and   outputs.  
#define   S0   PORTD7  
#define   S1   PORTD4  
#define   S2   PORTD2  
#define   S3   PORTB5  
#define   S4   PORTB4  
#define   S5   PORTC3  
#define   S6   PORTC2  
#define   S7   PORTC1  
#define   LED_ON   PORTC0  
 
Void   initialize_   ports   (void);  
Void   reset   (void);  
Void   M1_forward   (unsigned   char   pwm);  
Void   M1_reverse   (unsigned   char   pwm);  
Void   M2_forward   (unsigned   char   pwm);  
Void   M2_reverse   (unsigned   char   pwm);  
Void   motors_init   ();  
 
Int   main   (void)  
{  
Initialize_port   ();  
Motors_init   ();  
Reset   ();  
 
PORTD   |  =  (1   <<   LEDR);  / /   Diodes   on.  
PORTB   |  =  (1   <<   LEDV);  
 
M1_forward   (64);  / /   Right   motor.  
M2_forward   (192);  / /   Left   motor.  
 
While   (1)  
{  
}  
Return   0;  
}  
 
Void   initialize_ports   (void)  
{  
DDRD   =  0x6A;  / /   0110   1011   0,1,3,5,6   Outputs  
PORTD   =  0x00;  
DDRB   =  0x0A;  / /   0000   1010   1.3   Outputs  
PORTB   =  0x00;  
DDRC   =  0x01;  / /   0000   0001   0  Output  
PORTC   =  0x00;  
}  
 
Void   reset   (void)  
{  
PORTD   |  =  (1   <<   LEDP);  / /   Light   Led   on   Baby   Orangutan.  
_delay_ms   (300);  
PORTD   &  =  ~  (1   <<   LEDP)   //   We   turn   off   Led   in   Baby   Orangutan.  
_delay_ms   (300);  
PORTD   |  =  (1   <<   LEDP);  
_delay_ms   (300);  
PORTD   &  =  ~  (1   <<   LEDP);  
_delay_ms   (300);  
PORTD   |  =  (1   <<   LEDP);  
_delay_ms   (300);  
PORTD   &  =  ~  (1   <<   LEDP);  
}  
 
//   Functions   to   control   the   speed   and   direction   of   the  
//   engines.  P   WM   controls   the   speed,   value   between   0­255.  
Void   M1_reverse   (unsigned   char   pwm)  
{  
OCR0A   =  0;  
OCR0B   =  pwm;  
}  
Void   M1_forward   (unsigned   char   pwm)  
{  
OCR0B   =  0;  
OCR0A   =  pwm;  
}  
Void   M2_reverse   (unsigned   char   pwm)  
{  
OCR2A   =  O;  
OCR2B   =  pwm;  
}  
Void   M2_forward   (unsigned   char   pwm)  
{  
OCR2B   =  O;  
OCR2A   =  pwm;  
}  
 
//   Configuration   of   the   hardware   of   the   micro   that   controls   the   motors.  
Void   motors_init   ()  
{  
//   configure   for   inverted   PWM   output   on   motor   control   pins:  
//   set   OCxx   on   compare   match,   clear   on   timer   overflow  
//   Timer0   and   Timer2   count   up   from   0  to   255  
TCCR0A   =  TCCR2A   =  0xF3;  
//   use   the   system   clock   /  8  (=   2.5   MHz)   as   the   timer   clock  
TCCR0B   =  TCCR2B   =  0x02;  
//   initialize   all   PWMs   to   0%   duty   cycle   (braking)  
OCR0A   =  OCR0B   =  OCR2A   =  OCR2B   =  O;  
//   set   PWM   pins   as   digital   outputs   (the   PWM   signals   will   not  
//   appear   on   the   lines   if   they   are   digital   inputs)  
DDRD  |  =  (1  <<  PORTD3)  |   (1  <<  PORTD5)  |   (1  <<  PORTD6);   //  Once  initialized  in  another 
function,   it   can   be   removed.  
DDRB   |  =  (1   <<   PORTB3);  / /   Once   initialized   in   another   function,   it   can   be   removed.  
}  
 
It  is  compiled  and  recorded  on  the  same  as  the  previous  examples.  The  only  thing  that  makes 
this  code  is  to  generate  two  pwm  signals  that  go  through  the  pins  of  the  microcontroller  and 
arrive  at  the  inputs  of  the  bridge  in  h  that  controls  the  motors.  In  the  right  motor  (M1)  a  signal 
with  a  pulse  width  of  25%  and  in  the  left  motor  (M2)  a  signal  with  a  pulse  width  of  75%,  which 
causes   the   left   motor   to   rotate   rather   faster   than   the   right   .  
 
M1_forward   (64);  / /   Right   motor.  
M2_forward   (192);  / /   Left   motor.  
 
The  speed  of  each  motor  and  its  direction  of  rotation  is  established  in  these  two  calls  to  the 
functions,  to  the  right  we  assign  the  value  64  that  is  little  more  than  25%  of  255, and to the left 
we  pass  192  that  corresponds  with  75%  Of  the  maximum  value  to  pass,  255.  If  we  want  our 
robot  to  go  at  maximum  speed  we  will  have  to  pass  255  to  each  motor.  If  a  motor  turns  in  the 
opposite direction to that expected, that is to say that it goes backwards instead of advancing for 
the  foward  function,  changing  the cables of the motor connection one by the other is solved (the 
motor   does   not   have   polarity),   or   we   change   the   names   of   Reverse   by   forward   in   the   functions.  
 
If  we  connect  an  oscilloscope  to  the  terminal  at  higher  voltage  of  each  motor  we  can  observe 
the   following   signal,   yellow   M1,   blue   M2.  

 
 
This  is  the  voltage  at  which  the  positive  terminal  of  each  motor  is  connected  in  time,  you  can 
see  how  the  results  correspond  to  the  values   passed  in  the  functions  M1_foward  and 
M2_foward  that  we  copied  from  pololu,  and  therefore  their  operation  is correct . In other words, 
the  higher  our  pulse  width,  the  greater  the  effective  voltage  we  provide  to  the  motor,  so  the 
faster   it   will   turn.  
 
Video   of   the   operation   of   the   previous   code.  
 
 
For   any   doubt,   comment,   idea:  f orum   .  
+++++++ 
 
 

Reading   the   sensors,   assigning   the   error.  
 
The  first  attempt  of  robot  sprinter  with  the  sensor  board  QTR­8A is going to be made instead of 
the  initially  selected   QTR­8C  ,  for  reasons  of  simplicity,  if  the  result is not good as it will have to 
consider  the  use  of  the  QTR­  8C  which  involves  complicating  the  code  in  exchange  for  having 
an   analogue   reading   of   the   line,   but   in   principle   with   the   QTR­8A   should   suffice.  
 
Physically  the  two  plates  are  equal  in  size  and  position  of  the  connector,  so  that  they  can  be 
substituted   one   without   another,   without   problems,   to   read   both   in   digital.  

  
 
The  QTR­8A  plate  is  designed  to  read  an  analog  voltage  value,  which  corresponds  to  the 
position   of   the   line   with   respect   to   the   sensor.  
  
For  this  robot  is  not  going  to read the analog value that requires the use of an ADC, in the Baby 
Orangutan  there  are  8 ADCs removing the user potentiometer, so it could be used for an analog 
readout  of  this  sensor  board.  The  sensors  will  be  read  in  digital,  that  is  to  say  we  will  detect 
when  the  line  is  under  the  sensor.  Reading  this  way  we  have  an  error  of  the  measurement 
corresponding  to  the  space  between  sensors,  but that we can consider despicable as far as the 
location   of   the   robot   with   respect   to   the   line.   If   this   is   not   possible,   the   other   plate   must   be   used.  
 
To  read the sensor simply set the pin of the micro that is connected to each sensor as input, and 
see if it is one or zero. If it is at one it means that the black line is underneath the sensor, and if it 
is   at   zero   the   sensor   is   on   white,   that's   easy.  
 
We  have  8  sensors  and  we  want  the  line  to  be  placed  in  the  center  of  the  sensor  board,  each 
sensor  must  assign  a numerical value that represents the distance of the sensor to the center of 
the   sensor   board   (midpoint   of   the   two   central   sensors)   .  
 
We  have  8  sensors  and  we  name  them  from  left  to  right:  I3  I2  I1  I0  D0  D1  D2  D3,  at  the 
midpoint  between  I0  and  D0  we  assign  the  value  0,  to  the  sensors  on  the  right  from  D0  to  D3 
the   values   1,   3,   5  ,  7  and   those   on   the   left   from   I0   to   I1   the   values   ­1,   ­3,   ­5,   ­7.  
 
I3   ­7  
I2   ­5  
I1   ­3  
I0   ­1  
D0   1  
D1   3  
D2   5  
D3   7  
 
If  the  line  is  on  the  sensor  I2  we  have  an  error  of  ­5,  if  D1  is  an error of 3, etc ... When reading 
the  sensor  board  we  must  calculate  an  error  (distance  from  the  line  to  the  midpoint  of  the 
Sensors),  which  corresponds  to  the  sum  of  the  values  of all sensors to 1 divided by the number 
of  sensors  to  1.  When  making  divisions  with  these  micros  we  must  avoid  that  in  the  result  we 
have  decimals,  since  to  do  this  type  Of  operations  take  a  long  time  to  the  microcontroller, 
whenever   it   is   divided   you   have   to   look   for   whole   results.  
 
With  these  values   we  are always going to get integer error numbers when dividing (sensors to 1 
must  be  consecutive).  If  I  have  2  sensors  at  1,  for example 3 and 5, rest at first 1 and I add it to 
the  second,  I  have  4  and  4  which  is  the  same  as  2  *  4,  that  between  two  active  sensors  I  get 
error  =  4.  If  I  have  3  sensors  ­1,  1,  and  3,  rest  two to last and I add it to the first one and I have 
1.1   and   1  that   is   the   same   as   3  *  1  and   between   3  active   is   the   error   =  1,   and   so   onwards...  
 
So   a  function   to   read   the   sensors   would   be   as   follows:  
 
Char   get_errorp   (void)  
{  
Char   errorp   =  0;  
Unsigned   char   counter_sensor   =  0;  
 
If   ((PINC   &  0x02)!   =  0)   //   I3   PC1   ­7  
{  
Errorp   ­  =  0x07;  
Sensor_sensor   ++;  
}  
 
If   ((PINC   &  0x04)!   =  0)   //   I2   PC2   ­5  
{  
Errorp   ­  =  0x05;  
Sensor_sensor   ++;  
}  
 
If   ((PINC   &  0x08)!   =  0)   //   I1   PC3   ­3  
{  
Errorp   ­  =  0x03;  
Sensor_sensor   ++;  
}  
 
If   ((PINB   &  0x10)!   =  0)   //   I0   PB4   ­1  
{  
Errorp   ­  =  0x01;  
Sensor_sensor   ++;  
}  
 
If   ((PINB   &  0x20)!   =  0)   //   D0   PB5   +1  
{  
Errorp   +  =  0x01;  
Sensor_sensor   ++;  
}  
 
If   ((PIND   &  0x04)!   =  0)   //   D1   PD2   +3  
{  
Errorp   +  =  0x03;  
Sensor_sensor   ++;  
}  
 
If   ((PIND   &  0x10)!   =  0)   //   D2   PD4   +5  
{  
Errorp   +  =  0x05;  
Sensor_sensor   ++;  
}  
 
If   ((PIND   &  0x80)!   =  0)   //   D3   PD7   +7  
{  
Errorp   +  =  0x07;  
Sensor_sensor   ++;  
}  
 
If   (sensor­counter!   =  0)  
Return   (errorp   /  counter_sensor);  
Else  
Return   (0);  
}  
 
The  function  returns  a  value  that  corresponds  to  the  distance  from  the  line  to  the  center  of  the 
sensor  board,  we  can  have  values   between  ­7 and +7, when the robot is in the center the value 
returned  will  be  zero.  If  the  robot  does  not  read any value it returns the value zero, this must be 
changed  by  returning  for  example  the  value  ­9  if  the last sensor that has been read is to the left 
and  the  robot  sees  everything  white,  and  +9  if  the  last  sensor  read  It  was on the right. You can 
also   implement   a  maximum   spin   left   or   right   when   the   robot   loses   the   line.  
 
At  the  moment  it  is  left  like  this  and  to  check  the  reading of the sensors the following main loop 
is   made:  
 
While   (1)  
{  
Speed   =  get_errorp   ();  
 
If   (velocity   ==   0)  
{  
M1_forward   (0);  / /   Right   motor.  
M2_forward   (0);  / /   Left   motor.  
}  
 
Else   if   (speed   <0)  
{  
Speed   =  speed   *  (­   36);  
 
M1_forward   (speed);  / /   Right   motor.  
M2_forward   (0);  / /   Left   motor.  
}  
 
Else  
{  
Speed   =  speed   *  (36);  
M1_forward   (0);  / /   Right   motor.  
M2_forward   (speed);  / /   Left   motor.  
}  
 
We  have the speed variable that receives the value of the call to the previous function, get_error 
(),  the  farther  the  line  from  the  center  of  the  sensor  board  is,  the  faster  it  rotates  the 
corresponding  motor  wheel,  so  that  everything  works  correctly.  Black  line  across  the  plate 
slowly,  and  we  see  as  the  engine  increases  or  decreases  its  speed  as  it  moves  away  or 
approaches   the   line   to   the   center. Complete   code   .  
 
Also  a  code to test the robot on the track at a slow speed and only with proportional error, to see 
if  it  is  able  to  walk  ....  The  crazy  rear  wheel  I  will  remove  it,  since  if  it  encounters  surfaces  not 
smooth  as  The  one  that  I  have  here  the  robot  loses traction to have 4 points of support, reason 
why  it  will  have  to  balance  or  perhaps  to  think  in  a  new  base,  since  the  expanded  pvc  of  3mm 
has   too   much   flexibility.  
 
Video   test   of   sensors   and   first   steps   of   the   robot.  
 
The   first   impression   is   that   I  do   not   like   the   sensors   or   the   base   =  (.  
 
  For   any   doubt,   idea:  f orum.  
++++++++++ 
 
 
 

Derivative   error   and   proportional   proportional   control.  
 
In  the  previous  update  the  sensors  were  read  to  locate  the  position  of  the  line,  and  depending 
on  how  far  the  line  was from the center of the sensor board an error was assigned. That error is 
proportional  to  the  distance  from  the  line  to  the  center  and  we  will  use  it  to  establish  a 
proportional  control,  the  further  the  robot  rotates  to  focus  on  the  line.  The  problem  with  this 
proportional  controller  is  that  we  will  never  get  the  robot  to  focus  on  the  line,  it  will  always  be 
oscillating  on  the  line  as  it  could  be  seen  in  the  video,  the  robot  arrives,  passes  and  corrects, 
and   so   on   indefinitely.  
 
To  get  the  robot  to  focus  on  the  line  and  not  to  oscillate  we  have  to  implement  a  derivative 
control  (in  addition  to  the  proportional),  for  this  we  must  know  the derivative of the error, ie how 
the  error  changes  with  respect  to  time,  which  is  the  same  Than  the  speed  with  which  the  line 
travels  between  the  sensors.  With  a  derivative  control  we  can  anticipate  the  future  error, 
observing   how   it   varies   and   anticipating   the   response   before   it   occurs   obtaining   its   derivative.  
 
The  first  thing  to  be  able  to  measure  the  speed  with  which  the  error  changes  is  to  have  the 
ability  to  measure  the  time  that  has  passed  between  two  error  measures  ((speed  of  change  = 
(error_previous  ­  error)  /  time),  for  this  we  have  to  use a It is going to create a main interrupt so 
that  the  program  that  controls  the  robot  is  executed  in  fixed  intervals  of  time,  of  this  form 
between  a  measurement  and  another  one  of  the  sensor  plate  we  will  know  the  time  that  has 
passed  that  always  is  the  same,  Is  the  time  of  the  interrupt  that  we  set  in  the  timer,  so that the 
derivative   of   the   error   happens   to   be   error_previous   ­error.  
 
Setting   up   a  timer   with   an   interrupt   that   calls   a  function   every   x  time   is   a  few   lines   of   code:  
 
Void   initialize_timer1   (void)   //   Set   the   timer   and   interrupt.  
{  
OCR1A   =  0x0C35;  
TCCR1B  |  =  ((1  <<  WGM12)  |  (1  <<  CS11)  |  (1  <<  CS10));   //  The  bits  that  do  not  touch  0  by 
default  
TIMSK1   |  =  (1   <<   OCIE1A);  
Sei   ();  
}  
Adding  this  to  the  previous  programs  configures  the  Baby  Orangutan's  timer1  so  that  every  10 
ms  an  interrupt  is  activated  that  calls  a  function  to  attend to it. When the interruption occurs the 
micro  executes  the  code  that  we  indicate,  more  information  about  the  interruptions  in  the  AVR 
and  WinAVR   here  .  So  to  prove  that  the  timer1  of  the  baby  Orangutan  is  set  correctly  we write 
the   following   code   to   execute   when   the   interrupt   is   activated:  
 
ISR   (TIMER1_COMPA_vect)  
{  
PORTD   |  =  (1   <<   LEDP);  
_delay_ms   (5);  
PORTD   &  =  ~  (1   <<   LEDP);  
TIFR1   |  =  (1   <<   OCF1A);  
}  
 
To  work  with  the  interrupts  of  WinAVR  we  must  put  the following include at the beginning of the 
program:   #include   <avr   /  interrupt.h>.  
 
Each  time the timer reaches the count that we have indicated in the OCR1A register (10 ms) the 
micro  turns  on  the  red  led  of  the  user  plate,  counts  5  ms  and  turns  it  off,  connecting  the 
oscilloscope   to   the   led   we   can   verify   that   the   timer   is   Correctly   configured.  C
  omplete   code   .  

 
 
You  can  see  how  every  10  ms  runs  what  is  inside  ISR  (TIMER1_COMPA_vect)  and  works  as 
expected.  If  instead  of  turning  on  the  led,  we  read  the  sensor  board  to  know  the  error,  this 
reading  will  be done every 10 ms, so subtracting the error measured to the previous one we can 
know  the  speed  of  change  of  this,  since  the  time  is  constant  Among  all  measures.  If  we  are 
reading  sensors  in  analog  or  we  use  the  capacitor  sensor plate this calculation is direct, (error ­ 
error_previous)  will  give  us  the  derivative  of  the  error  since  the  error  can  be  considered 
continuous, we have the real measure of the distance of the sensor to the Line and the sampling 
time   is   constant.  
 
If  we  use digital sensors we can not do so directly, since we only know if the sensor is 1 or 0, we 
have  the  error  in  steps  equivalent  to  the  distance  between  sensors,  so  we  do  not  have  a 
derivative  if  not  We  look  for  the  average  speed  of  error  change  between  two  sensors.  So  one 
way  to  have  a  precise  measurement  of  the  speed of the error is to measure the time it takes for 
the  sensors  to  change,  how  long  it  takes  from  one  sensor  to  another.  Knowing  the  distance 
between  sensors  that  is fixed and the same for all and the time we can know the average speed 
of   movement   between   sensors   of   the   line   under   the   sensor   board.  
 
So  a  function  to  determine  the  derivative  /  mean  velocity  of  the  error  (distance  from  the  line  to 
the   center   of   the   sensor   board)   could   be   as   follows:  
 
Int   get_errord   (void)  
{  
Int   error   =  0;  
Static   int   error_old   =  0;  
Static   int   errord   =  0;  
Static   int   errord_old   =  0;  
Static   int   tic   =  1;  
Static   int   tic_old   =  1;  
 
Int   difference   =  0;  
 
If   (((PINB   &  0x10!!   =  0)   &&   ((PINB   &  0x20!!   =  0))  
Error   =  0;  
 
Else   if   ((PINB   &  0x20)!   =  0)   //   D0   PB5   +1  
Error   =  1;  
 
Else   if   ((PINB   &  0x10)!   =  0)   //   I0   PB4   ­1  
Error   =  ­1;  
 
Else   if   ((PIND   &  0x04)!   =  0)   //   D1   PD2   +3  
Error   =  3;  
 
Else   if   ((PINC   &  0x08)!   =  0)   //   I1   PC3   ­3  
Error   =  ­3;  
 
Else   if   ((PIND   &  0x10)!   =  0)   //   D2   PD4   +5  
Error   =  5;  
 
Else   if   ((PINC   &  0x04)!   =  0)   //   I2   PC2   ­5  
Error   =  ­5;  
 
Else   if   ((PIND   &  0x80)!   =  0)   //   D3   PD7   +7  
Error   =  7;  
 
Else   if   ((PINC   &  0x02)!   =  0)   //   I3   PC1   ­7  
Error   =  ­7;  
 
Else  
{  
If   (error_old   <0)  
Error   =  ­9;  
Else   if   (error_old>   0)  
Error   =  9;  
}  
 
//   Calculation   of   the   average   speed   of   the   error.  
If   (error   ==   error_old)  
{  
Tic   =  tic   +  1;  
If   (tic>   30000)  
Tic   =  30000;  
If   (tic>   tic_old)  
Errord   =  errord_old   /  tic;  
}  
Else  
{  
Difference   =  error   ­  error_old;  
Errord   =  Kd   *  (difference)   /  tic;  / /   mean   error  
Errord_old   =  errord;  
Tic_old   =  tic;  
Tic   =  1;  
}  
 
Error_old   =  error;  
Return   (errord);  
}  
 
It  is  started  by  reading  the  sensors  to  determine  the  position  of  the line, the average error of all 
the  activated  sensors  is  not  read,  since  this  due  to  the  thickness  of  the  line  and  to  the  space 
between  sensors  can  give  rise  to  errors,  that  is  to  say,  it can happen From one error to another 
(distance)  with  for  different  displacement,  which  would  be  an  erroneous  measure  of  speed. 
Reading  the  sensors  one  by  one  from  the  center  was  out  and  considering  that the line is in the 
sensor   that   activated   before   we   avoided   the   previous   problem.  
 
The   calculation   of   the   average   speed   of   change   of   the   error   is   done   here:  
 
//   Calculation   of   the   average   speed   of   the   error.  
If   (error   ==   error_old)  
{  
Tic   =  tic   +  1;  
If   (tic>   30000)  
Tic   =  30000;  
If   (tic>   tic_old)  
Errord   =  errord_old   /  tic;  
}  
Else  
{  
Difference   =  error   ­  error_old;  
Errord   =  Kd   *  (difference)   /  tic;  / /   mean   error  
Errord_old   =  errord;  
Tic_old   =  tic;  
Tic   =  1;  
}  
Error_old   =  error;  
Return   (errord);  
 
The  first  thing  to  say  is  that  we  will  call  this  function  through  an  interrupt  so  tic  ++  represents 
fixed  increments  of  time.  Once  we  have  read  the  error,  the  distance  of  the  line  to  the  sensor 
board,  is  compared  with  the  previous  error,  if  it  is  equal  we  increase  the  time  count  and  the 
function  is  finished.  If  it  is  not  equal  to  the  previous  one  it  compares  of  what  has  been  the 
change,  ie  how  many  sensors  the  line  has  been  displaced,  difference  =  error  ­  error_old;  And 
the speed is calculated errord = Kd * difference / tic, it is like calculating the speed, nothing more 
than  to  space  we  call  error  (distance  of  the  line  to  the  plate of sensors), Kd is a constant that is 
used  to  adjust  the  regulator  And  tic  counts  from  the  last  time  a  change  took  place,  ie how long 
the   line   has   passed   from   one   sensor   to   another.   Calculated   the   error   the   function   returns   it.  
 
When  it  does  not  change  the error this function can return two things, the errord (value returned 
by  the  function)  calculated  when  changing,  and  another minor errord. To do this, when the error 
is  changed  and  the  speed  of  change  is  calculated,  the  time  it  took  to  change (even if implicit in 
the  previous  one)  is  saved,  that  speed  is  fixed  in  the  next  interval  and  the  tics  count  is reset. If 
the  tics  account  exceeds  the  tics  account  of  the  previous  calculation  it  means  that  more  time 
has  passed  and  the  error  has  not  yet  changed,  so  that  the rate of change of the error is started 
as   time   goes   by.  
 
Although  it  may  seem  a  bit  messy  is  to  calculate  space  and  speed,  speed  =  space  /  time, 
nothing  but  space  we  call  it  error.  Knowing  the  speed  we  can  anticipate  the  response  of  the 
robot   and   avoid   oscillations.  
 
An   example,   we   have   the   8  sensors:  
I3   ­7  
I2   ­5  
I1   ­3  
I0   ­1  
D0   1  
D1   3  
D2   5  
D3   7  
 
For  example  we  read  the  sensor D2 and a while later read the sensor D3, which means that the 
line  is  moving  from  left  to  right.  If  we  apply  the  formula   errord  =  Kd  *  (   error  ­  error_old   )  /  tic; 
Wehave  errord  =  Kd  *  (7­5)  /  t,  a  positive errord, if this error is very large it tells the robot to turn 
more  to  the  left  than  at  the  next  instant  of  time  the  line  will  be  higher  from  the  center  ,  So  we 
anticipate   what   is   going   to   happen.  
 
Now  for  example  we  read  D0  and  the  previous  sensor  read  was  D1,  errord  =  Kd  *  (1  ­  3)  /  t, 
gives  a  negative  error  which  indicates  to  the  robor  that  the  line  is  moving to the left, if this error 
is  large  enough  The  robot  will  begin  to  "straighten"  the  direction  before  reaching  the  center  of 
the  sensor  plate  and  passing  us, getting into the area of  the sensors I and beginning to oscillate 
on  the  line,  as  only  happens  with  the  proportional  regulator  when  we  do  not  look  at  the 
derivative   To   anticipate   what   is   going   to   happen.  
 
The   proportional   error   function   is   the   same   as   the   previous   one:  
 
Int   get_errorp   (void)  
{  
Char   errorp   =  0;  
Static   char   ultimo_errorp   =  0;  
Char   counter_sensor   =  0;  
 
If   (((PINB   &  0x10!!   =  0)   &&   ((PINB   &  0x20!!   =  0))  
{  
Errorp   =  0;  
Return   (0);  
}  
 
If   ((PINC   &  0x02)!   =  0)   //   I3   PC1   ­7  
{  
Errorp   =  errorp   ­  0x07;  
Sensor_sensor   ++;  
}  
 
If   ((PINC   &  0x04)!   =  0)   //   I2   PC2   ­5  
{  
Errorp   =  errorp   ­  0x05;  
Sensor_sensor   ++;  
}  
 
If   ((PINC   &  0x08)!   =  0)   //   I1   PC3   ­3  
{  
Errorp   =  errorp   ­  0x03;  
Sensor_sensor   ++;  
}  
 
If   ((PINB   &  0x10)!   =  0)   //   I0   PB4   ­1  
{  
Errorp   =  errorp   ­  0x01;  
Sensor_sensor   ++;  
}  
 
If   ((PINB   &  0x20)!   =  0)   //   D0   PB5   +1  
{  
Errorp   =  errorp   +  0x01;  
Sensor_sensor   ++;  
}  
 
If   ((PIND   &  0x04)!   =  0)   //   D1   PD2   +3  
{  
Errorp   =  errorp   +  0x03;  
Sensor_sensor   ++;  
}  
 
If   ((PIND   &  0x10)!   =  0)   //   D2   PD4   +5  
{  
Errorp   =  errorp   +  0x05;  
Sensor_sensor   ++;  
}  
 
If   ((PIND   &  0x80)!   =  0)   //   D3   PD7   +7  
{  
Errorp   =  errorp   +  0x07;  
Sensor_sensor   ++;  
}  
 
If   (sensor­counter!   =  0)  
{  
Errorp   =  errorp   /  sensor   counter;  
Ultimo_errorp   =  errorp;  
Return   (Kp   *  (int)   errorp);  
}  
Else  
{  
If   (ultimo_errorp   <0)  
Errorp   =  ­0x09;  
Else  
Errorp   =  0x09;  
 
Ultimo_errorp   =  errorp;  
Return   ((int)   errorp   *  Kp);  
}  
}  
 
Returns  the  error  of  the  line  to  the  center  of  the  sensor  plate  that  we  multiply  by  a  constant  to 
adjust   the   regulator.  
 
The  regulator  and  control of the motors we implemented it in the ISR of the timer1, to take place 
with   a  fixed   time,   necessary   to   be   able   to   make   the   derivative   or   average   speed.  
 
ISR   (TIMER1_COMPA_vect)  
{  
PORTD   |  =  (1   <<   LEDP);  
 
Int   errort   =  0;  
Int   proportional   =  get_errorp   ();  
Int   derivative   =  get_errord   ();  
 
Errort   =  proportional   +  derivative;  
 
If   (errort>   speed)  
Errort   =  speed;  
Else   if   (errort   <­   speed)  
Errort   =  ­  speed;  
 
If   (errort>   0)  
{  
M1_forward   (speed   ­  errort);  / /   Right   motor.  
M2_forward   (speed);  / /   Left   motor.  
PORTB   |  =  (1   <<   LEDV);  
PORTD   &  =  ~  (1   <<   LEDR);  
}  
Else   if   (errort   <0)  
{  
M1_forward   (speed);  / /   Right   motor.  
M2_forward   (speed   +  errort);  / /   Left   motor.  
PORTD   |  =  (1   <<   LEDR);  
PORTB   &  =  ~  (1   <<   LEDV);  
}  
 
Else  
{  
M1_forward   (speed);  
M2_forward   (speed);  
PORTB   &  =  ~  (1   <<   LEDV);  
PORTD   &  =  ~  (1   <<   LEDR);  
}  
 
PORTD   &  =  ~  (1   <<   LEDP);  
TIFR1   |  =  (1   <<   OCF1A);  
}  
 
We  start  by  calling  the  previous  functions  which  gives  us  the  proportional  error  and  the  mean 
velocity  of  error  (space  and  velocity), the total error is the sum of the two, the value of the errors 
obtained  by  the  functions  are  already  multiplied  by  two  constants,  Kp  and  Kd,  which  we  use to 
adjust  the  behavior  of  the  error,  increasing  or  decreasing  them  make  each  of  the  errors  have 
more  or less weight in the final result. It may seem a bit confusing but once seen the idea is very 
simple.  
 
Once  we  have the total error we go to adjust the speed of each motor, if this is greater than zero 
we  turn  to  the  left  and  if  not  to  the  right, when the motor of one side goes faster than the one of 
the   other   one   lights   its   led   ,  When   both   go   at   the   same   speed   the   two   leds   turn   off.  
 
At  the  beginning  of  the  ISR  we  turn  on  the  led  of  the  board  and  at  the  end  it  goes off, this way 
we  have  a  quick  way  to  check  the  execution  time  of  the  code  without  having  to  use  an 
oscilloscope,  if  the  led  shines  a  little  about  time  (in this Program almost does not shine) and if it 
shines  a  lot  bad  signal.  This  is  important because we are making divisions and for these micros 
that  can  take  a  lot  of  time,  so  we  have  to  check  that  by  the  time  we  fix  the  code  we  write  has 
time   to   run.  
 
The   complete   robot   controller   program   to   see   it   run   over   the   line   is  h   ere   .  
 
At   the   beginning   of   the   program   we   find   the   following:  
/   ***********   Adjust   robot   behavior   *********   /  
//   Constants   Regulator   PD.  
Int   Kp   =  10;  
Int   Kd   =  65;  
Int   speed   =  100;  / /   Maximum   255.  
/   *************************************************   /  
 
They  are  used  to  adjust  the  behavior  of  the  robot,  for  this  an  average speed is established and 
the  Kp  is  increased  so  that  the  robot  follows  the  line  without  leaving,  once  this  is  done 
increasing  the  Kd  until  the  robot  follows  the  line  without balancing. At this point we increase the 
speed   and   repeat   the   process   from   the   values   of   Kp   and   Kd   we   had.  
 
To  see  the importance of these constants and how really the average speed of the error is worth 
to   anticipate   and   that   the   robot   does   not   oscillate,   a  video:  
 
 
We  start  with  the  value  of  Kd  to  zero,  that  is,  we only have proportional error and we pass from 
the  derivative  and  as  seen  in  the  video  the  robot  does  not  go  from  oscillating.  The  LEDs  that 
indicate that one motor rotates faster than the other only turn on when the line is on the opposite 
side,  making  it  very  difficult  (if  not  impossible)  to  continue  without  oscillating.  Then  we  try  to 
increase  the  Kd  and  give  it  the  value  65  for  the  same  value  of  Kp  and  previous  speed,  and  as 
you  can  see  the  response  of  the  robot  is  very  different,  we  have  stopped  oscillating,  you  can 
also  see  how  they  are  turned  on  and  Off  the  motors  when  the  line  is  on  the  same  side  of  the 
sensor   board,   which   means   that   the   derivative   error   is   greater   and   we   anticipate   what   is   coming.  
 
To  see  more  or  less  the  speed  of  the  robot  I  put  another  video,  the  constants are not adjusted, 
only   tried   two   or   three   values   to   see   what   came   out.  
 
 
The  result  is  good,  in  the  second  cut  that  is  the  one  that  has  the  most  speed  of  the  two,  the 
speed  is in 220 of 255, and I think we already passed the meter per second. The regulator is not 
adjusted,  I  have  put  the  values   that  seemed  to  me 2 or 3 times so that the response can still be 
improved,  it  is  observed  as  the  robot  oscillates  and  stops  a  bit.  I  do  not  know  what  the  track is 
for  calculating  the  speed,  but after the first cut, the robot gives 4 turns in something less than 30 
seconds,   that   is   7.3   s  per   turn.  
 
And   I  compare   with   this   other   video   in   the   same   track:  
 
 
They  are  last  year's  MiniZ  Cosmobot  and  the  fastest  of  the  two  I  count  the  first  4  laps  to  8.2  s 
per  lap,  and  if  I  remember  correctly  last  year  was  fourth  in  the  standings,  I  can  not  remember 
the  speed.For  what  bad  news  for  the  MiniZ  2009,  a  low­cost  and  unadjusted  robot has already 
surpassed   it   =  (  
 
Well  the  basics  to  have  the  robot  running  have  already  been  done,  it is necessary to adjust the 
robot  and  put  the  speed  to  the  maximum  to  see  the  final  result,  which  I  will  do  in  the  next  few 
days  /  weeks  on  a  large,  bumpy  track  ..,  and  that  I  have  measurement  In  addition  to  adjusting 
the  regulator  is  to  make  the  code  for  the  switches  and  implement  the  ADC  to  read  the  battery, 
but  less  important,  the  part  that  would  determine if the robot was worth the meter per second or 
not,  was  to  implement  this  regulator.  The  sensors  are  read  in  digital  and  if  there  is  no  ambient 
light  (although  this  also  charges  the  analog  if  it  saturates  them)  because I think there will be no 
problems,   but   it   would   have   to   be   tested   with   different   illuminations.  
 
The  code  is  only written and seen that it works, I have not reviewed it so it may have some error 
and  it  can  be  improved,  I  have  done  it  according  to  what  I  have  been  thinking  and  it  seems  to 
work   so   I  leave   it   that   way.  
 
In  principle  the  first  result  of  the  robot  seems  quite  good,  so  to  be  the  first  differential  sprinter  I 
make  and  with  the limitations of the chosen pieces because I am happy. The regulator is still set 
but  I  do  not  know  when  I  will  because  I  have  to  devote  time  to other projects. What is shown is 
that  a  low  cost  sprinter  robot to run for a contest and not be left of the last can be done in two or 
three  weekends  and  is  not so difficult, this has been my first differential sprinter so I have had to 
think   almost   everything   from   scratch,   and   I  have   spent   more   time   writing   than   doing   ...  
 
For   any   doubt   about   everything   this,   idea,   etc   ...:  f orum   .  
 
 
++++++ 
 
 
 

Final   Robot.  
After  a  few  months  without  finishing  the  robot  of  initiation  ..  I  leave  here  what  from  my  point  of 
view  are  the  best  components  available  to  realize  a  robot  sprinter,  without  spending  a  fortune 
and   obtaining   an   acceptable   result.  
 
Control   board   (one   of   two   options).  
● Baby   Orangutan.   $  19.95 
● Baby   Orangutan   +  Programmer.   $  28.95 
Sensor   board   (one   of   two   options)   .  
● Resistance   plate.   $  14.95   Recommended   to   get   started. 
● Condenser   plate.   $  14.95 
Engines   (one   of   two   options)   .  
● 10:   1  Micro   Metal   Gearmotor.   $  15.95 
● 10:   1  Micro   Metal   Gearmotor   HP.   $  15.95 
Other   components   .  
● Wheel.   $  6.98 
● Crazy   wheel.   $  2.99 
● Motor   support.   $  4.99 
● Converters   dc   /  dc.   $  11.95 
● Battery.   9.90   €  (+   tax) 
● Charger.   13.60   €  (+   tax) 
Total   price:   $  87.66   approximately.   Price   with   charger   and   programmer:   $  111   approximately.  
 
Adding  the  $  11  shipping  pololu,  and  having  to  buy  a  printed  circuit  board  or  tops,  plus  the 
material  to  make  the  base  (pvc  expanded  3mm)  the  cost  of  the  robot  with  the  charger  and 
programmer   as   it   stays   approximately   at   100   €,   According   to   the   change.  
 
If  we  do  not  have  a  programmer  for  the  Baby  Orangutan  the  clear  choice  is  to  buy  it  with  the 
plate,  we  will  not  find  anything  cheaper  and  also  will  serve  us  to  program  micros.  When 
choosing  the  engines  there  are  two  possibilities,  some  that  consume  more  current  (HP)  and 
others  that  consume  less.  The  electronics  is  dimensioned  for  the  motor  of  less  consumption 
since an dc­dc converter is going to be used that limits the input intensity to 2 A, reason why this 
one  will  cut  the  power  if  we  use  the  motors  of  more  current  and  we  try  to  put  them  to  the 
maximum  .  But  to  the  maximum  we  are  not  going  to  put  them  since  the  speed  would  be  very 
high,  reason  why  you  can have cycles of work of the pwm with enough speed without that dc­dc 
comes   to   cut,   I  think   that   from   200/255   the   Dc­dc   said   enough.  
 
So  far  nothing  has  been  burned  in  the  electronics  using  the  HP  motors  (they  already  have 
several  hours  of  operation)  and  the  result  is  a  little  better  than  with  the  less  intense  motors, 
although  if  we  do  not  want  to  risk  to  burn  anything  (I  have  not  looked  at  the  Datasheet  of  the 
integrated  dc­dc  so  I  do  not  know  if  it  cuts  or  does)  the  choice  is  the  motor  of  less  intensity, 
although  I  would  say  the  other  is  the  first  choice  if  we  are  going to go to a contest and we want 
to   get   the   best   result   possible.  
 
The  difference  with  the  first version of the Robot Zero is that the battery has been changed from 
7.4V  to  a 3.7V. A voltage converter has been added that raises the voltage of the 3.xV battery to 
a  fixed  output  voltage,  by  means  of  a  dc­dc  potentiometer  we  select  the  output  voltage  up  to 
9.5V,  this  is  used  first  to  carry  a  battery  that  Weighs  and  takes  up  less  and  second  to  set  the 
supply  voltage  of  the  motors  regardless  of  the  state  of  the  battery,  which  will  help  us  to  adjust 
the  necessary  constants  in  the  program  to  control  the  robot.  The  battery has protection against 
overload  and  discharge,  so  when  the  robot  is  spent,  we  do  not  run  the  risk  of  discharging  the 
lipo   more   than   allowed.  
 
The  sensor  board  if  we  choose  the  resistance  we can read in a simple way in a digital way, that 
for  a  robot  initiation  from  my  point  of  view  is the most accurate. With the capacitor plate we can 
not  read  it  in  such  a  simple  way,  but  we  can  get  better  results  at  the  cost  of  complicating  the 
code.  I  have  not  tested  it  experimentally  and  I have to try and program to get out of doubt using 
both   plates,   but   each   reading,   digital   and   analog,   has   its   advantages   over   the   other.  
 
To  join  all  the previous components we can do it by creating a base where to place them more a 
printed  circuit  /  plate  of  topos  to  join  the  part  of  the  electronics.  Or  directly  use  a  printed  circuit 
board   as   a  base   to   reduce   weight.  
 
Some  ideas  of  how  to  unite  everything  and  design  the robot, click on the images for bigger size 
and   to   see   components.  
 

  
 

  
 
To  achieve  a  good  basic  design  is  fundamental,  we  can  choose  to  make a robot of a maximum 
of  20  cm  in  width  and  30  cm in length, 2 kg in weight. The longer you are, the more you will see 
the  curve,  but  the  farther  the  center  of  inertia  is  from  the  midpoint  of  the  axis  connecting  the 
motors (which is the ideal point for all centers). The larger the robot is, the greater the torque the 
wheel  makes,  ie  more  inertia  we  can  counteract  without  skidding,  but  the  greater  the  turning 
time  and  the  more  chance  we  have  of  touching  the  red  line.  Being  heavier  we  increase  our 
normal  but  greater  will  be  the  force  that  throws  us  out  in  the  curve,  and  increase  the  inertias 
enormously   if   the   mass   is   poorly   distributed.  
 
Everything  consists  of  finding  a  robot  base  balance  for  the  selected  engines  and  the  friction 
force  that  we  are  going  to  find,  and  this  is  not  an  easy  thing,  at  least  for  me  I  know  little  about 
mechanics.  For  a  lot  of  electronics  that  we  put,  a  lot  of  programming  that  we are going to do, if 
the   base   is   badly   designed,   it   will   not   work.  

 
Looking   for   a  good   design   is   essential.   CAD   by   Raúl.  
 
I  compile  the  results  of  the  previous  robots,  the  code  is  the  same  in  all  and  has  not  yet  been 
worked  on,  it  is  a  basic  code  to  follow  the  line  at  constant  speed.  All  have  a  sensor  board with 
resistance  in  the  collector  of  the  phototransistor,  and  the  reading  is  done  in  digital.  It  is  not 
necessary  to  program  the  switches  to  select  different  options,  the  example  can  be  taken  from 
previous   entries.  
 
White   Robot.  
Photolite   pcb   without   dc­dc   .  The   last   version   takes   the   dc­dc   but   in   a  format   I  forgot   to   save   the 
file.  
Code   .  Dc­dc   8.5   V.   Motor   10:   1  low   intensity.  
 
Video   working.  
 
 
Long   pcb   robot.   PCB   0.4   mm.  
Photolith.  
Code.   HP   10:   1  high   intensity   motor.   Resistance   sensor   board   made   with   CNY70.   Dc­dc   6.4   V.  
 
Video   operation.  
 
 
Red   Robot.  
Photolith   .  
Code.   HP   10:   1  high   intensity   motor.   Dc­dc   6.2   V.  
 
Video   of   operation.   Robot   still   unadjusted.  
 
 
Robot   pcb   short.   PCB   0.4   mm.  
Photolith.  
Code.   10:   1  low   intensity   motor.   Dc­dc   8.5   V.  
 
Video   operation.  
 
Well  with  these  ideas  I  end  up with the initiation robot, they are robots with which you can reach 
150  cm  / s and work to overcome them. We will not be in the top positions but neither in the last, 
so  it  is  valid  as  a  first  robot.  To  say  that  this  does  not pretend to be an exact or correct guide of 
how  to  make  a  robot  sprinter,  since  I  do  not  have  enough  knowledge  to  cover  many  of  the 
questions  that  arise  in  its  development.  The  only  intention  has  been  to  fill  a  little  the  huge 
information  gap  on  the  subject  on  the  internet,  from  a  basic  point  of  view  and  from  my  short 
experience   going   to   contests.  
 
The  code  is  quite  improved,  not  very  tested  and  has  not  been modified since it was made, so it 
may  have  bugs  but  in  general  it  seems  sufficient  for  a first robot reading the sensors in digital. I 
commented  in  the   CIrE  (   electronic  club  that  we  have  set  up  with  weekly  meetings)  that  there 
were  people  who  wore  this  code  of Robot Zero in the past Co $ moBot (annual sprinter contest, 
reference  for  high  prizes),  but  I do not know that such I worked because they have not bothered 
to   leave   a  message   telling   me   the   result,   in   short,   great   online   community   that   we   have   !.  
 
Spending  the  2  m  /  s as do the robots that occupy the first positions is complicated and requires 
a  lot  of  work.  Although  you  always  see  the  typical  internet  forums  that  loose  that passes the "2 
m  /  s more" while demonstrating their little knowledge of the subject, or case, spend 2 m / s on a 
medium  circuit  in  difficulty,  has  Been  quite  complicated,  and  only  a  few  have  done  in  the 
competitions  in  Spain,  and  generally  it  is  people  who  have  been  participating  for  years  and 
years.  And  of  course  they  do  not  bother  to  upload  things  to  the  internet  so  that  the  rest  of  the 
beginners  can  learn  and  do  not  have  to  start  from  Zero,  very  logical  point of view, the best way 
forward  and  evolve  that  a  community  has  is  not  Share  individual progress XD. And today if you 
do   not   share   on   the   internet,   you   do   not   share.  
 
Unfortunately  robotics  in  Spain  has  very  little  interest,  so  to  start  the  best  is  to  find  a  group  of 
friends  with  whom  to  make  the  first  robots  and  exchange  ideas.  From  the  internet  little  can  be 
drawn,  there  is  no decent online community about amateur robotics, with knowledgeable people 
interested  in  sharing  and  working,  and  you  know  that  in  this electronics everything that  smokes 
bad   is;).  
 
For   any   doubt   about   everything   this,   idea,   etc   ...:  f orum   .  
 
Thanks   for   reading,   see   you   at   the   Co   $  moBot   (if   you   let   me   enter   XD).  
 
 
 
==================== 
 

 
● HOME 
● ROBOTICS   COMPETITION   IN   SPAIN 
● RELATED   LINKS 
● ABOUT   CIRE 

Robot   Zero.   Sprinter   for   beginners. 
December   2nd,   2010  3
  9   Comments 
 

If  you have seen a robotics contest and you want to participate, or you are interested in building a 
robot  follower  of  line  maybe  this  project  can  help  you.  Detailed  construction  of  a  basic, 
easy­to­do,  low­cost  sprinter  robot  to  get  started  on  this  test. Although everything is already said 
in  t he  p
  roject  R
  obot  Z
  ero  ,  I  m
  ake  a
   s  mall  s  ummary  h
  ere  w
  ith  t he  f inal  v  ersion. 

One  of  the  projects  that  we  have  in  common  several  people  in  the  CIrE  is  the  development  of 
sprinter  robots,  so  we  have  been  talking  about  the  subject  for  months  and  discussing  ideas. 
Trying  to  synthesize  part  of  the  ideas  I  upload  here  my  final  version  with  which  I  close the robot 
project  of initiation, unless I have mistaken in some pin of the pcb or similar I leave here the world 
of  t he  s  printers. 

I  am  not  an  expert  on  the  subject and I have only gone to a couple of contests, in the absence of 


available  information I hope that someone who wants to go to a contest and knows even less that 
I  the  subject  can  help.  I  do  not  guarantee  the  operation  of  anything,  I  only  put  what  has  worked 
for  m
  e,  s  o  i f  s  omeone  r  ides  i t  t o  d
  o  i t  a
  t  t heir  d
  iscretion. 

One  option  is  to  buy  the  entire  sprinter  directly,  on  the internet you can find some sprinter robots 
to  buy.  I  do  not  recommend  it  as  it  loses all the grace of the matter, they give us everything done 
and  most  of  the  program,  so  all  you  have  to  do  is  hit  the  button.  And  I  suppose  that  in  the 
contests  they  will  not  admit  their  participation,  since  the  merit  of the one that takes it is minimum 
and  t herefore  l ittle  w
  orthy  o
  f  b
  eing  r  ewarded. 

The  first  thing  to  set  up a robot is to choose the components and it is where everyone who wants 


to  make  their  first  robot  finds  the  first  difficulty,  which  motor  to  choose,  what  sensors,  etc.  The 
best  I  have  found  are  the  components  of   Pololu  ,  For  a  very  reasonable  price  we  find  all  the 
necessary  components  to  build  a  robot  that does not do badly in the contests, we will not win but 
the  same  we  can  pass  the  first  qualifying,  which  would  be  a  satisfactory  result  for  many 
beginners. 

My  c  hoice  o
  f  c  omponents  i s  a
  s  f ollows: 

● Control  b
  oard  p   lus  p  rogrammer  $    3
  1.95. 
● Sensor  b  oard  $    1
  4.95. 
● Wheels  $    6  .98. 
● Crazy  W
  heel  $    2
  .99. 
● Support  e   ngines  $    4
  .99. 
● DC­DC  $    1  1.95. 
● Battery  $
   1  1.95. 
● Charger  $    1  6.95. 
● HP  M
  otor  $    3
  1.90  (  option  A   ). 
● Motor  $
   3
  1.90  (  option  B   ). 

We  can  choose  two  engines  for  the  project,  if  your  goal  is  to  make a first robot and you conform 
to  which  functions  I  recommend  option  B,  if  your  goal  is  to  try  to  go  as  fast  as  possible  I 
recommend  option  A.  The  problem  of  option  A  is  that  Are  motors  that  consume  a lot of intensity 
and  there  is  the  possibility  of  burning the DC­DC, it is very unlikely to burn it, but the possibility is 
there,  for  my  taste  are  the  best  engines  we  can  buy  for  that  price.  With  the  selected  wheel  and 
option  B
  ,  s  peeds  c  an  b
  e  r  eached  o
  ver  2
   m
   /  s  ,  w
  hile  w
  ith  o
  ption  A
   w
  e  c  an  r  each  4
   m
   /  s  . 

In  total  for  about  $  122.66  we  have  all  the  necessary  components  for  the  sprinter,  which  would 
have  to  add  about  $  10­15  in  components  to  unite  everything.  Let's  put  the  whole  project  on 
about  €  100­110  to  change  in  material. The components are in two stores and the shipping costs 
of  each  are  between  $  10  and  $  15  by  regular  mail  and  usually  take  7­12  days,  I  have  placed 
orders  m
  any  t imes  a
  nd  a
  lways  a
  rrive  a
  nd  d
  o  n
  ot  u
  sually  f all  i nto  c  ustoms. 
Still  if  we  want  to  buy  everything  in  a  single  order  at  http://www.robotshop.com/eu we find all the 
components,  although  it  is  more  expensive  since  as  every  store you make the change $ 1 = € 1, 
so  m
  ost  O
  f  t he  t imes  i t  i s  b
  etter  t o  b
  uy  d
  irectly  a
  t  $
  $. 

To  join  all  the components we have two options: use a pcb that serves as the base of the robot to 


connect  everything,  or  use a pcb / tops plate to put in a base that we make. I put photo of the two 
options: 

The  best  option  of  both  for  our  objectives  is  to  build  a  base  on  which  to  put  the  pcb, since it will 
allow  us  to  have  a  versatile  robot  to  which  we  can  put  different  bases  with  different  length  and 
width,  which  will  allow  us  to  test  and  Experiment  with  different  configurations  and  adapt  to  the 
circuits  that  give  us  in  the  contests.  For  example  in  a  circuit  with  curves  with  a  large  radius  and 
long  straight  lines  we  may  be  interested  in  carrying  a  longer  and  wider  base,  while  if  we  give  a 
circuit  with  many  small curves and little straight can be a small base option better. In addition, the 
dimensions  of the robot depend on the inertias and the frictional force of the robot that adheres to 
the  g
  round,  s  o  t hat  o
  ften  t he  o
  nly  w
  ay  t o  f ind  t he  o
  ptimal  d
  imensions  i s  t o  t ry  d
  ifferent  b
  ases. 

If  we  mount  the  whole  robot  in  a  pcb  because  we can not change its dimensions, the robots that 
sell  facts  come mounted on a pcb since it is easier to integrate everything and I guess cheaper to 
manufacture,  weight  saving  is  minimal  since  the  base  In  plastic  weighs  about  the  same  as  the 
pcb.  S
  o  f or  a
   f irst  r  obot  t o  l earn  a
  nd  e
  xperience  t he  b
  est  i s  t o  h
  ave  i nterchangeable  b
  ases. 

The  f inal  i dea  i s  t o  h
  ave  s  omething  l ike  t his,  a
   r  obot  t o  m
  ount  o
  n  d
  ifferent  b
  ases. 

So  the  first  thing  could  be  to  start  building  the  base,  for this we make a template by hand or with 
the  pc  that  we  paste  on  a  piece  of  expanded  PVC  or  forex  of  3mm,  with  a  punch  we  mark  the 
holes  of  the  engines  (they  have  to  Go  in  the  template  as  they  must  be  well  aligned)  and  with  a 
blade  cut  and  mark  the PVC in the template, then cut and do the rest of drill holes, the PVC 3mm 
expanded  c  an  b
  e  c  ut  a
  nd  w
  orked  b
  y  h
  and. 

Attached  is  a  pair  of  sample  base  templates  (the  dimensions  of  the  robots  in  the  maximum 
contests  a
  re  3
  0  c  m  l ong  a
  nd  2
  0  c  m  w
  ide)  a
  nd  a
   p
  hoto  o
  f  t he  p
  rocess  t o  m
  ake  t he  b
  ase. 

Base  1
   .  

Base  2
  . 

The  d
  imensions  o
  f  t he  b
  ase  f or  m
  y  t aste  a
  re  n
  ot  i deal,  b
  ut  t hey  a
  re  t he  o
  nes  I  h
  ave  t ried. 

 
The  other  part  that  we  need  to  join  the  components  is  to  make  a  pcb  or  use a plate of moles as 
explained  Guillermo  in the  previous entry. In addition this plate will serve to double­sided tape the 
chosen  b
  attery,  s  o  t hat  i t  i s  b
  elow  t he  r  obot,  w
  hich  p
  rovides  a
   c  enter  o
  f  g
  ravity  a
  s  l ow  a
  s  p
  ossible. 

The  e
  lectronics  b
  oard  c  an  b
  e  s  een  h
  ere  (  click  f or  m
  ore  d
  etail): 

The  f eatures  w
  ith  t he  a
  ssembled  c  omponents  w
  ould  b
  e  t he  f ollowing: 

● 8  d
  igital  i nputs  o   r  6
   a
  nalog  s  ensors  i n  t he  c  entral  s  ensors  (  I  d   id  n   ot  w
  ant  t o  u
  nsolder 
the  p  otentiometer  o   f  t he  A
  DC  t o  p   ut  t he  8
  ). 
● Pin  t o  t urn  t he  s  ensors  o   n  a
  nd  o  ff  a  nd  t hus  a   djust  t he  l evel  o   f  l ight  t hey  e
  mit. 
● Two  L   EDs. 
● A  p
  ushbutton  t o  o   utput,  c  alibrate  R   C  s  ensors,  e   tc. 
● Two  s  witches  t o  s  elect  d   ifferent  s  trategies  i n  t he  c  ontest,  f undamental  t o  c  hange  t he 
speed  a   gainst  a  n  o   pponent,  o   r  r  isk  m
  ore  i f  w
  e  l ost  t he  f irst  r  ound. 
● A  d  c­dc  p  rovides  u   s  w
  ith  a
   f ixed  r  eference  v  oltage  f or  t he  m   otor  s  peed,  s  o  i t  f acilitates 
the  c  ontrol  a  lgorithm. 
● A  c  onnector  w   ith  5
  V  o
  utput  a   nd  T
  X  a  nd  R
  X  p
  ins  f rom  t he  U  SART  o   f  t he 
microcontroller,  t o  c  onnect  a    c  ommunications  m   odule  i f  w
  e  w  ant  t o  s  end  d   ata  f rom  t he 
robot  t o  t he  P
  C. 
● Battery  l ife:  2  8  m
  inutes  (  duty  c  ycle  1   60/255,  V   med  =    2
  15  c  m  /  s   i n  t est  c  ircuit). 

If  we use high­current motors DC­DC we can burn it if we do not put the electrolytic capacitor that 
is  at  the  height  of  the  regulator,  or  if  we  put  a  small  value.  Although  it  is  the  typical  mounting 
capacitor  of  any  dissipative  regulator  it  is  providing  the necessary peak of intensity to the motors 
when  i ts  f cem  i s  l ow. 

I  carry  it with a value of 22 uF and is enough for the engines to go at high speeds. I did the test to 
remove  the  capacitor  to  see  if  the  dc­dc  cut  at  a  higher  intensity  than  it  can  give  (I  do  not  know 
which  integrated  leads)  and  it  ends  up  burning,  since  HP  motors  can  have  peaks  of  up  to  1.6 A 
per  motor  And  the  DC­DC  only  supports  2A  input. Putting this capacitor (once seen could be put 
closer  to  dc­dc  or  duplicate)  we  should  not  have problems burning the dc­dc for a good speed of 
the  robot.  With  the  low  intensity  motors  there  is  no  problem  since  they  only  consume  0.36A 
maximum  a
  t  6
  V. 

To  connect  the  control  board  and  dc­dc  we  put  a  strip  of  female pins, where we insert them, this 
way  we  can  remove  the  plate  for  use  in  other  projects  and  dc­dc  to  adjust  the  output  voltage  to 
different  values   according  to  Engines  to  use.  If  we  use  the  high  intensity  motors we will put it on 
5.5­6.5  V
   a
  nd  i f  w
  e  u
  se  t he  l ow  o
  nes  w
  e  c  an  p
  ut  i t  t o  9
  V  t o  g
  et  m
  ore  t orque  a
  nd  s  peed  f rom  t hem. 

The  battery  connectors,  pin  strip  shown  in  the  picture,  buttons  and  so on can also be purchased 
in   Pololu  (the  higher  the  order  the  greater  the  possibility  of  customs),  although  in  any  physical 
store  e
  lectronics  c  an  f ind  t he  c  omponents  t o  A
   r  easonable  p
  rice. 

The  scheme  to  unite  the  whole  electronics  part  (click  on the image for more detail), if all the pins 
are  w
  ell  a
  ssigned  (  I  h
  ave  n
  ot  c  onfused  i n  a
  ny  s  ince  I  h
  ave  n
  ot  r  eviewed)  s  o  i t  w
  ould  s  tay. 
C1  and  C2  are the electrolytic capacitors of 22 microFaradios, R1 R2 and R4 470 Ohms, R10 R7 
and  R8  330  Ohms,  R3  R5  and  R6  15K,  a  dissipative  5V  regulator  looking  at  its  drop,  if  we take 
out  of dc­dc 9V we could put a 7805, but taking out only 6V so better put one with a lower voltage 
drop  a
  s  a
   L
  F50ABP,  L
  4941BV,  i e  a
  ny  l do.  T
  he  S
  MD  1
  206  c  omponents. 

The  c  omponents  m
  ounted  o
  n  t he  p
  cb  a
  nd  t he  p
  hotolite  .  

 
 
 

We  mount  the  pcb  and  put  it  in  the base of the robot, to connect the motors you can put a pair of 


connectors  or  solder  the  cables  directly.  The  next  thing  is  to attach the battery with double­sided 
tape  t o  t he  p
  cb  a
  nd  m
  ake  a
   h
  ole  t o  p
  ass  t he  c  able. 
 
 

We put the crazy wheel, we can use some screws to fix or glue directly, even if this means having 
to  use  one  per  base.  Finally  we  place  the  sensor  board  making the corresponding holes to pass 
the  s  crews,  a
  nd  w
  e  m
  ake  t he  c  ables  t o  j oin  t he  s  ensors  w
  ith  t he  e
  lectronics  b
  oard. 

Regarding  the  sensor  board  that  we  bought,  we  must  change  or  remove  some  resistors,  as  we 
carry  t hem  v  ery  c  lose  t o  t he  g
  round  a
  nd  t hey  a
  re  d
  esigned  f or  a
   g
  reater  d
  istance. 
 

In  the  image  above  you  can  see  how  a  resistance  of  100  Ohms  (101)  has  been  soldered  and 
desoldering  two  resistors,  these  two  resistors  in  parallel  come  to  limit  the  current  of  the  diodes, 
we  can  remove  one  or  remove  the  two  and solder one where it appears In the iamgen of greater 
value.  Although  I  have  not  tested  many  values   a  resistance  of  about 82 ohms could work well, it 
depends,  since  some  Pololu  plates  give us with resistors of 43 Ohms and others with resistors of 
66  Ohms  in  the  diodes.  Another  thing  we  have  been  able  to  verify  is  that  these  sensors  are 
terrible  to  make  readings in analog, since their orientation (inclination) greatly affects the reading, 
so  if  the  robot  vibrates  or  oscillates,  or  the  track  is  not  totally  smooth  we  can  find  Problems, but 
well  this  looks  good  when  we  develop  the  part  of  the  teletría  in the CIrE, which I suppose will be 
the  f ollowing. 

So  e
  verything  m
  ounted  i s  s  omething  l ike  t his: 
 
 
 

This  would  be  the  part  of  the  base  and  now  missing  the  part  of  the  programming,  I  attached  a 
simple  program  for  these  robots  that  follows  the  line  without  oscillating  at a constant speed. The 
program  has  not  been  given  time,  is  the  first  to  do  and  has  been  going  from  robot  to  robot 
because  it  seemed  to  work,  so  it  may  have  failures  somewhere.  The  idea  is  very  simple,  to 
measure  the  distance  of  the  line  to  the  center  of  the  sensors,  to  measure  the  speed  with  which 
the  line  moves  away  or  to  the  center  of  the  sensors,  to  multiply  these  means  by  means  of 
constants  that  we  use  to  adjust  the  response  of  the  Robot,  add  them  and  convert  the  amount 
obtained  i n  a
   s  peed  d
  ifference  b
  etween  t he  e
  ngines,  w
  hich  c  auses  t he  s  pin. 

Program  .  
I  put  a  couple of videos in which you can see the operation of the program, the second of them in 
slow  motion  (from  the  second  30).  The  robot  is  mounted  on  the  longest  base  and  the  dc­dc 
output  v  oltage  i s  6
  .4  V
  . 

Slow  m
  otion  (  second  3
  0). 

The  robot makes an average speed of 210 cm / s in the videos. I think in the last contest a couple 
of  months  ago  the  winning  robot  was  at  an  average  speed  of  260  cm  /  s,  although  it  can not be 
compared  because  the  speeds  depend  on  each  track,  I  think  that  with  this  speed  we  can  pass 
the  qualifying  round  and  reach  The  robot  versus  robot  races.  We  are  not  going  to  win  since  we 
can  find robots in which only one of its engines is worth more than all our robot together, and also 
they  are  very  tested  and developed since its creators have been going for a long time going to all 
the  c  ontests  t hat  t hey  c  an. 

This  is  my  idea  of   a  robot  that  has  tried  to  do  and  explain  the  basics:  component  selection, 
hardware  a
  nd  s  imple  p
  rogram  t o  f ollow  t he  l ine,  m
  ore  i nformation  o
  n  d
  evelopment  h
  ere  .  

It  still  remains  to  do  all  the  programming  that  is  complex  and  where  times  are  improved  and 
results  are  obtained.  The  ideas  to  apply  and  strategies  are  many,  I  will  not  put  with  it  since  I  do 
not  intend  to  go  through  any  contest,  in  the  current  situation  is  not  worth  it  and  there  are  other 
projects  t o  d
  evote  t ime  i n  t he  C
  IrE  w
  e  w
  ant  t o  g
  o  d
  oing. 

To  the  people  that  arrive  in  this  world  for  the  first  time  only  to  recommend  that  it   shares  its 
advances  ,  is  the  unique  form  to  learn  and  to  make  this  hobby  accessible  and  each  time  the 
competitions  go  to  more.  Trying  to  be  competitive  in  the  current  situation  is  totally  absurd,  there 
are  not  enough  people  for  it,  nothing  is  worth  winning  a  contest  that  after  a  few  months  no  one 
remembers.  In  the  end I do not start that I do not stop XD, maybe one day we leave a community 
of  B
  obótica  a
  nd  w
  e  h
  ave  a
   R
  obotics,  b
  ut  f or  t hat  w
  e  h
  ave  t o  d
  o  m
  ore  t han  c  ollect  p
  ress  c  lippings. 

I  hope  this  attempt  to  make  and  explain  a  basic  robot  is  useful  for someone, that a few versions 
of  t est  a
  nd  p
  rototypes  h
  as  t aken  m
  e  . . 
 

Hits:  1
  29830 

Author:  J  MN 

Posted   in  R
  obotics   | 

«  C
  onstruction   of   a  sprinter   robot 

How   to   design   a  home   plate?   » 

Both   comments   and   pings   are   currently   closed. 

39   Responses   to   "Robot   Zero.  S
  printer   for   beginners.   " 
1.   O
  scar  s
  ays: 
2. December   2,   2010   at   23:51 
3. Only  with  what  you  have  spent  in  robots  to  prove  which  was  better  and  the  documentation  that  you 
have  generated  already  for  me  you  are  a  reference  to  follow  in  the  world  of  national and international 
robotics. 
4. BRAVO 

5.  R
  aul  s
  ays: 
6. December   3,   2010   at   03:24   AM 
7. Thanks,  you  do  not  really  know  the  sensations  that  cause  you  to  read  a  unique  article  for  robotics 
enthusiasts.  I  am  convinced  that  readers  will  not  get  caught  just  with  the  idea  of   a  low  cost  modular 
robot   that   exceeds   the   2  m  /  s  barrier. 
8. Think   about   how   to   transport   them. 

9.  _
  Silent  s
  ays: 
10. December   3,   2010   at   07:49   AM 
11. Balls 
12. Congratulations   jota,   a  great   job   that   finally   paid   off. 

13.  G
  uillermo  s
  ays: 
14. December   3,   2010   at   08:16   AM 
15. It's  great,  it  has  much  merit  to  expose  as  clearly  and  accurately  as  constructing  a  robot  that until now 
would   not   have   been   the   most   pointers. 
16. Also  along  with  the software, the system to consider the components on the one hand and on the other 
the  chassis  offers  the  possibility  that  whoever  uses  this  design  to  start  can  experiment  with  new 
configurations   and   see   how   far   you   can   get   with   this   hardware. 

17.  J
  orge  s
  ays: 
18. December   4,   2010   at   08:40 
19. Thanks   for   the   comments,   if   anyone   else   wants   a  pcb   tell   me. 

20.  P
  elayator  s
  ays: 
21. December   9,   2010   at   14:50 
22. Thank   you   for   your   generosity!  
23. I   can   not   imagine   the   effort   that   has   brought   you   all   this.  
24. It  is  nice  to  meet  people  who  share  knowledge  and  so  predisposed  to  lend  a  hand  so  that  those who 
started   with   this   healthy   robotic   habit   we   took   our   first   steps.   The   said   male,   you   are   a  reference.  
25. Pelayo 
26. Cosmobot   |  V
  iew   Profile 
27. December   23,   2010   at   08:20 
28. [...]  participate,  you  can  think  of  doing  something  like  the  Robot  Zero  that  we  have  done  in  the  CIrE: 
link,   we   have   not   taken   it   to   any   contest   but   could   pass   the   first   qualifier   if   it   does   not   rise   [...] 

29.  A
  ndi  s
  ays: 
30. January   15,   2011   at   07:24 
31. Hey  first  of  all  this  is  the  fastest  and  easiest  line  follower  so  thank  you  very  much.But  can you tell me 
what  modifications  should  be  done  so  that  robot  will  be  able  to  follow  white  line  on  black  surface? 
Thanks   in   advance. 

●  J
  orge  s
  ays: 
● January   15,   2011   at   08:50 
● Hello,   thx   for   the   comment. 
● Use   the   ==   operator   instead   of!   =  To   read   the   sensors. 
● Change   the   following   lines: 
● In   the   function   get_errorp   (void): 
● If   (((PINC   &  0x04)   ==   0)   &&   ((PINC   &  0x08)   ==   0))  
● {  
● Errorp   =  0;  
● Return   (0);  
● } 
● If   ((PIND   &  0x10)   ==   0)   //   I3   PD4   ­7  
● {  
● Errorp   =  errorp   ­  0x07;  
● Sensor_sensor   ++;  
● } 
● If   ((PINC   &  0x01)   ==   0)   //   I2   PC0   ­5  
● {  
● Errorp   =  errorp   ­  0x05;  
● Sensor_sensor   ++;  
● } 
● If   ((PINC   &  0x02)   ==   0)   //   I1   PC1   ­3  
● {  
● Errorp   =  errorp   ­  0x03;  
● Sensor_sensor   ++;  
● } 
● If   ((PINC   &  0x04)   ==   0)   //   I0   PC2   ­1  
● {  
● Errorp   =  errorp   ­  0x01;  
● Sensor_sensor   ++;  
● } 
● If   ((PINC   &  0x08)   ==   0)   //   D0   PC3   +1  
● {  
● Errorp   =  errorp   +  0x01;  
● Sensor_sensor   ++;  
● } 
● If   ((PINC   &  0x10)   ==   0)   //   D1   PC4   +3  
● {  
● Errorp   =  errorp   +  0x03;  
● Sensor_sensor   ++;  
● } 
● If   ((PINC   &  0x20)   ==   0)   //   D2   PC5   +5  
● {  
● Errorp   =  errorp   +  0x05;  
● Sensor_sensor   ++;  
● } 
● If   ((PIND   &  0x80)   ==   0)   //   D3   PD7   +7  
● {  
● Errorp   =  errorp   +  0x07;  
● Sensor_sensor   ++;  
● } 
● In   the   function   Get   _errord   (void): 
● If   (((PINC   &  0x04)   ==   0)   &&   ((PINC   &  0x08)   ==   0))  
● Error   =  0; 
● Else   if   ((PINC   &  0x08)   ==   0)   //   D0   PC3   +1  
● Error   =  1; 
● Else   if   ((PINC   &  0x04)   ==   0)   //   I0   PC2   ­1  
● Error   =  ­1; 
● Else   if   ((PINC   &  0x10)   ==   0)   //   D1   PC4   +3  
● Error   =  3; 
● Else   if   ((PINC   &  0x02)   ==   0)   //   I1   PC1   ­3  
● Error   =  ­3; 
● Else   if   ((PINC   &  0x20)   ==   0)   //   D2   PC5   +5  
● Error   =  5; 
● Else   if   ((PINC   &  0x01)   ==   0)   //   I2   PC0   ­5  
● Error   =  ­5; 
● Else   if   ((PIND   &  0x80)   ==   0)   //   D3   PD7   +7  
● Error   =  7; 
● Else   if   ((PIND   &  0x10)   ==   0)   //   I3   PD4   ­7  
● Error   =  ­7; 

32.  J
  orge  s
  ays: 
33. January   29,   2011   at   22:41 
34. Possible   error   in   the   code,   in   get_errord   () 
35. //   Calculation   of   the   average   speed   of   the   error.  
36. If   (error   ==   error_old)  
37. {  
38. Tic   =  tic   +  1;  
39. If   (tic>   30000)  
40. Tic   =  30000;  
41. If   (tic>   tic_old)  
42. Errord   =  (errord_old   *  tic_old)   /  tic;   //   failed   to   multiply   *  tic_old 
43. It   seems   to   work   better   with   the   error   ... 

44.  I  srael  s


  ays: 
45. February   14,   2011   at   16:02 
46. Hello, 
47. I   bought   the   same   regulator   you   mention   from   Pololu   and   when   I  tried   it   today   I  loaded   it   ... 
48. I  tried  it  with  a  source  of  3.3v  and  it  is  seen  that  I  have  surpassed  the  output  range  because  when 
turning   the   potentiometer   and   only   takes   me   through   the   exit   the   same   as   in   the   input   ... 
49. The  fact  is  that  to  ask  again  Pololu  me  out  for  a  pasta  and  over  time  I'm  on  ...  do  you  know  a  cheap 
alternative   or   a  shop   in   Madrid   where   I  could   get   it? 
50. Thank   you   very   much   for   the   help. 

●  J
  M  s
  ays: 
● February   14,   2011   at   16:21 
● Hi,   what   have   you   done   to   load   it? 
● The   only   way   to   break   it   is   by   shorting   its   output   or   by   asking   for   more   current   than   it   can 
give,   in   the   robot   zero   is   put   a  capacitor   to   withstand   the   peaks   of   the   motors. 
● If   you   did   not   have   a  load,   ie   the   regulator   did   not   feed   anything,   it   will   be   fine. 
● To   adjust   the   output   you   must   do   this   by   connecting   a  resistance   between   its   output 
and   ground   of   1  K  I  think   ,  specify   it   on   the   page,   if   you   do   not   put   it   you   can   pass   what   you 
say. 
● In   Madrid   the   only   store   I  have   seen   that   have   components   of   pololu   is   Jugetrónica   / 
Robotrónica: 
● Http://www.robotronica.com/nueva_web/informacion/contactar.php 
● Contact   them   to   see   if   they   have   the   regulator   or   they   can   bring   it   to   you,   since   they   have 
enough   Pololu   things. 
● If   they   do   not   have   it   or   they   can   not   bring   it   to   you   in   a  reasonable   time,   say   so   and   we'll   see 
if   we   have   any   reservations   that   are   not   open. 
● It   is   almost   certain   that   I  have   some   new   house   unused,   if   you   spend   some   Friday   afternoon 
that   we   are   for   the   robots   by   the   Medialab   Prado,   we   give   it   to   the   price   of   the   page   of   Pololu. 
● Greetings. 

●  J
  M  s
  ays: 
● February   14,   2011   at   16:24 
● Resistance   between   output   and   ground   that   had   gotten   him   wrong. 
● Setting   the   output   voltage 
● The   output   voltage   can   be   adjusted   using   a  meter   and   a  light   load   (eg   a  1k 
resistor).   Turning   the   potentiometer   clockwise   increases   the   output   voltage.   The 
output   voltage   can   be   affected   by   a  screwdriver   touching   the   potentiometer,   so   the 
output   measurement   should   be   done   with   nothing   touching   the   potentiometer.   The 
potentiometer   has   no   physical   end   stops,   which   means   that   the   wiper   can   be 
turned   360   degrees   and   into   an   invalid   region   in   which   the   output   voltage   is   set   to 
approximately   2.5   V  (for   both   the   2.5   V  to   9.5   V  and   4  V  to   25   V  versions   ).   The 
input   voltage   should   not   exceed   the   output   voltage,   so   we   recommend   setting   the 
output   voltage   with   the   input   voltage   set   to   around   2.5   V. 
● Once   the   input   exceeds   the   output   set   point,   the   output   voltage   will   rise   with   the 
input   voltage   since   the   input   is   connected   to   the   output   through   an   inductor   and   a 
diode. 

●  I  srael  s
  ays: 
● February   15,   2011   at   00:13 
● Hello   jm 
● Well   basically   I  did   the   jerk   and   I  started   to   try   it   taking   assumptions   instead   of 
reading   the   web   ... 
● I   connected   the   input   (3.3v),   GND   and   set   a  multimeter   on   the   output   to   regulate   it, 
without   the   resistance   between   output   and   ground. 
● I   turned   the   potentiometer   slightly   and   the   output   went   up   to   4v   and   something,   I 
turned   a  little   more   and   goodbye   regulator   ... 
● I   suppose   I  would   reach   an   area   "out   of   range"   where   supposedly   the   output 
voltage   is   2.5v   and,   being   smaller   than   the   input,   because   I  loaded   the   stupid   way 
the   circuit. 
● Last   night   I  wrote   to   Juguetrónica   just   in   case   they   had   the   regulator,   to   see   if   there 
is   luck   ... 
● But   I  would   appreciate   it   very   much   if   you   could   sell   one   of   yours,   because   my 
biggest   problem   now   is   the   time   (I   wanted   to   have   the   plates   ready   for   this 
weekend,   but   now   I  do   not   know   whether   to   go   ahead   with   them   or   look   for   another 
component   which   would   force   me   to   Stop   the   design   until   you   know   your   physical 
form). 
● regards 

●  I  srael  s
  ays: 
● February   15,   2011   at   02:14 
● Well,   they   just   answered   me   from   Juguetronica   and   they   do   not   have   it   in 
stock,   according   to   whether   I'll   take   it   for   a  month   ...   so   I  discard   it. 

●  J
  M  s
  ays: 
● February   15,   2011   at   05:35 
● Hello,   try   to   try   again   with   the   load   resistor,   it   is   very   possible 
that   it   is   not   broken   and   is   OK.   I  remember   putting   it   in   that 
area   and   nothing   happened   to   him. 
● If   it   does   not   work,   on   Friday   afternoon   we   usually   stay   at   the 
Medialab   Prado   where   we   put   a  sprinter   track,   I  have   a  new 
one   without   using. 
51.  I  srael  s
  ays: 
52. February   15,   2011   at   06:32 
53. Hello   again. 
54. JM,  the  load  resistance  (as  well  as  using an input voltage of less than 2.5 volts) I tried it last night after 
loading  it  (I  read  too  late  the  description  of  the  Pololu  website  ...)  without  apparent  change 

 
55. If  you  go  to  Medialab  on  Friday,  you  would do me a great favor if you could take it with me to finish the 
control   plate   at   the   weekend.   Just   tell   me   the   price   to   take   the   money   and   what   time   you   will   be. 
56. By   the   way,   is   the   entrance   free,   something   to   show?   I  do   not   know   exactly   what   Medialab   is   ... 
57. Could   you   give   me   an   email   or   something   to   contact   you,   please? 

58. Thank   you   very   much   for   all   the   help.     

●  J
  M  s
  ays: 
● February   15,   2011   at   07:09   AM 
● On   Friday   I  take   you,   the   price   of   the   page   of   Pololu,   put   9  €  to   change. 
● Unless   you   have   entered   the   2.5V   zone   feeding   from   5V,   doubling   the   input   as   specified,   it 
should   not   break,   I  did   not   expect   them   to   be   so   sensitive. 
● Pelayo   happened   something   similar   with   a  regulator,   I  do   not   know   that   he   did   it   and   I 
stopped   working,   and   a  few   hours   later   or   the   next   day   it   worked   again,   so   I  do   not   know,   I 
would   make   one   last   attempt. 
● The   Medialab   is   a  site   of   the   Madrid   City   Council   for   anyone   who   wants   to   go,   the   entrance   is 
totally   free,   there   is   nothing   to   teach.   Friday   afternoons   are   dedicated   to   groups   that   do 
electronics,   programming,   and   many   other   things.   So   there   are   welders,   multimetros, 
computers,   space,   etc   ...   The   ideal   place   to   do   things   of   these. 
● My   mail   is,   in   the   forum   we   usually   set   up   meetings,   we   usually   be   between   18:30   to   20:30, 
anything   send   me   an   email   or   open   a  thread   in   the   forum. 
● Greetings. 

59.  I  srael  s


  ays: 
60. February   17,   2011   at   09:50 
61. Hello   again, 
62. Although   tomorrow   we   see,   I  take   the   opportunity   to   ask   a  few   things   not   to   forget   me   ... 
63. I  have  noticed  in  the  photos  that  between  the  terminals  of  the  motors  you  have  welded  a  ceramic 
capacitor.   What   value   have   you   used? 
64. On  the  other hand, you comment that to avoid burning the DC­DC using the HP motors you have to put 
a  22  uF  electrolytic  capacitor  near  it,  but  I  do  not  see  it  in  the  photos  or in the photolithography of the 
plate   ...   Could   you   tell   me   where   Put   it   exactly?   Between   GND   and   Vout   of   the   regulator? 
65. Thank   you   very   much 

66.  I  srael  s


  ays: 
67. February   17,   2011   at   09:56 
68. Looking  at  the  enlarged  photo  it  seems  that the capacitors of the motors' terminals are not ceramic but 
of   tantalum,   right? 

69.  J
  M  s
  ays: 
70. February   17,   2011   at   10:36   am 
71. Hello, 
72. Capacitors  are not necessary to put them, they are ceramic capacitors of 100 nF that are put to remove 
noise,  in  most  of  the  robots  we  take  them  without  capacitors  and  there  are  no  problems  of  noises.  In 
the  last  robots  I  have  done  I  have  not  bothered  to  put  them,  if  once  mounted  the  robot  you  have 
problems  resetting  the  micro  if  you  have  to  look  to  put  them,  those  and  even  others  between  each 
terminal   of   the   motor   and   the   housing. 
73. The  capacitor  for  the  dc­dc  is  the  electrolytic  of  the  bottom  of  the  whole  (it  has  stayed  a  little  far from 
where  it  should  be  in  the  pcb).  It  goes  between  the  dc­dc  output  and  ground.  Put  a  value of about 47 
uF,  it  may  even  be  better  to  take  it  bigger,  depends  on  the  weight  of  the  robot  and  the  voltage  peaks 
you   see. 
74. Tomorrow   you   see   how   robots   are   made,   there   are   also   other   things   done   differently   that   work   well. 
75. Greetings. 

76.  I  srael  s


  ays: 
77. February   17,   2011   at   11:20   am 
78. Mmm,   I  still   do   not   see   ...   You   mean   those   marked   in   the   design   as   C1   and   C2? 

●  J
  M  s
  ays: 
● February   17,   2011   at   11:34   am 
● If   the   two   electrolytic   capacitors   to   the   left   of   the   dissipative   regulator   would   be   the   c2   of   the 
schematic,   which   goes   to   the   input   of   the   dissipative   regulator   (dc­dc   output)   and   ground. 
● Ideally,   the   capacitor   would   be   closer   to   the   baby   orangutan,   or   add   another   in   addition   to   that 
near   the   microcontroller   board   that   is   where   the   bridge   in   H  is. 
● You   can   place   it   near   the   power   supply   of   the   H­bridge   (the   one   of   the   motors)   that   you   are 
going   to   use. 

79.  V
  icente   Izcara  s
  ays: 
80. March   16,   2011   at   11:18   am 
81. Hello   everyone.  
82. From   the   Association   of   Microbótica   of   the   UVa   we   follow   your   work   with   attention. 
83. We   will   be   delighted   to   meet   you   at   ROBOLID   if   you   are   ready   to   participate,   next   April   8th. 
84. Http://www.robolid.net 
85. A   greeting! 

●  J
  M  s
  ays: 
● March   20,   2011   at   06:10 
● Hi,   thanks   for   the   notice,   the   date   is   very   bad   for   most   of   us   being   midweek,   but   if   anyone   can 
maybe   come   closer. 
● A   greeting   and   that   goes   well   the   contest. 

86.  J
  uan   Carlos  s
  ays: 
87. March   20,   2011   at   14:08 
88. I   want   to   be   the   first   to   congratulate   you   on   your   participation   in   Cosmobot   ...   Simply   Spectacular   .... 
89. Congratulations 

●  J
  M  s
  ays: 
● March   20,   2011   at   16:04 
● Thank   you,   the   truth   is   that   we   have   a  much   better   competition   than   we   could   imagine. 
● Greetings. 

90.  A
  lejandro  s
  ays: 
91. April   12,   2011   at   12:04   PM 
92. Very  interesting  project,  you  can  apply  the  program  to  a  pic18F452,  if  you  can,  what  modifications 
would   you   have   to   perform?   ...   Thank   you,   excellent   info   !!! 

●  J
  M  s
  ays: 
● April   12,   2011   at   12:15   PM 
● Hello,   the   program   can   be   applied   to   a  pic18f452,   you   would   simply   have   to   adapt   it   to   it 
(configure   the   pic   hardware   as   required).   The   idea   is   the   same   you   program   in   an   AVR   or   a 
PIC,   usually   everything   you   can   do   with   one   you   can   do   with   the   other. 
● What   you   have   to   check   when   reading   in   digital   is   that   the   pins   that   you   use   of   the   PIC   as 
inputs   of   the   sensors   are   ST   (schmitt   trigger),   since   you   are   going   to   read   in   digital,   in   AVR   all 
the   pins   carry   an   ST,   in   the   PIC   some   They   do   not   carry   it   but   you   can   also   put   an   external 
ST. 
● For   any   doubt   about   how   to   program   a  pic,   you   can   check   here: 
http://www.todopic.com.ar/foros/index.php 
● S2 
93.  P
  aco  s
  ays: 
94. May   2,   2011   at   12:29   PM 
95. First   of   all,   thank   you   for   the   contribution.  
96. I  have  a  sprinter  I  made  two  years  ago  for  a  contest  (to  call  it somehow) a robotics summer course, it 
has  12  sensors  instead  of  the  8  of  the  pololu  plate. If I wanted to adapt your code to that robot would I 
have   to   add   something   like   that   ??  
97. If   ((PINC   &  0xXX)!   =  0)   //   I6   PCX­11  
98. {  
99. Errorp   =  errorp   ­  0x11;  
100.If   ((PINC   &  0xXX)!   =  0)   //   I5   PCX­9  
101.{  
102.Errorp   =  errorp   ­  0x09;  
103.If   ((PINC   &  0xXX)!   =  0)   //   D6   PCX   +11  
104.{  
105.Errorp   =  errorp   ­  0x09;  
106.If   ((PINC   &  0xXX)!   =  0)   //   D5   PCX   +9  
107.{  
108.Errorp   =  errorp   +  0x11; 
109.Change   all   errors   =  +/­   9  to   +/­   13.  
110. Greetings. 

●  J
  M  s
  ays: 
● May   2,   2011   at   13:03 
● Hello, 
● That   is,   you   have   to   add   each   sensor   in   steps   of   two   in   the   function   that   calculates   the 
proportional   error   and   in   the   function   that   calculates   the   derivative   of   the   error,   following   the 
order   of   the   sensors   of   each   of   the   fucnions. 
● Then   you   will   have   to   adjust   the   constants   by   trial   and   error   for   your   robot. 
● Greetings. 

111.  L
  ainus  s
  ays: 
112. June   15,   2011   at   11:00   p.m. 
113. Hello   everyone,   I  just   downloaded   this   page   and   some   of   its   links,   and   put   it   into   practice   was   said. 

114.  F
  abian   Alfonso  s
  ays: 
115. September   15,   2011   at   11:45   am 
116. Hi,  thank  you  so much for sharing all your time and work unselfishly, you have helped me a lot to better 
understand  the  PD  control,  and  soon  I  want  to  build  my  own  lineas  sprinter,  I  hope  that  in  the  future 
your   projects   will   continue   as   good   and   complete   and   even   better   ,  Thank   you   and   good   luck! 
●  J
  M  s
  ays: 
● September   19,   2011   at   17:33 
● Thanks   for   the   comment,   you'll   do   well   that   follows   lines. 
● Greetings. 

117.  M
  iguel  s
  ays: 
118. September   19,   2011   at   17:15 
119. Dis  guilty for not here and components of those but put a robot to zero to zero only with pic18f4550 and 
a  bridge  h  l293  I  would  like  to adapt the system pid sera k you can help me the sensors are connected 
to  the  analog  0  to 4 and the bridge h To b7, b6, b5 and b2, b1, b0 porfabor I hope your help eneybol b7 
and   b2 

●  J
  M  s
  ays: 
● September   19,   2011   at   17:37 
● Here   you   have   the   complete   development   of   the   robot   explained: 
http://www.jmnlab.com/robotzero/robotzerov.html   step   by   step 
● To   ask   questions   about   pics   you   have   the   forums   of   all   pic:  h   ttp://www.todopic.com.ar/foros/ 
● When   you   ask   for   help   it   is   best   to   ask   a  question,   a  specific   doubt,   if   not   difficult   to   give   you 
an   answer.   Pregunta   en   ese   foro   que   son   expertos   en   pic,   aunque   no   dberías   tener   ningún 
problema   en   adaptar   el   código   de   AVR   a  PIC   en   C,   aunque   eso   es   algo   que   deber   hacer   tú 
(si   quieres). 
● Greetings. 

120.  E
  MRE   KARCI  s
  ays: 
121. December   24,   2011   at   17:26 
122.hi   Show   him   how   to   compile   the   program   which 

123.  J
  orge  s
  ays: 
124. December   24,   2011   at   17:38 
125.http://www.jmnlab.com/robotzero/rzvd4.html 
126.Para   cualquier   duda   sobre   los   AVR:   http://www.avrfreaks.net   ,  en   sus   foros   podrás   preguntar. 
127.Y  por  favor,  deja  de  usar  el  traductor  de  google  para  preguntar,  ya  que  se  entiende  muy  mal  (he 
borrado   tus   comentarios   que   no   hay   por   donde   leerlos). 

128.  E
  MRE   KARCI  s
  ays: 
129. December   24,   2011   at   18:34 
130.Build   24.12.2011   at   19:33:43   started  
131.mmcu  =  ATmega328P  ­Wall  ­O2  ­fsigned  ­gdwarf­2­char  ­MD  ­MT  ­MP  BlinkLED.o  ­MF  dep  / 
BlinkLED.od   ­c   ../BlinkLED.c  
132./   usr   /  bin   /  sh:   ­Wall:   command   not   found  
133.make:   [BlinkLED.o]   Error   127   (ignored)  
134.mmcu   =  ATmega328P   BlinkLED.o   BlinkLED.elf   ­o  
135./   usr   /  bin   /  sh:   BlinkLED.o:   command   not   found  
136.make:   [BlinkLED.elf]   Error   127   (ignored)  
137.avr­objcopy   ihex   ­O   ­R   ­R   .eeprom   .fuse   ­R   ­R   .lock   .signature   BlinkLED.elf   BlinkLED.hex  
138.avr­objcopy:   'BlinkLED.elf':   no   such   file  
139.make:   ***   [BlinkLED.hex]   Error   1  
140.Build   failed   with   1  errors   and   0  warnings   ... 

    

ARDE 

 
MOST  P
  OPULAR  E   NTRIES 
 
Robot  Z
  ero.  A
   L
  ine  F
  ollower  f or  B
  eginners   ­  190900   hits 
 
Android  +
   P
  rocessing  +
   B
  luetooth   ­  155,750   hits 
 
Kinematic  m
  odel  o
  f  a
   d
  ifferential  d
  rive  r  obot   ­  147,532   hits 
 
Robot  Z
  ero.  S
  printer  f or  b
  eginners.  ­   129,830   hits 
 
Starting  w   ith  Z
  igBee.  ­   87   622   hits 
POSTS  B
  Y  A
  UTHOR 
Cire   (20) 
David   (21) 
William   (2) 
NAMB   (99) 
MA  R   ivera   (2) 
Oscar   (25) 
Raul   (4) 

Copyright   © C
  ire   ­  Computer   Club,   robotics   and   electronics. 
Powered   by  W
  ordPress   | M
  odern   Style   theme   by  F
  lexiThemes 

Vous aimerez peut-être aussi