332:428 Communications Capstone Design Spring 2013
Senior Project Final Report Brien Range Daniel Townsend Prince Mingle Wyatt Borden January 30, 2012 Contents 1 Introduction 1 2 Technical Specications 1 2.1 System Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2.2 Modem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.2.1 Level Shifter [1] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.2.2 Modulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2.3 Demodulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.3 Modem API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.3.1 Multiplexing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.3.2 Demultiplexing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.3.3 TDMA: Multiplexing Transmitters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3 Cost Analysis 10 4 Future Work 10 5 Roles of Each Member 11 5.1 Brien . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 5.1.1 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 5.1.2 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 5.2 Dan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 5.3 Prince . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 5.4 Wyatt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 A Equipment Cost 13 1 Introduction The goal of this project was to create a multiple access data network. A two sender-one receiver sys- tem model was implemented by manually constructing three amplitude-shift keying modems with a carrier frequency of 400 kHz and coding a multiplexing scheme in the C programming language. Each node in the data network was a laptop connected to a modem board via an RS232 to USB adapter, allowing serial data to be modulated to the carrier frequency. The goal was to connect the system to a power line to enable low speed data transmission between devices. However, this was not achieved within the allotted time. 2 Technical Specications 2.1 System Overview The structure of the system centers around a single receiver node and multiple transmitter nodes. Each transmitter and receiver node has its own modulator and demodulator. In the receiver, the modulator is used to synchronize the two transmitters, and the demodulator is used to recover the data sent by the transmitters. In each transmitter, the modulator is used to send data to the receiver, and the demodulator is used to receive a timing signal from the receiver. The system was designed with two senders and a single receiver in mind as shown in Fig. 1, but with more resources, the transmitter count could have been increased quite easily. Figure 1: The block diagram representing the system design. The two colored lines in the block diagram represent the timing wire (green) and the data wire (red). Since there was some loading eect being caused by the modulators, attenuating the received data signal, it was decided to separate both the timing and data wires. Each pair of modulators and demodulators are 1 Figure 2: The circuit used to interface the RS232 and TTL logic types of the system [1]. connected to a laptop through a circuit known as the level shifter, that converts TTL voltage levels to RS232 voltage levels. The laptops connected to the transmitters send data to the receiver laptop, and the receiver laptop sends timing signals to the transmitter laptops. Each transmitter has the capability to multiplex with the other laptops as well as multiplex data from individual programs on the laptop. This enables multiple programs or users on each device to access the channel and send information to the receiver. 2.2 Modem Every device in the system is connected to a modem, and each modem consists of three parts. Each of the three parts of the modem level shifter, modulator, and demodulator are outlined and explained in the subsections below. 2.2.1 Level Shifter [1] The level shifter is a circuit used to invert and shift the digital signal coming and going to and from the RS232 ports on the laptops. This is required because the output levels of the RS232 adapter are between 6 V and +6 V, and the required voltages of the designed modulator and demodulator are between 0 V and 5 V. For the level shifter to work both pin 2 and 3 of the RS232 port need to be connected to the circuit, otherwise the required voltage levels can not be achieved. The conversion from RS232 to TTL works by turning the NPN transistor on and o. When the base voltage is high (+6 V at the RS232 transmit), the NPN transistor turns on, which sets the TTL output to ground. When the base voltage is low (6 V at the RS232 transmit), the NPN transistor turns o, which sets the TTL output voltage to 5 V. The conversion from TTL to RS232 relies on the negative voltage supplied by the RS232 receive to 2 Figure 3: The circuit diagram for the modulator circuit. The CD4016 is a CMOS switch which allows analog signals to be sent through based on an input command. be stored inside of a capacitor. When the base of the PNP transistor is low (0 V at the RS232 input), the transistor turns on which allows the 5 V to travel to the RS232 receive. When the base of the PNP transistor is high (+5 V at the RS232 input), the transistor turns o which allows the 6 V inside the capacitor to show up at the RS232 receive. Through these methods the conversion circuit applies a voltage shift and an inversion to the incoming and outgoing signals which suits the needs of our system perfectly. 2.2.2 Modulator The modulator circuit consists of very few components, which perform the modulation of the device quickly and reliably. The main component in this setup is the CD4016 CMOS Bilateral Switch. The CD4016 integrated circuit has four separate switches. Each switch has an input, an output, and a control. When pin 13 is high, pin 1 is connected to pin 2, and when pin 5 is high, pin 3 is connected to pin 4. To ensure that either the connection between pins 1 and 2 or the connection between pins 3 and 4 are shorted at all time, and neither are shorted at the same time, the data signal is sent to pin 5 and an inverted data signal is sent to pin 13 . Since pins 2 and 4 are connected, a high voltage will produce a zero volt output, and a low voltage will produce a 400 kHz sine wave. Through this switching an OOK signal is generated. The last stage of the modulator is the amplication circuit. This is simply an inverting operational amplier gain circuit which gives a theoretical gain of 30. In practice, this gain circuit does not produce a gain of 30, because the operational amplier has a frequency response of its own and attenuated our OOK signal.. 3 Figure 4: The circuit diagram and block diagram for the demodulator circuit. 2.2.3 Demodulator The demodulator circuit consists of several steps, each outlined in the diagram shown in Fig. 4. The rst stage of the demodulator is the high pass lter. This circuit was originally designed to lter a second frequency in a FSK modulation scheme; however, it proved useful to lter out low frequency noise from the channel. A majority of the channel noise was focused around low frequencies around 100 kHz. The second stage of the demodulator is necessary because although the LF347N Operational Amplier advertises a bandwidth of 4 MHz, it actually attenuates frequencies above 300 kHz. Therefore the OOK signal needs to be amplied again, which is why the second stage is present. The third stage of the demodulator is a very important step in demodulation. This stage takes the ltered OOK signal and recovers the outline of the signal, meaning where the amplitude of the OOK signal is high, the output is high, and then the amplitude of the OOK signal is low, the output is low. This is accomplished by using a diode connected to a RC circuit whose time constant is designed so that the output does not return to zero during a high. A sample input output reading for this stage is shown in Fig. 5. The fourth stage of the demodulator takes the noisy envelope detected in the previous section and creates a more square like shape for the nal stages of the receiver which is also at the required TTL voltage levels (0 V to 5 V). This device is known as a Schmitt Trigger. The schmitt trigger consists of a comparator, a voltage divider, a feedback resistor, and a pull up resistor. The comparator inputs are the envelope detector output (at the negative terminal), and the voltage divider which provides the reference voltage (at the positive terminal). The feedback resistor provides hysteresis by 4 Figure 5: A sample of the waveform before the envelope detector (yellow) and after the envelope detector (blue). The data rate of the system is 58600 baud/s in this oscilloscope screenshot actually changing the reference voltage. The pull up resistor allows the output to be set to 5 V when the collector inside the comparator is open. 2.3 Modem API 2.3.1 Multiplexing Data Program Access to Modem The system is capable of multiplexing up to 5 separate applications at one time. Each application is manually assigned one of ve names, null, audio, messaging, misc1, and misc2. These application channels dier only in these application strings and the headers assigned to them; in other words, there is no require- ment that only audio applications be sent over the audio channels. These applications use only two functions to interact with the system: modem read() and modem write(). No other functions are transparent to the user applications. The function modem read() allows the user application to read from a shared buer, and modem write() allows the user application to write to a shared buer. 5 Figure 6: The separation of individual programs within a computer and how they access the data buer. Modem Object A modem client was created to manage requests to send data over the modem. Upon initialization of the modem object, two static buers are created for each application. One is created to maintain data to be sent to the modem, and the other is created to maintain data to be received from the modem. These buers persist whether the applications tied to them are running or not. Figure 7: Flow Chart for how senders transmit data. 6 Figure 8: Packet sent over serial port After initialization, two software threads are started: one to monitor the modems serial port for received data, and another to monitor the transmit buers for data ready to be sent over the serial ports transmit line. Multiplexing and Transmitting Data The modem object monitors the ve transmit buers in a round robin, using the function RR read write(). If there is data for the current application, and that data is greater than seven bytes, the algorithm to package the data is initiated. Otherwise, the next application is checked. Each application name has a corresponding header associated with it. This header is prepended to the seven bytes, and the completed packet is then transmitted over the serial port. At the serial port level, a standard baud of 57600 was chosen. At the next standard baud, 112500, there was signicant data loss over the modulated channel. Because the same serial port is used for both transmit and receive directions, this baud pertains to both. 2.3.2 Demultiplexing Data Receiving and Demultiplexing Data The modem polls for any data written to the serial port from the demodulator and writes it to a large temporary buer. It then reads bytes from the buer, and if a header has not yet been read from the buer, these bytes are then discarded. If the byte read is one of the ve headers, then the header byte is stripped away, and any subsequent bytes are written to the shared read buer that has the application that corresponds to the acquired header. Figure 9: Bitsream read from serial port In a separate user process, the user applications can read from these shared read buers using the function modem read(). 7 Figure 10: Program Data Demultiplexing 2.3.3 TDMA: Multiplexing Transmitters This system has 2 transmitters and 1 receiver sending data at a carrier frequency of 400KHz. In this scheme, the algorithm that is being used allows for data to be sent for the duration of a slot that lasts T seconds. A buer time u, a function of serial baud rate, exists such that u << T. This u exists to guard from collisions between one round and the next. Prior to the setup of our transmitters, Sender 1 and Sender 2 will be allocated a slot N, where N is either 0 or 1. The single receiver is master controlling node, sending a timing pulse to the two transmitters. The transmitters will wait for a jamming signal from the receiver with a length of a byte before either sender begins any transmission. However, each sender will be transmitting at a dierent slot. Sender 1 will rst send from t 1 = u t 1 = T u. Sender 2 will then send from t 2 = T +u t 2 = T +T u. Sender 1 and 2 will then transmit again for another round, for M rounds. Such that t M N = t M1 N + 2T. Below is the formula in general form. (2M +N) +u < t M N < (2M +N + 1) T u After the specied M rounds, the transmitters will wait for another timing signal. As the original intent of the system was to transmit voice data, it was decided to not have any type of packet acknowledgement. This choice greatly simplies data transmission, and allows for much higher data rates than a system with packet acknowledgement. 8 Figure 11: The timing diagram of how two devices access the single channel. 9 Figure 12: Multiplexed Signals from Sender 0 and Sender 1 3 Cost Analysis The parts listed in the appendix below ranged from several ampliers, resistors, capacitors which all together cost $49. The competion price is typically $130 per node for a wireless sensor network which means that our system will be cheaper to implement [2]. Based upon electronic markups being normally 80% of total cost, the price of $49 that we paid would actually cost $9.80 (20% of 55dollars). If we were to manufacture this project, we would have it on one printed circuit board that would consist of all of the parts in the Appendix below with the exception of the RS232 cable. If we were to obtain a prototype from an external vendor such as Silvers circuits, the cost for a prototype would be $75 [3]. However, given that the markup cost is 9.80, we would either attempt to do it ourselves or nd a cheaper alternative. 4 Future Work Currently the implementation relies on the labs power supplies to create the supply voltages for the ampliers and ICs. It also relies on the labs function generators to supply the 400kHz signal. A shippable product would require a DC power supply which gives the 5V used by the logic circuits and the 20 V used by the ampliers. The project would also require its own 400 kHz oscillators circuits. Each modem requires dierent physical channels for their transmit and receives lines, as the group was unable to solve the loading problem as discussed in the System Overview section. By properly increasing the impedances of the modulators, they will not draw as much current away from the demodulators. Then, the signal will be strong enough to recover data. Some applications may have dierent quality of service requirements than others. Neither guaranteed 10 bit rate nor timeliness were considered during the implementation. However, both should be considered if or when this project is visited once more.. If another device is added to the network, the code to accommodate a new transmitter must be added manually. A better product will sense a new modem on the network and adjust accordingly. During initialization, the device can request serial numbers from any connectected members from some time period, and then respond with a maximum N value (as described in the TDMA section) and a specic N value for each serial number. The large buer time of 28, 612 s greatly reduced the data rate achieved (24.6kbps), but given the time constraints, it was quickest way to ensure there were no collisions. A better implementation would have a smaller buer time and less rounds between time signals to ensure no drifting. Another aspect to view for future work is the applications that would be valuable to use a power line sensor network. For example, this network could work in conjunction with a wireless sensor network to help detect unwanted presence as used in home and oce security systems. 5 Roles of Each Member 5.1 Brien 5.1.1 Hardware I designed the original BPSK modulator circuit that Dan Townsend modied to suit our OOK imple- mentation. I also designed the level shifter circuit that translated voltages between the RS232 logic and the CMOS logic. 5.1.2 Software I created the RS232 interface that would directly communicate with the modem. I designed and imple- mented the Modem API that allowed the multiple programs to interface with the modem concurrently. I also designed and implemented the networks TDMA scheme. Although audio was eventually dropped from the project, I implemented and tested mu-law compression software. 5.2 Dan I designed the demodulator portion of the modem. I worked closely with Prince in the lab to actually create the hardware used. I came up with a compact layout for each component on the breadboard so all three components could t on a single breadboard. I breadboarded the three individual modems. I worked on many Multisim simulations for the project including a simulation of the now defunct FSK modem and wall adapter. 11 5.3 Prince I was in charge of constructing the modulator that we used to supplement the demodulator that was being built by Dan. When using both components together, it eventually will be known as the modem. While working closely with Dan on guring out design layouts to place on the breadboard, this portion of the modem was built to convert the data that was coming out from the RS-232 cable, which is connected to a sender node, into a digital output that would be sent over to the demodulator for it to be converted back into an RS-232 signal at the receiver node. I also built the wall adapters, and worked with Dan on an attempt to measure and observe the noise characteristics within the walls of the EE building. The purpose of that was to gain an understanding of how the randomness of the noise through the wires that run within the walls of the building would aect our ability to get data sent over the powerlines as we originally intended for this project. Unfortunately, this attempt was not successful and with time constraints we were never able to understand why. 5.4 Wyatt When this project originally started, my role was to get a sampled audio signal connected to the modem. The original plan was to use a raspberry pi along with a Gobbler Pi Kit and ADC chip to produced a digitized signal that was sampled at 10 khz. However, it was evident based upon the microphone purchased that it had a sampling rate of 8 kHz which satisfy the Nyquist Criterion.. However, due to time constraints, the audio was not successfully implemented and I spent the remainder of the time helping with the RS-232 connections from the laptops to the transmitters. 12 A Equipment Cost Part Name Quantity Cost per Unit Total Cost Sabrent CB-RS232 1 13.10 13.10 IN3904 NPN Transistor 1 0.05 0.05 IN3906 PNP Transistor 1 0.05 0.05 IN4148 Diode 1 0.75 0.75 IN914 Diode 1 0.75 0.75 LF347N JFET Operational Amplier 2 2.00 4.00 CD4016 CMOS Quad Bilateral Switch 1 0.30 0.30 LM7404 Hex Inverter 1 0.85 0.85 LM 393 Dual Dierential Comparators 1 0.20 0.20 82 pF Capacitor 5 0.30 1.50 10uF Capacitor 1 0.25 0.25 1 Kohm Resistor 8 0.40 3.20 6.2 Kohm Resistor 2 0.40 0.80 6.8 Kohm Resistor 2 0.40 0.80 8.2 Kohm Resistor 2 0.40 0.80 12 Kohm Resistor 1 0.40 0.40 30 Kohm Resistor 1 0.40 0.40 39 Kohm Resistor 2 0.40 0.80 Total 29.00 13 References [1] TTL to RS232 Adaptor Explained. Hobby Microcontrollers and Electronics. (mu)C Hobby, n.d. Web. 01 May 2013. <http://www.uchobby.com/index.php/2007/06/11/ttl-to-rs232-adaptor-explained/> [2] Beigl, Michael, Albert Krohn, Till Riedel, Tobias Zimmer, and Christian Decker. Parts: Low Cost Sensor Networks at Scale. Karlsruher Institute of Technology,Web. <http://www.teco.edu/ ~ cdecker/ pub/beigl-uparts.pdf> [3] <http://www.custompcb.com/> 14