<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3540/custom-service-design-irq-vs-timer</link><description>I have several asynchronous аperiodic sensors with their interrupt handlers. My service should gather the data from those sensors and do some math. The outcome of this math may be cause of alarm. Delays in few seconds are acceptable. Losing some alarm</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 22 Aug 2014 14:26:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3540/custom-service-design-irq-vs-timer" /><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12826?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 14:26:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f3dc2b0-a6fd-4f3e-8b4c-1a9afd97ff0c</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;You can read more about how slave latency works in the first link I pointed you to on this thread, look at the &amp;quot;Tuning connection parameters&amp;quot; section.      Method 1: large slave latancy and short connection interval. Set up RTC timer to calculate periodically and then give data to softdevice.      Method 2: Set up radio event that will trigger your calcualation (happens also periodically) and then you give your data to softdevice just before connection event.  I think both methods are equally low power. On second thought, I think that the former method is easier to implement, and additionally, you do not need to worry about time constraints of the connection event.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12825?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 14:14:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2c2d76d-eefd-4115-8a06-d8da49deecea</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;Here what I&amp;#39;m thinking: the client will communicate with my server at sub Hertz rate. I&amp;#39;ll have large slave latency and can start to do my math on connection event. Does it sound reasonable?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12824?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 14:07:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:255cb1be-6aee-48ac-a53a-15d66ce5fe3b</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;I think a good choice would be to have relatively short connection interval and a large slave latency. Then the softdevice will send your data over the BLE link with low latency, no matter when you perform your calculations, but it would still be relatively low current. Another method would be to get radio notification from the softdevice just before data is sent over the BLE link. In that case, you would not need a timer, the calculation procedure would be triggered when you get the radio event. This method requires though that you approximately know how long your calculation procedure will take at maximum, so you can finish the calculation in time and and hand your data to the softdevice before the BLE transmission begins.  So if you decide on the method, we could try to dig up some code for it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12823?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 13:54:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f23bd2ea-1121-4fc5-baba-cb1ddd1a3386</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;Sure, that is why I want to avoid doing math without communication on schedule! So, gathering data isn&amp;#39;t an issue, wake up/sleep - not biggie, math is! How can I set up RTC to wake me up just before radio exchange?  Do you have an example?&lt;/p&gt;
&lt;p&gt;Thank you and appreciate you help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12822?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 13:49:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc5936f0-c4e6-4ebf-8c20-fc4d52e3ac63</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Yes, sorry :)  Fixed&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12821?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 13:48:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e09b2be9-28e1-4262-aee7-000c264c604c</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;&amp;quot;...but in System off you will draw less current than in System off.&amp;quot;
Is this typo?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12820?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 13:42:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c062766d-9478-446d-9fe8-ba50a58b1a8e</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;The overhead of waking up and going to sleep is small, at least if going into System On low power mode, the overhead is bigger if you enter System off low power mode, but in System off you will draw less current than in System On. So if you wake up once a second or 10 times per second from System On does not matter that much, the main thing is to make your code efficient so that the execution of it takes minimal time, to stay awake is what will cost you power.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12819?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 13:40:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84f4ed5d-e43e-467b-ab2d-1c4ec8e0b13f</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;&amp;quot;I think it is a good option to collect sensor data into a buffer and then periodically process the data.&amp;quot;
I think so too. You&amp;#39;re saying RTC  because other timers are in the sleep mode?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12818?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 13:37:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51afcfb4-8079-41ae-9eec-d68cdc725486</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;I think it is a good option to collect sensor data into a buffer and then periodically process the data. You can do that with starting a RTC timer that periodically wakes up the chip to perform the calculations.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12817?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 13:35:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97b93754-20b8-4ca2-ba9e-f3fd603ae566</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;I still have the feeling that you are asking questions I have already answered. Anyhow, I can point you to a code example which shows how to wake up the chip with a press of a button. By pressing one button, the device is put to sleep, and by pressing another button you can wake the device up again, &lt;a href="https://github.com/NordicSemiconductor/nrf51-powerdown-examples"&gt;github.com/.../nrf51-powerdown-examples&lt;/a&gt;    Look at the system-on-wakeup-on-gpio example.   If you would use SPI slave to collect data from a sensor, the event is triggered when the sensor sets CSN line high (see SPIS chapter in the nRF51 Series Reference Manual). For see how this is done, look at the spi_slave_example in the nRF51 SDK. When the SPI transaction is complete and the SPI master sets the CSN line high, you will get a callback into the spi_slave_event_handle where you can fetch your data that was received on the MOSI line.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12816?ContentTypeID=1</link><pubDate>Thu, 21 Aug 2014 12:27:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b75600a-8965-4472-aab5-aeaa087505e5</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;I&amp;#39;m  working on a family of devices. Different sensors, different configuration. But the same design, the same output - alarm. Devices are disposable so have to live long enough or in other words battery consumption is a key. My question asks how to design, and not how to reduce consumption: I&amp;#39;m familiar with that particular aspect but not mach with BLE. Based on what I read and know my plan is to go with very low sub-Hertz exchange rate to the client and thus allows me to deal with delays. The plan is to read from the sensor(whatever it happens to be) using interrupts and store the data and then using timer to do the math. Another option was to do the math using interrupts from the sensor(s), but they are aperiodic by default. Where can I find the wakeup event for the next scheduled comm to use this for my math?
Thank you for your input.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12815?ContentTypeID=1</link><pubDate>Thu, 21 Aug 2014 08:43:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6067134-f3b0-4702-930a-01ead6d9896b</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;What are you actually trying to achieve? To answer your question it would be good to know if you are trying to achieve low current consumption, high throughput or anything else. You say that delay is not important, but what is important then? Also, what is your sensor output, digital signal, serial communication, or analog signal? How is your sensor interrupt generated? A more description of your scenario would perhaps be helpful in order for me to understand what you are trying to do.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12814?ContentTypeID=1</link><pubDate>Thu, 21 Aug 2014 08:19:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e40c5ca4-7f43-451e-b8c0-6e2dee31b663</guid><dc:creator>Peter Myerscough-Jackopson</dc:creator><description>&lt;p&gt;michurin, you clearly state that battery life is more important than some delay, so telling you how to minimize power consumption is the correct answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12813?ContentTypeID=1</link><pubDate>Wed, 20 Aug 2014 13:22:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58773b6d-9130-4cc3-93cb-d697631b185f</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;Stefan,
You&amp;#39;re telling me how to minimize power consumption for collecting data. It is not the subject of my question. Let me ask it again:  when is it better to process collected data at the time of the interrupt for collecting the data from each/some/one sensor( in this case I&amp;#39;ll need to do math probably more often than I need to or unknowingly aperiodic) or to do it periodically using timer interrupts( extra wake ups and interrupt handling but low frequency less than !Hz). As I mentioned above I can deal with delays.&lt;/p&gt;
&lt;p&gt;Appreciated, thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service design: irq vs timer</title><link>https://devzone.nordicsemi.com/thread/12812?ContentTypeID=1</link><pubDate>Wed, 20 Aug 2014 13:07:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a7984f5-8e73-4d38-9f1a-7624118658d5</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;General guidance on how to minimize current consumption is available on &lt;a href="https://devzone.nordicsemi.com/question/5186/how-to-minimize-current-consumption-for-ble-application-on-nrf51822/#reply-5187"&gt;this thread&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I understand it so that you have multiple sensors on your PCB. The nRF51822 should gather sensor data from those sensors and send it wirelessly via BLE.&lt;/p&gt;
&lt;p&gt;Do your sensors provide analog or digital output?&lt;/p&gt;
&lt;p&gt;If the sensor output is analog, you can periodically wake up the chip with a low power RTC timer and sample the sensor voltage with the internal ADC. Instead of sampling periodically, you could use the LPCOMP to wake up the chip when an input voltage exceeds a certain threshold.&lt;/p&gt;
&lt;p&gt;If the sensor output is digital, you can gather data on the UART interface, SPI interface or the TWI interface. Perhaps it is possible to provide a wakeup signal from your sensors to the nRF51822. The nRF51822 will then enable the UART, SPI, TWI interface and receive data, forward it to the softdevice in order to send it over the BLE link, and then go back to sleep. If you have the nRF51822 configured as SPI slave, then current is only consumed when the SPI slave interface is active, i.e. when the SPI master sets CSN (chip select line) high when sending/receiving data.&lt;/p&gt;
&lt;p&gt;It might also be possible to periodically wake up the nRF51822, enable the communication interface, and send a GPIO signal to the sensors, indicating that they can send data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>