Specific examples: Method 1
Photo Sensors - Real-time communication
Temperature Probe - Real-time communication
Boe-Bot with Photo and Temp Sensor - Data dump
Specific examples: Method 2
Simple Message - One-time communication
Photo and Temp Sensor - One-way communication, dump data
Two-Way Communication - Two-way, real-time communication
Display PS2 Controller - One-way, real-time communication
PS2 Virtual/Real World Control - One-way, real-time communication
This page is designed to help people get an understanding of how to download sensor information from the Parallax Basic Stamp 2 (BS2) microcontroller to MATLAB. This can be thought of as an enhancement of the DAQ
of the BS2. I hope this information will be particularly beneficial to professor Eke's students taking her Computer Applications course.
Supplies needed:
kit (one of the following)
Any starter kit that uses the BS2
raw components: BS2
, connection wire (usb or serial), sensors, Basic Stamp Editor software, and bread board.
- Not needed for Method 2 (free software)
software (student edition or better)
Note: The older version of PLX-DAQ is called StampDAQ, they are identical. Throughout the rest of this page it is assumed that the user is familiar with the MATLAB programming environment and basic commands, is familiar with the Basic Stamp Editor, and has gone through some of the example programs that teach the user how to use PLX-DAQ (if Indirect Communication is chosen). Chances are for those interested in transferring information from the BS2 to MATLAB a knowledge of these programs has already be established, so the only thing that will seam new will be the PLX-DAQ which is very simple to understand. There are only 10 commands in PLX-DAQ, so if you know those commands then you have mastered PLX-DAQ!
Below are shown the steps to take in order for the data transmission from the BS2 to MATLAB to take place.
Method 1: Indirect Communication
1. Have the following programs installed: Basic Stamp Editor, MATLAB, PLX-DAQ.
2. Have the sensors and BS2 connected, tested, and up and running.
3. Transfer information from the BS2 to PLX-DAQ (either through a data dump or real-time transfer).
4. Copy the information in PLX-DAQ and paste it into a new Excel document (optional*)
5. Transfer the information from PLX-DAQ to MATLAB.
6. Use MATLAB's advanced programming language to analyze and interpret the sensor information.
*Step 4 is optional because MATLAB usually reads the data in PLX-DAQ just fine but I use this step just in case.
Because there are numerous examples and forums available to help people connect the Basic Stamp Editor to PLX-DAQ, I will be focusing on how to connect PLX-DAQ to MATLAB. Just as the connection from the BS2 to the PLX-DAQ is setup almost entirely in the Basic Stamp Editor so the data transfer from the PLX-DAQ to MATLAB is done almost entirely in the MATLAB environment.
Method 2: Direct Communication
1. Have the following programs installed: Basic Stamp Editor, MATLAB.
2. Have the sensor(s) and BS2 connected, tested, and up and running.
3. Transfer information from the BS2 directly to MATLAB.
6. Use MATLAB's advanced programming language to analyze and interpret the information.
The following sections consist of specific examples of how I transferred data from the BS2 to MATLAB.
This section contains information about how to take data from two photo sensor, log this information into an Excel file using PLX-DAQ, then read the Excel file into MATLAB which will analyze the information.
Hardware
I am using a two Photoresister
(sold by Parallax or found at any electronics store) to acquire light level readings. I am using the photo resistors that came with the Boe-Bot kit which I already own. The circuit diagrams for this hook up can be found in the Robotics with the Boe-Bot
text on page 206.
Step-by-Step
1. Setup and test the hardware.
2. Run the program
3. Connect the BS2 to PLX-DAQ and run it.
4. Upon completion, save the PLX-DAQ as PhotoSensor.xls.
5. Copy the information in PhotoSensor.xls and paste it into a new xls document, save as PhotoSensor.xls (see
6. Run the program
Read Photo DAQ using MATLAB ( .m format).
Results
After running Communicate.m MATLAB will plot two graphs of light intensity vs. time.
This section contains information about how to take data from a temperature sensor, log this information into an Excel file using PLX-DAQ, then read the Excel file into MATLAB which will analyze the information.
Hardware
I am using a Parallax AD592 Temperature Probe
to acquire temperature readings, although any temperature sensor will work. I am using the AD592 because this temperature probe came with the Applied Sensors kit
which I already own. The circuit diagrams for this hook up can be found in the Applied Sensors text on page 66. Make sure that whatever temperature sensor is used is also properly calibrated before beginning this procedure to ensure accurate temperature readings.
Step-by-Step
1. Setup and test the hardware.
2. Run the program
AD592 Temp Probe in the Basic Stamp Editor ( .bs2 format).
3. Connect the BS2 to PLX-DAQ and run it.
4. Upon completion, save the PLX-DAQ as TempProbe.xls.
5. Copy the information in TempProbe.xls and paste it into a new xls document, save as TempProbe1.xls (see
6. Run the program
Read Temp DAQ and run it using MATLAB ( .m format).
Results
After running ReadDAQ_xls_file.m MATLAB will plot a graph of temperature vs. time.
This section contains information about how to take data from a photo and temperature sensor, dump this information into an Excel file using PLX-DAQ, then read the Excel file into MATLAB which will analyze the information.
Hardware
I am using a Photoresister
(sold by Parallax or found at any electronics store) to acquire light level readings. I am using the photo resistors that came with the Boe-Bot kit which I already own. The circuit diagrams for this hook up can be found in the Robotics with the Boe-Bot
text on page 206. I am also using a Parallax AD592 Temperature Probe to acquire temperature readings, although any temperature sensor will work. I am using the AD592 because this temperature probe came with the Applied Sensors kit
which I already own. The circuit diagrams for this hook up can be found in the Applied Sensors
text on page 66. Make sure that whatever temperature sensor is used is also properly calibrated before beginning this procedure to ensure accurate temperature readings. In addition to the sensors I am also using the Boe-Bot setup as shown on page 100 of the Robotics with the Boe-Bot
text. Navigation is done with two IR pairs whose setup is shown on page 237 of the "Robotics with the Boe-Bot" text. See electrical
Boe-Bot Photo Temp and Dump Data ( .bs2 format). Also see Basic Stamp code Flowcharts.
3. Run the two programs in this order: Boe-BotPhotoTemp.bs2 then DumpData.bs2.
4. Connect the BS2 to PLX-DAQ and perform a data dump.
5. Save the PLX-DAQ as Boe-BotPhotoTemp.xls.
6. Copy the information in Boe-BotPhotoTemp.xls and paste it into a new xls document, save as Boe-BotPhotoTemp.xls (see
Boe-BotPhotoTemp1.xls example).
7. Download the program
Read DAQ Photo Temp and run it using MATLAB ( .m format).
Results
After running ReadDAQPhotoTemp.m MATLAB will plot two graphs. One graph will plot light light vs. time for three locations. The other graph will plot temperature vs. time for three locations.
This section contains information about how to send a simple message from the BS2 to MATLAB.
Hardware
None
Step-by-Step
1. Run the program
Hello from Boe-Bot ( .bs2 format).
2. Run the program
Simple Message using MATLAB ( .m format).
Results
After running Simple_message.m MATLAB will display the properties of the COM port it is connected to along with a message the Boe-Bot sent to it.
This section contains information about how to take data from a photo and temperature sensor and have MATLAB read this information directly from the BS2 when the BS2 dumps all its data to it. Repeat of #3 but use direct communications.
Hardware
(sold by Parallax or found at any electronics store) to acquire light level readings. I am using the photoresistors that came with the Boe-Bot kit which I already own. The circuit diagrams for this hook up can be found in the Robotics with the Boe-Bot
text on page 206. I am also using a Parallax AD592 Temperature Probe to acquire temperature readings, although any temperature sensor will work. I am using the AD592 because this temperature probe came with the Applied Sensors kit
which I already own. The circuit diagrams for this hook up can be found in the Applied Sensors
text on page 66. Make sure that whatever temperature sensor is used is also properly calibrated before beginning this procedure to ensure accurate temperature readings. In addition to the sensors I am also using the Boe-Bot setup as shown on page 100 of the Robotics with the Boe-Bot
text. Navigation is done with two IR pairs whose setup is shown on page 237 of the "Robotics with the Boe-Bot" text. See electrical
Photo Temp 2 and Dump Data 2 ( .bs2 format).
3. Run the two programs in this order: Boe-BotPhotoTemp2.bs2 then DumpData2.bs2.
4. Run the program Read DAQ Photo Temp 2 using MATLAB ( .m format).
Results
After running Communicate.m MATLAB will display the properties of the COM port it is connected to along with two graphs. One graph will plot light light vs. time for three locations. The other graph will plot temperature vs. time for three locations.
This section contains information about how to send and receive data using both MATLAB and the BS2 simultaneously.
Hardware
None
Step-by-Step
1. Download the two programs
Send and Receive and Read Data ( .bs2 format).
2. Run SendAndRecieve.bs2
3. Run the program Two Way Communication using MATLAB ( .m format).
4. Run ReadData.bs2
Results
After running ReadData.bs2 a debug terminal will open and display values. These values should be the same as those that were seen in MATLAB after running the program TwoWayCommunication.m.
This section contains information about how to take the PS2 controller readings acquired from the BS2 and transfer them to MATLAB to be displayed.
Hardware
I am using the PS2 controller setup as described on Aaron's Interest page (Only the circuit diagram is needed).
Step-by-Step
1. Setup and test the hardware.
2. Download the two programs
Display Values and PS2 Controller Values ( .bs2 format).
3. Run DisplayValuesOfButtonsAndJoysticks.bs2 to find button values for the controller used, then run PS2ControllerConnectToMATLAB.bs2.
4. Run the program Display Values in MATLAB using MATLAB ( .m format).
Results
After running ReadData.bs2 a debug terminal will open and display values. These values should be the same as those that were seen in MATLAB after running the program TwoWayCommunication.m.
This section contains information about how to use the PS2 controller to control the movements of the Boe-Bot. In addition to Boe-Bot control, the information from the PS2 controller will also be used to direct the movements of a virtual car in MATLAB at the same time.
Hardware
I am using the Boe-Bot setup as shown on page 100 of the Robotics with the Boe-Bot
text. I am also using the PS2 controller set-up as described on Aaron's Interest page (Only the circuit diagram is needed).
Step-by-Step
1. Setup and test the hardware.
2. Run the program
Virtual Car to test the virtual environment in MATLAB*
3. Run
Boe-Bot/Virtual Control ( .bs2 format).
4. Run the program
Virtual/Real Control using MATLAB ( .m format).
*vrmount.wrl will not work if the demo version of the virtual reality toolbox is used; if the demo version is used, then look for the demo: "Car in the Mountains."
Results
After running PS2_Boe_Bot_and_VW.m a virtual reality simulation will start. By using various buttons on the PS2 controller not only will the Boe-Bot move but so will the virtual car in the simulated environment.
There are some advantages and drawbacks to using my approach, some are listed below.
Advantages
No expensive DAQ software - MATLAB's DAQ toolbox is about $50 and MathView is $100 plus you have to set up the connection manually because Parallax is not inherently supported by either platform.
Besides method one, there is no new software to learn - Method one uses PLX-DAQ which uses a total of 10 commands! MATLAB's DAQ toolbox and MathView have hundreds of new commands to get familiar with.
Disadvantages
Although real-time data analysis is possible using my method, it is not very reliable. A software tool dedicated to real-time analysis - both MATLAB and LabView offer such tools - would work much better.
Support - Parallax is currently working on connecting their hardware to LabView and other related software, so when that occurs they will have much more customer support and examples than I can offer.