The past week has been spent trying to get a reliable SPI connection between the MSP430F5529 and the Analog Devices sensors as well as mapping pin connections for all devices needed for this project.
SPI Connection
The initial design plan was to use one SPI module for all SPI devices, this would include the CC3100 as well as the accelerometers and temperature sensor. The spi.c file was altered to allow for multiple device selects and all code was changed through the tcp_socket demo project. Once this was cleaned up and compiling with no issues the code was tested with the CC3100 and found to be working reliably. The next step was to attach a second SPI device.
At this point interesting things started to happen. When the ADXL362 was connected as it should be (MISO <->MISO, MOSI<->MOSI…) the CC3100 no longer worked, however, switching the connections (MISO <->MOSI, MOSI<->MISO) the CC3100 proceeded to work again. Using a logic analyzer it was clear the SPI was communicating in both cases but possibly not correctly (clock ticks were missed due to sampling rates of the old Saleae Logic) . It was also pretty clear from the sample data that the SPI frequency was set to 12 MHz. Once this was discovered and realizing it was not a hardware issue (verified using a Bus Pirate to talk to the ADXL362) the datasheet for the ADXL revealed the clock speed for the device MUST be between 1 MHz and 5 MHz (or 8 MHz depending on datasheet version). The Plan now is to write a new SPI driver for the ADI devices that will run at an acceptable clock rate for ALL the needed devices (ADXL362 1MHz - 5MHz, ADXL375 < 5 MHz, ADT3720 - Unknown). Once reliable communication has been established correct interpretation of input data will be worked out to enable proper interpretation and use of sensor data.->->->->
UART Code Removal
Also this week, time was spent removing code to control the CC3100 via UART. This was done to increase code readability and to remove possible confusion within the code. This was also done to help identify unused pins that may be used for the UART control of the CC3100. During this process the overall understanding of the code was greatly increased.
Pin Mapping
Since there was no clear indication of what pins were free, a quick code review was done to find all used pins and what they were used for. This was done to find all available pins and to correctly detail the used pins. As can be seen in the table below the CC3100 has a lot of pins broken out but only six are used. There are four for SPI, one for interrupts and one to enable and disable the CC3100, this excludes the 3.3 V rail and ground.
Once these were eliminated from the list six analog pins were selected, these would be set aside for the ADXL377 and time permitting the heart rate monitor. These were chosen next as there are only a limited number of analog pins on the MSP430F5529 and it was preferable to try have them consecutively numbered to potentially allow for easier programing.
Once the analog pins were selected the SPI for the ADI devices and their chip selects were chosen. All pins assigned so far can be seen in the table below.
Table 1. Pin Mapping For MSP430F5529 & CC3100
Next Steps
This coming week will be spent getting all SPI devices working correctly and reporting back some data (Device ID) and formatting that data correctly. Once the SPI modules are working correctly and their data is correctly interpreted the ADC module will be attempted.
It may be obvious by now, but the user interface has been neglected at this point due to complexity in the learning curve for QT. For now data will either be sent to plot.ly for plotting at a decimated rate or logged on a local computer in a not athsetic interfcae, something like a terminal.
Its been a while since my last update. In this time I have received the contest kit, which I will outline below, and outline a basic approach to move forward taking into account the short period of time left for this project. There has also been some analysis done on data rates and possible data representation for end users.
Kit Outline
The kit came with everything as expected. One big Tektronix box with the oscilloscope, four brown boxes one each with the AD8232 breakout board, evaluation kits for the ADXL375, ADXL362 and with the ADuCM350 development kit. Lastly there was the ADT7320 flex board and the ADXL377, ADXL375 and ADXL362 breakotboards. All the break boards were well sized to include just main components with its needed external components as well as space for a through hole connector. Opening everything at once was rather overwhelming. At this point it was decided a plan was needed to move forward, the previous one step at a time and hope it all works was not going to work.
Project Outline
Looking at what parts there where, their complexity to use and the project duration an outline was formed. As there is no way to use this project fully without a user interface (maybe a flashing LED in case of severe injury…) this was determined to be the first step. It allows for parts delays and other unforeseen issues to carry on while work moves forward. For the interface I have decided to use QT due to its apparent simplicity as well as due to the easily available help I have due to its use in my work place.
While I work on the interface there is the need for the embedded code to move forward as well. For this an MSP430F5529 will be used for two reasons. Firstly it integrates easily with the CC3100 that will be used to transmit the data back to the PC. Secondly it is relatively easy to use and with only two months to complete the project using a controller and IDE that is known will help save precious time. Unfortunately do this this choice the possibility of using the heart rate monitor may be reduced do to the abilities of the MSP430F5529. During this time all code will be written in a hardware independent nature so as to allow for switching the controller at a later date should the possibility arise.
Keeping the available time frame in mind the sensor choice has also been reduced. The system will start with just the two high g accelerometers and a temperature sensor. This will allow for a basic system to help iron out the basic bugs. Also as these sensors do not need any intense calculations to get them up and running their data will be useful to test and work out any bugs in the WiFi connection as well as in the the user interface. One main aspect that will be attempted will be to have a hardware abstraction layer to allow for the overall system to be ported to a separate microcontroller at a later stage should time permit,
System Capabilities
Looking over the system there was a clear need for a single wireless connection that could handle all the data. A quick calculation was done to determine what bandwidth was needed in order to allow for a better choice of wireless protocol.
Figure 1. Data Flow & Data Rates as Data Moves through the System
At the above calculated data rate of 264 kbps there was no real choice other than WiFi. While for a single player or even two players other options may be possible, for a full team the data rate quickly climbs above 1Mbps and only WiFi has a practical data rate above 3Mbps. While in theory the WiFi can handle the data rates for a team of players it is unclear at this point if the range needed to cover a hockey rink is possible. As the design moves forward this will be tested and hopefully resolved.
Basic Sensor Fusion
Due to both the relatively high data rate needed as well as the need to verify data values using redundant data the system will incorporate a very basic form of sensor fusion. To reduce noise in the system only shocks above a predetermined threshold will be registered. The accelerometer data will be combined to using an as yet undetermined algorithm (potentially simple averaging will produce sufficient results). This single result will be relayed back to the PC helping to reduce the required bandwidth as well as presenting the end user with only easy to understand data. In the first iteration there will be only one temperature sensor but there is a hope to add a second sensor. Having two sensors positioned on the temples will allow for a easy averaging and easily averaged results that should yield a consistent and repeatable body temperature.
Figure 2. Simple Representation of How Data Will Be Merged in the System
User interface
The other aspect of the design that has been looked at and has been started is the user interface. The concept is to have an uncluttered easy to read and understand interface that allows for anyone to quickly understand the situation of a player. For this reason there is both a text based output as well as a graph based output. These together allow for both an immediate situational understanding as well as a context to be added to the current situation to help understand the whole situation. For now there is no method for looking at more than one players information but the hope is to add in tabs or a drop down menu to allow a user to select an individual player to view in detail. Also in order to allow for a coach to quickly identify an issue even if the coach is not viewing a the information of a player who may be in trouble that players tab will flash yellow or red depending on the severity of the situation, there may be the potential to rather automaticly switch tabs so immediately the coach could see the relevant information.
Figure 3. Simple User Interface Displaying All the Relevant Data in an Easy to Understand Format
This past summer has been somewhat of a sad one. With this past summer not being particularly hot there was still an ongoing media presents of infant fatalities related to heat stroke due to these unfortunate children being left in cars. This past year alone in the USA there were approximately 30 fatalities due to heat stroke[1]. For some people and even the car companies this sounds like a small number and a number that does not warrant the need to invest any engineering resources, but for each of those children and parents or for someone who needs to deal with the aftermath, there may be a different view. For this reason I started thinking what would be an easy and simple way to help these children.
This graphic SIMULATED video gives an awfully real feeling of what a child goes through as they experience this horrible ordeal.
Issue & Resolution
It is known that the greenhouse effect is the major cause for a car heating to well above the outside temperatures. This happens when sunlight passes through the a window and strikes an object inside the car converting the sunlight to a longer wavelength that cannot escape thus increasing the temperature in the car.
Figure 1. Greenhouse Effect Causes a Car to Heat Up Quickly
A seemingly simple solution would then seem to be to break thermal seal allowing for the heat to escape and reducing the internal temperature. If the windows of the car could be opened then the temperature would not increase as fast and may even decrease. The objective behind this solution was to find an immediate low cost low complexity solution. Allowing strangers to help also seemed a reasonable option. This assumption was made due to the realization that in most cases where children were saved from extreme harm and even death, it was often a stranger that helped, so why not start with that as a part of the solution.
There have been other attempts to resolve this issue but they are usually complex solutions requiring a decent amount of infrastructure. As car companies are dealing in the millions of units, anything that adds even a 1¢ quickly adds to $10,000 over the manufacture of the product. While this may seem trivial, to a CEO and shareholders this is money no longer in their pockets and therefore lost revenue [2]. For this reason alone it is worth keeping the system to minimal cost input and try use systems already available in a car.
System Hardware
Freescale recently released their KEA family of ARM processors. These microcontrollers are made for automotive applications and therefore have specs that allow them to operate in the temperature range of -40 ℃ to 125 ℃ (-40 ℉ to 257 ℉). Using the KEA64 as a starting point a very simple and basic prototype was developed to see how well it performs, if the basics could be proven to work and show its reliability and safety than it would be worth attempting to incorporate such a system in an actual car.
Keeping to simplicity and minimalism the demo system is composed of only 4 components. These components are the KEA64, an ADT7420 and for the demo a steppermotor controlled by a ULN2003. Missing from the demo are pressure sensors used for child detection. The system operation follows a simple linear flow removing potential logic confusion or code errors.
Some extra hardware was used in this demo, but the basics of the system is already found in most modern cars today. While some extra coding may be needed, the overall system could be implemented with no additional hardware added by the car company. The addition of pressure sensors as well as communication from the car seat to the car could be added to the cost of the car seat removing this from automotive production cost. This no extra cost method may allow for more serious consideration and implementation by a manufacturer.
System Operational Model
The program in the KEA64 is interrupt driven allowing for simplicity as well as maximum power consumption. The flow of the program is outlined in figure 3 below.
Figure 3. System Flow Diagram
The system is initialized when the car is powered up (change of battery) or when the back door is opened. This is done to ensure whenever a child is in the back seat the system is in a known state. During initialization the ADT7420 is set to sample once per second and interrupt on a high temperature. Once initialization is completed the system goes into a low power state. The system will remain in this state until either the back door is opened at which point the system is reset or until a high temperature interrupt is fired.
If a a temperature interrupt is fired the system wakes to start doing a situation assessment. The first step taken is to check the car's internal temperature. This is done to prevent the system activating based on a false interrupt. Should the interrupt in fact be false the system is put back in power saving mode to once again await a temperature interrupt.
However, should it the system verify the cars internal temperature is high the system will then attempt to check if a child is present in the car. This is done by reading three pressure sensors fitted in the child's car seat. The sensors would be fitted to the bottom, the back and shoulder section of the seat. If a child is in fact in the seat and not something else 2 of the 3 sensors should indicate so. Using this method of two out of three the system would then assume a child is present and move to the next step. This would involve opening the windows and monitoring the car for a reduction in temperature, if the car does not begin to cool the horn and flashers could be activated in an abnormal fashion to attract the attention of other people in the vicinity.
Figure 4. Locations of Pressure Sensors in Child Seat
If instead it is found that although the car is at a high temperature but there is no child present the system would disable the temperature interrupt and go back into a low power mode. The disabling of the interrupt is to prevent further false alarms until a child is possibly placed in the back seat. This would be determined by one of the rear doors opening. Once opened the system would once again reset itself starting the monitoring cycle anew.
When starting of the project one major issue that was a recurring concern among people consulted for this project was theft. There appeared to be a concern that if someone could somehow heat the car to the critical point, the windows would open and the car could be easily broken into. For this reason as well as others the need for sensors in the child seat to detect whether it is in fact a child present is crucial. In the initial attempt it has been assumed that a three sensor system would be sufficient. By placing a sensor in the seat, back and shoulder parts of the child seat it would be possible to determine if a child or something else is in the seat.
Another concerns was power consumption. While it is often assumed a car has a large battery that could not possibly drain easily this thinking needed to be reconsidered. The first issue pointed out was the other systems using power, each device added could easily tip the consumption scale causing unsustainable power consumption . Another scenario is a car left for a long duration without being driven. In this case the battery has no chance to recharge and therefore if a car was left for several months the battery would be dead. For this reason the system is put into a low power state to reduce power consumption. The KEA64 when in run mode uses 6.7 mA (~2.25 Ah over 2 weeks) and 5.5 mA in WAIT mode (~1.85 Ah over 2 weeks). If the KEA64 is however in STOP mode the KEA64 only draws 145 µA (~48.7 mAh over 2 weeks) even with the ADT7420 sampling at 1 sps which has a current draw of only 65 µA (~21.5 mAh over 2 weeks) the total over a two week vacation would be 70.2mAh.
It is for this reason if an interrupt is fired and a child is deemed to be absent the interrupts are disabled. This prevents the system needing to wake each time the temperature gets above a set value when it is already known a child is not present.
System Testing
The system was tested at various stages during the project as well as upon completion. During the project a hair dryer was used to simulate high temperatures. While the whole system was not subjected to these elevated temperatures this method was sufficient to test the functionality of the system. Included in this testing was successive cycling to ensure such cases as a car being cooled by AC and than left to heat up and then cooled again would not negatively affect the system.
Upon completing this first stage the system was tested in thermal chamber. The chamber was set to 65 ℃ although the critical temperature is set to 50 ℃. This was done to speed up the testing since while the chamber may register 65 ℃ the air inside takes a while longer to reach the set temperature. Figure 5 below shows the thermal chamber as well as the system inside.
Figure 5. Thermal Chamber with System inside
Figure 6. System in Thermal Chamber Resting on Cardboard to Insulate the Two Systems
The full system test can be seen in the video below. As expected when the system reaches the critical temperature the “window” rolls down. The video shows this test being performed once but the actual test was completed several times to ensure repeatability.
While not shown in the video, this test was performed a few times in close succession again to ensure the system could handle a modest cycling of the surrounding temperature.
Figure 7. ULN2003 Arlington Array Used to Control the Stepper Motor
During testing, with both the hair dryer as well as in the thermal chamber, it was noticed that the KEA64 had an unusual and unexpected behaviour at some points. This was evidenced by the LEDs turning on when nothing had happened. With the hair dryer this was witnessed when the hair dryer was initially turned on but not near the unit. In the oven, as can be seen in the video below, it happened when the oven was turned on.
It was not possible to reliably reproduce the issue with the hair dryer, however, with the thermal chamber it was reliably reproduced three times as seen in the above video. Each time the issue was reproduced, it was only when the chamber was turned on, having an initial large power draw, but never when the chamber was being turned off. The few times it did occur with the hair dryer it was also only when turning on the hair dryer.
While further testing needs to be conducted to better understand the issue, there are a few similarities between the two situations which leads to some initial thoughts. In both cases the power outlet is shared by the KEA64 system and either the hair dryer or thermal chamber. With the hair dryer the KEA64 was powered from a laptop that was sharing the same outlet and with the Thermal chamber the USB power supply was plugged in the same outlet as can be seen in figure 8. In the case of the hair dryer and the laptop it may be though that the power supply as well as the USB subsystem would shield the KEA64 from any negative power effects seen at the outlet. In the second case, with the thermal chamber and the USB charger, again it would be assumed that the charger would provide some form or isolation. In both cases without proper testing the isolation can not be be guaranteed, perhaps in later testing a battery pack could be used to ensure complete isolation from the power mains.
Figure 8. KEA (Top Right) Plugged into Same Socket as the Thermal Chamber (Bottom Left)
These symptoms have led to the assumption that it is a power issue of some sort and related to the KEA64 and not the ADT7420 generating false interrupts. This is assumed because the motor does not run as it should if it was an interrupt generated falsely by the ADT7420. It is therefore assumed the KEA64 is susceptible to something either EMI or some power disturbance that is causing some bits to be flipped.
Figure 9. Power Supply Used to Power the System During Thermal Chamber Testing
Figure 10. LEDs on KEA64 Lit Showing Some Issue & the Breadboard Isolated from the Chamber with Cardboard
Moving Forward
The next steps for this project would be to attempt to control the windows in a car via the CAN bus. As these commands are not published this will require some reverse engineering. The CAN bus will be accessed via the OBD port as this is the the easiest and most convenient access point but this may provide other issues. Some ODB ports do not allow all messages to be transmitted to the CAN bus but rather only those needed for diagnostics. Another issue is controlling the windows when the car is off. In this case it would be needed to turn on the electronic subsystems of the car in order to power the windows. Each one of the issues pose their own challenges and will hopefully be dealt with to accomplish the end goal of this project.
I would like to say a big thank you to Element14 for hosting this challenge. I would also like to say thank you to the supporters, Analog Devices, Tektronix, Electrolube and Leeds Becket University for selecting my proposal and giving me the opportunity to take this idea further.
Project Outline
This objective of this project is to monitor an athlete to determine if any critical harm may have occurred or will have the potential to occur. The technologies that will be incorporated are as follows.
Temperature sensor - to look for heat stroke or other temperature related issues
2 or 3 Accelerometers - concussion sensing using sensor fusion
ECG front end - for potential or occurring heart attack detection
ECG front end - Detect sudden heart rate increase that could be potentially harmful
Wi-Fi/Bluetooth - to relay information back to a monitoring station
The exception of the system is to have a battery life of 1 ~ 2 years and to be self contained in a sports helmet (hockey, football or bicycle). If some components are not possible to incorporate directly into the helmet a chest strap may be added that will communicate wirelessly with the rest of the unit.
Deliverables
To keep the project at an achievable level the deliverables I propose will be inline with what I hope to be able to achieve in 3 months. While this list is somewhat smaller than the initial proposal, it will still deliver a decent overview of the athlete and will also provide a platform for potential future development.
Heat stroke will be fully implemented looking for abnormal body temperatures.
Heart attack will be implemented on a simple level; this would be only looking at abnormally high heart rate or abnormally high climb in heart rate. There is the potential to look for an abnormal heart rhythm time permitting. However, learning the athletes unique heart rhythm will most likely not be a possibility due to time constraints and potential complexity in doing such.
Individual concussion severity will be fully implemented and have a high degree of accuracy this should use some form of filtering to ensure only actual concussions are registered and measured
Cumulative concussion force may not be fully or correctly implemented. As it is still not fully clear in the scientific community how this should be measured, my attempts to do so may appear flimsy and illogical. While there may be an attempt at this it may be incorrect and inaccurate and therefore left out in the final product.
Monitoring and reporting, for this the CC3100 in conjunction with a MSP430F5529 or similar will be used to post the data to a cloud based system such as Plot.ly to give real time information on the athletes sensor measurements.
Next Steps
The immediate next steps is to better understand the proposed devices to be used. This includes reading through and understanding the data sheets and mapping what each component needs in the way of power (3.3V or some other value) communication (I2C, SPI, etc.) and what its limitations are in terms of performance and usability (FIFO, interrupt driven, etc)
At this point there is no plan for any software implementation or outline as there needs to be a better understanding of the individual components and what each one needs and is capable of. There is however an intention to layout a data flow and processing diagram in the coming steps to better help the layout of the hardware and the outline of the software.
Data Sheets
For convenience I have linked the data sheets for the proposed components to be used, as more components are added their data sheets may be added below.
ADuCM350, 16-Bit Precision, Low Power Meter On A Chip with Cortex-M3 and Connectivity (link)