lecture 5: inter processor communicationscherrygregory13.weebly.com › uploads › 5 › 9 › 2...

16
Lecture 5: InterProcessor Communications ME EN 3200 Mechatronics I Stephen Mascaro Associate Professor Mechanical Engineering

Upload: others

Post on 06-Feb-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

  • Lecture 5: Inter‐Processor CommunicationsME EN 3200  Mechatronics I

    Stephen MascaroAssociate Professor

    Mechanical Engineering

  • Updates

    • Problem Set #1– Due this Friday midnight– Electronic submission only– Dept. gave us a 2nd grader, so we will grade all problems (see grading policy in updated syllabus)

    – Tentative Office Hours: MWF 1‐2pm (except today)• Lab #1 this week

    – Lab Handout is posted on Canvas. Print it out before you come to lab.

    – No pre or post‐lab questions this week. Grade will just be based on participation.

  • Lab Switches

    • Section 002 (Thursday 10:45am‐1:45pm) still has a few spots available.

    • One spot has opened up in Section 006 (Wednesday 11:50 A.M. – 2:50 P.M.) and one spot has opened up in Section 011 (Thursday 6:00 P.M.– 9:00 P.M.). Come up front immediately after class if you would like to move to either of those spots.

    • Reminder: If you need to reschedule a lab, you must make arrangements 2 weeks prior (except for valid emergencies)

  • Help with PS#1

    • Reading spec sheets– Most important specs are found on first page– Pin Diagrams and Schematics can also be helpful– Atmel ATmega128A– Microchip PIC16LF727

    • Example problems with binary math– convert ‐99 to 16‐bit hexadecimal representation (using 2’s complement)

    – What result do you get for (225*2)/5 if values are contained in byte‐sized variables?

  • Hexadecimal Decimal Binary0 0 0000

    1 1 0001

    2 2 0010

    3 3 0011

    4 4 0100

    5 5 0101

    6 6 0110

    7 7 0111

    8 8 1000

    9 9 1001

    A 10 1010

    B 11 1011

    C 12 1100

    D 13 1101

    E 14 1110

    F 15 1111

  • Common Peripherals/Subsystems

    • Serial/Parallel Communications• Digital Input/Outputs• Timers• Pulse Width Modulation (PWM)• Analog‐to‐Digital (A/D) conversion• Interrupts

  • Inter‐processor communication

    Two main approaches

    USB: 4 wires (Tx, Rx, GND, 5V)

    Parallel cable: 25 wires(8‐bit data, GND, 5V, etc.)

  • Serial communication• Data transferred in one stream, so more bits requires more time!• Requires coordination between sender/receiver• Two approaches: (1) synchronous vs. (2) asynchronous

    Uses one line: fall/rise of first bit determines the timing

    1     0    1    0    0   1    0    0    1    0   0

  • Synchronous  Serial Communication• Requires minimum of three lines: 

    – (1) serial data, – (2) clock to synchronize or determine when data is valid, and – (3) ground.

    • Sender is the master (controls the clock) and receiver is the slave

    • Clock idle state – either high or low, depends on the system• Lots of variations to serial protocol (MOSI, SPI, I2C, etc..)

    Data valid on rising edge

  • Asynchronous  Serial Communication• No clock line is used (compared to synchronous)• Typically used in RF or other wireless communication applications where 

    separate clock line is not practical• Two lines: (1) data and (2) ground.  Clock is handled by each side• Requires bit time: agreed upon time duration for each bit (e.g. baud rate)• Data is sent immediately after the “start bit”.  Both sides knows that 

    immediately after the start bit, data is being transferred.

  • Parallel communication

    Data bits

    Control bits

    Very fast process to transfer data, but required many physical connections (lines)!

  • Example: connecting microcontroller to LCD

    Parallel connection between LCD and microcontroller

  • Limited Bandwidth Communications

    • Without a direct wire, communication suffers from limited bandwidth (range of frequencies than can be transmitted)– e.g. telephone, light waves, radio waves

    • Requires use of a modem (Modulator DE‐Modulator)• Modulation techniques typically involve modulating a carrier signal to encode digital information onto it

    Modem Modem

    Data In/Out

    Data In/OutLimited 

    Bandwidth Channel

  • Modulation Techniques

    Amplitude modulation (AM)or ON/OFF Shift Keying (OOSK)

    Frequency modulation (FM)or Frequency Shift Keying (FSK)

    Filters are used to separate out logic 1 or 0. Can superimpose multiple frequencies on same line.

    Other modulation techniques can encode even more information onto signal• Phase Modulation (PM) or Phase Shift Keying (PSK)• Quadrature Amplitude Modulation (QAM) combines AM and PM

  • Communicating with light

    Receiver designed to only lock in on frequency of carrier wave

    • Wireless communication• Requires carrier frequency• Requires line of sight• Cannot penetrate walls

  • RF Communications• In ME EN 3200/3210 we will use the XBee ® for wireless serial communications.• Acts as a wireless modem between two serial ports• Uses a more sophisticated modulation technique (IEEE 802.15.4)• Looks like a “virtual wire” as far as the Arduinos are concerned (just use the Serial 

    library of functions)