MEAM.Design - MEAM 247 - P1P2: Morse and Servos



Project 1, Part 2: Morse and Servos
(due by 2:00 p.m. on Monday, 9/26)

To be completed by Monday the 26th, these exercises should provide additional experience with Matlab, and introduce you to the Phidget servo controller. While you can work together, it is vital that everyone understands the concepts! PLEASE read through all of the steps before you begin. You will be submitting Matlab code via email for this exercise, so please follow the instructions below.


1.1 - Encoding Morse

1.1.1 - Create a Matlab script to read in a plaintext message from the keyboard and output the message via Morse code on an LED connected to a digital output. To get user-generated text into Matlab, you may find some useful commands in the Matlab section of the wiki. To aid in the conversion process, we've made a custom function which will return an array of Morse-code related numbers (we'll call this 0123 code) when you pass in a plaintext string - you can download and extract the Matlab function from here (the instructions at the top of the function should explain how to use it). The fundamental period of your output signal (the DIT length) should be between 0.1 and 0.5 seconds (hint - it would be best if you can make this a variable at the top of your script so that you can change it at will!). You may want to see Morse Code on Wikipedia for more information on Morse Code standards.

1.1.2 - Once your script works, re-name your file as morse_PennKey.m (where "PennKey" is your school email address before the @ sign), and attach it to an email to medesign@seas.upenn.edu entitled 247-L1-Morse. This must be received by 2:00 p.m. on Monday, September 26th for review. If your script is non-functional, you should be sure to include additional comments in your code to explain what you think is wrong.


1.2 - Decoding (BONUS)

1.2.1 - Replace the visible LED with an IR LED (the LTE-4206 from the ministore in the GM lab will do just fine), and use your phone (though not an iPhone 4) or other inexpensive camera to verify that it is still outputting morse code.

1.2.2 - Grab a second Phidget (provided there are extras), and connect a phototransistor to an analog input. Pre-soldered phototransistors (complete with an appropriately-sized gain resistor and a Phidget analog connector) can be found on the shelves of Towne 205. Connect the sensor to one of the analog inputs, and now you should be able use getAIN(channel); to monitor the voltage from this sensor. Experiment with this in conjunction with the output from the IR LED, and see how the getAIN value changes when the IR lED is on and off.

1.2.3 - Now, decode the incoming IR signal. You will need to read in the analog value from the Phidget, parse the signal to look for changes in the phototransistor voltage, convert those changes into Morse code, and finally convert from Morse code into plaintext. To spare you a couple hours of coding, we are providing a function that takes in 0123 code and returns plaintext here.

1.2.4 - If you get something that works, use the same method as you did for the encoding to submit your Matlab script, only now name your file as decode_PennKey.m and title the email as 247-L1-Decode. Oh, and good luck.


1.3 - Servo Power

Alongside with the Phidget IK boards, you should see a number of the servo-motor control boards shown below:

Shown above are the Phidget 1066 (single motor) and 1061 (eight motor) Advanced Servo controllers (the manuals for the boards can be found here: 1066 Manual, 1061 Manual, and if you want to run this on a computer outside of the GM or Towne 205 labs, you'll need the drivers from here, unless you've already installed them for the Interface Kit 8/8/8).

1.3.1 - To start using either of these servo controllers, you'll need to download and extract this zip file, which contains the low-level code that Matlab will use to communicate with the Phidget servo controller board over the USB port. Once you've extracted this somewhere, create a new Matlab script in the resulting folder (this can be the same folder as used for the IK). Within the script, you can use the following commands to interact with the Phidget board:

servoConnect; - Initialize the servo controller (you must do this first - note that the board must be connected to the computer before you execute this script)
servoRelease; - release the servo controller (you MUST do this when you're done with the board)
servoRun(channel); - enable the output for a particular servo channel
servoPause(channel); - disable the output for a particular servo channel (default)
servoTarget(channel,position); - set the target position for a particular servo channel. Position can be anywhere between -22 and 233.
servoCurrent(channel); - receive an analog value corresponding to the current draw for a particular servo channel (we believe this is in Amps).

1.3.2 - Retrieve a servo motor from the shelves at the front of Towne 205, examine the board to see which way the plug should be oriented, connect the servo cable to the servo control board, and if you are using the 8-motor board, ensure that the power cord is attached to the board.

1.3.3 - Write a Matlab script to rotate the servo output in a sinusoidal pattern at a frequency of approximately 0.2 Hertz. You may find that the servo struggles near the limits. To avoid these issues, decrease the amplitude, and set your min and max well away from the limits (min=45, max=135 seems to work well).

1.3.4 - Once your script works, re-name your file as sine_PennKey.m (where "PennKey" is your school email address before the @ sign), and attach it to an email to medesign@seas.upenn.edu entitled 247-L1-Sine. This must be received by 2:00 p.m. on Monday, September 26th for review. If your script is non-functional, you should be sure to include additional comments in your code to explain what you think is wrong.



1.4 - Teams

1.4.1 - For Part 3 of the project, you will need to work in a team of three. If you would like to choose who you will be working with, add your names here before 2:00 p.m. on Monday, September 26th. Those not listed on the page by the deadline will be randomly assigned.