Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microchip PIC Networks Amrit Bandy, Ben Funk Neil Goldsman.

Similar presentations


Presentation on theme: "Microchip PIC Networks Amrit Bandy, Ben Funk Neil Goldsman."— Presentation transcript:

1 Microchip PIC Networks Amrit Bandy, Ben Funk Neil Goldsman

2 2-Node Wired Set-up PICs hooked up with wire connections PICs are small micro-controllers made by Microchip Tx μP1μP2 Tx Rx µP: 16F88 by Microchip Features Built in A/D Conversion Module Universal Asynchronous Transmit and Receive using Tx and Rx ports. (Serial communication controlled by programmer)

3 Step 1: Establish Network via Clock Synchronization Node Clock Definition: –Built-in 8-bit timer, counts up from 0 to 255, sets off an interrupt upon overflow. Prescalar of up to 256 available. –Node Clock (our timer) updates every time the interrupt occurs (part of code) Synchronization of Clocks –Node A transmits its NodeClock to Node B while Node B receives it and updates its own NodeClock

4 Timer Synchronization Algorithm Node A: 1.Setup Tx Port for RS232 Transmission and Rx port for RS232 Reception using Universal Asynchronous Reception and Transmission 2.Check for hardware switch-If “on” goto 5 else 3 3.Transmit packet comprising AB in hex (frame sync byte to intelligently qualify data packet to follow), followed by the NodeClock 4.Goto 2 (only one or two iterations needed) 5.Transmit NodeClock value to Real Terminal on Computer and print value on screen. Step 5 is to test the node synchronization

5 Timer Synchronization Algorithm Node B: 1.Setup Tx Port for RS232 Transmission and Rx port for RS232 Reception using Universal Asynchronous Reception and Transmission 2.Check for hardware switch-If “on” goto 7 else 3 3.Receive first byte, if it is not equal to ABh repeat 3. 4.Clear and start NodeClock 5.Receive second byte (clock of node A), add to NodeClock to update NodeClock 6.Goto 2 7.Transmit NodeClock value to Real Terminal on Computer and print value on screen. Step 7 is to test the node synchronization

6 Step 2: Data Transmission After Synchronization Voltages represent sensor node reading Each node compares its own voltage with voltage received from the other node and an LED is lit on the node with the highest voltage Procedure: –Assign PIC_id for each node and COMM_id for the node that is transmitting –Establish Network by synchronizing clocks –Transmission and Reception are carried out in equal slots (TDMA) –Transmitting slot includes reading A/D data and transmitting packet –Reception slot includes receiving packet, comparing voltages of all the nodes, and lighting LED –Update COMM_id to give next node a chance to transmit data

7 Data Transmission Algorithm 1.Synchronize timer to node A 2.If PIC_id=COMM_id goto 3 (transmit) else 7 (receive) 3.Read A/D voltage(10 significant bits) into two 8-bit registers, right justified 4.Transmit packet: ABh, NodeClock, highbyte(data), lowbyte(data) 5.Update COMM_id to allow next node to transmit 6.Wait for slot to expire, goto 2 7.Receive first byte, if it is not equal to ABh goto 7. 8.Clear and start timer 9.Receive second byte, add to NodeClock to update NodeClock 10.Receive highbyte (data) followed by lowbyte (data), and store information for the node which is transmitting 11.Compare voltages for all nodes, light LED if self is highest 12.Update COMM_id, Wait for slot to expire, goto 2

8 Step 3: Extend Wired Setup to 3 nodes Issue: 16F88 has only one Rx port! Solution: Use AND gate to choose correct line, since the transmitting line is high while receiving. TxRx µP1 TxRx µP2 TxRx µP3

9 3-Node Wired Setup Using AND Gates Why AND gates? Transmitting line is high while receiving Truth Table shows that the AND gate reproduces the Tx signal TxRxOut 010 111 Slot1Slot2Slot3 NodeATxRx NodeBRxTxRx NodeCRx Tx

10 Step 4: Remove the Wires – Employ Transceivers Transceiver used: TR-916-SC-P by Linx Technologies TXEN pin to enable Transmit RXEN pin to enable Receive Can only transmit or receive at a time Algorithm remains the same except –Allow enough time for transceiver to start-up –Enable TXEN, disable RXEN for transmit –Enable RXEN, disable TXEN for receive

11 Testing Steps 1-4 Setup: 3 PIC 16F88 microcontrollers connected to potentiometers. Nodes B&C synchronize themselves to Node A, transmit their own voltages, receive that of the others, compare and indicate who is the highest using an LED. Baud Rate: 19.2Kbps Transmit/Receive Slots : 200ms with 20MHz clock Results: Both the wired and the wireless models work for 3 nodes.


Download ppt "Microchip PIC Networks Amrit Bandy, Ben Funk Neil Goldsman."

Similar presentations


Ads by Google