Your Scribbler 3 robot has a built-in way to receive commands from any Sony-programmed IR Remote Control. The tutorials in this section teach you how to use BlocklyProp to create and fine-tune your programs for the S3 robot using a Remote Control.
You will need a window, or tab, open to the BlocklyProp website [1] to follow along with these tutorials.
Before you begin, you should have already completed:
To complete these tutorials, you will also need:
*These items are for the final tutorial in this series, which requires external components be connected to the Hacker Port. The other tutorials can be completed with just a remote.
Your S3 comes ready to receive signals or commands from a Sony-programmable Remote Control. All you need to start is a remote control and the knowledge contained in these tutorials. Later on, we'll add more of a challenge by connecting an external IR receiver circuit to your hacker port.
An IR receiver can detect bursts of infrared (IR) light sent by something that emits IR light such as a remote controller (like that for a television). The receiver sends a pattern of high/low signals to one of the S3 robot’s Propeller microcontroller’s I/O pins. Remember that your S3 has an IR receiver built-in to the very front of the shell. (You can review this here: Avoiding Obstacles With Infrared [10]).
To complete these first 4 tutorials, you will only need:
First, you will need to configure your remote for Sony protocol.
The Sony Remote value block is in the SENSOR > SONY REMOTE category of the BlocklyProp menu. The block returns a value detected by the IR receiver that indicates which button on the remote was pressed. If no button press has been detected, this block provides a value of -1.
This block's drop-down menu allows you to select the Propeller I/O pin connected to an infrared receiver. When using the S3 board type, the default option is the onboard sensor, located front and center of the S3 (which internally connects to P20). However, the drop-down also gives the option of connecting to P0..P5 on the S3's Hacker Port. The final tutorial in this series will go over how to connect an external IR receiver to your S3.
In 1950, Zenith Radio Corporation developed the first remote intended to control a television. The remote, called Lazy Bones, was connected to the television by a wire. By the early 2000s, the number of consumer electronic devices in most homes significantly increased, along with the number of remotes to control those devices.
One solution to reduce the number of remotes needed is the universal remote, a programmable remote control with the operation codes for most major brands of TVs, DVD players, etc.
The primary technology used in home remote controls is infrared (IR) light. The signal between a remote control handset and the device it controls consists of pulses of infrared light, which is invisible to the human eye but visible through a digital camera, video camera or a phone camera. The transmitter in the remote control handset sends out a stream of pulses of infrared light when the user presses a button on the handset. A transmitter is often a light emitting diode (LED) built into the pointing end of the remote control handset. The infrared light pulses form a pattern unique to that button. The receiver in the device recognizes the pattern and causes the device to respond accordingly. That is what our S3 and the Sony Remote value block do.
Since infrared (IR) remote controls use light, they require line of sight to operate the destination device, meaning there must be a direct, unblocked path from the remote to the device. The signal can, however, be reflected by mirrors, just like any other light source. This will be a limitation for the remote control of our S3 since the onboard receiver is on the front of the S3. You must be in front of the S3 for it to “see the light.”
Article source: https://en.wikipedia.org/wiki/Remote_control [11] Photo: Sidik_iz_PTU [12]
It is possible to accidentally reset the remote's programming. If you experience any problems with your remote (especially if it has worked previously), check the batteries first and then follow the procedure above to setup the remote again.
Let’s move on to the next tutorial and put the Sony Remote value block to work in a BlocklyProp program.
Let’s test our S3’s IR receiver and our SONY remote. To do this we will write a simple test program in BlocklyProp that decodes signals received by the SONY remote and displays them in the BlocklyProp Terminal.
You may notice that pressing and holding a button for a half-second or more gives more consistently readable Terminal results than a rapid press-and-release. Why? Hint: it has to do with how quickly the program completes each cycle through the loop, and the clear command at the beginning of the loop.
You should see the remote button number displayed in the Terminal. Note that the Channel up/down, Volume up/down, and Mute buttons also return numbers. When no button is pressed you should see Remote button = -1. You may also see this message if the IR signal of the button that is pressed is not one that is recognized by this block's library. Some universal remotes have a LOT of buttons, and if you use a non-Parallax remote for this activity, some of them may not display a number.
Write down the numbers that you see when you push the various buttons on your remote. Use the chart below or create your own for your Sony or Universal Remote (set for Sony use).
The IR receiver looks for pulsing infrared light. The IR remote sends short bursts of this pulsing infrared light, in different on-off patterns for each button on the remote. When the IR receiver detects these bursts it sends a 0 to the Propeller I/O pin, and a 1 when it does not. The C code underneath the BlocklyProp Sony Remote value block does the work of decoding the on-off pattern conveyed by the Propeller controller I/O pin.
Interested in a more in-depth look at IR emitters and receivers? Check out our Propeller C Simple Device tutorial: IR Receiver and Remote [13]. The C library it uses is the same library being used to generate our Sony remote blocks in BlocklyProp.
This project's blocks are all inside a repeat forever loop (except for the comment at the top).
The program begins by clearing the terminal and displaying “Remote Button = “. Then, it gets the value of whichever button is being pressed on the remote and stores it in the variable Button. If no button is being pressed, the value will be -1.
The send number block then prints this value to the Terminal so you are able to see which button is being pressed. Then, the program waits 200 milliseconds before repeating the whole process.
This brief pause of 200 ms gives the Terminal time to display the message before code execution returns to the top of the repeat forever loop (where it is cleared.).
In the tutorial called Using Reset as Part of a Program [14], you learned that the S3 can count the number of times the reset button is pressed. It displays that count using the S3’s indicator LEDs as shown below.
Does pressing buttons 1-0 on your remote create these different LED patterns on your S3? If so, move on to the Your Turn section below. If not, find the coding error and retry.
Now that you have the basics of remote control down it's time to learn how to use the remote to drive your S3. For this simple version, you will use the Channel -, Channel+, Volume -, Volume +, and the Mute buttons.
First, recall or retest to find the code sent for each of the Sony IR Remote buttons. Review the Test the Receiver and Remote tutorial if needed.
We're going to use Channel+ to move forward, Channel- to move backward, the Volume- to rotate counterclockwise (CCW), the Volume+ to rotate clockwise (CW), and the Mute button to stop driving.
Now take your S3 for a little drive around. Does everything work as you expected? If not, find the mistakes in your code (a process called debugging) and correct them. Remember that you should have a direct line between the Sony IR Remote and the S3’s IR receiver, so you need to always be positioned more or less in front of the S3. That may mean running around a bit (or a lot), depending on the lighting of your room or how many of these remote S3's are running at once.
Why would lighting and other robots make a difference? Some fluorescent lights (and even bright sunlight) can cause signal interference, sometimes preventing your receiver from responding correctly to your remote. In the case of other robots, any Sony-programmed remote can send a signal to your robot, meaning another student can control your robot by accident (or maybe on purpose) if their remote is pointed at your receiver.
The terms "bug,” “debug,” and "debugging" are popularly attributed to Admiral Grace Hopper in the 1940s. Hopper was a pioneer of computer programming, inventing the first compiler for any computer programming language. She popularized the idea of machine-independent programming languages, which is what Blockly and BlocklyProp are. While she was working on a Mark II Computer at Harvard University, her associates discovered a moth stuck in a relay and thereby impeding operation, whereupon she remarked that they were "debugging" the system. Debugging is the process of finding and resolving of defects that prevent correct operation of computer software or a system.
Sources (Wikipedia): Debugging [15], and Admiral Grace Hopper [16]
Be creative! Remember that you, as the programmer, are in charge.
In the last tutorial, you tested out a simple S3 driving program. In this tutorial, we will expand our remote control possibilities. By utilizing more buttons for more possible maneuvers you can fine-tune your robot's motion.
Remember that if you haven’t recorded the IR Remote button code for a particular button, take a quick run through the main program in the Test the Receiver and Remote tutorial and write down your results.
The code you’ve written should drive the S3 (or control the LEDs and speaker) using buttons 1 - 9, and 0. The S3 will move (or activate a device) only while a particular button is pressed and should stop when it is released.
The list below reflects which button on your remote controls each motion or device. Note that these button maps are assigned assuming you're using a Parallax Brightstar remote.
Does it work the way you thought it would and does it function properly? If not, do a little “debugging” of your code.
Make sure it works the way you thought it would and functions correctly. Did everything work as you expected? If not, find the errors and correct them.
Up until now, we’ve used the Sony Remote value block to receive signals from the S3 onboard IR receiver. We also learned that IR remotes work in a “line of sight” method - meaning that the Sony remote must face the IR receiver on the front of the S3 robot.
We might resolve this directional limitation by having an IR Sensor that could “see” the remote’s signal from any direction. Luckily, the S3 comes with a hacker port that allows you to easily add external sensors to your S3.
To complete this tutorial, in addition to your S3 and Sony IR Remote, you will need the following supplies:
On a personal note - The first solution that I came up with to overcome the line of sight problem, was to place four (4) IR receivers oriented front, back, left, and right. I wasn’t sure how to wire this circuit, so I sent an email to some Parallax friends. I got back a response almost immediately! My friend Ben (who is actually one of the members of the Parallax Team that designed the S3) sent me the idea of the laying a single sensor (i.e., one (1) sensor) on its back facing straight up. It is the idea shown here and it works well, is less expensive than needing four. That is the way real engineers always try to think!
It also turns out the idea is documented here on Learn in a tutorial for a different robot [17]. Here is a photo of an ActivityBot setup to receive IR remote signals and do some other things too! This is a view of the ActivityBot’s breadboard area with the circuit built. It shows the IR receiver facing straight up, just like we're going to do here.
It always a good idea to “get a little help from your friends!” You’ll learn new things. Asking others or visiting Learn and studying the examples there is a way to get help when you need it.
The infrared receiver needs three connections: 5V, GND, and an I/O pin to read the signal it sends:
The drawing to the left is called a pinout diagram and it shows symbolically where each pin is supposed to connect. The drawing to the right represents the same information in a more 3-dimensional way.
The circuitry inside the S3 makes it safe to connect the infrared receiver's signal pin to your S3's 3.3V Propeller I/O pin without adding a resistor, even though the sensor itself is powered by 5V. In our S3 circuit, this required resistance is built into the hacker port, so we do not need to connect an external one. When using other Propeller boards or chips, you will need to provide the resistor to protect the chip - see below.
When working with sensors, especially unfamiliar ones, always check their datasheets or product guides to make sure you understand how to safely connect them to your microcontroller. A sensor that requires 5V for operation can damage a 3.3V microcontroller like the Propeller if the proper protection is not provided in the circuit. Many Parallax sensors and microcontrollers have datasheets or product guides available on their product pages. Visit the Parallax website [18] and search the product name or number to find them easily.
Note: Be mindful of the IR Receiver's pinout as compared to the pinout of the hacker port. Look at the pin labels for both the receiver and hacker port to be sure they are connected properly before you turn on your robot. The receiver's pins are configured differently than the hacker port's will be.
Here is the pinout diagram of the S3’s Hacker Port, taken from the S3 User Guide included with your Scribbler. (See What's A Hacker Port?) It is the nearest and neatest choice.
If you have multi-colored jumper wires, use a red jumper wire to make the 5V connection, a black jumper wire to make the G (Ground) connection and a white or yellow jumper wire to make the signal to P5 connection. Refer to the hacker port diagram above and the receiver pinout above to be sure you're making the proper connections.
Note: The GND-PWR-SIGNAL arrangement is standard for many Parallax 3-pin sensors, but the pins are oriented differently on the IR Sensor. So again, be mindful of the IR Receiver's pinout as compared to the pinout of the hacker port!
Mount the IR Receiver on the top of the S3, with the receiver's domed side pointing directly up. Use a dot of poster tack putty or double stick tape. The cables can be tied in a loop to keep them out of the way. This makes its small dome visible (remember - direct line of sight) in all directions and from above. The hack is perfect for controlling the S3 with our Sony remote from any direction.
When you have completed this process, carefully check the whole circuit before powering on the S3.
Let’s test our S3’s new external IR receiver and our SONY-programmed remote.
As earlier in the tutorial, you should see the remote button number displayed in the Terminal.
If so, the Hack is successful! If not, turn off your S3 and carefully check everything. Pay particular attention to the how the pins on the external IR sensor are connected with the cable to the pins on the hacker port. Make sure the signal pin, Ground, 5V connections are in proper order. This is another sort of debugging process – debugging the hardware.
It’s pretty nice not having to chase the S3 around - always trying to be in front of it, isn’t it? This ability to add external sensors to your S3 robot is one of its most powerful new features. As you continue to work with the S3, you will likely find many ways to expand on basic programs using the Hacker Port.
Links
[1] http://blockly.parallax.com/blockly/
[2] http://learn.parallax.com/tutorials/robot/scribbler-robot/getting-started-blocklyprop-s3
[3] http://learn.parallax.com/tutorials/robot/scribbler-robot/lights-and-sounds
[4] http://learn.parallax.com/tutorials/robot/scribbler-robot/simple-motion-motors-blocks
[5] http://learn.parallax.com/tutorials/robot/scribbler-robot/navigating-sensors
[6] http://learn.parallax.com/tutorials/robot/scribbler-robot/hacker-port-expansion
[7] https://www.parallax.com/product/020-00001
[8] https://www.parallax.com/product/350-00039
[9] https://www.parallax.com/product/800-00062
[10] http://learn.parallax.com/tutorials/robot/scribbler-robot/navigating-sensors/avoiding-obstacles-infrared
[11] https://en.wikipedia.org/wiki/Remote_control
[12] https://commons.wikimedia.org/wiki/User:Sidik_iz_PTU
[13] http://learn.parallax.com/tutorials/language/propeller-c/propeller-c-simple-devices/ir-receiver-and-remote
[14] https://learn.parallax.com/tutorials/robot/scribbler-robot/getting-started-blocklyprop-s3/using-reset-part-program
[15] https://en.wikipedia.org/wiki/Debugging
[16] https://en.wikipedia.org/wiki/Grace_Hopper
[17] http://learn.parallax.com/tutorials/robot/activitybot/remote-control-rock-talk-and-roll-activitybot
[18] https://www.parallax.com