Difference between revisions of "ArduinoRF Class"

From BloomingLabs
Jump to: navigation, search
(New page: == Bloomington Hackerspace "Arduino RF" Class at The Collaboration Room == <big>'''Description:'''</big> This is a simple beginners course in which participants will learn how to use sim...)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Bloomington Hackerspace "Arduino RF" Class at The Collaboration Room ==
+
== Bloominglabs Arduino RF/Wireless Class ==
  
 
<big>'''Description:'''</big>
 
<big>'''Description:'''</big>
  
 
This is a simple beginners course in which participants will learn how to use simple+cheap RF modules to communicate wirelessly with microcontrollers. We will focus on the Arduino platform although the RF modules and techniques are easily applied to most microcontrollers. Time will be spent both working on hardware as well as writing simple software routines. Participants will also spend time troubleshooting basic reception problems and learn techniques to eliminate noise and spurious signals. At the end of the course we will connect components such as potentiometers and light sensors to the transmitter and receive the data both on the receiving Arduino as well as the computer it is connected to. Lastly we will see what kind of range can be expected and how to get the best possible distance with these RF boards.
 
This is a simple beginners course in which participants will learn how to use simple+cheap RF modules to communicate wirelessly with microcontrollers. We will focus on the Arduino platform although the RF modules and techniques are easily applied to most microcontrollers. Time will be spent both working on hardware as well as writing simple software routines. Participants will also spend time troubleshooting basic reception problems and learn techniques to eliminate noise and spurious signals. At the end of the course we will connect components such as potentiometers and light sensors to the transmitter and receive the data both on the receiving Arduino as well as the computer it is connected to. Lastly we will see what kind of range can be expected and how to get the best possible distance with these RF boards.
 +
 +
 +
<big>'''Handouts:'''</big>
 +
* Arduino RF code samples [[Image:ArduinoRF.2010-07-27.zip]]
 +
* Arduino RF/wireless workshop outline (handout) [[Image:ArduinoRF_outline.pdf]]
 +
* Arduino RF/wireless workshop questionnaire [[Image:Questionnaire-ArduinoRF_workshops.pdf]]
 +
  
 
<big>'''Requirements:'''</big>
 
<big>'''Requirements:'''</big>
  
 
We will provide all required hardware to participate in this course however attendees are encouraged to bring their own gear if they have it. A microcontroller, RF board (TX and RX), and computer will be used by each pair of participants. Participants should already be somewhat familiar with the process of breadboarding circuits and loading code onto microcontrollers, however this is not a requirement.
 
We will provide all required hardware to participate in this course however attendees are encouraged to bring their own gear if they have it. A microcontroller, RF board (TX and RX), and computer will be used by each pair of participants. Participants should already be somewhat familiar with the process of breadboarding circuits and loading code onto microcontrollers, however this is not a requirement.
 +
  
 
<big>'''Age group:'''</big>
 
<big>'''Age group:'''</big>
Line 16: Line 24:
 
<big>'''Instructor notes:'''</big>
 
<big>'''Instructor notes:'''</big>
  
Participants should be setup in pairs where each individual has either a transmitter or a receiver on their breadboard. Students will work together to send and receive data reliably between their Arduino boards. If you have an odd number of students then you should issue the odd student a receiver board and combine them with another group.
+
Participants should be setup in pairs where each individual has either a transmitter or a receiver on their breadboard. Students will work together to send and receive data reliably between their Arduino boards. If you have an odd number of students, then you should issue the odd student a receiver board and combine them with another group.
  
You should be careful to keep groups on the same frequency at opposite ends of the table to reduce problems with interference. Physical dividers can be used to further reduce interference problems. Be watchfull that participants don't add antenna wires to transmitter boards except for debugging purposes as this extends the TX range and can add to interference problems.
+
You should be careful to keep groups on the same frequency at opposite ends of the table to reduce problems with interference. Physical dividers can be used to further reduce interference problems. Be watchful that participants don't add antenna wires to transmitter boards except for debugging purposes as this extends the TX range and can add to interference problems.
  
 
Required hardware for class - you need a complete set of these components these for each pair of students:
 
Required hardware for class - you need a complete set of these components these for each pair of students:
Line 27: Line 35:
 
1x TX board
 
1x TX board
 
1x RX board
 
1x RX board
1x 9V pigtale with 2.1mm power plug (for TX board distance testing in section V)
+
1x 9V pigtail with 2.1mm power plug (for TX board distance testing in section V)
1x 5k potentiometer
+
1x 9V battery
2x 1.2k resistor (1/4-1/8W)
+
3x 1.2k resistor (1/4-1/8W)
 
1x photoelectric sensor (light sensor)
 
