COSC 422/COSC 524 - Introduction to Microprocessors
Winter 2020
ID 24718/24720
PH 503 10:00-11:50am

Instructor: Dr. William Sverdlik
Office: 512 Something_or_other Pray-Harrold

Office Hours: (tentative)
MW 9:00-9:50,
MW 12:00-2:00,
W 4:30-5:30
Phone: 734-487-7081
e-mail: wsverdlik@emich.edu

Meeting Times: MW   503PH  10:00-11:50am

Textbook: No book to buy!! All material will be available from the Internet. 

Hardware: There is hardware to purchase. I have already emailed you about purchasing about $12 worth of electrical items from Amazon.
Additionally, you will need to purchase a robotics kit from Tinkertech. This is a Maker's Space on MIchigan Ave. in Yp[silanti. We will be spending some time there.

The TinkerTech robot will cost you about $90. The $90 plus your lab fee will also get you a one month membership at the Maker's Space and will also include training and
check-out on the laser cutter.

Format:
   
There will be one examination (Monday March 16)  (changed to Wednesday March 18)  a major programming project (broken up into smaller parts), and some "extra" work, plus surprise quizzes.
    - Examination: are open book, open notes. It is worth 100 points.
    - Quizzes (announced) Jan 27 and Feb. 17 . Open book and worth 50 points each
    - Quizzes  (unannounced) , and assorted assignments:  Probably about 5. Each worth 5 points. Here's a hint: if I say "try this", "do this", or "figure this out", there is a good chance I will quiz you on it.
  
    - Programming Assignments:
There will be 7 programming assignments. These are generally cumulative, that is, you must complete one before proceeding as they build upon each other. The firat 5 assignments are "solo" projects, the last 2 are team projects.
The end result is a remote controlled robot. Each programming assignment is worth 25 points.

The assignments (given in more detail below):
1) Flash an LED at 38 khz
2) Flash an LED on/off at 38khz for 1 millisecond intervals
3) Bit bash 3 bits. Hardwired processor to processor
4) Bit bash 3 bits with IR LED and IR receiver. Interrupt driven receiver.
5) Bit bash 3 bits. Transmitter uses keypad
6) Move robot forward for 2 feet, turn left, go forward 2 feet, turn right, go reverse 2 feet
7) Remote controlled robot (combine programs 5 and 6)


Extra Stuff : (probably working alone
) from time to time, I may approach you and give you some unknown piece of electronics. You will be given approximately 1 week to explain and demo this to class.  
Final Exam : Monday April 27 9:30-11:00. Comprehensive . 100 points

Total points=500

Approximate Grading Scale:
    450-500    A
    400-450    B
    325-400    C
    250-325    D
    <250         E

Important Dates This Semester
Jan. 6 - classes begin
Jan 20 - MLK Day (no classes)
Feb 24 - March 1 Winter Recess (no class)
March 11 - March 19 (changed! March 16-19) Bill is not here ( But Fear NOT! You will have class, including lectures and an exam)
April 20 - Last Day of Classes
April 27 - Your Final Exam

Cheating: It violates University policy, you know....so don't do it. Cheating is defined as representing all or part of someones elses work as your own. While you are certainly encouraged to seek the advice of others in this class on assignments, the work you hand in should represent your own efforts. Violation of this rule will be dealt with according to University policy. If you are really stuck on a problem, come see the instructor!


What will happen in this class:
You will build and program a remote controlled robot. You will need to build both the robot and the remote control. Both require programming.

