Home

INF-3996 Master of Science Master of Science Thesis in

image

Contents

1. 42 43 44 45 46 47 48 49 50 51 52 53 54 55 3 10 Available from http www connectblue se produkts bluetooth products oem modules oemspa31 1331 downloads Guide to Thermocouple and Resistance Thermometry http www tc co uk TC Ltd Pico Picoscope 2104 amp 2105 PC Oscilloscopes User Guide 2006 cited February 2007 PS2100044 1 0 Available from http www picotech com document pdf ps2100044 pdf Varmedal R and Eriksen HO Mobile to Sensor Interface Requirement Document IRD 2007 Troms Telemedicine Laboratory connectBlue OEM Serial Port Adapter cB 0901 Electical and Mechanical Datasheet INDUSTRIAL BLUETOOTH 2006 September cited February 2007 1 7 3 Available from http www connectblue se produkts bluetooth products oem modules oemspa31 1331 downloads KCWirefree KC 22 Datasheet Bluetooth OEM Micro Module 2007 cited March 2007 KC 22 4 Available from http www kcwirefree com documents html connectBlue Product Brief OEMSPA31 1 331 INDUSTRIAL BLUETOOTH 2006 October cited February 2007 1 3 Available from http www connectblue se produkts bluetooth products oem modules oemspa311331 downloads KCWirefree KC 21 Datasheet Bluetooth OEM Module 2007 cited March 2007 KC 21 3 Available from http www kcwirefree com documents html Sena OEM Bluetooth Serial Module Parani ESD100 1 10 200 210 2006 cited March 2007 Available from htt
2. 5 5 Power supply As power source the project groups has chosen the CR2477 which is a Lithium manganese dioxide primary battery CR A primary battery is not rechargeable The CR2477 is a button shaped battery of size 24x7 7mm and weighs 10 grams The CR lithium batteries has high cell voltage high energy density a stable discharge voltage good energy flow rates at low temperatures down to 60 C and good capacity for storage 51 It is easy accessible and it is the most common type occupying around 8046 of the lithium market It is suitable for long life and low cost applications in need of high pulse currents But how long this battery will function in the step counter is not known as there has not been performed a power consumption analysis of the system yet The lithium battery is undoubtedly the best commercially available battery However therein lays the flaw considering this project Its flat discharge curve is a great advantage as it simplifies the system design This because supply voltage stays fairly constant through the whole discharge cycle 52 But it causes problems for 41 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen using voltage measurements to determine of the battery s state of charge The voltage drops so late that it might not be power enough left to send a warning message 5 6 The Step counter software 5 6 1 Program overview After having reviewed the basic program code of
3. ek Title Pedometer for Telemedisin ok Filename main asm ok Block diagram 7 ok 3 Versjon 1 1 OA BETA ek Last updated 2007 05 02 ok Target ATmegal64p ok H Description Main function ok Designed by Willy Mortensen ok Modified by Odd Arne Olsen ok H LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL main sei set global interrupt main loop sleep set sleep mode Power save rjmp main loop 121 128 INF 3996 Appendix D The modified program Odd Arne Olsen 122 128 INF 3996 Appendix E Bluetooth module setup Appendix E Bluetooth module setup Odd Arne Olsen Category Setting Value AT command Local name TTL Lifestyle Step Counter AT AGLN o amp Class of device 0 AT AGLC E E Connectable Connectable AT AGCM Discoverable General discoverability AT AGDM Pairable Pairable AT AGPM SET Security mode Link Level AT AGSM Pin code 1234 AT AGFP 5 Server profile SPP AT ADDSP z Master slave switch policy Don t care AT AGMSP E Wireless multidrop no value AT ADWM Client nothing selectable nothing selectable n S AT AMWEM D Allow configuration over air Enable AT ACCB DTR DSR mode On connection Ignored AT AMDS Watchdog 0 0 0 AT AMWS 123 128 INF 3996 Appendix E Bluetooth module setup Odd Arne Olsen 124 128 INF 3996 Appendix A The Project group s block Appe
4. INF 3996 Master of Science Thesis in Telemedicine and e Health A SENSOR DEVICE AND ITS APPLICATION IN E HEALTH Odd Arne Olsen June 2007 FACULTY OF SCIENCE Department of Computer Science University of Troms Number of pages including this 128 1 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 2 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen Preface The assignment described in this thesis is a tiny part of a long running project at the Norwegian Centre for Telemedicine NST The project is focused on self help and health motivational devices This part concentrates on the debugging phase of a ready made wireless step counter prototype I had hoped to get more work done on the device However events beyond my control laid some obstacles in my way I would like to thank my supervisors Weihai Yu and Eirik Arsand for immense amounts of patience help advice and inspiration Further on I would also like thank Willy Mortensen at Sensotek and Harry Jensen at Faculty of Medicine University of Troms Finally I have to thank my wife Chun Lan and our three daughters for helping me through this 3 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 4 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen Contents jn o M 3 n
5. The microcontroller s and the Bluetooth module s UART where setup to handle the following data byte format 2400 baud 1 start bit no parity 8 data bits 1 stop bit and no hardware flow control 40 The total data package can be seen in Figure 16 It consists of 14 data bytes The function of each byte is as follows The two first bytes are synchronization characters Here the character ASCII value Ox7E is used These bytes are mainly used to ease the debugging process A transmission starting with two identical and rarely used characters is easy identifiable The ID byte identifies which device this actual transmission is coming from The package number will help to identify the transmission in order to make it possible for the receiver to organize incoming packages At present its contents is a value incrementing for each transmission The 4 bytes of sensor data will contain the number of steps acquired since the last timed transmission The 4 bytes with optional contents gives possibilities for a future expansion of system For instance it could contain the report from additional sensor or step controller system info At present all bytes are set to zero The last 2 bytes are reserved for checksum data 1 package number byte 4 bytes with optional content 2 sync byte 1 ID byte 4 bytes of sensor data 2 checksum bytes H H v Figure 16 Data package format 7
6. Y j j vy J 5 SUMMARY ose saraeeenaeseoeiseg eesi eroe oansgesi ger ienei Staiano ase seo oiea ra eiee so aao is eoste sipose r sose e t ei Erota draoi seisata 7 1 INTRODUCTIOON cccsssssssssssscssssssessssecsessssessessessssessesscssssssessssssesscssssessssessessessessssossessesonse 9 2 BACKGROUND neenennenvenvonensenoononsencenoenonsenvenennensenvenensencenensensenennensenvonensenvenvenensenvenen 11 2 1 oU M 2 2 SELF MONITORING SYSTEM THE NST PROJECT a esses eene eene enne nene 2 3 WEARABLE HEALTH MONITORING SV STEMS 2 4 THE MICROCONTROLLER aaneen 2 4 1 Microcontrollers 2 4 2 The AVR Architecture 2 4 3 The ATmegal64P microcontroller eese eee 2 5 PROGRAMMING ENVIRONMENTS 2 5 1 IAR Embedded Workbench 2 5 2 CodeVisionAWVR 2 5 3 WinAVR GNU GCC an a e RERA 2 5 4 ImageCraft v7 C compiler and Crossworks for AVR 2 6 AVR ASSEMBLY PROGRAMMING 4 2 22222002222202 2222222222222222222222222222222222222222 VAO ENEN NEIL OEE 23 Zels WIRELESS COMMUNICATION inst e de EN redt ERU RR e and 24 2 8 SENSORS EM M 25 EWL KE LAT 27 3 1 SENSORS MEASUREMENTS ussen SEENEN ENEE A 27 3 2 PROGRAM DEVELOPMENT AND TESTING ccccssssssesseescccccsccssseeseeessessssesseesececccesseseuseeeseeess 28 3 2 1 The STK 500 starter kt
7. detector k Bt ME N Sensor Analog display Figure 2 A microcontroller interfacing with external devices with a minimum of extra components 17 With Figure 2 as basis one could conclude that a reasonably well equipped microcontroller could in addition to the CPU contain Program memory Could be of type EEPROM EPROM Flash Mask ROM or PROM RAM data memory Clock oscillator Digital I O Analog I O Reset and brownout detector circuitry Serial port Timer Real Time Clock 14 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen Watchdog timer etc 2 4 1 1 Architectures Modern microcontrollers architecture is mainly based on the von Neumann model or its close relative the Harvard model Up to the point of memory organizing they are quite similar In a von Neumann based architecture the data storage and processing units are separated Instructions and data fetches from the storage are performed sequentially This procedure has led to a problem called the von Neumann bottleneck as the data transfer rate between CPU and memory is small compared the amount of memory The unfortunate result of this is a high number of clock cycles per instruction 18 In the Harvard the memory is split into an instruction part and a data part This enables the parallel management of instruction and data units The immediate outcome of this is the reduced rate of clock cycles per instruction 16 T
8. eHealth means applying new low cost technologies such as web enabled transactions advanced networks and new design approaches to healthcare delivery In practice it implies not only the application of new technologies but also a fundamental rethinking of healthcare processes based on using electronic communication and computer based support at all levels and for all functions both within the healthcare service itself and in its dealings with outside suppliers eHealth is a term which implies a way of working rather than a specific technology of application 1 2 How can a step counter be considered an eHealth device The definition above is so broad that it embraces a wide range of services bordering to both healthcare and information technology As such this involves both self help systems for people suffering from diseases as well as for instance activity monitoring of healthy persons for the cause of disease prevention 3 The step counter is at present only capable of registering a persons walking activity But by combining this data with his her weight and average step length data like walking distance and caloric consumption can be found These parameters would be a useful tool for persons in need of a balanced diet Examples of such users could be people with lifestyle related or chronic diseases Being made available for the person s physician these data could also form the basis for adjustments of medical dosage levels With
9. states that the sampling frequency has to be at least twice the highest analog frequency 63 In order to incorporate the ADXL330 into the step counter system it has to be fitted with a controllable on off switch An example could be the 74HC4016 analog switch However another problem is that the output impedance of the ADXL330 and the input impedance of the Atmel ATmegal64 don t match The ADXL330 output impedance might be too high as it sends it signals through 32KQ resistors The input circuitry of the ATmegal64P s AD converter is optimized for sensors with output impedance of 10KQ or lower If this demand is met the microcontroller s sampling time will be negligible If not the sampling time will 51 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen depend on how fast the microcontroller s sample and hold capacitor is able to charge 25 6 2 Power consumption At this stage of the project it is quite limited what can be done in order to reduce the power consumption Much has already been done in order to reduce the idle power consumption but more can be achieved by reducing the active power and active time 64 The easiest place to start is the reduction of the output power of the Bluetooth modules When exchanging data it is a high probability that the step counter and mobile base is close vicinity to each other There should then be no need to run the connectBlue OEMSPA311 full power its maximum ra
10. 35N and 0 35N Mechanical testing revealed that the Camden CSSM switch seen in Figure 21 b was the most promising of these test The lever of the Omron D2F L felt too wobbly and imprecise while the Alps SPPB had no click point of activation and as such was imprecise and difficult to get to operate correctly All three were tested with lumps of lead with weight starting at 5 grams and ending at 10 grams However these switches will not be useful before better ways of mounting the weight to the lever are found Equally important though is finding an optimal shape of the weight which ensures both minimal volume and optimal weight 48 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen m gy iy TT TL III 0 cm 1 2 3 O cm 2 3 O cm 1 2 a b c Figure 21 Three attempts of making a movement sensor by using sub miniature micro switches a Omron D2F L 54 b Camden CSSM 55 c Alps SPPB 56 6 1 4 Tilt and vibration sensors In addition to these I tested some tilt and movement sensors The project group had bought a number of sensors where the Sencera 709 and the Sencera 102 were the most promising see Figure 22 A and B In addition I ordered the NMS24M from SCM International Inc on the basis of it being used as vibration sensing in a car security system 57 see Figure 22 C Its small size and its position insensitiveness were the final key words that initiated the purchase A sensor which can regis
11. 67 8 2 ALTERNATIVE POWER SUPPLY eegent eau gege NNUS ERE VE EN ESTE MEO 67 8 3 REMOTE PROGRAMMING eege 68 9 Eon ep aile 71 REFERENCES PE Aere 73 APPENDIX A THE PROJECT GROUP S BLOCK DIAGRAM APPENDIX B MY BLOCK DIAGRAM eee e eee eee eese een oett s e tense tetas esta se eene eaae eene sesta eee en a eee APPENDIX C THE UNMODIFIED PROGRAM eese eee ee eee eene eee o esten setas e eaae setas see en eee ea aee 91 APPENDIX D THE MODIFIED PROGRAM eere eee eee 0222 20 eee tena eee 00000000000000000000 000 sese sena a 107 APPENDIX E BLUETOOTH MODULE SETUP eese esee e eee ene eene esten sete tn setae sten s etna 123 APPENDIX F THE SENSOR TESTS 4 eese eee e e eee ee eee tn eset en esten aste ta e tense seen s eene e eaae esee ee ena 125 6 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen Summary The projects Self help through a mobile ICT tool and The ICT Lifestyle and Health Motivation Project at the Norwegian Centre for Telemedicine NST have designed and built a prototype smart sensor system Just days before the hand in of this thesis the second version of the prototype was ready for testing Central for this thesis is the hardware and software debugging process of this first prototype The result of this process is a number of suggestions for changes in the microcontroller s software an
12. Given an oscillator frequency of IMHz 50mS equals 50000 clock cycles This is a standard piece of code which pops up nearly everywhere With reference to the listings above at label loop1 the routine should waste a predestined number of clock cycles hereafter named z This is to be performed the number of times decided by the value y loaded into the templ register at label loopO All this is to be performed x times decided by the value loaded into tempO at label intl loop In addition will each decrement and a true branch command combination count for 3 clock cycles 65 And as such this loop can be represented by the following formula Delay _ clock _ cycles x y z 3 3 As probably can be seen from the code in Table 4 z 0 y 164 and x 101 for this instance This loop is 5 clock cycles away from the desired 50000 goal However the andi cpi breq uses each one clock cycle to perform and the jmp instruction takes three clock cycles This still not totals to exactly 50000 clock cycles but for the use intended the accuracy is more than sufficient The calculations of these loop constants X y and z can be done by the help of a spreadsheet or a self made program A direct consequence of the global interrupt being activated is that the 4 1 isr timer routine has to be changed The 3 2 routine might be interrupted at any time Therefore 58 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen the temporary registers tempO a
13. SPL and SPH stack pointer registers That value represents the last RAM address in the microcontroller Each time new data is put into the stack this value is decremented and consequently when data is removed from the stack this value is incremented Instead of using a numeric value the highest RAM address is available as the constant RAMEND in the microcontroller definitions file 25 32 The reason for using it is to make the code as universal as possible Universal is here used in terms of AVR microcontrollers As such the four lines immediately below the label start now looks like shown in Table 3 Table 3 Stack pointer initialization changes lditempO HIGH RAMEND Set stack pointer to point at out SPH tempO the last RAM address Idi temp0 LOW RAMEND out SPL tempO 6 4 2 The communication and time control routines The project group s intention was that the step counter should report its harvested data every 24 hour at for instance nine o clock in the evening The send button should send the data gathered since the last timed report and otherwise leave the data unchanged Unfortunately this was not the case with the received program The 24 hour send did function as intended but if the send button was activated in between the real time clock value was replaced by its preset value In other words no matter the cause of the last transmission it would take 24 hours from that point in time until the next timed tr
14. ZL 0x00 set data stack pointer to start Idi ZH 0x02 Idi count stacklen initialize loop counter mov temp0 packnub update pack number inc tempO mov packnub tempO std Z 0x03 packnub store packed number std Z 0x06 stcH put step counter higher byte to data stack std Z 0x07 stcL put step counter lower byte to data stack power_on sbi PORTD Bt power arm Bluetooth power and wait for active DTR signal ldi r22 0x00 Bt_ready rjmp delay100ms 119 128 Appendix D The modified program INF 3996 inc 122 cpi r22 0xC8 brsh endtransm in temp0 PIND sbrs _temp0 Bt DTR rmp Bt ready transm Id temp1 Z rcall putchar dec count brne transm untilempty Ids temp0 UCSROA sbrs temp0 UDREO rmp untilempty rjmp delay100ms cbi PORTD BT power endtransm ret delay100ms Idi temp1 0xA5 dtrloop0 Idi r21 OxC9 dtrloopl dec r21 brne dtrloopl dec templ brne dtrloopO ret Odd Arne Olsen check for time out here approximately 20 sec Wait until Bluetooth is ready ie wait for an active DTR signal loop until BT ready fetch data from data package stack send data put in UART buffer branch if not the last byte wait for last byte in UART to be transmitted give Bluetooth time to finish disarm Bluetooth power wait 100ms 120 128 INF 3996 Appendix D The modified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL
15. for the step counter As such the movement sensor is the biggest sinner Its position sensitivity forces the step counter to be nothing more that a hip worn device The result of this is the major restrictions introduced for other types of measurements 65 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 66 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 8 Future work 8 1 The time set function As already mentioned for the routines suggested and implemented they have serious weaknesses when thinking of the current consumption The routine chosen keeps the step counter awake for at least 5 seconds just to set the watch In addition it introduces a secondary function for the transmit switch This might complicate matters for a user and it may introduce an extra error source The third alternative has the immediate consequence that the user send routine can more or less be changed back to its original state In other words from 3 3 back to 3 see appendixes A B and C In addition the timer send routine can return to version 4 1 see Figure 26 However for the third alternative to work two way communication between the mobile phone and the step counter has to be introduced As a part of a receipt message the mobile phone can transmit the number of eight second sequences between now and the 24 hour report time On the mobile phone the user can set up which time he she wants the tim
16. however is just a presumption and has to be tested if the 3 1 routine is to be used But having this in mind plus that the 3 2 routine seemed shorter and easier to implement it became the chosen one It is basically a routine that every 50 mS polls the intl input to check whether the button has been released A counter keeps track of 56 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen every poll When this has performed a hundred times or more the button has been pressed for over 5 seconds If this is the case the 24 hour real time clock is initialized with its preset values However if not the routine performs as originally and transmits data In Table 4 the new user send routine is listed 57 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen Table 4 The new user initiated send routine 3 2 isr_mtransm sei Idi count Ox00 delaying 49995 cycles nearly 50mS at 1MHz int1 loop Idi tempo 101 loopO Idi temp1 164 loop1 dec temp1 brne loop dec tempO brne loopO check if switch is released in tempO PinD andi temp0 0x08 cpi temp0 0x08 breq time1 jmp int1 loop If button has been pressed down for 5 seconds or more reset the 24 hour counter values timet cli Disable global interrupt cpi count 100 brit outi Idi rtcH deltaThigh Idi rtcL deltaTlow movw r3 r2 rtcH rtcL reti The only really new code here is the 50mS delay sequence
17. is its downside Not needing an extra instructions for read and write operations is the memory mapped I O s main advantage However the occupation of memory locations is its main disadvantage 18 In order to carry out I O operations there are only three possibilities polling interrupt driven I O and DMA During polling the status of the register in question is checked at intervals in order to find out if it has received or produced data When in need of servicing the I O unit in question raises a CPU flag Given the interrupts designated priority the microcontroller will initiate the assigned interrupt service routine at once or when its current task is finished DMA is not relevant here as it is not available in the chosen microcontroller However it was traditionally used to increase performance but in low power embedded systems it helps servicing interrupts allowing the microcontroller core to remain in sleep mode longer 2 4 1 3 Pipelining By observing that during execution of instructions a large part of the microprocessor was not used someone found out that the instruction cycle could be broken down into a sequence of steps Each of these steps would only use a small portion of the time needed to complete the whole instruction Having a pipeline with multiple stages each of these steps is assigned to an exclusive stage The instructions enter the pipeline at one end and steps finished exit at the other end When a subtask result
18. not last byte Set data stack pointer set frame sync tilde set protocol ID 0x55 stor ID value set crc bytes 111 128 INF 3996 Appendix D The modified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLELI H ek Title Pedometer for Telemedisin ok H Filename isr count asm ok Block diagram 2 ok H Versjon 1 1 OA BETA ok Last updated 2007 04 19 ok Target ATmegal64p ok E Description Interrupt service routine for INTO step count update ok Designed by Willy Mortensen ok Modified by Odd Arne Olsen ex LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL H isr_count intO_loop in temp0 PinD test for step puls off simple filter routine andi temp0 0x04 cpi temp0 0x04 breq ou jmp intO loop loop until end of step puls out0 adiw stcH stcL 1 Increment step counter reti 112 128 INF 3996 Appendix D The modified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLELI H ek Title Pedometer for Telemedisin ok H Filename isr timer asm ok Block diagram 4 2 ok H Versjon 1 2 OA BETA ok Last updated 2007 04 28 ok Target ATmegal64p ok Description Interrupt service routine for TIMER2_OVF and id test of the 24 hour limit day end flagg ok Designed by Willy Mortensen ok Modified by
19. pin definitions equ equ equ equ equ equ xD z0 UART receive pin is PDO tD l UART transmit pin is PD1 intdO 2 interuptO down on PD2 intd1 3 interupt1 down on PD3 Bt_power 0 Bt power on off Bt_DTR 1 data ready from Bt 92 128 INF 3996 Appendix C The unmodified program geese slobal defenition CSEG org 0x00000 Seem def interupt vektors init Odd Arne Olsen jmp start reset handler org INTOaddr Step interupt service routine jmp isr count org INTIaddr manualt transmitt of data service routine jmp isr mtransm org OVE2addr rtc overflov service routine timer2 jmp isr timer Sei MCU register init start Start register initiering Idi temp0 0x04 load SPH out SPH temp0 Idi tempO Oxff load SPL out SPL temp0 Idi temp0 0xc3 Idi temp0 Oxff mov r3 temp0 temp0 0x50 Idi tempO0 0xfb mov 12 temp0 preset rtc for counting up Idi temp0 0x0A sts EICRA tempO Idi tempo 0x03 out EIMSK emp load ext interupt mask register cbi DDRD intdO initier port direction INTO NB load EICRA ext interupt controll register A falling edge sense on INTO and INTI 93 128 INF 3996 Appendix C The unmodified program Odd Arne Olsen cbi DDRD intd1 initier port direction INT1 Idi temp0 0x00 load MCUCR controllregister out MCUCR temp0 Idi temp0 0x07 load sleep mode and power save out SMCR temp0 peek initier rtc regist
20. programmable Flash memory used as program memory Its size is processor dependent In addition to being the storage for the program instructions it also stores the interrupt vectors The program memory data bus is 16 bits wide and only feeds the instruction register 17 3 On chip data memory EEPROM and RAM in most devices The 8 bit data memory data bus connects most of the peripherals to the register file The data memory consists of five different components 17 a Aregister file with 32 general purpose 8 bit registers 17 b 64 VO registers of 8 bits width 17 c Internal static RAM Its size is processor dependent 17 d External SRAM for larger AVRs 17 e EEPROM in a separate memory space 17 4 0 10 MHz clock speed operation 17 Most AVR instructions are one word long and as such occupy one memory location Because of the AVRs two stage pipeline many of its instructions executes in a single clock cycle The next instructions is being fetched while the current one is being executed 17 The AVR family has more members than the 8 bit microcontrollers Here however the 8 bit ATmegal64P will be the only center of attention 2 4 3 The ATmega164P microcontroller For this part of the project the project group has chosen the brand new Atmel ATmegal64P microcontroller This was done in order to accommodate not only the needed I O features but also the presumed memory space demands needed for 18 128 INF 3996 A Sensor Dev
21. reference to the definition of telemedicine adopted by NST the step counter could also be categorized as a telemedical device Telemedicine is the investigation monitoring and management of patients and the education of patients and staff using systems which allow ready access to expert advice and patient information no matter where the patient or relevant information is located 4 The collected and processed data are available at the person s mobile phone and as such the data could be made available to the physician irrelevant to the involved persons individual geographical position 2 2 Self monitoring system The NST project NST s lifestyle research team is trying to develop a self help system for patients suffering from chronic or lifestyle related diseases The motivation for doing this was 11 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen that diseases like diabetes require a sharp eye on the blood glucose levels These levels are then used as a measure to balance the patient s diet and physical activity and possibly medicine However this approach does apply to other diagnoses also as for instance high blood pressure A tool like this would have an inestimable impact on the everyday life for those suffering from these and other diseases relevant for this system In addition there are persons with no immediate diagnosis who could benefit from such a system for instance people who for one re
22. seven This is especially the case for mechanical sensors Voltage V Vout M Time s Voltage V Vout M Figure 20 Illustrations of output from a movement sensor V indicates the border between a logical high and a logical low level a The ideal situation one movement one pulse b A situation closer to the truth one movement and a lot of ripple The reason for using mechanical sensor is that there is no need for a quiescent current or indeed no extra power at all However the ripple needs some extra attention A low pass filter made out of passive components letting the movement signals through and blocking the fast ripple could solve some of the problems This works to a certain extent The mechanical sensor must of course be able to perform well at the intended movement frequency range if not no filter can save the signal In Figure 24 an example of this can be seen Further signal conditioning can of course be done by adding extra external components as for instance a monostable multivibrator or a Smith trigger A possibly 47 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen smarter way would be to do a software implementation of the component function or adapt and utilize features already available in the microcontroller 6 1 2 The inclinometer test The tests done by the research group using an inclinometer is a good example of the above An inclinometer is in its si
23. that a reset is synchronized on both sides of the bus Among many other uses it is nowadays also used as a debugging tool for embedded systems Although a standard there seem to exist many versions of the JTAG bus The version of interest here is the one that Atmel uses as communication between their ATmega microcontrollers and the AVR JTAGICE mkII emulator Figure 4 shows signals involved in their implementation The signals have the following functions TCK is the bus clock TDO is the signal from the target JTAG device to the JTAGICE mkII emulator VTref is the target reference voltage TMS is the mode select signal from the JTAGICE mkII to the target JTAG device nSRST is the same as TRST described above synchronized system reset nTRST is not connected TDI is the data signal from the JTAGICE mklTI to the target JTAG device GND is of course ground 17 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 2 TCK GND TDO VTref TMS nSRST nTRST TDI GND Figure 4 Atmels 10 pin JTAG connector 23 2 4 2 The AVR Architecture The AVR architecture is the name of Atmel s family of RISC processors based upon the Harvard architecture Two students at NTH now NTNU devised the basic AVR architecture and further developed it as employees of Atmel Norway 24 Some of the features common for the AVR family is 1 Operating voltages 1 8 5 5V 25 2 On chip and in system
24. the step counter s microcontroller I started breaking it down into a block diagram My diagram is found in appendix B whereas the project team s diagram handed me later are found in appendix A Furthermore in appendix C a listing of the complete program prior to my proposed changes is found and consequently in appendix D the program listing subjected to my modification suggestions are to be found The purpose of the examination was both to gain detailed knowledge about the program and its functionality and to propose improvements and new functionalities The first task however was to discover errors in writing form or logic and to suggest corrections Figure 19 gives a general overview of the different modules in the step counter software The black arrows indicate a standard procedure call whereas the red arrows indicate an interrupt initiated procedure call The software consists of seven modules These modules are tied together as include files in the main program ped164 asm see Table 1 Somewhat confusingly both the main program and a routine are described as main However the complete step counter software is called the main program whereas the main routine main asm mentioned below is just a small part of the total program see chapter 5 6 3 Table 1 The ped164 asm main program pee main program nolist include m164pdef inc list include inite reg asm initialize the registers for start reset includ
25. 0 2 5 3 0 3 5 4 0 45 5 0 23Mar2007 11 46 Figure VI Output from NMS24M vibration sensor Test circuit seen in Figure I B 127 128 INF 3996 Appendix E Bluetooth module setup Odd Arne Olsen e x 892 3us s 0 0 0 5 1 0 15 2 0 2 5 3 0 3 5 4 0 45 5 0 23Mar2007 11 53 Figure VII Output from NMS24M vibration sensor Test circuit seen in Figure I A 128 128
26. 2007 Available from http winavr scienceprog com avr gcc tutorial Weddington EB WinAVR User Manual 20050214 cited Sourceforge net February 2007 Available from http winavr sourceforge net WinA VR user manual html Rowley Associates Crossworks for AVR Professional Tools for AVR Developers cited February 2007 Available from http www rowley co uk avr index htm Atmel AVR development tools Version 7 C Compiler Tools with Windows IDE for Atmel AVR Microcontrollers cited February 2007 Available from http www imagecraft com Morton J AVR an introductory course 2002 Oxford Newnes 6 bl 241 s Bluetooth SIG Bluetooth Basics Learn 2007 cited Available from http www bluetooth com Bluetooth Learn Basics Bluetooth_SIG Bluetooth Technology Benefits Learn 2007 cited Available from http www bluetooth com Bluetooth Learn Basics Bluetooth_SIG How Bluetooth Technology Works Learn 2007 cited Available from http www bluetooth com Bluetooth Learn Basics Blankenbeckler D An Introduction to Bluetooth The Bluetooth Channel 2000 cited March 2007 Available from http www wirelessdevnet com channels bluetooth features bluetooth html connectBlue Serial Port Adapter Version 2 and 3 AT Commands INDUSTRIAL BLUETOOTH 2006 October cited February 2007 74 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 38 39 40 41
27. 36 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 5 4 2 Hardware flow control In order for the microcontroller to know whether the Bluetooth module was active or not there was some uncertainty whether the flow control was needed or not I suggested the use of the DTR Data Terminal Ready line available on the Bluetooth module For RS 232 communication a unit can check whether a receiving unit is active and ready to operate by checking the status of the DTR line However it was not clear whether the active status of the Bluetooth module s DTR line was determined by flow control settings or not After some searching I found that the DTR and DSR Data Set Ready lines where controlled by a separate AT command As a direct consequence of this the hardware flow control could be disabled The AT command AT AMDS gave two functional possibilities for the DTR line The DTR line could be activated when the module started or when there was an active Bluetooth connection present 37 The latter was chosen since it meant an easy and foolproof method of checking not only the Bluetooth module s status but also whether there was an approved mobile base ready to receive the transmission An active flow control would have required two additional control lines the CTS and RTS in addition to software routines handling them 5 4 3 Choosing baud rate Initially the baud rate was set to 9600 baud But with the chosen cloc
28. 6 A Sensor Device And Its Application in eHealth Odd Arne Olsen 56 57 58 59 60 61 62 63 64 65 66 67 68 69 subcategory asp Category MINIATURE 20S WITCHES amp Sub V4 20T ype Alps Alps Compact Type Detector Switch SPPB Series cited February 2007 Available from http www3 alps co jp cgi bin WebObjects catalog woa wa varietyList language english amp country com amp top_mode 2003 amp productId 3 amp varietyId 8 Jeng JI Electronic circuit system named mobile safety communication MSC device embedded in the rearview side mirror of a vehicle 2004 United States Dimension Engineering A beginner s guide to accelerometers cited February 2007 Available from http www dimensionengineering com accelerometers htm Weinberg H MEMS Micro Electro Mechanical Systems Technology How they work cited March 2007 Available from http www sensorland com Analog Devices ADXL330 Small Low Power 3 Axis 3 g iMEMS Accelerometer cited February 2007 Available from http www analog com en prod 0 2877 ADXL330 00 html VTI CA3000 E01 3 AXIS ULTRA LOW POWER ACCELEROMETER WITH DIGITAL SPI INTERFACE cited February 2007 Available from http www vti fi en products solutions products accelerometers sca3000 accelerometers VTI SCA3000 Accelerometer in Speed Distance and Energy Measurement cited February 2007 Application Note 50 Available from http w
29. A quick search for literature reveals many possibilities though few in understandable languages Norwegian English Worth to mention is a tutorial 28 and a slightly aged user manual 29 In addition there is also a book available C Programming for Microcontrollers Featuring Atmel s AVR Butterfly and the free WinAVR Compiler by John Pardue ISBN 10 0976682206 ISBN 13 978 0976682202 The AVR Butterfly is a 20 evaluation card containing the ATmegal69 processor plus display and sensors 2 5 4 ImageCraft v7 C compiler and Crossworks for AVR These two software packages are also often mentioned along with the others Why these have not gotten more room here is mostly because of their license restrictions and advertised device support According to their current web pages Crossworks does not yet support the megal64 microcontroller 30 This of course may only be caused by slow working web masters More serious is their license policy There are three possibilities commercial educational and personal However in order to achieve the commercial freedom presumed desired by the research group only the commercial version to 950 would suffice This is not a problem with the ImageCraft system as its license levels only limits the number of features supplied A common feature which seems to disqualify them both is that they presumably only support their own line of emulators and programmers 30 31 22 128 INF 3996 A Sensor Device And Its Ap
30. AMON It is a wrist worn device designed for continuous medical monitoring 13 Its similarity with the NST project is the harvesting of biometric data for the purpose of wireless transfer to a base station for further handling Current status of this project is unknown as the project is terminated A problem with biometric measurements is the correct placement of sensors This is especially true if the patient is supposed to perform the task by him herself For devices as the AMON and the step counter this is not a problem But to register parameters such as ECG EEG heart sound lung sound etc sensors has to be placed on the torso This could be a problem for a patient A solution to this might be smart clothing where sensors are woven into the textiles An example of this is the WHEALTHY project Here the sensors and necessary wiring is woven or knitted into the fabric The sensors are controlled by a hip worn patient unit taking care of signal conditioning preprocessing and transmission of data 14 A project similar was the VTAM t shirt 15 They both use GSM GPRS as information carrier 2 4 The microcontroller 2 4 1 Microcontrollers A microcontroller is in contrast to a microprocessor designed for standalone operation A short list of the microcontroller s main features is low performance low 13 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen cost and high strength I O drivers This makes the m
31. EE initialize Bluetooth control lines cbi sbi sbi sbi cbi DDRD Bt_DTR DDRD Bt_RESET PORTD Bt_RESET DDRD Bt_power PORTD Bt_power set Bluetooth DTR line direction in set Bluetooth RESET line direction out Set RESET line high inactive set Bluetooth power line direction out turn Bluetooth power off See intialize uart Bluetooth communication lines sbi sbi PORTD txD DDRD txD initialize USART port transmit 110 128 INF 3996 cbi cbi Idi sts Idi sts Idi bits sts Idi sts Idi sts Appendix D The modified program Odd Arne Olsen PORTD rxD initialize USART port recieve DDRD rxD temp0 0x00 set single USART transm speed UCSROA tempO temp0 0x18 UCSROB temp0 temp0 0x06 UCSROC temp0 tempo 0x00 UBRROH tempO temp0 0x19 UBRROL tempO enable receive and transmit set frame format asynchronous 8 data bits 1 stop no parity bit set baud rate IMHZ 2400 bps pee Initialization of data package protocol stack Idi Idi Idi clrdstack Idi st dec brne Idi Idi Idi std std Idi std Idi std std end_init rjmp ZL 0x00 ZH 0x02 count stacklen temp0 0x00 Z temp0 count clrdstack ZL 0x00 ZH 0x02 temp0 0x7e Z40x00 tempO Z 0x01 temp0 temp0 0x55 Z 0x02 temp0 temp0 0xe6 Z 0x0c temp0 Z 0x0d temp0 main Set data stack pointer initialize start loop counter clear data stack branch if
32. H transmit_bt Idi ZL 0x00 set data stack pointer to start Idi ZH 0x02 Idi count stacklen Initier loop counter mov temp0 packnub update pack number inc tempO mov packnub tempO std Z 0x03 packnub stor packed number std Z 0x06 stcH step counter higher byte to data stack std Z 0x07 stcL step counter lower byte to data stack sbi PORTA Bt_power arm Bt power and wait for DTR high level Bt_ready in temp0 PINA test Bt ready sbrs temp0 Bt_DTR rmp Bt ready loop until BT ready transm ld temp1 Z Load data from data stack rcall putchar dec count brne transm branch if not last byte 101 128 INF 3996 Appendix C The unmodified program Odd Arne Olsen untilempty Ids temp0 UCSROA wait for last byte in UART to be transmitted sbrs temp0 UDREO rmp untilempty cbi PORTA BT power disarm Bt power Idi stcH 0x00 reset step counter stc Idi stcL 0x00 i ldi rtcH Oxc3 preset teal time counter rtc NB eee Idi rtcL 0x50 Idi rtcH Oxff preset teal time counter rtc Idi rtcL 0xfb movw 13 r2 rtcH rtcL Save preset value endtransm ret 102 128 INF 3996 Appendix C The unmodified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLELI ek Title Pedometer for Telemedesin ok Finamn main asm ok H Versjon 1 0 BETA ok Last uppdated 07 03 22 ex Target A Tmegal64p ek Description Main function ok H LLLL
33. KC 22 42 D KC Wirefree KC 22 real size 10x13mm 42 E KC Wirefree KC 21 44 F KC Wirefree KC 21 real size 15x27mm 44 G Sena Parani ESD200 45 H Sena Parani ESD200 real size top and side view 18x20x11 7mm 45 As already mentioned the KC 22 is delivered without an antenna see Figure 18 C and D This is the main reason for its small 10x13mm size There are many ready made possibilities but what is gained in simplified design is lost in increased size In order to keep the miniature size advantage an antenna system designed and adapted 40 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen for the step counter would be preferable Another short search revealed a number of possibilities where the Fractus Compact Reach Xtend chip antenna 46 seemed the most promising when size and efficiency were considered In addition when compared to similar chip antennas the Fractus required a somewhat simpler circuit board layout 47 Here however the simplicity seems to end in order for the system to perform optimally the signal line between the antenna the module has to possess certain characteristics Going further with the printed circuit boards mentioned above the easiest solution is a microstrip line A microstrip line is a transmission line geometry with a single conductor trace on one side of a dielectric substrate and a single ground plane on the other 48 49 The properties of a microstrip line ar
34. LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLI ek H Title Pedometer for Telemedisin ok a Filename ped164 asm ok H Versjon 1 1 OA BETA ek Last updated 2007 04 18 ek Target ATmegal64p ek Description Main include file ok Designed by Willy Mortensen ok Modified by Odd Arne Olsen ok LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLI H eke main program nolist include ml64pdef inc list include jnite reg asm initialize the registers for start reset include ier count asm interrupt service routine for step counting include ar timer asm interrupt service routine for RTC include isr mtransm asm interrupt service routine for user initiated transmit include uartO0 asm low level routins for UART handling include transmit bt asm data transmit routine include main asm main function 107 128 INF 3996 Appendix D The modified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLELI H ek Title Pedometer for Telemedisin ok Filename inite reg asm ok Block diagram 1 ok H Versjon 1 1 OA BETA ex Last updated 2007 04 19 ex Target ATmegal64p ek Description Initialization file ok Designed by Willy Mortensen ok Modified by Odd Arne Olsen ok a LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL H see global register definiti
35. LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL H putchar USART transmit Ids sbrs rjmp sts ret temp0 UCSROA wait for empty transmit buffer temp0 UDREO USART transmit UDRO temp1 put data in to buffer 117 128 INF 3996 Appendix D The modified program LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL H ok Function getchat ek x Description Get one character ok Usage ex H Return Yes ok H Note Return to be transmitted in temp ok H LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL getchar USART receive Ids sbrs rjmp Ids ret temp0 UCSROA temp0 RXCO USART_receive temp1 UDRO wait for data to be received get and return recieved data from buffer Odd Arne Olsen 118 128 INF 3996 Appendix D The modified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL ek Title Pedometer for Telemedisin ok H Filename transmit bt asm ok H Block diagram 5 2 DTR time out additions ok 3 Versjon 1 3 OA BETA ok Last updated 2007 05 19 ex Target ATmegal64p ok H Description Service routine for transmitting step counter data ok Designed by Willy Mortensen ok Modified by Odd Arne Olsen ok H LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL transmit bt cpi temp 0 0xAA breq power on Idi
36. LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLI H main sei set global interupt main loop sleep set sleep mode Power save S reall start sync 5 FE a e ak ek ok ok aka eh ok oa aal ek ak ok ale al ak kok rcall transmit bt nop nop rmp main loop TEST OF RUN start test Idi temp0 0x01 out PORTA tempO out DDRA tempO Idi temp1 0x01 test loopl add tempO templ bres gol 103 128 INF 3996 jmp gol Idi out Idi test_loop2 add brcs jmp Appendix C The unmodified program test loopl temp0 0x00 PORTA tempO temp1 0x01 tempO templ go2 test loop2 venteloop loop until next inerupt synkpuls for UART test start sync sbi sbi Idi Idi loop_sync add brcs jmp loop out cbi ret start syncx Idi out out Idi Idi PORTA 0x00 DDRA 0x00 r21 0x7f r22 0x01 r21 r22 loop_ out loop sync PORTA 0x00 temp0 0x01 PORTA tempO DDRA tempO r21 0x00 r22 0x01 Odd Arne Olsen 104 128 INF 3996 loop_syncx rcall add bres jmp loop outx cbi ret loop syn add bres jmp ret Appendix C The unmodified program indre 121 722 loop out loop syncx PORTA 0x00 123 0x00 124 0x08 123 724 loop out loop syn Odd Arne Olsen 105 128 INF 3996 Appendix C The unmodified program Odd Arne Olsen 106 128 INF 3996 Appendix D The modified program Odd Arne Olsen Appendix D The modified program 3 LLLLLLLLLLLLLLLLLLLLLDLLLLLLL
37. Odd Arne Olsen ok H LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLELI H isr_timer mov r4 tempO mov r5 templ movw rtcH rtcL r3 r2 load rtc value adiw rtcH rtcL 0x01 increment the rtc counter movw r3 2 rtcH rtcL save rtc value bres carry set 24 hours since last transmit jmp oldvalue carry set Idi temp0 0x00 rcall transmit bt transmit data Idi stcH 0x00 reset step counter stc Idi stcL 0x00 113 128 INF 3996 Appendix D The modified program Idi rtcH deltaThigh preset real time counter rtc Idi rtcL deltaTlow movw r3 r2 rtcH rtcL save preset value oldvalue mov tempO r4 mov templ r5 reti Odd Arne Olsen 114 128 Odd Arne Olsen INF 3996 Appendix D The modified program ok ig ie ok ok K KE K K K ok oft K ols oke oke K K K K K ols ols ols K K K K K K K oke ok oft ols ole K oke ok ols K K K K K K K K K ok K K K ok oke ok ok ok ok oke s ok Title ok H Filename ok Block diagram 3 3 ok Versjon SW Last updated ok Pedometer for Telemedisin isr_mtransm asm 1 2 OA BETA 2007 05 02 E Target A Tmegal64p ok em Description Interrupt service routine for INT1 manually d initiated data transmission 3 ok Designed by Willy Mortensen ok Modified by Odd Arne Olsen ok H LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLELI H isr_mtransm sei Idi count 0x00 delaying 49995 cycl
38. R JTAGICE mkII in circuit emulator 23 The emulator was used to test and edit the step counter software on the prototype printed circuit boards 29 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 30 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 4 Requirement Specification 4 1 Ergonomics power consumption and usability There are many factors why a user might chose not to continue using an e health device acquired during a sudden urge for health and fitness However the only factors possible to concentrate on here are of course device related issues like size weight and usability As such this calls for a step counter which is both light in weight and small in physical size The ideal situation is a system which when properly mounted is more or less unnoticeable for the user during his her daily activity Unfortunately these desires are at current in directly conflict with the wish for a long life span of the device A long life span is synonymous with large battery capacity A large battery capacity is in turn equal to increased size and weight Therefore keeping the current consumption at a minimum is vital Usability calls for a device with as few buttons and user controllable functions as possible Ideally the only thing the user should have to do is to attach the unit at a suitable place on his her body and think nothing more of it The planned wireless interface is a ma
39. The Atmel AVR JTAGICE mkll emulator 4 REQUIREMENT SPECIFICATION es sesesvonsenoonensenseneononsensonensenvenoonenseneenensencenensenvenensen 31 4 1 ERGONOMICS POWER CONSUMPTION AND USABILITY certet tentent 31 4 PERSONAL ADAPTATION AND CONTEXT AWARENESS eerte tenere tennt rete ne tne 31 4 3 RELIABILITY AND INFORMATION SECURIT 32 5 DESIGN AND IMPLEMENTATION nnen onenvenvonensensenonsensensenennensenconensenveneonensencenensenvenensen 33 5 1 THE STEP COUNTER PROTOTYPES ronnie ooa aeaa er EEES KVE e VEVE Eea i E 5 2 STEP COUNTER FUNCTIONALITY hrer E A EE EE nnne nsn nerit ases nennen n seen r renes nnn 5 3 BLUETOOTH MODULE SETUP eegen err rr tratta Eed Ee aere peser ree erro assailed dence trud 5 4 BLUETOOTH UART INTERFACING eene SLL Dat form een texere een 5 4 2 Hardware flow control eee 5 43 Choosing EE 5 4 4 Connecting microcontroller with the Bluetooth module esse 5 4 5 Some alternatives 3 5 POWER SUPPLY reete ees 5 6 THE STEP COUNTER SOFTWARE nana e 5 6 Program TA UTAH 6 2 wnilialization inite reg sm auicm ee eret eee eee 5 6 3 Main routine moin gem 5 6 4 Interrupt service routine for step counting isr_count asm 5 6 5 Interrupt service routine for user initiated data transmission isr mtransm asm 44 5 6 6 Interrupt service routine for real time clock update isr_timer asm n
40. able for the user before the time or step limits have been passed What might separate these two could be usability For a misplaced or forgotten device the activity controlled system seems to be the one to prefer If the time controlled unit is not found within the time frame the data is lost Whereas for an activity controlled system the data would have been safe Both solutions seem initially to be equally simple to implement and as such this would be the only thing dividing them Concentrating on the activity controlled system there has to be made changes to three routines First the Bluetooth control routine has to be able to know which data set to transmit see in Figure 29 on the right side The user send routine has to have the logic needed in order to decide which data set to send see Figure 28 Finally the timer send routine has to disable this feature as it should only transmit the data harvested within the last 24 hours see in Figure 29 on the left side 59 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 63 E global interrupts it SOMS and keep track of time Send switch released Time limit Yes passed No 4 Step limit No 4 passed d Yes f E E old data transmit oan old data transmit Y j Send data via Bluetoothi E the 24 hour sequence Return Figure 28 The final prototype version of the user send routine Since the retransmit order is c
41. an USB dongle for 500kr Only the computer with this dongle attached can run the program The prices gives one year of updates additional update beyond the first year is obtainable at a cost of 20 of the full license fee All prices are exclusive value added tax and freight charges More information to be found in reference 26 2 5 2 CodeVisionAVR CodeVisionAVR is an IDE and C compiler It does not contain a debugger but is designed to work with Atmel s AVR Studio Debugger This is a cheap alternative compared to the IAR Embedded Workbench The downside is a lower rate of updates and a system not as streamlined and well integrated as the IAR system However users seem to be very pleased with its features and level of usability It is undoubtedly a good alternative when price and available documentation is taken into the consideration There are two versions available however only the standard version is relevant for this project The reason for this is that the light version does not support the ATmega line of microcontrollers The prize for the standard version is 150 180 plus value added tax This includes a one year subscription of updates and e mail tech support The yearly updates costs at the time of writing 90 75 The ordering procedure is somewhat complex First the commercial version of the compiler has to be downloaded Then an order including the buyer s address details and name of product has to be sent via e mail t
42. ansmission The main reason for this was that the real time clock value was restarted every time the Bluetooth service routine was running This was fixed by moving relevant commands from the Bluetooth routine over to the timed transmit routine as indicated in Figure 26 This however does not give the user or the project group for that matter any control over when the timed transmit should perform Keeping in mind that the step counter only has one user accessible button introduces a small challenge It will have to maintain both the function as a transmit button and as a time setting control In the current setup of the step counter I see two closely related possibilities plus a third 54 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen solution which in turn requires a more extensive change in software This solution will be presented in the future work chapter The first two solutions just involve a modification of the interrupt service routine for user initiated transmission From the user side the first solution involves that he she presses the button on the step counter a given number of times within a certain time frame While the second one just demands that the user holds the button down for a certain time frame Bluetooth controller Timer send Read clock value Prepare data stack Increment clock value Start Bluetooth module Time to Send package byte by byte transmit Turn off Bluet
43. aptured by the user send routine it has to use a temporary register as a messenger In the timer send routine this temporary register has to contain a message disabling this feature in the Bluetooth routine as it should only be available from the user send routine For this I chose to use the register named as tempO For the system to retransmit old data tempO has to contain the number OxAA or in binary format 0b10101010 60 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 63 e E Bluetooth controller nporary registers K ransmit old Yes data Read clock value No Prepare data stack Increment clock value Start Bluetooth module Time to transmit Send data via Bluetooth counter value and 24 hour sequence emporary registers eu Figure 29 Final prototype versions of the timer send and the Bluetooth controller routines Send package byte by byte Turn off Bluetooth 6 4 4 DTR timeout A more serious flaw in the given microcontroller software was the lack of timeout when waiting for the DTR signal from the Bluetooth module If the step counter was waiting to transmit its data and were for some reason not able to connect with the mobile base the system would continue in an endless loop waiting for an active DTR signal This was a relatively easy thing to fix the main problem was to choose the length of the timeout It had to be long enough for the syst
44. ason or another has to keep a diet and maintain a certain level of physical activity Starting with the Easy Health Diary application made for smart phones see Figure 1 they are working on an automatic system collecting biometric data by the help of a smart sensor system which is the focus of this thesis The smart sensor would consist of a microcontroller with computing capacity enough to perform the signal conditioning and the interface tasks relevant to the attached measuring units It will then perform the necessary data transformation before sending it on via a short range wireless interface to the smart phone 5 8 The mobile phone in question has to have computing and visualization powers sufficient to collect data automatically and manually Plus it has to be able to perform report generation and presentation of the data This is to be controlled from a simple and intuitive user interface By combining electronic gathered data with the user s own notes the system can in addition to presenting statistics of activity nutrition and health parameters also provide advices for future nutrition intakes and activity levels Sensor input The number of steps the user walks per day and each blood glucose measurement are automatically and wirelessly transferred to the smartphone diary using Bluetooth communication FTT 47 98765432 TE ICE relative Figure 1 The Easy Health Diary graphical user interfac
45. compact It is equipped with an internal antenna and as such it is ideal for this purpose The setup is taken care by a set of AT commands enabling the user to configure the module optimally in relation to his her needs In order to accommodate this the module has two operational modes transparent data mode and AT mode 37 24 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 2 8 Sensors The main purpose of a sensor is to give an environmental variable a numerical representation There are most likely a number of approaches available for every measurable entity some more successful than others An example of a sensor is the thermocouple sensor Two different types of metal wires are joined together in a small contact point Over this junction point there will be an electrical potential depending on the type of metals used and the junctions temperature There are many types available depending on area of usage accuracy and cost The potential difference over a modern thermocouple could be between 1 u V C to approximately 70 u V C 38 This is an example of an analog sensor which would need an amplification of its output signal and an A D converter in order to get a readable representation of its data into the microcontroller However this is also an example of a sensor which would need software correction due to non linearity in addition to value look up tables or a polynomial interpolation formula in order to pr
46. d health management elektronisk ressurs state of the art and future challenges Studies in health technology and informatics v 108 2004 Amsterdam Washington DC IOS Press xii 354 s NST What do we mean by telemedicine cited April 2007 Available from http www telemed no index php cat 4636 Arsand E Andersson N and Hartvigsen G No touch wireless transfer of blood glucose data from patient operated blood glucose monitors 2006 NST Arsand E and Hartvigsen G A wearable eHealth system for people with Type 2 diabetes in Scandinavian Conference on Health Informatics 2005 2005 Aalborg Denmark Aalborg University Arsand E and Hartvigsen G Reprogrammable Hardware used in future Patient Centric eHealth Tools in TTeC 06 2006 NST Troms Arsand E Wangberg SC and Hartvigsen G Capturing and presenting patient data through a smartphone designing a self help tool in Troms Telemedicine and eHealth Conference 2006 Tromsg Norway NST Norwegian Centre for Telemedicine Poster Welsh M CodeBlue Wireless Sensor Networks for Medical Care 2006 cited January 2007 Available from http www eecs harvard edu mdw proj codeblue Jovanov E and Milenkovi A WHMS Wearable Health Monitoring Systems Huntsville 2006 cited January 2007 Available from http www ece uah edu jovanov whrms Polastre J Szewczyk R and Culler D Telos enabling ultra low power wireless research 2005 Jovanov E et al A wireles
47. d the routine calls the Bluetooth transmit routine After completion of the transmit routine the microcontroller returns to the main routine 5 6 6 Interrupt service routine for real time clock update isr timer asm The interrupt service routine for the real time clock is called every eight second This routine counts the amount of eight second sequences When this amount equals to 24 hours the Bluetooth transmit routine is called One interesting thing with this routine is that this real time clock value has to be stored in a different set of registers than the registers used for the updating The reason for this is that it is only possible to perform additions on a 16 bit value in a limited number of the general purpose registers However this register also has alternate functions and as such a back up storage is needed 44 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 5 6 7 Control routine for transmitting step counter data transmit_bt asm The control routine for transmitting step counter data transmit_bt asm or the Bluetooth transmit routine as it also has been called retrieves the step counter data from its storage and inserts into the data package After having turned on the power to the Bluetooth module the routine checks the DTR input line whether it has made contact with the mobile base and is ready to transmit When this is the case the routine sends the data package frame by frame
48. d the hardware generally The suggestion for changes does not introduce any new features but rather tries to direct the functionality towards the project group s intention The main suggestions involve how to avoid loss of data and also let the user take charge over when the step counter should report to the mobile base The thesis starts with an introduction to the main project and a revision of similar projects The direction then changes towards the theory and tools necessary to perform the intended task are presented A somewhat large part is devoted to design of movement sensors As a part of this there were done some tests The results of some of these plus suggestions for some new are presented As wireless communication carrier the project group has chosen Bluetooth The thesis gives a revision of the module chosen plus some alternatives In addition there is also some suggestions regarding the setup of the module 7 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 8 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 1 Introduction The aim of this project is to test and further develop a prototyped smart sensor system This system is designed and built by the Norwegian Centre for Telemedicine NST and SensoTek as part of the projects Self help through a mobile ICT tool and The Lifestyle Project The smart sensor system is at the moment implemented as a step counter able t
49. e 8 12 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen Here the glucose measurements are used as example of biometric data but other alternatives could be a pulse counter a blood pressure monitor etc The reports generated from such a system could be forwarded to other receivers approved by the patient at hand For instance to an electronic health record or in the case of infants the parents 5 8 2 3 Wearable health monitoring systems The NST project is however one among many others in the field Closest when it comes to the technology chosen is the as Harvard University s Code Blue 9 and the WHMS Wearable Health Monitoring System from The University of Alabama 10 They base their smart sensor system on the Telos sensor node platform Telos is module made at Berkley University for the purpose of research and experimentation It uses Zigbee as its communication carrier 11 Common for these two projects is that they are emphasizing on wireless body area networks and the use smart sensors for professional medical purposes The areas involved are continuous monitoring as a part of a diagnostic procedure observation and counseling of patients with chronic conditions supervised convalescence or multiple patient observations at hospitals or in disaster areas 9 12 There are many other projects which are based on non invasive measurements One of the smallest and handy ones seems to be the
50. e given by its physical measurements and the substrate s electrical abilities At 2 4GHz this is vital in order to obtain an adapted and reflection free connection with correct impedance A well designed and well tuned antenna system will ensure that as much as possible of the power produced by the Bluetooth module is transmitted If there however does not exist any special needs in terms of the positioning of the antenna for instance mechanical design or noise considerations the other alternative KC 21 is basically the same module but with an antenna Anyhow reading through the data of each module the reason for choosing any of the other modules than the connectBlue OEMSPA311 has to be smaller sizes In terms on features and power consumption they offer roughly the same Both connectBlue and Parani has Norwegian representation but KC Wirefree has dealerships in England and Germany A foreign dealer is not necessarily a weakness as both KC Wirefree s and connectBlue s delivered their respective devices well within a working week in contrast to what many Norwegian representatives are able to do In the project group there has been a lot of talk about a manufacturer named Cambridge Silicon Radio Limited CSR But as far as I could tell they only manufacture Bluetooth chips not modules 50 Because of this they are not of interest in the current stage of the project however for later step counter versions the chips can be well worth looking into
51. e isr count asm interrupt service routine for step counting include isr timer asm interrupt service routine for RTC include Tier mtransm asm interrupt service routine for user initiated transmit include uartO asm low level routins for UART handling include transmit bt asm data transmit routine include main asm main function 42 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen Initialization inite_reg asm Main routine main asm O Interrupt service routine for Interrupt service routine for Interrupt service routine for step counting user initiated data transmission real time clock Dier count asm isr mtransm asm ier timer asm Control routine for transmitting step counter data transmit_bt asm Low level UART servicing routines uart0 asm 9 Figure 19 Overview of the complete step counter software 5 6 2 Initialization inite reg asm In addition to taking care of the definitions of global constants the initialization module inite_reg asm sets up the microcontroller features according to the desired functionality To be more specific Qiving often used registers and ports names matching their function in the program Specify the needed I O ports as inputs or outputs Set up timer counter 2 for real time counting Set up UART serial interface Define interrupt vectors Initialize stack pointer register Alloca
52. e at every Bluetooth module power up If the connectBlue module is not able to perform in this manner it has to be replace with one who does v 5 E ms 10 0 10 20 30 40 50 60 70 80 90 27Mar2007 13 54 Figure 17 Oscilloscope picture of the output from the microcontroller s UART 5 4 5 Some alternatives One weakness of the OEMSPA311 s became apparent when the project group found another module with a physical size over four times smaller However this module the KCWirefree s KC 22 needs an external antenna 42 39 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen In addition to the already mentioned KC 22 module from KC Wirefree I found two other promising alternatives The first one is the KC 21 also from KC Wirefree and the second one is the Parani ESD200 from Sena There are of course other modules available these are just the result of a short internet search Figure 18 shows pictures of the mentioned modules and gives an idea of their real size Figure 18 All reviewed Bluetooth modules On the left side is a photo of each module whereas on the right side the illustrations show the modules footprint A connectBlue OEMSPA311 43 B connectBlue OEMSPA311 real size 16x36mm 43 C KC Wirefree
53. ed transmit to perform The user can check and or change the time anytime he she chooses to When receiving a step counter report the software in the mobile phone has to translate current time into this eight second scheme and transmit it along with the receipt All the step counter has to do is to store this value It may have to take in account latency time however this will most likely be well within 8 seconds When to way communication is implemented the changes and additions on the step counter side would be relatively small The receiving routine has to extract the time data and store it On the mobile phone side this solution will probably put a little bit harder challenge on the programmer In addition to usability the most important thing gained with this solution is the reduced active time of the step counter But let s not forget the removal of an error source An erroneous activation of the transmit time set button might cause loss of data 8 2 Alternative power supply In order to make the step counter more flexible and to extend its duty cycle the possibility of using a rechargeable battery system should be looked into This change would require many new components but the need for battery capacity would be reduced The direct consequence of this would be a smaller and lighter battery A wired recharging system is of course a possibility But the wires and headers involved would most likely be looked upon as a step backwards in t
54. ed but not described in detail Here however a short definition list follows Hexadecimal numbers are marked with the prefix Ox Binary numbers are marked with the prefix Ob Decimal numbers have no prefix Brown block diagram boxes illustrates parts of the original program Blue block diagram boxes illustrate a suggested change In this thesis the abbreviation ISP means in system programming The rest of the report has the following outline Chapter 2 gives a brief introduction to eHealth and the use of smart sensors in eHealth for then to slide into descriptions devices used for this project Chapter 3 describes the equipment and its usage Chapter 4 presents the project requirements and some of the immediate technical implications they have Chapter 5 presents the step counter and its software Chapter 6 describes changes and additions made in addition to making suggestions for further development Chapter 7 discussion Chapter 8 presents some possibilities for future work Chapter 9 conclusion 9 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 10 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 2 Background 2 1 e Health Trying to find plain e Health definition is difficult It seems as though every involved party has coined their own meaning satisfying their own needs The Norwegian Center for Telemedicine has adopted the definition quoted below
55. em operator without physical access to the system to perform remote service The only condition would be that the smart phone is in an area of mobile network coverage with the step counter in its vicinity The system suggested below might seem a bit extravagant However if in need of a total reprogramming this might be worth looking into But if only smaller parts of the program need updating the ATmegal64P is capable of handling this on its own 25 But in order for any of these to function the system has to be supplemented with for instance a CRC checksum routine in order to intercept transmission errors The solution described here requires an extra microcontroller not necessarily of the same type as the first one The requirement for the second one has to be that its SRAM or data EEPROM is large enough to store the whole contents of the first ones 68 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen program memory In Figure 32 an idea for a possible solution on how to solve this can be found For this to work the following assumptions has to be made MCU2 must have SRAM big enough to store the whole program memory of MCUI Where MCUI is the controller interfacing the sensors wireless communication etc If this is not possible then an arrangement similar to that involving ICT IC2 and Rell has to be made for MCU2 also The MCUI has to program MCUJ2 first via the serial SPI bus IC1 and IC2 here indicated as NOR
56. em to be able to connect but it has to have an upper limit in order to avoid extra strains on the already limited power budget But what happens if it is the 24 hour report that can t be transmitted After a 100 new steps the data would be lost according to chapter 6 4 3 However the user has 61 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen chosen the report time himself herself and presumably will he she check the mobile base for incoming data The user would as such be aware of a problem like this and would be able to perform the necessary steps to correct the situation It is possible to make the step counter transmit two messages in such situations First the 24 hour report then the steps registered since the report time However I chose to have faith in the user and believe that the 100 step limit will suffice as security limit In addition it will be to the benefit of the power budget The software solution is based around the same delay loop as is used in Table 4 under the label intl loop In appendix D file transmit_bt asm under label Bt ready is my suggestion listed 6 4 5 The final changes What remained after this in order to get a fully working prototype program was to remove all debug and test code In addition the DTR line check and Bluetooth power on off function had to be activated During the hardware debug phase it was decided that the Bluetooth reset function should be inco
57. ennen 44 5 6 7 Control routine for transmitting step counter data transmit bt asm sess 45 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 5 6 8 The low level UART servicing routines esses 45 6 RESULTS 6 1 MOVEMENT SENSORS sssseseensesssssseesserertttttrtttssssrssses tettette ttes estt es ttet tretten sssseeeeeeetetrerresesen 6 1 1 Sensor design and testing 6 1 2 J Thenclinometer Reese an E A See ERE e ACER x c BeOS 6 1 3 The sub miniature micro switch fest 6 1 4 Tilt and vibration sensors es 0 19 Acceleromelt rs dust ote ta rite he oe feni a Dh hase 6 2 POWER CONSUMPTION ecc dense e e IRSE EE DRE eR eS ONE e EROR Ed ee euet aede eee eS 6 3 DATA SECURITY cett 6 4 MICROCONTROLLER SOFTWARE 6 4 1 The initialization file inite_reg asm 6 4 2 The communication and time control routines eese eene 54 6 4 3 Retransmission of lost data 6 4 4 DTR timeout 0 425 Whesinal changes etur tora Boetii roc tates Ts DISCUSSION peer 63 7 1 SENSORS eese 7 2 WIRELESS COMMUNICATION 7 3 MICROCONTROLDER sss 2 1 220 ec estere biete tie testet eio iet des Pee bett eee det put 7 4 POWERSAVING SE TS MICROCONTROLLER SOFTWARE 7 6 HE STEP COUNTER EE A EEEE NH EE FEN FUTURE WORK ener 67 8 1 THE TIME SET FUNCTION ed ageet teen bide ches lere T eR Ore ie PERS EAR sheds teehee
58. eqep SZIJBINJIUI BOngounLiulo F S az d 1043u03 Jamod u1o93en g azi erniur apo dees ez Sidhlajut 8Qo D ojqgu3 DIM 12012 LS TT pZ Sp JEU 191X2 azijeiey Uew SJUJBU PUB SJUPJSUOI sudiuyeq uone 86 128 Odd Arne Olsen Appendix B My block diagram INF 3996 uinjey Hong CIA 23ep pues paseo a4 TGI pu s puas Jaen Uny 5d235 Jo 3unouue y azepdn Dis dajs jo pug dajunos dais 87 128 Odd Arne Olsen My block diagram Appendix B INF 3996 UJNJIUH PC pesay Woon 4o UINL Big Ag ejAq abe Inpotu Ujoojenig HEJS H9875 ejep 135 hallt DO u Line Moeng ei eyep puss NNWSULAIJ 03 Sully SMEA X209 1USUISDUT anjen 20 2 Pear puss Jaw 88 128 Odd Arne Olsen Appendix B My block diagram INF 3996 TREN ER Xr 385 aj q puss EIER PGAISI DU puas 0 Apeey SEET RR TS SST fe Jrd 89 128 INF 3996 Appendix B My block diagram Odd Arne Olsen 90 128 INF 3996 Appendix C The unmodified program Odd Arne Olsen Appendix C The unmodified program LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLI H ek Title Pedometer for Telemedesin ok Filnamn ped164 asm ok 3 Versjon 1 0 BETA ex Last uppdated 07 03 22 ex Target ATmegal64p ek Description Main of included files ex H LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLI a eke main pro
59. er looking for ways to shrink the size of the step counter and as such modules like the KC Wirefree KC 21 or the Sena Parani ESD200 could be worth taking a closer look at However in order to move further both in terms of lower power consumption and smaller physical size the solution might be to move a step back and start to construct a Bluetooth system at chip level Here the solutions from Cambridge Silicon Radio Limited could be a good place to Start 7 3 Microcontroller The microcontroller chosen by the project group Atmel ATmegal64P became available on the market in the end of 2006 It is the smallest one in a series of three quite similar microcontrollers They differ only in terms of memory sizes The immediate advantage of this is if future software demands calls for a larger memory size This can be achieved with minimal effort and practically no change of hardware except for the microcontroller of course The amount of available I O features should make this a good start for the sensor platform which the project group hopes to make 7 4 Power saving A feature available in many Bluetooth modules is the possibility to reduce the output power Since the communication between the step counter and the mobile base most likely will be performed over short distances a good power saving effort would be to reduce the step counter s transmit range to 10m As long as only one way communication is implemented there are no other real possibil
60. er on order to test the program under development the IDE will have to be supplemented with other programs and devices such as a simulator or an emulator A simulator is a software tool for simulating the microcontroller and its program The emulator will make it possible for the designer to test his her code in circuit Other tools one might stumble over are starter kits and flash OTP programmers The starter kit gives a low cost possibility of software testing in a hardware environment while the flash OTP programmer is a good tool for programming large series of microcontrollers Figure 6 gives an illustration of where in the development process each tool or program is used The figure also hints of a development cycle somewhat more intricate than for what one might in lack of better words call ordinary programming Assembler U KU SSS Assembly source code Emulator and the target system C compiler ep C source code Prototype Code yes Program the testing Code ves bug El microcontroller nn OM MG 7 free BR wi free Ne No Figure 6 Development cycle of a microcontroller based system Below is a listing of the programming environments involving an embedded C compiler that where relevant for this project In addition to these programming environments it has to be mentioned that Atmel supplies a free IDE system the AVR Studio It includes to
61. erms of usability There is however the possibility of wireless charging or inductive charging as it is called It is a relatively low cost space economic solution 67 As the smart card 67 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen applications constructed at Fraunhofer IIS is a good example of 68 se also Figure 30 Figure 30 Smart card with a wireless battery charge system 69 The main difference between a wired and a wireless charger is that in the wireless system the transformer is split in two The two halves functions respectively as a transmitter and a receiver antenna In addition in wired systems most of the charging electronic is placed inside the stationary power module Whereas in the wireless system this is situated in the wearable unit see Figure 31 Whether this is a possible solution for the step counter will only tests reveal The main challenge would be the co existence of a Bluetooth module and the wireless charge antenna in the same enclosure Charging System Reader System Antenna j Rectifier fp SE Figure 31 Block diagram of a wireless charge system 69 8 3 Remote programming In order to make a fully flexible system the possibilities of remote programming the step counter from the smart phone should be investigated This feature might not be open for the user but more as a means for system setups or updates Maybe it even could be an opportunity for the syst
62. ers Idi temp0 0x01 load T C2 overflow interupt mask register sts TIMSK2 temp0 Idi temp0 0x07 load T C2 controll register set prescaler sts TCCR2B temp0 divided by 1024 Idi temp0 0x01 reset T C2 interupt flagg register out TIFR2 temp0 Idi temp0 0x20 set assyncron clock from crystall T C2 sts ASSR temp0 counting eK initier Bt power sbi DDRA Bt_power set Bt power bus direction out cbi PORTA Bt_power disarm Bt power off cbi DDRA Bt_DTR set Bt DTR bus direction in RRR ein itier uart sbi PORTD txD initier USART port transmit sbi DDRD txD cbi PORTD rxD initier USART port receieve cbi DDRD rxD Idi temp0 0x00 set double the USART transm speed sts UCSROA tempO Idi temp0 0x18 enable receive and transmit sts UCSROB temp0 Idi tempo 0x06 setframe format asyacronous 8data bits Istop bits 94 128 INF 3996 sts Idi sts Idi sts Appendix C The unmodified program Odd Arne Olsen UCSROC temp0 no parity bit tempO 0x00 set baud rate IMHZ 2400 bps UBRROH tempO temp0 0x19 UBRROL tempO pee initiering protokoll stack Idi Idi Idi cldstack Idi st dec brne Idi Idi Idi std std Idi std Idi std std end_init rjmp ZL 0x00 set data stack pointer ZH 0x02 count stacklen Initier start loop countet temp0 0x00 clear data stack Z temp0 count cldstack branch if not last byte ZL 0x00 set data stack pointer ZH 0x02 temp0 0x7f se
63. es nearly 50mS at 1MHz intl loop Idi tempo 101 loopO Idi templ 164 loopl dec templ brne loopl dec tempO brne loopO check if switch is released in temp0 PinD andi temp0 0x08 cpi temp0 0x08 breq timel jmp intl loop If button has been pressed down for 5 seconds or more reset the 24 hour counter values 115 128 INF 3996 Appendix D The modified program timel cpi count 100 brit hundredstep Idi rtcH deltaThigh Idi rtcL deltaTlow movw r3 r2 rtcH rtcL hundredstep cpi stcH 0x00 brne newdata cpi stcL 101 brit olddata newdata Idi tempo 0x00 jmp outl olddata Idi temp0 OXAA outl cli rcall transmit bt reti Odd Arne Olsen 116 128 INF 3996 Appendix D The modified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLDLLLLLLLLLLLLLLLLEL ok Title ok H Filename ok H Version ok Read Write through USART uartcom asm 1 1 OA BETA Last updated 2007 04 19 ok Target ok ATmega164p LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL H ok 3 Function putchar ok 3 Description Puts out one character ok Usage ek Return None ok 3 Note Parameter to be transmitted in temp ok Designed by Willy Mortensen ok Modified by Odd Arne Olsen ok b LLLLLLLLLLLLLL
64. esent the correct measured temperature In order to record a number of recurring events for instance the number of a special movement a device which produces a pulse each time the situation occurs is needed Such a pulse can be fed directly to one of the microcontroller s digital input without any signal conditioning Here there are many possibilities also but in it simplest form it can just be a switch 25 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 26 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 3 Methods 3 1 Sensors measurements For testing out possible movement sensors two circuits where used This might seem redundant but the circuit shown in Figure 8 B was the one I used before the project group supplied me with the initial hardware specifications The components in Figure 8 A were chosen with sharp eye power consumption This is however a delicate trade off as a too high resistance circuit will give noise problems while a too low resistance circuit might cause a premature drainage of the power source 10KO 100nF IMO 3V 3v Figure 8 Sensor test circuits A Implemented in the step counter B Only used for test purposes As power source an Oltronic B202 laboratory power supply were used The measurements were performed with a Picoscope 2105 virtual oscilloscope It is a pen shaped probe with an USB interface combined with comp
65. f between the data s level of sensitivity the amount of information transmitted and the cost involved in implementing further security As such the project group s intentions for the future of this system will also have to be taken into account However here at this stage of the project I assume that the security available is adequate 52 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 6 4 Microcontroller software 6 4 1 The initialization file inite_reg asm The initial hardware setup had to be changed due to a possible conflict with features needed for future step counter version As can be seen in the program listing found in appendix C the Bluetooth control lines was initially designed to connect to I O port A On my request this was changed due to the fact that port A also doubles as interface for the A D converter As such the interface lines were moved to port D Figure 25 shows the final layout of port D Pin number 13 15 represents the changes DTR RESET L o u c U u a y u Send switch not connected Bluetooth on off Figure 25 Port D layout Pin numbering refers to the TQFP QFN and MLF packages These changes did however just represent changes in the declarations and port setup The changes and additions regarding this are listed in Table 2 Table 2 Additions and changes to constant pin and port definitions gee global pin and constant definitions eq
66. frame 25 These are not absolute values as higher error ratings can be acceptable But the system will have less noise resistance and have increased sensitivity for the deviations in the internal RC oscillator s frequency 37 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen In asynchronous mode the transfer rate can be doubled This is done by setting the U2Xn bit high This should have no effect on the transmitting side However for the receiver this halves the number of samples taken in the data reading and clock recovery procedures Having an accurate baud rate setting and a stable system clock this should not produce any problems 25 During the first testing the microcontroller UART baud rate was set to 9600 baud with the U2Xn bit high According to the microcontroller documentation this should only give an error rate of 0 2 But measurements done showed an error of around 8 slower on the produced data frames This could of course be caused by errors and inaccuracies in the measurement process But no matter the cause of this error it was obvious that a baud rate of 9600 baud could not be maintained with an oscillator frequency of 1MHz with the internal RC oscillator as its source The easiest solution was to clear the U2Xn bit and reduce the baud rate to 2400 baud For the current system this should cause no problem as the data package to be transferred consisted of only 14 9 bit frames With the help of a
67. gates It must be possible to wake up MCU2 via a standard input port The relay Rell here indicated as a MOSFET relay must not introduce a to high voltage drop on the power supply feed line to MCUI Outputs of IC and Rell must not affect the power supply feed during normal startup and run for MCUI Output of IC2 must not affect normal use of the reset function Both microcontrollers has to come from the same manufacturer they need not be of the same type though Vcc Vcc 1 IC1 Rel e 8 gt h ir Jd K zl i O Eu 7 JU Vee Pin out d IC Vee Pin out i of x Resel Pin in kekep siora 08 Fin out g O ep Databus O c Cm N MISOL Ene MOSI MOSI SPI pus MISO Pin out f SERM QN SCK Gnd E Gnd Figure 32 An idea for a solution for making it possible to reprogram the step counter from the mobile base The names Pin out d to Pin out g and Pin in k are chosen at random they just indicates standard I O ports If this is a plausible solution then the following will happen 1 MCUI receives an order from the smart phone to reprogram 2 MCUI wakes up MCU2 by the help of the Wake up signal 3 MCUI starts receiving the new program and forwards it to MCU2 via the data bus 4 After verification of received data MCU2 starts the programming sequence for MCUI To do this the MCU2 has to turn off the power to MCUI and turn it on again while keeping
68. gram LIST Include m164pdef inc include jnite reg asm initier the registers for start reset include isr_count asm interupt service routine for step counting include jsr timer asm interupt service routine for RTC include isr_mtransm asm interupt service routine for manuell data include uart0 asm low level routins for include transmit bt asm transmiterings routin include main asm main function 91 128 INF 3996 Appendix C The unmodified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLELI ok Title Pedometer for Telemedesin ok H Filnamn inite reg asm ok H Versjon 1 0 BETA ok Last uppdated 07 03 22 ex Target ATmegal64p ok Description Initietings fil ok H LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLI H rr global register definition def def def def def def def def def def temp r16 register for handling of temporary data templ r17 statreg r18 register for handling of global status flag transf r19 register for handling of global transmiting status flag count r20 loop counter general rtcH 127 rtc temporary timeing register rtcL r26 stcH r25 step count register stcL r24 packnub r4 pack number to be transmitted see global constants equ stacklen Ox0e length of data stack yee global
69. he secondary outcome as a direct consequence of the reduced number of clock cycles per instructions is reduced power consumption 19 The Atmel s AVR processor controller family is based on the Harvard architecture 17 Figure 3 illustrates the difference reece von Neumann Processor Harvard Processor 4 Address Pathway Data amp Instruction Pathway Gitter Instruction Data Address Data Address Pathway Pathway Pathway Pathway Instruction Memory Data Memory Output Ee ee E ES PE ERE De ee Figure 3 von Neumann vs Harvard architectures 16 2 4 1 2 I O organization Memory mapped input output I O and I O mapped I O are the two basic ways of organizing I O If the unit at hand is I O mapped the I O operations requires special instructions to perform This means that the I O registers are situated in an address space separate of the address space designated for the other functions in the microcontroller However if the I O registers have absolute addresses in the microcontroller s address space the I O are memory mapped 15 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen The separation of the memory address space and the I O address space is the main advantage with I O mapping Because the whole memory address space can be used for program and data purposes without any restrictions Whereas as the requirement for an extra instruction
70. his On the other hand lowering the resistance and or increasing the capacitance will put extra strains on an already stressed power budget Measurement wise the project would have gotten better results if it would have been possible to use an accelerometer as a movement sensor The ADXL330 will with a bit extra electronics and some movement measurements analysis possibly be able to fulfill the task 63 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 7 2 Wireless communication Although techniques using less power than Bluetooth exist there is at current no real available alternative Zigbee is not available in mobile phones and Wibree has not been made available on the market yet Actually for Zigbee s sake this is not the end of the story as the abbreviation Z SIM has often been mentioned lately Z SIM is a complete Zigbee node integrated in a SIM card 66 When it will be available is at current uncertain even more uncertain is when it will be available in Norway But having chosen Bluetooth there are many manufacturers producing modules with quite similar electrical characteristics The project group has chosen the connectBlue OEMSPA311 The experience so far has proved it to be robust and reliable Its wealth of features might however cause problems for a developer although nothing more than what can be solved by the help of the user manual or the connectBlue support service The project group is howev
71. his is the reason why registers R16 R31 are most widely used and that RO 15 is mostly used as backup storage 7 0 Addr a E a 0x0D OxOE OxOF 0x10 0x11 R26 Ox1A R31 Ox1F X register Low Byte X register High Byte Y register Low Byte Y register High Byte Z register Low Byte Z register High Byte Figure 7 The ATmegal164P general purpose registers 25 23 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 2 7 Wireless communication Bluetooth is at present the only short range communication protocol which is commercially available and most important it is a standard feature in many mobile phones Compared to other wireless technologies of equal accessibility it scores high because of usability small size and low cost In addition it is a true world wide standard as any Bluetooth based system can communicate with any Bluetooth unit in any country 33 34 Bluetooth uses the industrial scientific and medical ISM radio bands at 2 4GHz Here it works among 79 channels Jumps between channels occur approximately 1600 times per second Which channel it jumps too is decided by whether it is vacant or not This technique is called adaptive frequency hopping AFH 35 A competitor to Bluetooth is Zigbee it is more power efficient and simpler but although commercially available it is at the time of writing not implemented in any mobile phones Another technology often men
72. ice And Its Application in eHealth Odd Arne Olsen program and data The ATmegal64P is memory wise the smallest member of an AVR subfamily consisting of totally three otherwise nearly identical members The three members have respectively 16Kb 32Kb and 64Kb of flash program memory 25 In addition there are some differences in the sizes of EEPROM and RAM memories However the pin outs of these three are identical Judging by this a transition from ATmegal64P to one of its larger relatives should be a painless process with just minor software changes needed Such a transition would of course be caused by the demands for more program memory The reason why the research group started with the smallest member was that it was the only one that was available at the time in addition to it having some however minor advantages in terms of power consumption The ATmegal64P microcontroller is equipped with four bidirectional general purpose 8 bit I O ports named port A to port D These ports are called general purpose because also have alternate functions Just to mention a few port A pins doubles as analog inputs for the A D converter and pins from port C as the JTAG interface See Figure 5 the red arrows The functions of the ports and their direction if serving as an I O port are managed by software controllable registers In order to maintain communication between the microcontroller and the wireless interface the research group had to find a microcontrol
73. icrocontroller the ideal choice for any electronic or electrical device in need of some intelligence or decision power Three fundamental elements are however common for both the microprocessor and the microcontroller a register set an arithmetic logic unit ALU and a control unit The register set is a combination of special purpose and general purpose registers Type and variety of these registers differs with architecture type and brand Special purpose registers maintains tasks specific to the central processing unit CPU Examples here can be the program counter and the instruction register In order for a microcontroller or a microprocessor to perform arithmetic logical and shift operations the CPU needs an ALU And finally the control unit s purpose is to fetch decode and execute the program instructions 16 Traditionally this would have been a complete description of a microprocessor modern units though have had a tendency to grow richer on features Anyhow this would only form the basis of a microcontroller A significant property with the microcontroller is that it is designed to interface with a great number of devices requiring a minimal number of external components The situation described in Figure 2 could be a good example for this Seven segment 5x7 dot matrix Switch Motor LED Display display Digital LO Port Watchdog Timer CPU C lock Real Time Clock Reset Program Brownout Analog I O Port Memory
74. ion putchar ek Description Puts out one character ek 3 Usage ek 3 Return None ek H Note Parameter to be transmitted in temp ek b LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL H putchar USART transmit Ids sbrs rjmp sts ret temp0 UCSROA wait for emty transmit buffer temp0 UDREO USART transmit UDRO temp1 put data in to buffer 99 128 INF 3996 Appendix C The unmodified program LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL H ok Function getchat ek x Description Get one character ok Usage ex H Return Yes ok H Note Return to be transmitted in temp ok H LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL getchar USART receive Ids sbrs rjmp Ids ret temp0 UCSROA temp0 RXCO USART_receive temp1 UDRO wait for data to be received get and return recieved data from buffer Odd Arne Olsen 100 128 INF 3996 Appendix C The unmodified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLELI ek Title Pedometer for Telemedesin ok Filnamn transmit bt asm ok Versjon 1 0 BETA ok Last uppdated 07 03 24 ok Target ATmegal64p ok Description Service routine for transmitting step counter data ok LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLI
75. ities of reducing the power consumption for the Bluetooth module Sleep or sniff modes will have no effect as the module s only duty is to transmit the data after the connection is made After this it is turned off For the microcontroller however there is one possibility that should be checked out That is the task dependent run time change of clock frequency By reducing the 64 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen clock frequency as low as possible for the handling of the sensors and their data and turning it up for Bluetooth interfacing there will be some profits in terms of reduced power consumption One certain gain of using two clock frequencies sources would be a more flexible system For instance will the project group stand more freely in choice of Bluetooth modules and the same microcontroller hardware setup could be used for other purposes too For instance the system could also serve as Bluetooth interface for glucose meters requiring only minimal hardware changes if any Although the increased clock frequency causes higher power consumption this increase could be regained by the shorter transmission period It this is holds for the 14 byte data package implemented here is another matter but it will undoubtedly be valid for larger data packages Anyhow in order to be able to know much to gain by these restrictive power measures there should be made a power consumption analysis of the current s
76. its RESET and SCK inputs set to 0 Then the microcontroller s serial programming algorithm commences 69 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 5 After programming the RESET is set high for normal operation of MCU1 and MCU2 goes back to sleep The most obvious danger in addition to communication problems with this solution is if there occurs some sort of power failure during this operation The solution indicated earlier where MCUI first programs MCU2 s data EEPROM could solve this but with the downside of introducing more components Although should the suggestion in Figure 32 be very close to the truth the EEPROM solution would at best only need another MOSFET relay as the NOR gates comes in a package of four When it comes to downsides all these extra components imposes extra strain on the power budget It has to be emphasized that this is just a rough idea and one would not know if this works before a proper design has been made and it has been tested 70 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 9 Conclusion This is a multifaceted project involving sensors and signal conditioning serial communication Bluetooth battery power economization and not to forget the Atmel ATmegal64P microcontroller and AVR assembly programming As programming goes an assembly program might not look that impressive But in clear distinction to programming in a comp
77. ituation 7 5 Microcontroller software Although the software following the first step counter prototype wasn t complete and flawless it fulfilled its purpose It made it possible to test the total system and to discover its strengths weaknesses and possibilities But in order to obtain a well functioning system there were several things that had to be changed or rewritten The most serious problems were the report time settings the retransmission of lost data and the DTR timeout My suggestions has not been properly tested yet but if working as intended they would take care of these problems Although trying to take every measure in order to avoid loss of data one can never say for sure that you are 100 covered But combining the efforts suggested here with for instance a warning audible or visual on the mobile base when a transmission is missing would most like reduce the problem drastically In addition combining this with an active user this problem would probably be minimal 7 6 The step counter Combining a functioning and well tested software with a lightweight and physically small hardware covered by a smooth and user friendly exterior is the ideal This project is well on the way to achieve this There are still possibilities to explore on order to reduce size and weight Smaller Bluetooth modules different powering schemes and more suitable sensors are some examples of this At current the components limits the possibilities
78. ix E is the power mode setting under the category optimization The default sleep mode is chosen here This is not correct because this device should be active and transmit at once when a valid connection is achieved The sleep setting would make no sense as the first mode However a good idea would be to put the device in sleep mode when the transmission is finished It will only last from end of transmission until the microcontroller turns off the Bluetooth module A second setting that might seem strange is found under category misc Here the configuration over air is enabled When seeing this together with tight power supply scheme which the Bluetooth module is subjected to the setting makes no sense But 35 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen actually this will be the only way to change the setup module when mounted into the step counter This will of course require external powering of the module For later to way versions a more active use of the sleep mode maybe in combination with sniff mode should be tested out When in sniff mode the module is only up and listens for a short time at intervals for instance 5mS for every 100mS This mode is available in the OEMSPA311 through link policies 6 8 37 Sniff modes should only be used after thorough tests as connectBlue warns of possible traffic dependent link data loss 37 5 4 Bluetooth UART interfacing 5 4 1 Data format
79. jor leap towards this in lack of better words device unawareness It removes the need for any display and nearly all buttons The ultimate goal should be no buttons as there should be no need for any user initiated setups or features being controlled at the step counter device Ideally everything should be controlled from the mobile base 4 2 Personal adaptation and context awareness Although at current only equipped with a movement sensor there should be possibilities of getting more data than just the number of movements within the given timeframe For instance how many of these movements where caused by walking jogging or running This device is supposed to serve any type of person active as passive tall as short What might be running for one person might for the next one hardly pass as jogging The device will as such have to be able to handle individual setups of how the data is going to be interpreted Further on possibilities of context awareness should be investigated For instance is the person moving inside or outside Is he she climbing stairs or walking on a horizontal surface Such data would help the system into giving more accurate values of for instance caloric consumption 31 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 4 3 Reliability and information security It is quite impossible to secure every corner considering the technical reliability of such a device This is however no e
80. k source the microcontroller could not deliver the needed level of accuracy in the generated baud rate The reason for this was that the step counter microcontroller is using its internal oscillator which is running at IM The microcontroller s baud rate generator derives the baud rate directly from the oscillator frequency The Atmegal64P has two possibilities of generating the baud rate clock signal in asynchronous mode as it does in synchronous mode Here however only asynchronous mode is relevant and therefore the only center of attention The baud rate generator is controlled by the oscillator frequency The signal is fed to a down counter which is loaded with the contents of the USART Baud Rate Register UBRR every time it reaches zero The output frequency is i Un RRn 1 and depending on modes chosen the output baud rate at is a half an eighth or a sixteenth part of this frequency 25 The same network also generates a clock signal for the clock recovery logic The clock recovery logic synchronizes this clock signal with the incoming data bytes at the receive pin Rx 25 As such with the chosen oscillator frequency this network will produce a baud rate which at its best will be 7 below the wanted 9600 baud The receiving end of the OEMSPA311 Bluetooth adapter s UART tolerates an error of only 2 deviation from the predestined baud rate 37 While the microcontroller s UART receiver has an error margin of 1 5 for a 9 bit data
81. leaves a stage this stage is ready to take on results from the previous stage New instructions are accepted although the prior one is not completely finished The main goal of this is to keep the pipeline fully utilized and this is true when the input rate matches the output rate 20 The stages of a pipeline work in parallel each executing an instruction step But no matter how many steps the pipeline has the instruction needs the same amount of time to complete However an n step pipeline can process n instructions at the same time Given an ideal pipeline the completed instruction rate would be n times higher than without a pipeline 20 2 4 1 4 Serial communication There are two main classes of serial communication synchronous and asynchronous A synchronous bus transfers a separate clock signal in addition to the data communication lines As every bit is clocked over there is no need for start and stop bits to mark the borders of a data byte However in an asynchronous bus these bits are needed Since no external clock signal is transferred this has to be extracted from the transferred data Here the start and stop bits plays an important role The start bit is of opposite polarity from the data lines idle state whereas the stop bit has the 16 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen same polarity as the idle state 21 There is a third class the semi synchronous bus which also is a clocked
82. ler with an asynchronous serial interface As the two dark blue arrows in Figure 5 reveals the ATmegal64P has two USART modules Universal Synchronous and Asynchronous serial Receiver and Transmitter available In addition the microcontroller has a three wire synchronous serial interface SPI and a JTAG interface These are marked with light blue arrows in Figure 5 The SPI serves as a serial high speed possibility with external devices and the JTAG is the interface for the on chip debugger system PA7 0 PB7 0 Eni Converter Comparator i U SPI 16bit T C 1 Y ai rt Power Supervision POR BOD amp RESET RESET Watchdog Timer Watchdog Oscillator Oscillator Circuits Clock Generation USART 1 TOSC2 PC7 TOSCi PCe PC5 0 PD7 0 Figure 5 Block diagram of the Atmel ATmegal64P microcontroller 6 19 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 2 5 Programming environments In order to be able to develop system based on microcontrollers special software and hardware are needed The level of professionalism is the deciding factor for what is needed Standard equipment for an embedded systems developer is a text editor an assembler or compiler and a debugger These are often collected in a software package called an Integrated Development Environment IDE see Figure 6 inside the blue stippled border Howev
83. lerometers An accelerometer is an electromechanical device designed to measure acceleration forces 58 Modern devices are based on the MEMS technology Micro Electro Mechanical Systems By the help of micro fabrication technologies the mechanical elements and the electronics are implemented on a common silicon substrate The electronics are created by the help of traditional integrated circuit process sequences while the mechanics are created by the help of micro machining processes which adds or removes parts of the wafer in order to form the mechanical and electromechanical devices needed 59 50 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen Common for the ones that are relevant here is that they are part of an active electronic device and therefore in need of a continuously working power supply Well rather so we believed and this is one of the main the reasons why the research group decided upon not using them To verify this I performed an internet search The two alternatives found with the lowest power consumption in combination with a voltage range matching the microcontroller s was the ADXL330 from Analog Devices and the SCA3000 E01 from VTI Their power consumption was respectively 180uA at 1 8V 60 and 120HA at 2 5V 61 Both of these sense acceleration in 3 axes This is an advantage for the user as the final product could be worn almost any place on the body This is because a resultant of the
84. movw 13 r2 rtcH rtcL save rtc value bres carry set do transmitt if 24 hours reti carry set rcall transmit bt do transmitt 24 hours reti 97 128 INF 3996 Appendix C The unmodified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLELI H ek Title Pedometer for Telemedesin ok Filnamn isr mtransm asm ok Versjon 1 0 BETA ex Last uppdated 07 03 22 ex Target ATmegal64p ek 3 Description Interupt service routine for INT1 do manuell data transmission ok x ok ok ok ok E K ke K kk ok ok ok K K K ols K K K ok ok e K K K K K K ok ok K K K K K K K K ok ok K K K K K K K ok ok K K K ofk ols K K ok ok oke isr_mtransm int1_loop in temp0 PinD test for manual interupt puls off andi temp0 0x08 cpi temp0 0x08 breq outl jmp intl loop loop until end of transm puls outl rcall transmit bt do the transmiting manual reti 98 128 INF 3996 Appendix C The unmodified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLEL ek Title ek H Filname ek H Version ek Read Write through USART uartcom asm LO BETA Last updated 07 03 22 ek Target ATmega164p Description ek H LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL H LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLEL H ek H Funct
85. mplest form a tiny capsule with a mercury droplet inside A change in angle of the capsule causes the droplet to move and either make or brake contact between the components terminal pins The inclinometer s primary function is to measure the angle inclination or slope with respect to the earth s gravity 53 This is a good indication that it is designed for lower movement frequency than the project device would be subjected to As they suspected the tests revealed a ripple situation much worse than Figure 20 b illustrates and way beyond the signal salvage possibilities of what a low pass filter would be able to offer 6 1 3 The sub miniature micro switch test Inspired by the research group s attempts to find a good movement sensor I searched for possible candidates among sub miniature micro switches A clear advantage with micro switches is a well defined point of activation By pushing down the lever of the switch one might hear and feel a tiny click when switch is activated This activation point may also be one of their weaknesses for this project at least In order to make the switch react to movements a weight has to be mounted on the switch s lever The weights had a tendency of growing too voluminous for this project even if they were made of lead The three most promising and easy accessible switches can be seen in Figure 21 In order for these to activate they had to be subjected to a maneuver force of respectively 0 78N 0
86. n oscilloscope I found that the error was within 1 2 and therefore acceptable It should be noted though that an oscilloscope is not the best instrument to perform such measurements with The accuracy of such a measurement will largely depend on the visual estimate of person reading the instrument 5 4 3 1 Strategies for achieving a 9600 baud rate For later versions of the system one might aim for 9600 baud This can be caused by demands from different Bluetooth modules or other modules external to the microcontroller One solution can be to use the Atmegal64P s low power external oscillator and increasing the oscillator frequency to 1 8432MHz The project group was very reluctant to this idea because the use of this oscillator in addition to the higher clock frequency would most likely cause a higher power consumption This should however be tested out in case such a change is forced through due to external technical needs Such a need could be the interfacing between the step counter and a glucose meter The low power crystal oscillator is only capable of driving the microcontroller clock and it can be susceptible for noise However it will create a more stable clock than the internal RC oscillator The major downside is the need for three extra components two capacitors and a clock crystal The capacitors are negligible in size but a 1 8432 MHz crystal is quite visible A further increase in oscillator frequency to the next frequency ca
87. nd templ plus the counter register has to be stored in the start of 4 1 and retrieved at the end This is the case because other routines uses the same registers and will as such cause trouble for 3 2 The changes to 4 1 can be viewed in on the left side in Figure 29 The routine is here numbered 4 2 6 4 3 Retransmission of lost data Because this version of the system only relies on one way communication there is no possibility for the step counter to know whether the data sent was correctly received by the mobile base This would propose the biggest problem for the 24 hour transmissions as all accumulated data for this period could be lost For the user initiated transmissions the problem is not as serious The user would probably spot the problem at once and can then activate another transmission To solve the timed transmission problem I see two possible solutions If the transmit button is activated within a certain time frame lets say 60 minutes since the last timed transmission the old data is re sent The second possibility is that if the number of steps registered since the last timed transmit is below a certain limit the old data gets retransmitted Here could 100 steps be a suitable border It will provide ample time for the user to check his her data and reduce the possibility of loosing data Neither of these solutions should have any effect on the data collected since the last timed transmission The data will however not be avail
88. ndix F The sensor tests Odd Arne Olsen 100nF Figure I Test cicuit used M x 606ms o 1848ms xo 1242ms o 0 5 0 0 0 5 1 0 1 5 2 0 2 5 3 0 ch A Freguency X to O Hz 1 718 02Mar2007 11 44 WU TL Figure II Output from Cambden CSSM sub miniature micro switch Test circuit seen in Figure IB 125 128 INF 3996 Appendix E Bluetooth module setup Odd Arne Olsen vi x 898ms 0 1529ms xo 631ms 5 x o 4 3 2 1 MI D kl Z 3 4 5 0 5 0 0 0 5 1 0 1 5 2 0 2 5 3 0 3 5 4 0 45 ch A Freguency X to O Hz Not enough data 02Mar2007 11 33 Figure III Output from Sencera 102 shock sensor Test circuit seen in Figure I B v x 754ms 0 2255ms xo 1501ms 5 x o 4 3 e f e 2 U 0 1 Z 3 4 5 0 5 0 0 0 5 1 0 1 5 2 0 2 5 3 0 35 40 45 ch A Frequency X to O Hz 1 393 02Mar2007 11 16 Figure IV Output from Sencera 709 tilt sensor Test circuit seen in Figure I B 126 128 INF 3996 Appendix E Bluetooth module setup Odd Arne Olsen o x 1778ms o 3294ms xo 1516ms x E 3 E 5 s 0 5 0 0 0 5 10 15 2 0 25 3 0 3 5 4 0 45 ch A Frequency X to O Hz Not enough data 02Mar2007 11 10 Figure V Output from Sencera 709 tilt sensor Test circuit seen in Figure I A v x 892 3us 5 4 3 a T H aj 32 3 E 5 0 0 0 5 10 15 2
89. nge is 150 meters 43 The minimum range is 10 meters The maximum output power is the default value of the Bluetooth module By the help of the AT AMMP command and an integer value between 0 and 255 the output power can be set to a more suitable level 37 My guess is that a range of 10 meters is more than sufficient however this has to be tested out Another way of reducing power consumption is to vary the microcontroller s clock frequency at run time 64 The system could be working with two clock sources In normal mode when just sleeping or reading sensor data the system could work with an even lower clock frequency than now 1MHz and still continue to use the internal RC oscillator as source When servicing the Bluetooth module the microcontroller could switch over to the low power crystal oscillator As such the project group would be freer to choose a baud rate more suitable for their intentions concerning the system 6 3 Data security The Bluetooth module is already equipped security support When in this mode the authentication of communicating devices plus encryption of data is activated If one of the devices engaged in the data exchange has security enabled security will be used 37 The communication between security enabled devices can only be performed if they are bonded The bonding procedure creates a link key only valid between these two Bluetooth units 37 Whether this is sufficient or not will be trade of
90. ntroller resources as interrupts stack code and data memory These kits are just for small scale and hobby use and do of course not offer the debugging force of simulators and high end emulators But their main advantage is the real time operability and easy testing of I O functionality that they offer Figure 9 shows a picture of the STK500 As can be seen it provides a number of switches and light emitting diodes LED for the purpose of testing programmed input output functions The kit is also equipped with a number of IC sockets in order to provide support for all the different AVR microcontrollers intended Figure 9 The Atmel AVR STK500 starter kit 28 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen The Atmel AVR JTAGICE mkll emulator An emulator is a hardware device designed to behave as identical as possible to what the real microcontroller would have The emulator is connected to the developers PC via parallel RS 232 or an USB connection The JTAGICE mkII performs its duty as the name might imply via the JTAG interface This requires that the circuit designer equips the circuit board the ten pin JTAG header as this emulator requires This emulator further requires that the microcontroller is placed on the circuit board Figure 10 reveals the rather dull exterior of the emulator however on the left side of the picture the 10 pin JTAG header is clearly visible Figure 10 Atmel AV
91. o the chosen vendor The vendor 21 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen responds with a password for the downloaded zip archive This is however not the end of it After the installation the program supplies the user with a serial number which he she has to send to the program author Following this HP InfoTech which is the program maker author will send a license file and installation instructions for it At the moment it is not clear what has to be done in order to move the program from one computer to another But a fairly good guess would be that it involves some e mail exchange with the program author In addition to a 200 page user manual there are also books available covering AVR software development using the CodeVisionAVR software An example being recommended by many is Embedded C Programming And The Atmel AVR De edition by Richard H Barnett Sarah Cox Larry O Cull ISBN 10 1418039594 ISBN 13 978 1418039592 More information found via reference 27 2 5 3 WinAVR GNU GCC This is an open source collection of development tools The collection contains all the tools needed as compiler avr gcc programmer avrdude debugger avr gdb simulator simulavr and more It is developed and maintained by volunteers and independent groups A result of this is that a somewhat higher entry level is to be expected in addition to an even lower update rate than for instance CodeVisionAVR
92. o wirelessly report its accumulated measurement results to a mobile base The smart sensor s main building blocks are the Atmel ATmegal64P 8 bit RISC microcontroller and the connectBlue OEMSPA3111 04 Bluetooth adapter As mobile base the research group has chosen two smart phones the HTC Trinity P3600 and the HTC MTeoR Both are running the Windows Mobile 5 0 operating system At present the user has to initiate the wireless transmission by pressing a button positioned on the smart sensor or wait for an automatic transfer every 24 hour A startup initiated at the mobile base is possible but concerns for the smart sensors power budget has caused this feature to be put on hold The difference between this and a normal informatics thesis is the real world aspect this project involves As such this project embraces some basic measuring technique essentials as well as short range communication aspects for data transfer and eHealth Telemedicine considerations on the sensor system In order to perform construction or debugging at this level detailed component knowledge is vital This goes for both hardware and software in order to be able too give a valid numeric interpretation of the involved sensors output The fact that the system is programmed in AVR assembler intensifies this statement A large part of this thesis is devoted to the description of the debugging process and since electronics is part of the project it will be mention
93. of data service routine jmp isr mtransm org OVE2addr rtc overflow service routine timer2 jmp isr timer yee MCU register init start Idi out Idi out Idi mov Idi mov Idi Start register initializing temp0 HIGH RAMEND Set stack pointer to point at SPH temp0 the last RAM address temp0 LOW RAMEND d SPL tempO temp0 deltaThigh preset rtc for counting time until next transmission r3 tempO temp0 deltaTlow 12 tempO temp0 0x0A load EICRA external interrupt controll register A 109 128 INF 3996 sts Idi out cbi cbi Idi out Idi out Appendix D The modified program Odd Arne Olsen EICRA tempO temp0 0x03 EIMSK tempO DDRD intdO DDRD intdl temp0 0x00 MCUCR temp0 temp0 0x07 SMCR temp0 pee Initialize rtc registers Idi sts Idi sts Idi out Idi sts temp0 0x01 TIMSK2 tempO temp0 0x07 TCCR2B tempO temp0 0x01 TIFR2 tempO temp0 0x20 ASSR temp0 falling edge detection on INTO and INT1 load external interrupt mask register initialize port direction INTO initialize port direction INT1 disable internal I O port pull ups load sleep mode and power save enable overflow interrupt Timer2 output watch crystal frequency divided by 1024 giving 8 second overflow periods Clear T C2 interrupt flag by hardware when interrupt handling vector is executed Timer counter 2 clock source is external watch crystal FR
94. ols for writing and debugging plus an assembler and a simulator All the IDE s described below works as an addition to the AVR Studio The software and hardware tools used in this project will be described more closely in chapter 3 20 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 2 5 1 IAR Embedded Workbench IAR Embedded Workbench is a complete IDE consisting of among other things a text editor a C compiler AVR assembler and the C SPY debugger As the system is developed and maintained in co operation with Atmel Norway they more or less guarantee having the most recent additions and changes This is undoubtedly the most streamlined and professional product available The pricelist below obtained on the 8 of February 2007 from Norsys AS might be considered to reveal one of its major downsides Standard version kr 22 500 Light version kr 17 000 Embedded C kr 29 500 All prices are for one license The difference between the standard version and the light version is that the light version does not include the C SPY debugger However it can use the features available in the Atmel AVR Studio Embedded C is according to Norsys AS rarely used for 8 bit microcontrollers By paying 25 extra a floating license can be obtained Here any computer attached to the network can use the program However if only one license is bought only one computer can use it at a time Another possibility is to buy
95. on def temp0 rl6 register for temporary data handling def templ rl7 register for temporary data handling def statreg r18 register for global status flag handling def transf 2 r19 register for global transmit status flag def count 120 loop counter general def rtcH 127 RTC temporary timing register high 8 bits def cl 126 RTC temporary timing register low 8 bits def stcH 125 step count register high 8 bits def stcL r124 step count register low 8 bits def packnub r4 package number to be transmitted yee global constants equ stacklen Ox0e length of data package stack sh global pin and constant definitions equ rxD 0 UART receive pin is PDO 108 128 INF 3996 equ equ COU equ equ equ equ equ Appendix D The modified program Odd Arne Olsen KD l UART transmit pin is PDI intdO 2 interuptO down on PD2 intd 3 interuptl down on PD3 Bt DTR 4 data terminal ready from Bluetooth Bt RESET 5 Bluetooth RESET Bt power 6 Bluetooth power on off deltaThigh Oxff Time interval between clocked transmissions deltaTlow Oxfb Oxfffb 40 seconds debug Oxd5d0 24 hours yee olobal definition CSEG Assembler directive defines start of a code segment org 0x00000 Set program counter pee Interrupt vectors jmp start reset handler org INTOaddr step interrupt service routine jmp isr count org INTladdr manually transmit
96. onsumption makes it difficult to introduce a more active hardware filtration scheme As such the mechanical movement sensing element has to have the correct level of inertia It should only change state when a motion is detected and it should do so with the minimum amount of ripple The Silva Pedometer Dist Step uses custom built micro switch with a balanced weight attached to its lever see Figure 12 The tests performed here with commercially available sub miniature micro switches were not successful There are many reasons for this but first of all there should have been performed more accurate calculations concerning the mechanics and physics involved Secondly although using lead as weight material the weight turned out quite voluminous compared to the desired system size Last but not least the assembly of such a unit requires a certain skill in precision mechanics and as Figure 21 reveals this is not one of my strong sides But back to the filtering which is the last concern for the existing setup in this section As can be seen in Figure 8A it is a very high resistance filter circuitry which has been implemented In addition one might discuss how much filtering a 10nF capacitor will provide Figure 23 and Figure 24 reveals that because of this the high level output from sensor barely crosses the border of a logical high level In total this leaves the system quite vulnerable for noise But only real life testing will reveal the seriousness of t
97. ooth Send data via Bluetooth et step counter value and art the 24 hour sequence Return Return Figure 26 Block diagrams for the timed transmit and the Bluetooth service routines Intuitively the solution including a long single button press seemed to be most user friendly of the two The button in question is chosen because of its small size and in addition it is planned to be mechanically fitted into the step counter in such a way that accidental activations are avoided However this should not propose any difficulties for intended activations On the other hand if the step counter is placed for instance in a pocket along with other items the likelihood for an accidental activation is larger for the single button press algorithm than for a system requiring three consecutive activations within a short time frame Figure 27 shows block diagrams suggesting how both of the solutions above could be designed The block diagram marked 3 1 is the multiple press routine while 3 2 is the long single press routine According to Figure 27 the solution which seems easiest to implement is routine 3 2 A major problem with both these routines is that they prolongs the active time of the microcontroller As a direct consequence of this the global interrupts has to be enabled in order to keep the real time clock function running The global interrupts are 55 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen a
98. p www sena com Fractus Small SMD chip antenna for headset compact flash secure digital and small PCB devices Fractus Compact Reach Xtend Chip Antenna P N FR05 SI N 0 102 Data sheet short range wireless 2006 cited Available from http www fractus com sales documents FR05 S1 N 0 102 DS FRO05 S1 N 0 102 pdf Fractus User Manual Fractus amp Compact Reach Xtend Bluetooth 602 11b g WLAN Chip Antenna 2006 cited March 2007 Maloratsky LG Reviewing the basics of microstrip lines Microwaves amp RF 2000 39 3 p 79 88 Pozar DM Microwave engineering 1990 Reading Mass Addison Wesley XVII 726 s CSR Bluetooth ICs Bluecore 2007 cited May 2007 Available from http www csr com home php Holdg L Batteriet Den moderne Str mkilde Batteriskolen 1995 Oslo Norway Teknisk Presse AS mpower Performance Characteristics How To Specify Batteries 2005 cited April 2007 Available from http www mpoweruk com soc htm Wikipedia Inclinometer cited February 2007 Available from http en wikipedia org wiki Clinometer Omron Ultra Subminiature Basic Switch D2F cited February 2007 Available from http www omroncomponents eu home products S witches Microswitches Uns ealed default asp Camden Ultra Miniature Microswitch Miniature switches CSSM cited February 2007 Available from http www camdenelec com electronics product 75 128 INF 399
99. plication in eHealth 2 6 AVR Assembly programming 2 6 1 The registers Odd Arne Olsen When programming microcontrollers registers is vital part As already mentioned the AVR architecture specifies 32 general purpose registers and 64 I O registers The A Tmegal64P has an additional 160 extended I O registers 25 The I O registers are more to recon as storage shelves whereas in the 32 general purpose registers arithmetic logical etc operations can be performed Further on data can not be moved directly into an I O register First it has to be moved to a general purpose register then copied into an I O register 32 Most of the instructions have access to all the registers in the general purpose register file However as Figure 7 shows 6 of the registers separates from the others The registers R26 to R31 have some added functionality They form three 16 bit registers and are as such able to handle word values As such they operate as 16 bit address pointers for indirect addressing of the data space 25 What further can be seen from Figure 7 is that the register file is broken into two parts consisting of 16 registers each In addition to all the common instructions the registers 16 to 31 have 6 extra instructions the SBCI SUBI CPI ANDI ORI and LDI instructions 17 These are instructions operating on the contents of a register involving a constant the results are immediately stored in the register operated upon T
100. rporated This was suggested because the module would not connect to the mobile base and the idea was that it might need a delayed start up after the power had been turned on However the connection problem had other reasons it was not correctly set up In this program version the Bluetooth reset line is kept at the inactive level all the time The main reason for this is to reduce the power up time for the Bluetooth module in order save battery power In addition the module is equipped with power on reset making this feature superfluous 62 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 7 Discussion 7 1 Sensors It might be considered a bit daring starting off building a step counter without having found the proper movement sensing element and as such ending up with a device relying a component from a factory made device But my tests with the sensors already acquired by the project group or me have produced one possible alternative the Sencera 709 tilt sensor An immediate drawback with this sensor is its position sensitivity In other words it has to be mounted in a predestined position on order to perform as intended The consequence for the user is that the step counter has to be hip worn The consequence for the project group is the limitations in measurement possibilities this involves This limitation also holds for the sensor taken from the Silva Pedometer Dist Step The strict demand on power c
101. s Abd El Barr M and El Rewini H Fundamentals of computer organization and architecture Wiley series on parallel and distributed computing 2005 Hoboken N J Wiley xiv 273 s Piguet C History of Low Power Electronics in Low power electronics design Piguet C Editor 2005 CRC Press Boca Raton p 1 1 1 15 Alexandridis NA Design of microprocessor based systems 1993 Englewood Cliffs N J Prentice Hall XVI 541 s Stone HS Microcomputer interfacing 1982 Reading Mass Addison Wesley XV 383 s Davis L JTAG Bus Description Integrated Circuit Buses 2007 cited Available from http www interfacebus com Design Connector JTAG Bus hl Atmel JTAGICE mkII Quick Start Guide 2006 cited February 2007 Available from http www atmel com Atmel AVR 2007 cited January 2007 Available from http en wikipedia org wiki Atmel_AVR Atmel ATmegal64P V ATmega324P V ATmega644P V Preliminary 8 bit AVR Microcontroller with 16 32 64KBytes In System Programmable Flash 2006 February 2007 cited February 2007 Available from http www atmel com dyn products product_card asp part_id 3887 IAR Systems C C compiler and debugger tools for Atmel AVR IAR Embedded Workbench V4 21 for Atmel AVR cited February 2007 Available from http www iar com ewavr Haiduc P CodeVisionAVR Standard amp Light cited February 2007 Available from http www hpinfotech ro html cvavr htm WinAVR WinAVR tutorial cited February
102. s body area network of intelligent motion sensors for computer assisted physical rehabilitation Journal of NeuroEngineering and Rehabilitation 2005 2 1 p 6 Fabrice A et al Flexible technologies and smart clothing for citizen medicine home healthcare and disease prevention Information Technology in Biomedicine IEEE Transactions on 2005 9 3 p 325 336 Paradiso R Loriga G and Taccini N Wearable System for Vital Signs Monitoring in Wearable eHealth Systems for Personalised Health Management State of the Art and Future Challenges Lymberis A and Rossi Dd Editors 2004 IOS Press Amsterdam Netherland p 253 259 Weber J L et al Telemonitoring of Vital Parameters with Newly Designed Biomedical Clothing in Wearable eHealth Systems for Personalised Health Management State of the Art and Future Challenges Lymberis A and Rossi Dd Editors 2004 IOS Press Amsterdam Netherland p 260 265 Noergaard T Embedded systems architecture a comprehensive guide for engineers and programmers Embedded technology series 2005 Amsterdam Elsevier XIV 640 s 73 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 Gadre DV Programming and customizing the AVR microcontroller elektronisk ressurs 2001 New York London McGraw Hill xxi 339
103. t frame sync tilde Z40x00 tempO Z 0x01 temp0O temp0 0x55 set protocol ID 0x55 Z40x02 tempO stor ID value temp0 0xe6 Z 0x0c temp0 set crc bytes Z 0x0d temp0O main 95 128 INF 3996 Appendix C The unmodified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLELI H ek Title Pedometer for Telemedesin ok Filnamn isr count asm ok E Versjon 1 0 BETA ok Last uppdated 07 03 22 ok Target ATmegal64p ok Description Interupt service routin for INTO update of step counter ok H LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL A isr_count int0_ loop in temp0 PinD test for step puls off simple filter routine andi temp0 0x04 cpi temp0 0x04 breq ou jmp intO loop loop until end of step puls out0 adiw stcH stcL 1 Increment step counter reti 96 128 INF 3996 Appendix C The unmodified program Odd Arne Olsen LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLELI H ek Title Pedometer for Telemedesin ok Filnamn isr timer asm ok 3 Versjon 1 0 BETA ex Last uppdated 07 03 22 ex Target ATmegal64p ek Description Interupt service routine for TIMER2 OVF and test of 24 houer limit day end flagg ok LLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLEL isr_timer movw rtcH rtcL r3 r2 load rtc value adiw rtcH rtcL 0x01 increment rtc counter
104. te memory for the data package 43 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 5 6 3 Main routine main asm The function of the main routine is just to activate the global interrupts and then perform an endless loop activating the sleep modus An interrupt call will wake up the microcontroller The loop ensures that the microcontroller goes back to the power save mode after having returned from the interrupt service routine 5 6 4 Interrupt service routine for step counting isr count asm The interrupt service routine for step counting is called every time the external interrupt pin intO detects a falling edge i e a transition from logic high to a logic low level This transition is caused by a movement activating the movement sensor The routine performs a loop as long as the level at intO still is low This is done in order to filter out noise After a logic high level is detected at intO the routine updates the step counter value and returns to the main routine 5 6 5 Interrupt service routine for user initiated data transmission isr mtransm asm The interrupt service routine for user initiated data transmission isr_mtransm asm is activated by a transition from logical high to logical low level an the external interrupt pin intl This transition is caused by the user pressing the send button on the step counter The routine loops until the send button is released After the button is release
105. ter movement independent of its own position could be a big plus for the system as the step counter could be placed almost anywhere on the users torso It could as such open for measurements currently impossible because of its positioning on a belt between layers of clothing E Figure 22 A The Sencera 709 tilt sensor B The Sencera 102 Shock sensor C The NMS24M vibration sensor Unfortunately both the Sencera 102 and the NMS24M could not be used in this project This was mostly due to their degree of sensitivity In order to get a clean signal both would have required a type of hardware filtering which would have put a too high stress on the power source Oscilloscope pictures of some of these sensor tests can be found in appendix F The Sencera 709 tilt sensor looked very promising as Figure 23 reveals Figure 24 shows the output from the NMS24M sensor under equal conditions The sensors were connected as showed in Figure 8 A 49 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen It has to be noted that these tests was only performed on the laboratory table The sensor was being subjected to a pendulum movement with a presumed frequency of around 3Hz ch A Frequency X to O Hz O2Mar2007 11 10 Figure 23 Output from the Sencera 709 sensor V x 8923s 5 2 1 Jg T T tu M Cu aC Wt WI IT ME TTG 23Mar2007 11 53 Figure 24 Output from the NMS24M sensor 6 1 5 Acce
106. three axes defines the vertical direction by help of earth s gravity regardless of the axes orientation 62 Here however the similarity ends 6 1 5 1 The VTI SCA3000 E01 The SCA3000 E01 from VTI Technologies incorporates a storage facility a ring buffer In this buffer the movement data is stored Within a certain timeframe depending on the sample rate the accelerometer transmits the data via its SPI interface The SPI interface is a 3 wire serial synchronous data bus For walking VTI Technologies has calculated a sampling frequency of 12 5Hz which gives 15 seconds storage time 62 However the need for constant power supply is its downside As using any active device external to the microcontroller with no sleep or idle modes available will render the power saving efforts already implemented in the controller useless 6 1 5 2 The Analog Devices ADXL330 The ADXL330 is a much simpler device as it only can measure and present it results on its analog outputs The user decides its bandwidth by the help of external capacitors one for each axis 60 This is a device which can be turned on and off during measurements By controling this from the microcontroller one can achieve the desired sampling frequency As the step counter should be able to service walking running and other activities it is vital to find the maximum movement frequency From that the sampling frequency can be found according to the Nyquist theorem This roughly
107. tioned is Wibree however it is not been put out on the market yet Wibree might be the biggest competitor to Bluetooth in the future for this project as Nokia has announced its implementation in mobile phones The research group has chosen the connectBlue OEMSPA311i 04 module as its Bluetooth interface This 16mm by 36mm module is a class 1 device with a transmitting range of 10 to 150 meters depending on the attached antenna There are three Bluetooth power classes Class 1 has a range of around 100 meters class 2 around 10 meters and class 3 have a range of around meter 33 However there seems to be no class 3 devices available commercially If such a short range is desired many manufacturers have added a power limiting feature to their class 1 or class 2 devices This enables the user to set the output power on the module to a level giving the range which satisfies his her needs 36 The range values mentioned here for the power classes should not be regarded as absolute truths as these numbers varies according to which data sheet or book you read These ranges vary from producer to producer and also between identical modules with different antennas attached I addition these data are given for devices tested with an unobstructed line of sight connection and with no structures in the vicinity giving signal reflections which could jam the main transmission 36 In addition to being locally available the chosen module is relatively small and
108. to the UART service routine in charge of transferring the data to the Bluetooth module Before returning to its caller the routine turns off the Bluetooth power resets the step counter value and presets the 24 hour real time counter value 5 6 8 The low level UART servicing routines The two low level UART servicing routines handle the transmission at frame level Making sure a new frame is not put in the buffer before the old one has been transmitted The other routine forwards the incoming data from the receive buffer to the subsequent handling routines These handling routines are however not implemented here 45 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 46 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 6 Results 6 1 Movement sensors 6 1 1 Sensor design and testing Registering or counting movements is not as straight forward as one might think Finding a sensor that has the right degree of sensitivity and delivers a signal with as little noise as possible is difficult What complicates matters is that the movement to be analyzed varies in both speed and force for different users and activity levels No movement sensor will be able to present an output as perfect as can be seen in Figure 20 a where one movement causes a clean and well defined pulse on the sensor output Figure 20 b is somewhat closer to the truth Here in this example one movement might be read as
109. transfer but with one or more clock periods per transfer It is however not of interest for this project In addition to the data lines there might be several handshake lines in order to mark the start and stop of data transfers Examples of this can be the Request To Send RTS Clear To Send CTS Data Terminal Ready DTR and Data Set Ready DSR signals found among other places in the asynchronous RS 232 data bus 21 The use of these lines is however not mandatory and they can as such be deactivated when the service they provide are not needed The abbreviation UART will frequently be mentioned in the following UART expands to universal asynchronous receiver transmitter This is a unit found also in microcontrollers Here its task is to convert the internal parallel communication into serial start stop bit framed data bytes Atmel calls their device for USART Universal Synchronous Asynchronous Receiver Transmitter The units bearing this description can also perform the duties of a synchronous interface 2 4 1 5 JTAG The IEEE standard 1149 1 1990 JTAG Joint Test Action Group is a synchronous serial interface that was originally standardized as a means for testing printed circuit boards The standard specifies four signals Test Clock TCK Test Mode Select TMS Test Data Input TDI and Test Data Output TDO 22 In addition the Test Reset TRST signal plus ground and a reference voltage is supplied The TRST signal ensures
110. u Bt DTR 4 data terminal ready from Bluetooth equ Bt RESET 5 Bluetooth RESET equ Bt power 6 Bluetooth power on off peek Initialize Bluetooth control lines cbi DDRD Bt_DTR set Bluetooth DTR line direction in sbi DDRD Bt_RESET set Bluetooth RESET line direction out sbi PORTD Bt_RESET Set RESET line high inactive sbi DDRD Bt_power set Bluetooth power line direction out cbi PORTD Bt_power turn Bluetooth power off 53 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen In addition to this I also declared the global constants deltaThigh and deltaTlow as references for the 24 hour timer preset values This was done in order to simplify the debug process as these values are referred to in at least two different instances in the program But the real reason for the focus on these values was that the 24 hour preset value was wrong Initially it was set to 0xC350 A simple calculation reveals that the difference up to OXFFFF is 15535 Since the real time clock value is updated every eight second as mentioned earlier this result in 15536 eight second instances giving a total of over 34 hours By changing the real time clock preset value to OXD5DO the number of eight second instances is reduced to 10800 This in turn should give the desired 24 hour sequence The last change here concerns the initialization of the stack pointer In the original program the value OxO4ff was loaded into the
111. uit board dominated by a Bluetooth module a movement sensor and a battery is found These three units are also the major contributing factor to the step counter total physical size At present the size of the total unit is roughly 5x3x1cm The project group is aiming at reducing the size to 3x2x1cm within the time the next version is due As a curiosity it can be mentioned that the first of the project group s prototypes which can be seen in Figure 11 and Figure 12 was 10x4 5cm attery holder 3 Header for external Microprocessor JTAG header power source Figure 11 The first step counter prototype component side In Figure 12 the movement sensor which the project group took from a Silva Pedometer Dist Step is clearly visible The reason for using this sensor was that there at the time were no satisfying alternative 33 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen Figure 12 The first step counter prototype solder side Figure 13 and Figure 14 shows pictures of the second step counter prototype with its main features marked Bluetooth module Figure 13 The second step counter prototype side 1 RTC crystal Power control for the Transmit button Microcontroller Bluetooth module tuu VW p sk Figure 14 The second step counter prototype side 2 34 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 5 2 Step co
112. unter functionality The brain of the step counter is as already mentioned the microcontroller It spends most of it time asleep in order to save power A sensor event wakes the microcontroller up for the purpose of registering and storing the event Either caused by a timed wake up or by the transmit button being activated the microcontroller turns on the power to the Bluetooth module After having established contact with the mobile base the step counter transmits its data It will then to turn off the power to the Bluetooth module and go back to sleep The Bluetooth module has a built in sleep mode But with this mode activated it still consumes more than ImA By using an external power control the problem is more or less eliminated The drawback of this is a longer startup time for the Bluetooth module A functional block diagram of the step counter can be found in Figure 15 On Off Sensors Data and control Microcontroller signals Bluetooth module Transmit button Figure 15 Step counter block diagram 5 3 Bluetooth module setup In appendix E a table showing the setup of the connectBlue OEMSPA311 is found This should ensure that Bluetooth module would perform in the following manner When powered up it should attempt to connect to the mobile base Inform the microcontroller when contact is achieved Transmit the data received by its UART The only problem with the listing found in append
113. up s block diagram erator ra Jawa HM aA 4 4 De IM 0 12 dest o Aid Yyvoe 9 Aza ls mi 1147 9400279N4 77 128 E EE Erle a k_ vrag dien 4 78 128 INF 3996 Appendix A The Project group s block l File 1 82 God ndur Asn Sh Count td LORA Odd Arne Olsen EO 79 128 eN Fle Sr na fansm gim Sr mn nimm Inf dog 80 128 INF 3996 Appendix A The Project group s block Odd Arne Olsen Bles isp bine lom D 81 128 INF 3996 Appendix A The Project group s block Odd Arne Olsen File rausm bt im l CfANSIUFE H 82 128 INF 3996 Appendix A The Project group s block Odd Arne Olsen Fl wartcom Qna cr den a Le 83 128 INF 3996 Appendix A The Project group s block Odd Arne Olsen 84 128 Odd Arne Olsen Appendix B My block diagram INF 3996 iagram My block di Appendix B WSE OHEN SaulnoJ BUDIAISS L n Lana MOT PEE ISI 3 94 Stan ans Jdnsajuy USE 3ILUSUE EJBp 19junoo deis DUPBILUSUEJ 104 2unnoJ 043002 9 LSB WSUBIFU ISI JUDISSILUSULJJ EJED CIR TITRES ESTE JOJ SING a3inas 3dnj423u T MUISE UILLU UIJNO UIP U MEENE rUoljeZIjeNnI u i WSEUNDD SI BuQUNOS dogs OJ SUINOJ 2I14435 Jdnwaquy 85 128 Odd Arne Olsen My block diagram Appendix B INF 3996 UIEN 0 05 DES aberysed
114. using a minimal division error 3 6864 MHz gives higher power consumption but the crystals are smaller in size One possibility that should be looked into is a dynamically run time change of clock frequency or clock source 38 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 5 4 4 Connecting microcontroller with the Bluetooth module Having made sure that the microcontroller produced data frames of acceptable quality see Figure 17 it was attached to the Bluetooth module The module was set up and tested beforehand by the project group in the manner indicated above on a starter kit For initial testing all security and bonding features were disabled When hooking the Bluetooth module to 3 3V power ground and signal from the microcontroller no contact with the test base was achieved The step counter was visible from other Bluetooth devices but it would not connect or be connected to Confirming with the manual that there should be no reason why this minimal connection scheme shouldn t work the imminent conclusion was that the Bluetooth module s setup had to be revised 41 The project group s revision resulted in a successful connection between the step counter and a test base However when toggling the power on the step counter it did not try to connect The reason for this was that the connection was initiated by the test base When fully operative the step counter should attempt to connect to the paired bas
115. uter environment no matter type of programming language embedded system programming is often a result of trial and error due influence from uncontrollable external factors Examples of this could be non linear components inaccurate component values or minor flaws in external components In addition a wearable device has to be able too function as intended despite temperature changes and electrically noisy environments Many of the problems which has with a varying degree of success been dealt here has its basis in the attempts of using components initially specified for other purposes to the benefit this project A good example is the movement sensor tests Anyhow these tests revealed one good possibility namely the Sencera 709 tilt sensor But these tests were only performed in the laboratory To find out if it really is usable field tests has to be done 71 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 72 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen References 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 NST More Definitions of Telemedicine cited April 2007 Available from http www telemed no index php id 44355 Silicon_Bridge_Research_Limited Understanding the market for eHealth 2001 Silicon Bridge Research Limited Basingstoke UK Lymberis A and De Rossi DE Wearable ehealth systems for personalise
116. uter software for viewing a graphical interpretation of the signals measured upon The probe is powered via the computers USB interface and it can measure frequencies up to 25MHz The system can directly store or print out data if so desired 39 27 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 3 2 Program development and testing 3 2 1 The STK 500 starter kit In order to get acquainted with the ATmegal64P microcontroller and the AVR assembly language the AVR STK500 starter kit was used Starter kits are easy and low cost systems designed for testing the software in a hardware environment It consists of a hardware board and an in system programmer bundled with software component needed Often this software is just evaluation versions of a complete IDE or its separate components Atmel however delivers a complete IDE with assembler editor and simulator the AVR Studio The starter kits are mostly or almost exclusively only available for flash controllers This is because the flash memory allows the microcontroller at hand to well emulate itself as the in system programmer downloads the code into the flash and executes it To be able to perform debugging the starter kit downloads a short monitor code along with the developed code The monitor code allows the developer to examine the memory and insert break points in the code In order to be able to do this the monitor code has to use some of the microco
117. utomatically disabled during an interrupt call 25 The global interrupt must however be disabled again before the call of the Bluetooth control routine What is more serious is the increased current consumption these routines represent The running time of these routines will have to be a trade off between keeping it short for the sake of minimal current consumption and keeping it long enough to reduce the number of errors Ip H i Enable global interrupts Enable global interrupts Wait 50mS and keep track of time i E 50mS and keep track of time Send switch Send switch released released Time limit Yes passed Ne Switch activated Yes Lr number of activations Time limit Yes passed Send data via Bluetooth Reset the 24 hour sequence Return Correct number Yes of activations No Send data via Bluetooth Reset the 24 hour sequence d Return Figure 27 Two alternatives for a dual function transmission and report time set switch 3 1 The multiple button press routine 3 2 The long single press routine But having to choose between these two the long single press routine seems to be the best one As already mentioned it seems more user friendly and easier to implement In addition since the global interrupts are enabled multiple button activations might cause trouble The routine might be restarted instead of continuing in its task This
118. ww vti fi en products solutions products accelerometers sca3000 accelerometers Weinberg H Minimizing Power Consumption of IMEMS Accelerometers Application Note 2002 cited March 2007 AN 601 Available from http www analog com en cList 0 2880 764 255F800 255F43 00 html Bertozzi D and Benini L Battery Lifetime Optimization for Energy Aware Circuits in Low power electronics design Piguet C Editor 2005 CRC Press Boca Raton p 43 1 43 21 Covington MA An Atmel AVR Notebook August 2006 cited April 2007 Available from http www ai uga edu mc Turolla M and Alessio E ZSIM enabling innovative services to improve quality of life 2006 cited May 2007 Available from http www zigbee org en events documents Mar2006 Open House Presentat ions OpenHouseFinale7 pdf Spies P Energy Systems Power and Battery Management 2006 cited April 2007 Available from http www iis fraunhofer de fhg Images energy systems info tcm97 73296 pdf Arbinger F X Spies P and Rohmer G Wireless Battery Charger Chip for Smart Card Applications cited February 2007 Available from http www iis fraunhofer de Spies P Inductive Charge Regulator Power and Battery Management 2006 cited April 2007 Available from http www iis fraunhofer de fhg Images inductive charging info tcm278 73295 pdf 76 128 Odd Arne Olsen Appendix A The Project group s block INF 3996 Appendix A The Project gro
119. xcuse for not trying The most obvious danger is the loss of data due to power failure or communicational errors As such pre emptive measures to reduce these risks should be taken Further on is the step counter s ability to produce reliable data Here its noise susceptibility is a vital keyword This however can only be controlled to a certain degree by careful circuit board and hardware design plus shielding Information security might be an issue for the later versions of this device However considering the small amount of data being transmitted and the infrequent transmissions the danger seems not to be imminent Another matter will be the introduction of other sensors measuring biometric data with a higher degree of sensitivity than the number of steps within the last 24 hours As such data encryption in addition to identification of the mobile base and appurtenant step counter would eventually have to be addressed Not just for reasons of security but with scalability in mind 32 128 INF 3996 A Sensor Device And Its Application in eHealth Odd Arne Olsen 5 Design and implementation 5 1 The step counter prototypes As with the prototype the finished step counter will most likely have a rather modest exterior appearance Its external design will probably be a box with rounded corners The only visible features would probably be the transmit button and a belt clip Internally however the situation is guite different A printed circ

Download Pdf Manuals

image

Related Search

Related Contents

師 〟 平面ハンドル H-ー ーAN。H  slc® eco ep21    connector as shown above (User Manual Chapter 3 #11). Press the  TLP 2746 - Quad GmbH  Hotpoint HAG51K cooker  (地中線用)過電流ロック形高圧交流ガス開閉器    Sony PMW-200  取扱説明書 - SoftBank SELECTION  

Copyright © All rights reserved.
Failed to retrieve file