1x photoelectric sensor (light sensor)
12x 4" breadboarding wires per Arduino
+
1x 5k potentiometer
 +
1x LED
 +
~12x 4" breadboarding wires per Arduino
 
</pre>
 
</pre>
 +
  
 
<big>'''Additional hardware operated by instructor to assist participants with learning:'''</big>
 
<big>'''Additional hardware operated by instructor to assist participants with learning:'''</big>
 
<pre>
 
<pre>
 
Receiver or police scanner with TX frequencies pre-programmed into it (315.01MHz, 433.92MHz)
 
Receiver or police scanner with TX frequencies pre-programmed into it (315.01MHz, 433.92MHz)
Oscilliscope connected to data output of a working receiver board (no Arduino required)
+
Oscilloscope connected to data output of a working receiver board (no Arduino required)
 
</pre>
 
</pre>
 
These two pieces will allow students to get audio and visual feedback to help them in understand some of the problems they will encounter in section III.
 
These two pieces will allow students to get audio and visual feedback to help them in understand some of the problems they will encounter in section III.
  
  
Sample Arduino code provided in this course:
+
<big>'''Sample Arduino code provided in this course'''</big>
 +
 
 +
Section II code (borrowed from [http://www.sparkfun.com/datasheets/RF/KLP_Walkthrough.pdf KLP_Walkthrough.pdf]):
 
<pre>
 
<pre>
BHRF001-I-blinky.pde     - Arduino LED blinker code to verify Arduino works and students can send code to it
+
simpleCounterTX.pde           - Basic TX counter code for section II
BHRF001-II-TX.pde        - Basic TX counter code for section II
+
simpleCounterRX.pde           - Basic RX counter code for section II
BHRF001-II-RX.pde       - Basic RX counter code for section II
+
BHRF001-IV-TX.pde        - RFDriver TX code for section IV - pot averager output w/LED blinker
+
BHRF001-IV-RX.pde        - RFDriver RX code for section IV - output received data w/LED blinker
+
RFDriver.pde            - RFDriver library to be dropped into previous two projects
+
 
</pre>
 
</pre>
  
<big>'''Course Outline:'''</big>
+
Section III_IV code (RFLink borrowed from [http://www.glacialwanderer.com/hobbyrobotics/?p=291 Cheap Arduino Wireless Communications]):
 
<pre>
 
<pre>
I. Getting started - verify gear is working and get students familiar with the hardware and software
+
simpleErrorRejectionRX.pde    - Ignores values outside of a valid range, use with simpleCounterTX
 
+
lightSensorRXTX.pde           - RFDriver TX code for section IV - light sensor output w/LED blinker
A. Each pair of participants should have a unique station number, 1-n (to be used in section III).
+
RFLink.pde                    - RFDriver library to be dropped into previous two projects
B. Connect USB and/or power to your Arduino
+
C. Load the blinky sketch up in the Arduino application and upload to your Arduino board
+
D. Verify this process is working, you should have a blinking LED now
+
Troubleshooting:
+
1. Did the Arduino application give an error?
+
a. verify the correct board type is selected
+
b. verify the correct serial port is selected
+
c. reset the arduino and try again
+
d. unplug the arduino, then plug back in. restart the Arduino application. try it now.
+
+
2. The application said the sketch uploaded, but nothing is happening
+
a. verify the led is wired up correctly and check polarity
+
 
+
E. Instructor: make sure every group has two blinking LED's before moving forwards
+
 
+
 
+
II. Lets do some RF!
+
 
+
A. Wire up the TX and RX boards, one per arduino (remove power from board first)
+
B. Double check that power is wired correctly
+
C. Type in or copy/paste RF counter code into Arduino application (TX for transmitters, RX for receivers)
+
D. Power up boards, upload code
+
1. REMINDER!! RX boards MUST disconnect data-line to Arduino before code can be uploaded, otherwise strange errors will result
+
 
+
E. Participants with RX boards, activate serial port monitor
+
1. Do you see numbers counting from 0 to 255? If not begin troubleshooting:
+
a. make sure boards are side-by-side so they are in RF proximity to each other
+
b. verify participant with TX board is using TX code and participant with RX board is running RX code
+
c. verify wiring of power lines and data line to TX/RX board
+
d. verify baud rate
+
e. ask instructor for the scanner and how to use it
+
 
+
F. Instructor: make sure every group is now sending and receiving data before moving forwards
+
 
+
 
+
 
+
-----------------------------------------------------------------------------------------------------
+
 
+
III. Experimentation: this section to not be handed out to students, instructor should lead each step
+
 
+
A. Students with TX boards should increase delay at end of their sketchs from 10ms to 20ms
+
1. What happens on the receiving end (serial port monitor)?
+
2. Turn the delay back down to 10ms, verify receiver works again
+
3. Now turn up the delay to 50ms, what happens on the receiver end?
+
 
+
4. Instructor: if available, turn on the oscilliscope and connect RX receiver to demonstraight what is going on
+
a. start by showing receiver output with no TX, show the RF background noise
+
b. have student turn on a compatible TX board with 10ms timing, show the RX data output
+
c. have student turn up delay to 20ms on TX board
+
1. noise should be visible between TX packets, if not increase to 50ms or higher until this is seen
+
2. the "gaps" in transmitted packets are where the garbage data is coming from on the RX side
+
3. when the delay between packets is 10ms then there are no gaps for RF noise to creep in
+
 
+
B. Students should work together to make changes to their code to reduce errors
+
1. Suggest some schemes that could work
+
a. add header to tx code and detection code to rx code
+
b. add rx code to eliminate all but valid range of input
+
c. students may not have C experience, may need to have some easy sample code on-hand to use
+
d. code to send alpha would be good to
+
 
+
2. Students should have about 20-30 minutes to experiment at this point
+
3. Watch for groups that are struggling or off-course. Point them towards some example code if they need help.
+
 
+
 
+
C. After 20-30 minute period has passed, introduce students to the RFDriver library
+
1. First, what solutions did each group come up with? Did it work? Well?
+
2. Obviously someone else has already dealt with these problems before, how did they overcome them?
+
3. What does the RFDriver library do for you?
+
4. Why does it make your life easier, why is it more reliable than the code you've used so far?
+
a. ?adds initialization header (pre-amble)
+
b. rudimentary network address
+
c. CRC check
+
d. all you do is read or write to a variable, the rest is handled for you
+
 
+
5. Pass out RFDriver.pde on USB sticks or over the network (or hidden on each system)
+
 
+
6. Have students reload sketches BHRF001-II-TX/RX onto their appropriate boards
+
a. drop RFDriver.pde into their sketch directories for BHRF001-II-TX/RX, save and reload sketch
+
b. have students manually modify the BHRF001-II-TX/RX code so it's using the RFDriver library
+
 
+
c. have each pair modify their Network Identifier to be their group number
+
d. verify each pair of students is sending and receiving data
+
e. have students turn up TX delay to 500ms and verify they are cleanly receiving data
+
f. now have students move their boards around so TX and RX boards on the same frequency are interfering with each other
+
1. they should notice that opposite groups are not receiving data from each other
+
2. it's possible that they could still be interfering with each other, may need to increase TX delay ms
+
3. ask students if they understand what is happening - network ID of the RFDriver code
+
 
+
D. Instructor: do not move on until all students have gotten through the last steps.
+
 
+
-----------------------------------------------------------------------------------------------------
+
 
+
 
+
IV. Sending and receiving sensor data
+
 
+
A. Wire up 5k potentiometer on the TX breadboard to Arduino pin 3
+
1. Add-in code to read input analog data and provide a number from 0-9
+
2. Verify RX board receives data
+
3. Leave potentiometer wired up
+
 
+
B. Wire up light sensor on TX breadboard to Arduino pin 5
+
1. Add-in code to read light sensor data and send out TX
+
2. Verify RX board receives data
+
 
+
 
+
V. RF Distance Testing
+
 
+
A. Groups should finalize the code they want to run on the TX board for this test
+
1. Load code on TX Arduino
+
2. Disconnect USB from this Arduino
+
3. RX Arduino stays connected to computer with USB - Arduino application should be in serial port monitor mode
+
 
+
B. Carefully wire up 9V directly to TX boards rather than 5V from Arduino regulator as we have been using
+
C. Add antenna wire to TX and RX antenna pins
+
D. Connect 9V battery to TX Arduino
+
E. Start testing distance, TX Arduino is now free to be moved around the room
+
1. other groups should disable their TX boards while final distance testing is being performed :)
+
 
+
 
+
VI. Cleanup
+
 
+
A. Backup and save any code from the computer that you wish to keep
+
B. Disconnect all components from the Arduino breadboards, put back into bags
+
C. Put Arduinos back into containers, account for all pieces
+
D. Fill out questionair
+
E. Have a great night, thanks for coming!!
+
 
+
 
+
 
+
Going Further on your own:
+
1. Connect a motion sensor, have a basic motion sensor alarm for your house or the fridge
+
2. Make a basic Arduino 2-player game
+
3. Make the transmitter control an application on your computer
+
4. Control a circuit on the receiver from your computer
+
5. More extensive RFDriver library - VirtualWire: http://www.open.com.au/mikem/arduino/
+
 
</pre>
 
</pre>
  
--------------------------------------------------------------------------------
+
Auxillary code:
<big>'''Questionair:'''</big>
+
 
<pre>
 
<pre>
1) Overall, how would you rate each of these components of the course:
+
raw_analog_readings.pde      - prints raw analog values from light sensor to the serial port (use serial monitor)
  [1-5, 1 being poor, 3 being acceptable, 5 being beyond expectations]
+
potTX.pde                    - Read analog value of potentiometer and map it from 0 to 9, then transmit 0-9 - use RFLink.pde to RX
 
+
Using the Arduino:          1  2  3  4  5
+
Sample code used in course:  1  2  3  4  5
+
Debugging RF problems:      1  2  3  4  5
+
Using sensors:              1  2  3  4  5
+
RF Distance Testing:        1  2  3  4  5
+
 
+
2) For each section, how would you rate the speakers delivery of the information:
+
  [1-5, 1 being poor, 3 being average, 5 being beyond expectations]
+
 
+
Getting Started:            1  2  3  4  5
+
Lets do some RF!!:          1  2  3  4  5
+
Experimentation:            1  2  3  4  5
+
Using Sensors:              1  2  3  4  5
+
RF Distance Testing:        1  2  3  4  5
+
 
+
3) Was there any information regarding RF and microcontrollers you would like to have seen covered which was not?
+
 