REFERENCES (I keep these open whenever I'm programming)

Skeleton Program (please note: all programs need to follow this format. In fact, you should **copy** this to start all programs)

Instruction Set References and defined constants




xxx
aaa



Full Instruction Set Reference
Data Sheet for PIC 16F62X


SOFTWARE
Burner Software
MPLAB IDE - GUI for programming chip (new version)
Older versions of MPLAB (scroll down to MPLAB IDE archives. I like versions in the 8's)
Parallax Propscope download
Parallax Oscilliscope download


Helpful (???) Videos


A Simple Introduction to Breadboards

MPLAB X IDE (the newer version of MPLAB) - how to generate a hex file from source

Video on Timing Loops (uploaded January 19,2017    length: 26:54)
Source code to go with video



Programming Assignment #1 (Due: Wednesday January 22)- Flash an LED at 38kHz
Programming Assignment #2 (Due: Wednesday January 29)- Flash LED at 38kHz for 1 millisecond, off for 1 millisecond
                                                             
Homework 1 (not to hand in, but I will assume you know this)
Homework 2 (not to hand in, but.....you know the rest)

Programming Assignment #3 (Due: Wednesday  February 12) - Bit Banging

Homework 3 ( another quiz coming soon)

Sample I/O using Interrupts
Using the membrane keypad (you need this for project 4)

Programming Assignment #4 (Due: Wednesday March 4). Here's the assignment: redo assignment number 3 but use the IR LED and IR receiver I provided to you. This assigment MUST use interrupts. Specifically, on the receiver side, the IR receiver signal pin should be connected to pin B0. Recall, with no flashing LED this signal is HIGH. So an interrupt should occur on a HIGH-TO-LOW transition (that is to say, when the IR starts flashing).

Programming Assignment #5 (Due: Wednesday March 25). Here's the assignment: redo assignment number 4 but use a membrane keypad
that I will provide. Since you are transmitting 3 bits, the keys 0 thru 7 should be valid for transmisssion.

Assignment #6 (to be completed before your exam on March 16): watch video and do problems!

Some references forTimer0:
Timer0 reference 1
Timer 0 reference 2 (Microchip tutorial 1 Timer0)
Timer 0 Reference 3 (Microchip tutorial 2 on Timer0 interrupts)


Programming Assignments for the Rest of the Semester




------------------Old Class Below. Everything above is new and OK!! -----------------------------------------------


Programming Assignment #3 (Due Monday February 13) - Bit Banging
Programming Assignment #4 (Due Wednesday February 15) - Remote control robot !! Work in pairs. Robot
                   normally moves forward. When it detects 38kHz infrared LED, it stops. Remoce the LED and it                     moves again

Wednesday March 1 and Monday March 6 - Presentations of interrupts and timers

Programming Assignment #5 (Due: March 22,2017) Robot programming :
          a) Motor Control (Pulse Width Modulation) is controlled via timer interrupts. Timer is set to "low"                     time (20 milliseconds) and interrupt handler pulses motors high
          b) An external sensor, for now we use the robot antennaes, is hardwired to an interrupt line (line B0) and handled when triggered. Normally, the robot moves forward (see part a). When the antennaes are "triggered", the robot should move in reverse for 2 seconds and turn either left or right 30%. Then the normal program should take over (move forward).

Exam! Yes, we need to have one. Do you know the basic commands ? Can you poll a line, Can you write a timer loop ? We will have an examination on Wednesday March 29. You may bring nay printed material you like for reference; no computer access permitted.

Programming Assignment #6 (Wednesday April 10, 2017) - mystery sensor ?????



Links:


Powerpoint
USART Transmitter
USART Receiver
USART doc


Sample timer code

Harvard Architecture (wikipedia)

PICs!!!!
    Microchip - home of the PIC
    Data Sheet for the PIC 16F627/8

    PIC Training Videos!! Homework - watch them now!!
            My Notes on Video 1
   
Tutorials:
    Some quick and dirty assembler issues
    Nigel's Page   

Sample Code
Skeleton Program
Language Tutorial
IO Example 1
IO Example with interrupts
Using FSR and INDF
    Watch Dog Timer (WDT)
   Timed Delays
    Seven Segment Display Documentation
    Seven Segment Display Code
   Code (c code) for reading an ADC0831 A/D converter
    Pulse Width Modulation (PWM) and Servo Motors
    Analog/Digital (A/D) Conversion and Serial Peripheral Interface (SPI)



Other Topics:
    SPI - Serial Peripheral Interface (wikipedia)
    II-C Protocol (I squared C)



The following is from an old class. Just use it as a reference; we'll update as the class progresses

What to do (this is informal at this point)
    Week 1 - watch all the PIC Training Videos
            To Do; some elementary electronics
    Week 2 - start reading the tutorials. You should read thru the first 7 lessons of "You should work thru this one"
            To Do: how to use programmer, oscilliscope,
    Week 3 - finish up the rest of the tutorials and start reading Nigel's Page tutorials
            To Do: analyze timing loops
    Week 4 - serial communication, bit bashing
    Week 5 - A/D conversion, Serial Peripheral Interface(SPI)
    Week 6 - Pulse Width Modulation (PWM)
    Week 7 - Interrupts
    Week 8 - putting it all together - PWM, SPI, A/D

Tentative Dates (Winter 2014 - dates good up to 4/14/2014) :
Wednesday Januray 29, 2014 - Homework 1 due
Wednesday  February 5, 2014 - Program 1 due (flash and LED)
Wednesday February 17, 2014 - Program 2 due (7 segment LED and bit bashing)
Wednesday March 5, 2014 - Midterm Exam . Study Guide here  and here .
Monday March 10, 2014 - Program 3 (the dancing robot)

Final Project - Initial Ideas (nothing to do yet, but start thinking)

Wednesday March 13, 2014 - One page write up and presentation of your final project idea

Graduate Student Presentations

March 31 - Grad Student Presentation 1
April 2 - Grad Student Presentation 2
April 7 - Grad Student Presentation 3
April 14 - Exam 2


-----------------------------------------------------------------------------------