Group 11 Final Report April, 2005 Table of Contents Table of Contents ................................................................................................................... 1 List of Figures ......................................................................................................................... 3 List of Tables ........................................................................................................................... 3 Project Overview .................................................................................................................... 4 Design Problem .................................................................................................................. 4 System Overview ............................................................................................................... 4 Division of Tasks ................................................................................................................ 5 Smart Sensor System Design .............................................................................................. 6 Introduction.......................................................................................................................... 6 Wind Speed ......................................................................................................................... 7 Wind Direction..................................................................................................................... 8 System Microcontroller ........................................................................................................ 10 Selection ............................................................................................................................ 10 Features ............................................................................................................................. 10 Processing Software ............................................................................................................ 11 Overview ............................................................................................................................ 11 Power-up and Initialization.............................................................................................. 11 Configuration ..................................................................................................................... 12 Sampling ............................................................................................................................ 13 Output Data ....................................................................................................................... 14 Output Hardware .................................................................................................................. 16 RS-232 ............................................................................................................................... 16 RS-485 ............................................................................................................................... 17 RC1090 .............................................................................................................................. 18 Output Software.................................................................................................................... 20 RC1090 Configuration ..................................................................................................... 20 PCB ........................................................................................................................................ 23 The Design of the Printed Circuit Board ....................................................................... 23 Designing Footprints ........................................................................................................ 23 Board Dimensions ............................................................................................................ 23 Placement of the Components ....................................................................................... 24 Routing the Traces ........................................................................................................... 25 Manufacturing of the PCB ............................................................................................... 26 Wireless Transceiver PCB .............................................................................................. 26 Troubleshooting ................................................................................................................ 27 Recommendations ........................................................................................................... 27 References ........................................................................................................................ 27 Appendices............................................................................................................................ 28 Appendix A Schematic .................................................................................................... 28 Appendix B - PCB ............................................................................................................ 29 Appendix C - Data Sheets .............................................................................................. 30 Appendix D - Bill of Materials ......................................................................................... 31 Appendix E – Source Code ............................................................................................ 32 Pg. 2 List of Figures Figure 1. Overall System Block Diagram Figure 2. Detailed layout of the RM Young 05103[1] Figure 3. Wind speed circuit implementation Figure 4. Wind direction circuit implementation with dead band compensation Figure 5. ICL3221 External Circuitry and Interface[3] Figure 6. ISL83485 External Circuitry and Interface Figure 7. Connection to host MCU or RS232/422/485 drivers Figure 8. footprint layout of ICL3221 Figure 9. PCB Dimensions Figure 10. Fixed Location Parts Figure 11. PCB layout of top side Figure 12. PCB layout of bottom side Figure 13. PCB being etched at Camosun College 6 7 8 9 17 18 19 23 24 24 25 25 26 List of Tables Table 1. Project Tasks ............................................................................................................... 5 Table 2 Required Capacitor Values[2] .................................................................................. 16 Table 3. Basic Parameters ....................................................................................................... 19 Table 4. List of Configuration data for the smart sensor ........................................................ 21 Table 5. Procedures for Configuration.................................................................................... 22 Pg. 3 Project Overview Design Problem A portion of this design problem hinges on some research that needs to be completed on the RM Young 05103 wind sensor. This research will determine whether or not the wind sensor will be able to charge a battery when not acquisitioning data. If the charging power proves to be adequate then a transceiver will be added (PartB) to the initial design to provide a completely wireless sensor. The initial design problem (PartA), which is to create a smart sensor is detailed as follows: Operating input voltage is to be between 5 and 17 volts. The operating current will be less than 10mA. Package size is to fit within 2”x1”x1.2” area. Minimum input sampling rate is to be 10 Hz. Unprocessed data output is selectable from 1 to 10 Hz. Processed data output is selectable with averaging interval, averaging duration and data rate. Serial data rate is selectable from 1200 to 115kB/s. The target cost per unit is less than $25/unit. System Overview A PIC 16F88 microcontroller will be used for the overall control of: Hardware interface translating of aquisitioned data serial i/o to hardwired and wireless transceivers The aquisitioned data will come from the RM Young 05103 wind sensor, which produces both wind speed and direction. The serial i/o can be set via a jumper to choose either a hardwired connection or a wireless connection. This serial link will enable the user to select different output rates and protocols for transmission. Pg. 4 Division of Tasks Table 1. Project Tasks Shawn Derek Robert Jonathan Part Research RS232 RS485 Transceiver Microcontroller Wind Sensor Hardware Design Wind Sensor Interface Serial Interface Transceiver Interface Schematic Design Smart Sensor Transceiver Hardware Testing PCB Design Smart Sensor Transceiver PCB Implementation Smart Sensor Transceiver Software Design Sampling Functions Control Functions Data Processing Software Testing Documentation Progress Report#1 Progress Report#2 Final Report Poster Design Website Design Pg. 5 Smart Sensor System Design Introduction The entire system is based around a PIC16f88 from Microchip which aquires data from the wind sensor. Wind speed is measured via counting the rising edge of a square wave. This signal is originally a generated AC waveform from the sensor that has been conditioned through the use of an opamp. The WindSensor has a internal potentiometer that outputs a varying voltage depending on its position. This voltage is applied to the PICs A/D converter and the corresponding wind direction is determined. Communication is achievable via three ways. RS-232 RS-485 Wireless Each mode is controlled via an enable, which allows each device to be shutdown when not being used. The overall circuit schematic is seen in Appendix A. A block diagram of the circuit is seen in figure 1 below. Figure 1. Overall System Block Diagram Pg. 6 Wind Sensor To acquire the wind characteristics an RM Young Model 05103 wind sensor was chosen. A detailed layout of the RM Young 05103 is shown in Figure 2. This wind sensor is a high performance wind monitor that measures and records horizontal wind speed and wind direction. It contains four blades that produces an AC sine wave voltage signal with frequency directly proportional to wind speed. The wind sensor It also operates over a wide temperature range and is protected from high voltage transients. Figure 2. Detailed layout of the RM Young 05103[1] Wind Speed The propeller rotation of the RM Young 05103 produces an AC sine wave signal with frequency proportional to wind speed. This AC signal is induced in a stationary coil by a six-pole magnet mounted on the propeller shaft. Three complete sine wave cycles are produced for each propeller revolution. Conditioning of this AC signal must be done to produce a signal that can be easily converted to a digital signal. The generated AC sine wave is fed into the input of an operational amplifier(fig 2.) to produce a square wave with the same period and therefore still proportional to the wind speed. The period of the square wave can be calculated from the onboard asynchronous timer of the processor (PIC16F88). The period is measured from the number clock pulses of the oscillator between two consecutively rising edges of the square wave. The number of clock pulses and the frequency of the oscillator are Pg. 7 used to calculate the precise wind speed. The wind speed can be determined from the following formulas. Figure 3. Wind speed circuit implementation WIND SPEED vs PROPELLER RPM m/s = 0.00490 x rpm knots = 0.00952 x rpm mph = 0.01096 x rpm km/h = 0.01764 x rpm WIND SPEED vs OUTPUT FREQUENCY m/s = 0.0980 x Hz knots = 0.1904 x Hz mph = 0.2192 x Hz km/h = 0.3528 x Hz Wind Direction The RM Young 05103 transmits the wind direction by a 10k plastic potentiometer, which requires a regulated excitation voltage of 3.3 volts. With a constant voltage applied to the potentiometer, the output signal is an analog voltage directly proportional to wind direction angle. It is important to note that, while the sensor mechanically rotates through 360°, the full scale electrical signal only rotates through 355°. Therefore external signal conditioning electronics must be placed accordingly. When the potentiometer wiper is in the 5° deadband region, the output signal is floating and may show varying or unpredictable values. To prevent these false readings, the potentiometer was placed across an operational amplifier as a feedback resistor. One side of the pot was connected to output of the op-amp and the wiper was connected to the negative input of the op-amp. As the potentiometer enters the deadband region, then the op-amp goes open-loop and the output voltage goes to the railing voltage (3.3V). The output voltage is then fed into Pg. 8 another op-amp with negative unity gain to invert the voltage to a positive signal. The signal conditioning electronics are shown in Figure 4. The analog voltage corresponding to the wind direction now varies between 0V and 3.3V without a deadband. This analog voltage is converted into digital data using the 10 bit analogto-digital converter (ADC) of the processor. Figure 4. Wind direction circuit implementation with dead band compensation WIND DIRECTION vs VOLTAGE 0° = 0V 355° = 3.3V x (355°/360°) = 3.25417 360° = 3.3V WIND DIRECTION vs VOLTAGE 0° = 0V 355° = 1.65V x (355°/360°) = 1.62708 360° = 1.65V Pg. 9 System Microcontroller Selection During research for which type of microcontroller to use for the project, the PIC16F88 presented itself with many of the features required; low power, small in size, asynchronous timer - to name a few. The 16F88 belongs to the ‘Mid-Range’ level microcontroller family manufactured by Microchip Technology Inc and is widely available and relatively low priced. Because the project sponsor had specified a preference for PIC microcontrollers, the decision to choose the 16F88 as the processing core of the project was an easy one. Features The microcontroller, being at the heart of the data acquisition system, has to perform several different tasks. It has to acquire two separate forms of data; a linear voltage scale for direction and a linear frequency scale for speed. It also has to transmit its data, accept incoming configuration data, and all the while limit the power consumption of itself and the rest of the circuit. Due to the fact that it was uncertain how much power the BSS project group could provide, the overriding requirement of the sensor design was that it be low power. Indeed, low power operation is always a responsible goal, but in this situation it was a key element. The PIC 16F88 is among a group of Microchip microcontrollers which sell under the ‘nano-Watt Technology’ badge. Integral to the PIC’s miserly power consumption is its ability to enter ‘sleep’ mode. In this mode, the oscillator driver is turned off and under ideal conditions the PIC will draw around 100 nA. The 16F88 provides several options to prompt a wake up from sleep, but in order to provide a configurable periodic sleep cycle, this particular PIC has a separate prescaler for its watchdog timer, ideal for handling the sample rate range specified by the sponsor. In order to read the linearly changing voltage scale (representing direction) provided by the op-amp circuitry, the PIC 16F88 has an onboard 10-bit Analog to Digital converter (A/D). The PIC is quite generous with the number of analog pin configurations available, however only one active input is required for the conversion (Port A bit 0) with two other pins providing reference levels to the maximum voltage, Vref+ (Port A bit 3), and minimum voltage, Vref- (Port A bit 2). The ten bit A/D provides a resolution on the 360 degree scale of 360 / 210 0.3515625 per bit which is acceptable for the given application. The data acquisition circuitry provides a square-wave with a frequency directly proportional to the wind speed at the sensor. This presented a unique requirement for the microcontroller. In order to accurately measure speed, it would need to be able to count every cycle of the square wave, even though power consumption dictated that it must be ‘asleep’ for the vast majority of its operational life. The 16F88 has three onboard timers, but it is Timer1 alone that fills the niche of this particular challenge. One of the modes this timer can operate in is that of an asynchronous counter. In this mode the timer continues to increment asynchronous to the internal phase clocks and will continue to run during ‘sleep’ mode. By reading and clearing Timer1 at regular intervals, an accurate measurement of speed can be obtained. Pg. 10 To transmit and receive data, the PIC 16F88 has the choice of three serial standards; Serial Peripheral Interface (SPI™), Inter-Integrated Circuit (I2C™), and an Addressable Universal Synchronous Asynchronous Receiver Transmitter (AUSART). Contrary to the AUSART’s complex epithet, it was the standard of choice due to its ease of integration and lack of overhead. The PIC’s onboard baud rate generator is configurable over the entire communication rate range specified by the sponsor. Receives from the AUSART can generate an interrupt, freeing the processor from having to take time to ‘listen’ for incoming configuration data. Transmissions simply require a byte sized write to the TXREG and the AUSART will begin transmitting. Even though the PIC 16F88 had all the features required for the problem specification, one limiting factor made its presence felt near the end of development - program memory space. The 16F88 has 4 kilo-words of program space which is a mid to high amount for its device family, and seemed more than adequate upon initially sourcing the chip, but later proved to make the processing and averaging of the data a challenge to squeeze in. Processing Software Overview To utilize all the features offered by the PIC 16F88, Hi-Tech Software’s PIC-C compiler was used as the language suite within Microchip’s MPLAB developer’s environment to create the required software solution. Once compiled, the software produces a program for the microcontroller which manages all facets of the sensor operation. The source code is included within Appendix E. This section of the report will explain the operation of the device and how the end user can operate it. Power-up and Initialization As with any embedded application, it is necessary to initialize certain registers within the processor to ensure proper operation of the device after power-up. Within Main.C (refer to Appendix E) the initialization steps are performed at the bit level for clarity. These operations configure the direction of the I/O pins and whether they operate as digital or analog I/O. Timer1 is configured for asynchronous counter mode and the watchdog timer (WDT) is configured to run off its own prescaler. The only interrupt which gets enabled is the AUSART receive interrupt flag (RCIF), and once the global and peripheral interrupt enables are set, the device is ready to receive configuration data. However, the device will not wait to receive a configuration before beginning operation. It will either operate with the configuration it had preciously – if it has been configured already, or it will operate in a default mode – if it has not. This is possible because the device’s configuration is stored in the PIC’s Electrically Erasable Programmable Read Only Memory (EEPROM). During initialization, the device will check the location of its configuration bytes within the EEPROM. If there is valid data there, it will set it to its volatile configuration bytes and operate as previously programmed. Pg. 11 Configuration As soon as the PIC has set its global and peripheral interrupt enables, the device is ready to receive configuration data. If the device is operating in the default mode, this data will be sent over RS232 communication at 19.2k BAUD, if not, the data can come over which ever medium the sensor has been configured for. As soon as a character is received in the receive register (RCREG) the PIC triggers an interrupt which shuts off the WDT (preventing an unwanted reset during configuration) and calls the dataReceive() function (refer to Functions2.C in Appendix E). This function is written to look for a specific preamble (HEX ‘55’s or ASCII ‘U’s) before modifying the device’s configuration. At anytime within this function, if the device receives an invalid character, the PIC will leave the interrupt without modifying the configuration settings and return to its previous operation prior to the interrupt. Below is a map on how to construct a valid configuration string of ASCII characters for the device: Preamble: o A continuous transmission of ‘U’s for a period greater than the devices sleep cycle, such that it may catch the preamble and enter dataReceive(). First Character: ‘H’ or ‘W’ – not case sensitive o Select ‘H’ if the device is to be hardwired via either the RS232 or RS485 communication chips, or select ‘W’ if it will be communicating wirelessly. Second Character: ‘2’ or ‘4’ o Select ‘2’ if the device is to communicate via the RS232 chip, or select ‘4’ if it is to use RS485 communication. If the device is set to Wireless, this choice is not important, but a ‘2’ or ‘4’ must be entered to continue with configuration. Next Four Characters: A four bit ‘ASCII Binary’ string from“0000” to “1111” o These ones and zeroes will translate directly into the part of the configuration dealing with communication rate. For example, entering the combination ‘1’ ’0’ ’1’ ’1’ (equivalent to decimal 11) will set the device to communicate at 28.8k BAUD. Refer to the comSpeed() funtion within Funtions2.C in Appendix E for the entire table of configurable speeds. Seventh Character: ‘R’ or ‘P’ – not case sensitive o Select ‘R’ if the desired output is a raw data string, or select ‘P’ if the output must be a processed data string (Refer to Output Data within this section). Next Four Characters: A four bit ‘ASCII Binary’ string from“0110” to “1011” o This string defines the setting for the WDT prescaler which in turn determines the sleep cycle period (and in effect, the sample rate). The combination ‘1’ ‘0’ ‘0’ ‘0’ (decimal 8) will cause the sleep period to be 316ms. Refer to the setWdtPs() funtion within Funtions2.C in Appendix E for the entire table of configurable periods. Twelfth Character: ‘m’ or ‘M’ or ‘K’ or ‘N’ – only the ‘m’ is case sensitive o This character determines what unit the sensor will calculate speed with. ‘M’ for mph, ‘K’ for km/h, ‘N’ for knots, and ‘m’ for m/s. Pg. 12 An example of a valid configuration string: “.UU..<U’s over the length of the sleep cycle>..UUH21001R1010K” This string would set the device to hardwired communication over RS232 at a rate of 19.2k BAUD with raw data as the output, a sleep period (sample rate) of 1.12 seconds, and km/h as the unit of speed measurement. Once a valid string has been entered, the program translates the information onto the volatile configuration bytes and then returns to the interrupt service routine (ISR). Before exiting the ISR the WDT is re-enabled and an ‘updated’ flag is set which prompts the main program to act upon the recent configuration data and save that setting to the EEPROM before entering the next sleep cycle. Sampling When the device is not receiving data, it operates out of an infinite loop within Main.C. There, it checks the updated flag and updates the PIC’s settings if required. It then enables the appropriate communication chip and enables the sample circuit which provides reference voltages for the direction detection circuit before calling the sample() function within Main.c. The integral part of the sample() function is its data acquisition. It first performs an A/D read (readADC() function) and acquires a ten bit value for the wind direction. It then performs a fail safe read of the two Timer1 counter registers, TMR1H and TMR1L and combines the two bytes into an integer which is then multiplied by the appropriate conversion constant to obtain the correct speed, according to the device’s configuration. It then disables the sample circuit before acting on the acquired data (refer to Output Data). After acting on the data and transmitting its output string, the function returns to the main loop. Once back in the main loop, the program makes sure all power consuming circuits are disabled and then executes a sleep() function call to enter ‘sleep’ mode (refer to System Microcontroller – Features). It remains in this low power shutdown mode for the remaining time of the sleep cycle period which is governed by the WDT prescaler. At the end of that period, the PIC ‘wakes up’ and performs a NOP to allow the program counter to pick up at the next instruction which carries it to the top of the loop again. This essentially defines the sleep period of the device as the sensor’s sample period. Pg. 13 Output Data There are two separate forms of output for the device, as specified by the sponsor. The first is ‘raw’ data and the second is ‘processed’ data. Each has their own NULL terminated string of characters based on the NMEA standards (see http://www.nmea.org for more information) stored globally within Main.C. The raw data string is rawFeed[32], which is initialized at "$WIMWV,ID,999.9,R,888.88,m,A*CS” and processed data is processedFeed[70], which is initiallized to “$AXMWV,ID,036,175.1,R,000.00,000.00,000.00,000.00,000.00,000.0,m,A*CS". Below is a description of the NMEA elements within the strings: • rawFeed[32]: $WIMWV,ID,175,R,000,N,A*20 ID = Unique Sensor ID 175 = direction R – for Relative Direction 000 = speed N – Knots (M – MPH, m – m/s, K – km/h)* A – Alarm CS = XOR Checksum • processedFeed[70]: $AXMWV,ID,Dur,175,R,001,002,003,004,005,120,N,A*CS ID = Unique Sensor ID Dur = Wind Average Duration 175 = Average Vector direction R – for Relative Direction 001 = Average Scalar speed 002 = Average Vector Speed 003 = Gust Speed 004 = Minimum Speed 005 = Maximum Speed 120 = Wind Variation N – Knots (M – MPH, m – m/s, K – km/h)* A – Alarm CS = XOR Checksum *modified MPH to ‘M’ from ‘S’ for clarity during the demonstration. Within the sample() function, the PIC acts upon the data based on whether it is set for raw or processed output. If the output is the raw data, the program simply passes the speed and direction, individually, to a function which returns a pointer to the first element of a string containing the ASCII representation of the passed data, and then updates the appropriate elements of the rawData[] string. If instead the output data is set to processed, then a series of operations are performed to find each value within the processedFeed[] string. Pg. 14 DUR, Wind Average Duration. This value is hard-coded into the device as 36 seconds due to the fact that in order to sample over a long enough period to detect wind gusts, the device has to operate with the 1.12s sample period only. 175, Average Vector Direction. Over the Wind Average Duration, the PIC updates two eight element circular buffers every 4.5 seconds with pre-averaged values for the X and Y components of the wind’s vector speed - such that it can maintain moving average values for each. To find the vector components of the wind speed and direction, the values are passed to a function which converts the magnitude (speed) and direction into its orthogonal X and Y components (see the getXY() function within Functions.C in Appendix E). This happens every 1.12s with every sample. The pre-averaging is done by summing the four X and Y components sampled over the 4.5 seconds and then right shifting the data by 2 (divide by four). The moving average is maintained in much the same way. The two averages for X and Y (sumX and sumY within the sample() function) add their pre-averaged amounts, av_x and av_y, after pre-averaging them again (right shifting by 3 for the eight elements) . Then the current circular buffer element is subtracted from the moving average before inserting the new pre-averaged value into that circular buffer slot. With the moving average values, sumX and sumY, the Average Vector Direction can be found by passing these values to an arctan lookup function, arcTan() within Functions.C. This value is converted to a character string and the processedFeed[] string is updated. 001, Average Scalar Speed. The same eight element circular buffer technique used to average the X and Y components is also used to maintain the scalar speed moving average, sum_vel. The output string is updated with this value. 002, Average Vector Speed. This value is essentially the Pythagorean sum of the X and Y components. However, since squaring integers and subsequently finding the square root of their sum involves a lot of program memory overhead, the function hypotenuse() was developed for this application. A brief description of its operation is that it takes the largest value between X and Y and sets it as the base value. It then states that the other is going to be some ratio of 0 -1 of the base. It finds that ratio and determines the starting value for the hypotenuse from an eight position look up table. However, it maintains accuracy between the look up points by adding a remainder amount onto the starting value of the hypotenuse. The value from this function is then converted to a characters and the output string is updated, 003, Gust Speed. To find this, the elements within the scalar speed circular buffer are run through a max/min algorithm which finds both after one pass through the array. If the max and min differ by a set value, then the max is selected as the gust strength. This element requires another sort to ensure a gust is not reported after a long period of high winds followed by a lull. However program memory space dictated that should be looked at in a future revision. Pg. 15 004, Min Speed and 005, Max Speed. With the max and min values found during the Gust detection search, this operation simply involves a character conversion and output string update. 120, Wind Variation. This operation is done by doing the same max/min algorithm on the eight element circular buffer containing the instantaneous direction values taken every 4.5 seconds then finding the difference between them. If the difference is greater than 360 degrees, the output string is updated with 360 – the difference. Otherwise the difference is reported. Output Hardware RS-232 The first protocol of serial communication considered was RS-232. For this the Intersil ICL3221 device was chosen. This surface mount chip had many attractive features including its low operating power (1uA @ 3-5.5V), size, capable data rate of 250Kbps, auto power down and it meets the EIA/TIA-232/V.28/V.24 industry specifications. The supply current of 1uA is a result of Intersils efficient on-chip charge pumps along with the manual and automatic power down functions. The automatic power down function powers down the onchip power-supply and driver circuits. This occurs whenever the attached device removes its valid applied RS-232 voltage at the receiver input. For this design the chip is turned off and on through a software enable. This was achieved by tying pin 13 of the PIC to pin 16 (!FORCEOFF) on the ICL3221 chip. To disable, a logic low is applied. To re-enable, a logic high must be applied. A jumper header was also connected between these pins that could be removed when the in circuit debugger was to be used. This allowed for one pin to have multiple roles. For all the external circuitry please refer to the Intersil ICL3221 data sheet in Appendix C. It is important to note that for proper operation of the charge pumps the required capacitor values must match Vcc as seen below in Table 2. For this circuit we choose values in the 4.5 to 5.5V Vcc range. See figure 5 for the ICL3221 circuit and interface. Table 2 Required Capacitor Values [2] Pg. 16 Figure 5. ICL3221 External Circuitry and Interface [3] RS-485 The implementation of the RS-485 serial communication protocol was achieved using a Intersil ISL83485 surface mount device. The chip is a 3.3V, high speed, RS-485/RS-422 transceiver that meets both the RS-485 and RS-422 standards for balanced communication. This half duplex device configures the RX input and Tx output with RX and Tx disable functions. Data rates of up to 10Mbps are available. The devices logic inputs (pins DE and DI) allow for accepted input signals beyond 5.5V making them compatible with the majority of 5V logic families. Another attractive attribute of this chip is the “fail-safe if open” feature, which establishes a logic high output whenever RX inputs are left floating. The Tx driver outputs are also short circuit protected for any excessive power supply voltages. The operating current for this device is .65mA and 15nA in low current shutdown mode. Switching from operating mode to low current mode is achieved through the use of a mosfet as seen in figure 6 on the following page. For all external circuitry refer to the Intersil ISL83485 data sheets in Appendix C. Pg. 17 Figure 6. ISL83485 External Circuitry and Interface This mosfet allows both the !RE and DE pins on the ISL83485 to be configured using only one pin on the PIC. The !RE pin is the receiver output enable. RO is enabled when !RE is low; RO is high impedance when !RE is high. The DE pin is the driver output enable. The driver outputs, Y and Z, are enabled by bringing DE high. They are high impedance when DE is low. RC1090 The RC1090 is a RF Transceiver Module produced by Radiocrafts. This compact, "all included", standard transceiver made it very easy to implement radio communication in the smart sensor design. The RC1090 works in the ISM frequency band at 915 MHz which is usable in North America. The basic power and radio features are summerized in table 3 on the following page. Pg. 18 Table 3. Basic Parameters Communication between two RC1090 modules is handled by the proprietary RC232 embedded RF protocol. This protocol is invisible to the user, but is versatile enough to be configurable. The features of this protocol are: Un-buffered transparent mode Buffered packet transmission mode Variable packet length, end character or timeout Optional addressing of packets to a unique node, or broadcast to all nodes in a system Optional error detection using CRC-16 check sum On-the-fly configuration of the radio modem The modules can transfer data via a UART interface to/from either a host MCU or dedicated serial drivers. The interface to the module UART can be made with a simple two wire connection- one for transmit, one for receive. The UART protocol used by the module is a simple 8 bit, 1 stop bit, no parity. For communication with dedicated serial drivers, the RC1090 is compatible with RS232, RS422, and RS485 serial buses. This communication is again handled with the UART interface. Optional handshaking is also available through RTS and CTS signals for both host communication and dedicated serial drivers. If these signals are not used. It is recommended by the data sheets to connect them to the VDD pin. When connecting to the RC1090, refer to the diagram below. For a complete pin description and assignment refer to the RC10x0_Data_Sheet_1_3.pdf in Appendix D. Figure 7. Connection to host MCU or RS232/422/485 drivers The transceiver shown here has the on/off pin tied to Vcc. This option allows the transceiver to be powered all the time. For control of the power, a separate line to a host MCU should be Pg. 19 used. When turning the RC1090 on and off, the timing parameters and hardware control specifications need to be considered for fault free operation. The time required from RESET to IDLE state and OFF to IDLE state is 160ms. The wakeup time from SLEEP to IDLE is 55ms. Other timing parameters can be found on page 8 of the RC10x0 Data Sheet 1_3.pdf. For the OFF mode, it is important to follow the note on page 5 of the RC10x0 Data Sheet 1_3.pdf to ensure power-on-reset. There are 3 options listed in the note depending on design. For the smart sensor design, the ON/OFF pin was brought out to a header pin for control from the PIC16F88. As well, the RESET pin was also brought out to the header via a 100kohm series resistor for control from the PIC16F88. Output Software RC1090 Configuration The configuration of the RC1090 can be done through the host MCU or via the serial drivers. To begin this process, the CONFIG pin is first pulled low then high. The configuration data is then sent via the UART interface. Once in CONFIG mode, the module will return a '>' prompt on the TXD pin. This indicates that the module is ready to receive a command. Most commands are followed by arguments. For a complete list of commands and arguments, refer to pages 5 to 9 in the RC232 User Manual 1_4.pdf in Appendix C. The format for sending the configuration data should be in hexadecimal. If configuration is done via the host MCU, it needs to be able to read the '>' prompt signal from the module before sending commands. A configuration program can be sent to the host, then used to configure that actual module in circuit. This can be very beneficial in the field. A simpler method for configuring the transceivers is through the serial drivers. However, this needs to take place before installation. In order to load the data onto the transceivers via serial drivers, a terminal program is needed. This program needs to be able to send hexadecimal values from 0x00 to 0xFF. ASCII terminal programs, like Hyperterminal, will therefore not be suitable. There are two types of memory that can be configured- the volatile memory and the non-volatile memory. When configuring the volatile memory, all configuration will be lost on reset or if the power supply is turned off. The parameters that were configured for the smart sensor design are listed in table 4 on the following page. Pg. 20 Table 4. List of Configuration data for the smart sensor Parameter Memory Configuration Command in Address in Argument in Hex Hex Hex 0x11 BROADCAST_ADDRESS 0x28 DESTINATION_ID EXIT_MEM_CONFIG Command to enter into memory configuration 0x40 PACKET_END_CHARACTER 0x21 0xFF Note 0x0D To start transmission, send an ASCII 'CR' at the end of the packet 0x39 Set broadcast address to decimal 9 0x39 Set the destination of the packet the same as the broadcast_id Exits out of memory configuration Pg. 21 For a step by step procedure for configuration of the RC1090 modules refer to the table below. Table 5. Procedures for Configuration Module Input Value Module Response Notes > Assert CONFIG A logic '0' form the host MCU or pull to GND if using serial drivers 1 none De-assert CONFIG A logic '1' form the host MCU or pull to Vcc if using serial drivers 0x4D > 0x11 none 0x0D none 0x28 none 0x39 none 0x21 none 0x39 none 0 Memory Configuration Command Send an End Character Character to be sent Broadcast Address Address Destination of Packets Command to write to memory Address of value to be changed Write value of ASCII 'CR' to above address Address of value to be changed Write value of ASCII '9' to above address Address of value to be changed Address Write value of ASCII '9' to above address Exit Out of Memory Configuration Command Exits out of mem config and puts module into idle state 0xFF > Pg. 22 PCB The Design of the Printed Circuit Board There were several steps involved in the process of designing the printed circuit board (PCB) for the Whirl Wind Smart Sensor. For convenience, the PCB of the Smart Sensor was designed using Protel 2004 DXP software. The advantage of creating a PCB using Protel is that the creation of the schematic document and PCB document can communicate between each other (refer to Appendix B). The main aspects of designing the PCB of the Smart Sensor using Protel software are; designing the footprint layouts of each component, drawing the dimensions of the board, placing the components on the board, and routing all the traces. Designing Footprints Each component used in the circuit for the Smart Sensor must have a footprint layout. The correct dimensions for the footprint are specified in the component datasheet. The Protel library has most footprint layouts already designed, but for newer components, the footprints have to be constructed manually and assigned to the component. Figure 8 displays the footprint for the RS232 transceiver chip (ICL3221). Figure 8. footprint layout of ICL3221 Board Dimensions The PCB of the Whirl Wind Smart Sensor will need to fit inside the RM Young 05103 interface box. This enclosure of the RM Young Wind Sensor is small, therefore the entire space must be utilised. The areas of the PCB that will require height restrictions on the board are the connectors, potentiometer, and crystal. Tooling holes are required in the design of the board for assembly and manufacturing processes. All these factors need to be defined before the board can be designed, as well as, the maximum dimensions of the board and the location of connectors and tooling holes. For a diagram of the board dimensions refer to Figure 9. Pg. 23 Figure 9. PCB Dimensions Placement of the Components At this point, the placement of the parts on the board can begin. There are a number of factors to be considered when placing parts, such as, electrical function, physical size, temperature factors, minimum spacing, and routability. Start with placing all the fixed location parts. These parts must be placed in certain locations for functionality purposes. On the Whirl Wind Smart Sensor these parts include only the terminal connectors. The desired placement of these parts is shown in Figure 10. The remaining components were placed as to reduce trace length and to reduce the total amount of vias. Figure 10. Fixed Location Parts Pg. 24 Routing the Traces Due to the small physical size of the board and the complexity of the circuit, routing all the traces would be a difficult process. To make routing easier, the traces were connected automatically using the autorouting capabilities of DXP Protel. To use DXP autorouting, a netlist of all the connections must be constructed from the schematic document. This netlist is then applied to the PCB document. Some unusual traces occurred during autorouting, but were easily fixed by manually re-routing the trace. Figures 11 and 12 show the finished PCB layout of the top and bottom sides respectively. Figure 11. PCB layout of top side Figure 12. PCB layout of bottom side Pg. 25 Manufacturing of the PCB The finished PCB design was then checked against the schematic for correct operation and connectivity. The gerber and tooling files needed to create the physical board were completed. The PCB was etched and drilled on a copper plated board at Camosun College as shown in Figure 13. The components (surface mount and thru-hole) were manually soldered. The vias had to be manually soldered too because this particular machine cannot produce connected thru-hole pads. Figure 13. PCB being etched at Camosun College Wireless Transceiver PCB The wireless transceiver (RC1090) was made on a separate PCB and connected to the main board using an 8-pin header. The RC1090 is very susceptible to noise and interface and it was concluded that a separate board with a large ground plane and separate supply voltage would be the best solution to reduce the effect of noise. The process of building the PCB for the wireless transceiver was constructed using the same steps as for the main board (refer to Appendix B). Pg. 26 Troubleshooting Once the PCB was built, power was slowly applied to the Whirl Wind Smart Sensor and all areas of the board for tested without no load at the outputs. After the Smart Sensor was operating under no load correctly, then each transmission protocol was tested separately starting with the RS232 and the RS485 transceivers. These transceivers were operating properly as expected. The wireless transceiver (RC1090) showed signs of noise interference even with the considerations already taken in the design of the RC1090 board. These transmission errors were concluded to be the result of noise produced from the main board of the Smart Sensor. After extensively testing the Smart Sensor several intermittent faults appeared and the original could not be detected. The source of these faults is considered to be the result of one of the IC’s, but could not be concluded as time did not permit. Recommendations It is recommended that an alteration to the PCB design of the Whirl Wind Smart Sensor be looked at to increase stability. A modification to the main ground trace should be considered to increase the stability of the Smart Sensor to noise and other electromagnetic interference. The best solution to achieve better stability is to connect the main ground trace in a complete loop around the PCB and to increase the size of the ground plane. This will provide a better suppression of unwanted signals. References 1.) [1] RM Young 05031 data sheet See Appendix C 2.) [2] Intersil ICL3221 data sheet See Appendix C 3.) [3] Intersil ICL3221 data sheet See Appendix C Pg. 27 Appendices Appendix A Schematic 1 JP1 2 3 4 5 6 RM_Young_Header VCC 4 COIL2 5 POY+ 4 POT X 3 POT- 2 COIL1 1 IC2D TLV2404 13 14 12 A A 11 WindDirectionPotentiometer (0- 10k) -VCC 3.6864MHz 1 2 R6 XTAL VCC VCC Trimmedto~10k 4 1 IC2B TLV2404 6 R2 R4 7 5 IC2C TLV2404 9 8 100K VCC C2 15pF IC3 2 11 -VCC R5 50K 11 -VCC C1+ .047uF 4 C4 5 .33uF -VCC C1- IC1 1 Ref level + 2 3 R10 Ref Level - D2 4 VCC 1N4148 5 6 W3 R9 100K 7 C8 1uF 8 Jumper 9 VCC C RA0/AN0 RA4/AN4/T0CKI/C2OUT RA7/OSC1/CLKI RA5/MCLR/Vpp RA6/OSC2/CLKO Vss Vdd RB0/INT/CCP1 RB1/SDI/SDA RB7/AN6/PGD/TIOSI RB6/AN5/PGC/T1OSO/T1CKI RB2/SDO/RX/DT RB5/SS/TX/CK RB3/PGM/CCP1 RB4/SCK/SCL R1in En 12 VCC .33uF 13 C5 RS232Tx R1out 1 17 7 !FORCEOFF FORCEON 16 IC3221 INVALID 8 B RS232Rx 16 10 VCC 15 D3 14 14 10K Q1 MOSFET-N RA3/AN3/Vref+/C1OUT 18 T1out GND R8 100K RA1/AN1 100nF C7 .33uF 3 T1in 9 RA2/AN2/CVref/Vref- V- C2- VCC R7 100K V+ C2+ 6 11 B VCC 11 R3 5K C6 C3 0-Vcc/2~ WindDirection 10 Var Res 100K 15 15K 3 C1 15pF VCC R1 4 Z2 Tranzorb 4 IC2A TLV2404 2 Z1 Tranzorb 100K VCC 13 GE 12 11 JP3 W1 Jumper 10 RS232Tx RS232Rx PIC16F88 RS485Tx RS485Rx R12 1 2 3 4 5 C RS232/RS485_header 1M 5 IC6 OPA244 4 Sample Control Signal D1 3.3V RegEnable VCC 1 8 3 Frequency ~ WindSpeed 1N4148 IC4 R15 1M R13 100K 2 ON/OFF 3 R14 100K 4 3.3V JP5 !RE D/Z DE A/Y 7 6 RS485Rx RS485Tx DI ISL83485 5 1 2 3 4 5 D JP4 ICSP Connector RegEnable Title 1 2 3 4 5 6 7 8 5 4 3 2 1 RO GND RXEN TXEN CONFIG TxD RXD VCC 3.3V -VCC Q2 MOSFET-N VCC -VCC D 1 W2 Jumper 2 R11 1K Power JP2 RC1090Header Size Number Revision B Date: File: 1 2 3 4 5 4/7/2005 Sheet of C:\Documents andSettings\..\wind_sensor2[2].S D C raw HD n O B C y: 6 Pg. 28 Appendix B - PCB Top layer Bottom layer Pg. 29 Appendix C - Data Sheets 1. Intersil ICL3221 data sheet http://www.intersil.com/data/fn/fn4805.pdf 2. Intersil ISL83485 data sheet http://www.intersil.com/data/fn/fn6052.pdf 3. Microchip Pic16F88 data sheet http://ww1.microchip.com/downloads/en/DeviceDoc/30487b.pdf 4. RadioCrafts RC1090 data sheet http://www.radiocrafts.com/download.html 5. Texas Instrument TLV2404 data sheet http://focus.ti.com/lit/ds/symlink/tlv2404.pdf 6. Texas Instrument OPA244 data sheet http://focus.ti.com/lit/ds/symlink/opa244.pdf 7. RM Young MODEL 05103 Wind Monitor data sheet http://www.cleanair.com/Equipment/Rentals/equip/manuals/RMYOUNG.PD F Pg. 30 Appendix D - Bill of Materials Quantity Part Number 1 PIC16F88-I/SO IC1 1 TLV2404IPW IC2 1 ICL3221IA IC3 1 ISL83485IB IC4 1 1 1 2 1 2 2 IC5 IC6 X1 D1,D2 D3 Z1,Z2 C1, C2 1 2 4 1 3 1 7 RC1090 OPA244NA/250 ATS037 1N4148 1N23 P6KE18 ECUS2A150JCA GRM319R71H104KA01D GRM319R71H335KA01D GRM319R71H475KA01D ECJ-3YF1E105Z VN10KLS 929647-02-5-I 929647-02-8-I 929647-02-2-I ERD-S2TJ102V ERD-S2TJ104V 2 1 1 1 1 1 ERD-S2TJ105V EVNDJAA03B15 ERD-S2TJ153V ERD-S2TJ103V ERD-S2TJ473V ERD-S2TJ472V 1 3 1 Designator Description C6 Microchip PIC16F88 – 18-pin enhanced flash microcontroller with nanowatt technology Operational Amplifier - 880-nA/Ch rail-to-rail input/output with reverse battery protection One microamp supply-current, +3V to +5.5V, 250kbps, RS-232 transmitters/receivers 3.3V, low power, high speed or slew rate limited, RS-485/RS-422 transceivers Wide band multi-channel RF transceiver module Micropower single-supply operational amplifier Crystal oscillator 3.6864 MHz 15pF load capacitor High conductance fast signal diode Germanium crystal diode Transzorb transient voltage suppressor 15pF, 100V 5% monolithic ceramic capacitor 0.1uF, 50V 10% ceramic capacitor C4,C5,C7 0.033uF, 50V 10% ceramic capacitor C3 0.047uF, 50V 10% ceramic capacitor C8 Q1,Q2 JP1,JP3-JP5 JP2 W1-W3 R11 R4,R6-R9, R13,R14 R12,R15 R2 R1 R10 R5 R3 1uF, 25V ceramic capacitor N-channel enhancement-mode MOSFET - zener gate 5-pin header 8-pin header 2-pin header/jumper Resistor 1kΩ carbon film 1/4W 5% Resistor 100kΩ carbon film 1/4W 5% Resistor 1MΩ carbon film 1/4W 5% 100k potentiometer 6mm carbon top adjustment Resistor 15kΩ carbon film 1/4W 5% Resistor 10kΩ carbon film 1/4W 5% Resistor 47kΩ carbon film 1/4W 5% Resistor 4.7kΩ carbon film 1/4W 5% Pg. 31 Appendix E – Source Code See attached. Pg. 32