+
 
+
4) Do you have any other suggestions relating to this course?
+
 
</pre>
 
</pre>

Revision as of 00:13, 5 August 2010

Bloominglabs Arduino RF/Wireless Class

Description:

This is a simple beginners course in which participants will learn how to use simple+cheap RF modules to communicate wirelessly with microcontrollers. We will focus on the Arduino platform although the RF modules and techniques are easily applied to most microcontrollers. Time will be spent both working on hardware as well as writing simple software routines. Participants will also spend time troubleshooting basic reception problems and learn techniques to eliminate noise and spurious signals. At the end of the course we will connect components such as potentiometers and light sensors to the transmitter and receive the data both on the receiving Arduino as well as the computer it is connected to. Lastly we will see what kind of range can be expected and how to get the best possible distance with these RF boards.


Handouts:


Requirements:

We will provide all required hardware to participate in this course however attendees are encouraged to bring their own gear if they have it. A microcontroller, RF board (TX and RX), and computer will be used by each pair of participants. Participants should already be somewhat familiar with the process of breadboarding circuits and loading code onto microcontrollers, however this is not a requirement.


Age group:

15 to adult, anyone under 15 should be accompanied by an adult


Instructor notes:

Participants should be setup in pairs where each individual has either a transmitter or a receiver on their breadboard. Students will work together to send and receive data reliably between their Arduino boards. If you have an odd number of students, then you should issue the odd student a receiver board and combine them with another group.

