Sunday, March 25, 2012

This past week, we began a new assignment that utilizes sensors to guide our robot.  The first sensor we added was on Monday.  It was an infrared sensor (IR sensor).  Below is a picture of it mounted to the platform.


The following is the program used for the IR sensor.

symbol IRValue = b0
adcsetup = 2

do
  gosub IRSensor
loop

IRSensor:
  readadc A.1, IRValue
  sertxd ("IR Value = ", #IRValue, CR, LF)
  pause 500
  return

Once we were done programming the IR sensor on Monday, we had to solder some wires onto three line following sensors (LF sensors).  Plugs were then added to the other end of the wires so we could attach these sensors to our bread boards.  Below are pictures of one of the LF sensors and how they were plugged into the bread board.




The next step was to write a program for these sensors.  What follows is that program.

symbol StoreLF1 = b0
adcsetup = 3   'A.0, A.1, A.2

do
  gosub LFleft                                                                  'left sensor
 
  gosub LFcenter                                                              'center sensor
 
  gosub LFright                                                                'right sensor
  loop

LFleft:
  readadc A.0, StoreLF1
  sertxd ("LFleft = ", #StoreLF1, CR, LF)
  pause 500
  return

LFcenter:
  readadc A.1, StoreLF1
  sertxd ("LFcenter = ", #StoreLF1, CR, LF)
  pause 500
  return
 
LFright:
  readadc A.2, StoreLF1
  sertxd ("LFright = ", #StoreLF1, CR, LF)
  pause 500
  return

As you can see, each sensor is attached to a separate pin (A.0, A.1, A.2).  They run independently from each other.  Another thing that should become apparent is that this program is almost identical to the IR sensor program.  Upon completion of the programming, the LF sensors were mounted underneath the front end of the platform.  This is shown in the following pictures.



The next class we are supposed to program our robots to follow a line using these LF sensors.

No comments:

Post a Comment