This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to change accelerometer profile for free fall mode?

Other Parts Discussed in Thread: CC2540

Hello,

I want to add new functionalities to the keyfob demo and my first priority is to change a little bit the accelerometer function. I want to use the accelerometer in the "Free-Fall Detection" mode in order to detect when a free fall has been produced and I am not sure about what changes I have to do into the code to implement that.

My application idea is to make periodic device scans by means of the USB dongle every 10 seconds for example, in order to detect the keyfob, recognise it and pair with it for a very short period of time (only the necessary to read the state of the the interrupt register from keyfob in order to detect if a free fall have been produced). Meanwhile in the keyfob device, the accelerometer should always stay active in the free fall detection mode. When a free fall occurs the accelerometer generates an interrupt that should be comunicated to the USB dongle via BLE protocol. I think I have two ways for doing that (please, correct me if I am wrong):

1. The keyfob gets into advertising mode periodically in order to be paired with the keyfob dongle (every 10 seconds) and when it gets paired then transmits the interrupt state of the accelerometer (the drawback of this method is the battery consume)

2. The keyfob is always in sleep mode (except from the accelerometer), when a free fall is detected and the interrupt from the accelerometer is generated, the keyfob gets asleep and gets into advertising mode. When the usb dongle detects it in a scan, they get paired and it reads the interrupt register state, it can be concluded that a free call has been produced. (the drawback is that I am not sure if it is possible to have the accelerometer enabled while the CC2540 is sleeping)

Is there someone that can give an idea on what files I have to change and moreless what steps to follow to do them? Here are my initial ideas to do:

- I have to change the way how the accelerometer inititates to start in free fall mode (maybe changing the accelerometer service in accelerometer.c?)

- I am sure I have to change the accelerometer profile and add a new GATT service or a new GATT characteristic (I am not sure which one) that performs a read of the interrupt register state of the accelerometer periodically.

- How I can do it for managing that the CC2540 gets active when the accelerometer interrupt is activated (what part of the code contains that?)

I have some other doubts but actually, these are the most important ones!

Can anyone give me some ideas or help! Thanks!

 

Victor

  • The CMA3000 product spec includes information on the registers of the device, including how to switch to free-fall mode. You will need to modify the accelerometer driver in the files cma3000d.c to change the mode. The accelerometer service in accelerometer.c just defines the GATT characteristics for the service, so the code to change the mode will not be found here. You still may need to modify the service though since your use-case is different than it is in the KeyFobDemo application.