You should be careful to keep groups on the same frequency at opposite ends of the table to reduce problems with interference. Physical dividers can be used to further reduce interference problems. Be watchful that participants don't add antenna wires to transmitter boards except for debugging purposes as this extends the TX range and can add to interference problems.

Required hardware for class - you need a complete set of these components these for each pair of students:

1x PC - anything that can run Processing (Arduino software) and the example sketches linked below
2x Arduino (any model) - one for each student, but a pair is required
2x breadboard (Arduino proto-shield works great but any breadboard will suffice)
1x TX board
1x RX board
1x 9V pigtail with 2.1mm power plug (for TX board distance testing in section V)
1x 9V battery
3x 1.2k resistor (1/4-1/8W)
1x photoelectric sensor (light sensor)
1x 5k potentiometer
1x LED
~12x 4" breadboarding wires per Arduino


Additional hardware operated by instructor to assist participants with learning:

Receiver or police scanner with TX frequencies pre-programmed into it (315.01MHz, 433.92MHz)
Oscilloscope connected to data output of a working receiver board (no Arduino required)

These two pieces will allow students to get audio and visual feedback to help them in understand some of the problems they will encounter in section III.


Sample Arduino code provided in this course

Section II code (borrowed from KLP_Walkthrough.pdf):

simpleCounterTX.pde           - Basic TX counter code for section II
simpleCounterRX.pde           - Basic RX counter code for section II

Section III_IV code (RFLink borrowed from Cheap Arduino Wireless Communications):

simpleErrorRejectionRX.pde    - Ignores values outside of a valid range, use with simpleCounterTX
lightSensorRXTX.pde           - RFDriver TX code for section IV - light sensor output w/LED blinker
RFLink.pde                    - RFDriver library to be dropped into previous two projects

Auxillary code:

raw_analog_readings.pde       - prints raw analog values from light sensor to the serial port (use serial monitor)
potTX.pde                     - Read analog value of potentiometer and map it from 0 to 9, then transmit 0-9 - use RFLink.pde to RX
Personal tools