Am Dienstag, 13. September 2011, 21:54:25 schrieb Ivan Lisenkov: > > I'm implementing some sort of security system. The system uses DS2408 to > detect state of motion sensors. The sensors remain their state about 3-4 > sec after set off. So my task is not to miss this event. Is polling alarm > directory every 1-2 sec directory is right way to do so? > No. The DS2408 has an activity latch per input which is activated once an input is toggled. You can use it to extend the sample time to minutes. Just read the "latch" node instead of the "sensed" node and reset the latch by writing any number to the "latch" node afterwards.
Caveat: There is a small hole where you could miss an event between reading the latch and resetting it. That's a design problem of the DS2408. If you want to be sure you won't miss an event, you have to read the "sensed" node just before and after resetting the latch and check if there is a difference between both values, which is not in the latch any more because of the reset. In that case, you can handle it immediately, just like the events from the latch. Even with that caveat, using the latch is far better than polling a lot of chips every second. If you like to reduce the number of operations further, which I think is only useful if you have dozens of DS2408, you can add alarms to your program. Onewire alarms are not bus messages, but a state the chips can have. If the chip is in a certain condition, it will respond to a "conditional search", which works like the usual search used for enumerating the chips on the bus. That said, you have to note conditional search is an expensive operation if more than one or two chips are in alarm state. Just like enumerating. When using alarms, make sure to use owfs-2.13 or later, as the DS2408 alarm setup was broken in older owfs versions. How to set it up correctly: 1. set the "por" node of the ds2408 to 0 to disable the power on alarm. 2. reset the ds2408 latch by writing any number to the "latch.0" (or any other latch) node. 3. write the correct value to the "set_alarm" node to connect alarms to the latch. E.g. for signalling "alarm" on latch set for any input (meaning: change on any input), use 133333333. 4. poll the "alarm" directory regularily. For any DS2408 alarmed: 5. Check if power-on alarm by checking the "por" node. If not power-on alarm: 6. Get the "latch" node value 7. Get the "sensed" node value 8. Clear the latch by writing any number to the "latch.0" node. 9. Get the "sensed" node value again and calculate bitwise difference to the value from 7. 10. Bit-Or the result from 9. with the latch value from 6. 11. React to any bits set in the result from 10. > Or owfs (or > owserver?) is able to generate some signal, that I can catch in my > program? The program is a small deamon written in C, if it matters. > Onewire does not generate any interrupts and owfs does not fake them for user programs. Polling is the only way the onewire hardware knows, so polling is the way to go. > Also, I would be perfect if I is able to control my system with standard > iButton key. In this case my deamon should notice a new connected device > within 1-2 sec. Is it possible with owfs? > I do enumerating/using single_ds2400 three times a second in my application, works so far without excessive CPU load. Make sure to sample twice before reporting a key disconnected, as the electrical contacts of some locks aren't completely reliable. Enumerating the bus is an expensive operation, especially if a great number of devices is connected to the bus. The DS9490 USB host adapter handles it internally and is significantly faster and less CPU hungry than the DS9097U (RS232), any USB-RS232-Briged host adapter, and DS2482 (I²C) chips. Still, I discourage you connecting a great number of DS2408 and an iButton lock to the same bus. Use two host adapters, the DS2482-800, or a DS2409 based hub to separate them. If you can limit the bus to one iButton lock (and any number of non-key chips), there is an alternative to enumerating. Poll the simultaneous/single_ds2400. That would trigger a special Read_ROM command on the bus to which only the DS2400, DS2401 and the key iButtons respond. If there is only one keylock on the bus, using that command is feasible and reasonably fast. Note that this isn't possible with the DS9490 USB adapter, as that device has an additional iButton chip on the board which responds to the Read_ROM command, too. Open the host adapter and de-solder the DS2401C on it's board if you like to use single_ds2400 with USB. Or build your own host adapter. Kind regards Jan ------------------------------------------------------------------------------ Using storage to extend the benefits of virtualization and iSCSI Virtualization increases hardware utilization and delivers a new level of agility. Learn what those decisions are and how to modernize your storage and backup environments for virtualization. http://www.accelacomm.com/jaw/sfnl/114/51434361/ _______________________________________________ Owfs-developers mailing list Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers