How would you go about building this?

Thread Starter

TheRyad

Joined Jun 4, 2009
7
Hello everyone,

I hope I came to the right place for this type of question. Please assume that I am completely ignorant with regards to circuits/electronics (although if you can go into further detail, that would be very helpful in the long run).

I am looking to build a simple miniaturized door detection system with the following properties:

- System can detect when door is open and when door is closed.
- System stores this information in its memory along with the time when the door was open and when it was closed.
- One can extract this information and easily read it on a computer.

It is critical to keep it as small as possible (roughly the size of a bottlecap). If that is not possible, at what size would it be possible? Also, it can not be connected directly to a computer. What is the best form of energy source? More than one way of accomplishing this would be encouraged.

Thanks a lot guys. Looking forward to hearing from you.
 

bertus

Joined Apr 5, 2008
22,270
Hello,

You will need some microcontroller with a lot of memory.
(depending on how many events you want to record).
A real time clock IC.
A doorswitch.
When the door opens or closes you can read the "timestamp" from the RTC and store it in the memory of the microcontroller.

Greetings,
Bertus
 

Thread Starter

TheRyad

Joined Jun 4, 2009
7
Thanks for your quick reply Bertus.

Follow up questions if you don't mind.

How much memory do you think it would require if it is only to be used for a duration of not more than 3 months, with it being triggered at an average rate of 3 times a day?

Given that required memory capacity, what will be the size and price of the microcontroller?

What is the size of a real-time clock? what is the size of a doorswitch? what is the type and size of the energy source it requires?

How will the transfer of information from the device to a pc for the information to be read take place?

Appreciate it very much, bertus. I am not expecting you to answer all of this. I realize it may be too much for one person to tackle. Just throwing it out there for anyone that may help.
 

bertus

Joined Apr 5, 2008
22,270
Hello,

To be honest, I am not a programmer.
I have found an application note on a microcontroller and a RTC chip.
See attached PDF.
The amount of memory will be dependent on what data you want to store.

Greetings,
Bertus
 

Attachments

PRS

Joined Aug 24, 2008
989
There's always more than one way to skin a cat. But some are more complicated and expensive than others. Let's see...

You want the condition of door open/closed to be detected and its time recorded.
But not directly connected to a computer. (This sounds like intrigue! Are you a spy? LOL)
And you want a complete recording over 3 months time?

Bertus chose the easy way. A microcontroller. But what if there is a simpler, cheaper way? Hm.

You need a clock.
You need a sensor for the door.
You need memory.

I think a dedicated sequential logic circuit would be a bit more complicated than using a microcontroller (I could be wrong, sounds like a good project), and therefore I agree with Bertus.
 

Thread Starter

TheRyad

Joined Jun 4, 2009
7
Hello PRS,

Thank you for your input and for a different perspective on how to tackle this issue. I am interested in learning of as many ways as possible of achieving this, and then selecting using the following criteria:
Primary importance:
- Size
- Price

Secondary importance:
- Longevity

Simplicity/Complexity is not an issue for the moment although it would be welcomed as long as it is not at the expense of the other more important properties.

Would a dedicated sequential logic circuit be smaller? cheaper? longer-lasting (consumes less energy?).

Also, what type of sensor would be appropriate? Is it equivalent to the door-switch bertus mentioned earlier?

Thanks again fellas.

PS - I am not a spy, but I might be working for one ;)
 

bertus

Joined Apr 5, 2008
22,270
Hello,

The doorswitch can be simple.
Mount a magnet on the door.
Mount a reed-contact on the doorpost.
Connect the reed-contact to the controller.
When the magnet moves away from the reed-contact its status will change.

Greetings,
Bertus
 

KL7AJ

Joined Nov 4, 2008
2,229
This can be done with a simple datalogger. It will record a time stamp every second (or any interval you choose) and report a data condition for each entry...which can be a simple contact closure...a 0 or a 1. You can then load the data in to a spreadsheet, and even do a plot.

Eric
 

mango matto

Joined Jun 2, 2009
13
What type of budget are you working with. You can get a burglar alarm most of the big name alarms have event logging for a reasonable price.
 

Propaganda

Joined Jun 3, 2009
22
Hi

My quick thoughts...

PICmicro MCU, RTC, EEPROM, switch, battery, and supporting components.

A PIC 16F688 should work fine... it is only 14 pins!... you can connect the PIC to the RTC and EEPROM via software SPI. You can retrieve the data VIA USART.

The RTC can be any really... most are 8pins... with that you will need a supporting crystal.

The smallest EEPROM are 8 pins and run a 50 cents for 2-32k...

The battery is easy.


Data size my thoughts are a you want to log when the door changes state... open to close or close to open.. that will allow to also determine if the door was held open. So the needed data are DATE, TIME, DOOR STATE... 7 bytes. 7 bytes * 2 (open then close) * 3 times a day * 90 days = 3780... so you data space is really not a concern considering you can get a 32k EEPROM for 44 cents! (small package too!)

So how to retrieve the data? Just hook up the project to a serial port (RS232) and send it a pretermined code such as '123' on the USART port... then the PIC can transmit the data in one long burst... from there the PC reads and writes the data to a TXT file... so now you can import it to EXCEL.

Project cost?

PIC = $1.72
EEPROM = .50
RTC = 1.75 - 2.5
RTC support = .50 + .50
BATTERY = ?
SWITH = ? perhaps $3-$4
GENERAL SUPPORT COMPONETS = $1 - $3
PCB = depends where you get it... $2.50 - $ 20...

So, DIY = CHEAP!

Mounting issue: Drill a .75" hole near the bottem... place the project and the sensor in there... cover with a rubber stopper.... also in the door frame place the magnet for the REED SWITCH....

Well, I know you stated ur an amatuer but depends on how you want to tackle the project you should research some of the keywords stated above... An experienced developer with all the parts in hand could have a working prototype programed and on the breadboard in eight hours. While when I was new if this was my first project it could take me months! You really need a firm base of understanding to get to the ends.
 
Last edited:

CDRIVE

Joined Jul 1, 2008
2,219
Hello everyone,

I hope I came to the right place for this type of question. Please assume that I am completely ignorant with regards to circuits/electronics
As has already been stated, a microcontroller with sufficient memory is the only practical way to go. Unfortunately, learning the electronics of microcontrollers (without a basic electronics background) and also learning to program them, is hardly a newbie endeavor. Besides those issues there's the interface to the PC, which is a science unto itself. After those hurtles have been conquered there's the programming at the PC end to deal with. That's another (hardly minor) science.

If you had electronics background I'd tell you that this sounds like a fun project. However, in your case I think you would be wise to go the rout of a commercially available system.

If you do decide to dive into this I can recommend the PICAXE line of micros as the easiest to learn. That said, they and the circuits that they interface to still require basic electronics knowledge.
 

Zenock

Joined Jun 1, 2009
36
How accurate does the time need to be? To the second? Or is to the minute good enough? If the door opens 4:01 and closes at 4:03 is it ok to say it opened at 4:00 and closed at 4:02? Would it be sufficient to say it opened and closed in the 4:00 hour? Or does it need to recognize opened at 4:01:55 and closed at 4:02:01? The amount of storage you need definately effects the size.
 
Mr. 007

The problem here is... It must be wireless...and the person is not that technical....
So one easier way to do this is by getting something like this..
http://www.robot-italy.com/product_info.php?products_id=928
GSM module. Program its analog input and hook it up on the door with a sensor such as a reed relay..

Like posted previously a reed relay that will trigger/toggle the status of the door. Then everytime the status changes it will trigger the gsm module and send it to your e-mail or other cell phone together with its time and date. :D:D:D

Best Regards
Franz
 

Thread Starter

TheRyad

Joined Jun 4, 2009
7
As has already been stated... still require basic electronics knowledge.
I think I should address this issue first. CDrive, thank you for your honesty. I am well aware that the technicalities involving the designing and building of such a thing is beyond my expertise. For general design possibilities and directions, I am relying on helpful people such as yourselves. Rest assured I don't intend on tackling such an issue single-handedly. I do eventually, plan on hiring some help. Unfortunately, a commercially available system is not an option at the moment.

This can be done with a simple datalogger...
Eric, I have been reading a bit into data loggers. Thanks for this alternative suggestion. Although an ON/OFF data logger would be doing precisely what I need, I have two concerns regarding data loggers. Size and price. With regards to size, at least commercially, they seem quite large.

Stripped to its basic components, how small can they get? With regards to price; certainly commercial price is inflated, but they were still quite high. This leads me to wonder as to the price of the components and its assembly. Any ideas?

I realize that asking for the smallest sizes for cheap may sound like too much to ask for. Compromises are inevitable, but I must acquiant myself with what is already out there.

What type of budget are you working with. You can get a burglar alarm most of the big name alarms have event logging for a reasonable price.
I am sorry but I can't quite disclose the budget I am working with, however, I can tell you that there will be many more than just one consumer, and price will be a critical factor (as well as the other factors I mentioned earlier). Also, as previously mentioned, commercially available products are not an option.

Thank you for a thorough response, Propaganda!
I have researched the keywords you used and am now, at least at a very basic level, aware of their purposes.
Memory size not being a major obstacle is encouraging.

Few questions, if you dont mind.
What criteria did you use to select the PIC16F688? Is it the absolute minimum that is capabale of pulling the job?

Also, When looking up the PIC 16F688 here: http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=1002&mid=10&lang=en&pageId=74, one of the columns mentions EEPROM. Does it mean it comes included with one? If yes, will an external EEPROM be necessary?

Also, thank you for the RS232/USART method of communication. That seems user-friendly. Although, so far, I am not sure if I would need the PC to communicate to the device, will that be possible as well? Also, can you think of other methods of communication? In this case, if a specialized pricey "reader" is required, that is not a problem. Is magnetically an option? Scanner?

How accurate does the time need to be? To the second? Or is to the minute good enough? If the door opens 4:01 and closes at 4:03 is it ok to say it opened at 4:00 and closed at 4:02? Would it be sufficient to say it opened and closed in the 4:00 hour? Or does it need to recognize opened at 4:01:55 and closed at 4:02:01? The amount of storage you need definately effects the size.
Accuracy is not of major significance, certainly not to the second. A rough estimation to the minute would be sufficient. I suppose I should mention that chances are, the opening and closing of the door will occur within the same minute. Will that somehow pose a new problem? Seeing open at 4:00 and closed at 4:00 is good enough. Thanks for bringing that up.

Mr. 007...
Franz, I am afraid for this scenario I can't use this. Size and price are critical. But thank you for bringing it to my attention and trying to help :).

Its been pleasure hearing all your input. I am grateful.
 
Aha. Well if its price.. It is that sort of module that you would be needing to build. If that module was constructed DIY:eek:wn layout,own program, own components.. It can be reduced to 70$ a unit or maybe even less. It only costed 246 Euros because of the board,pre programmed IC and just for the sake of convenience,universal prototype purpose and of course commecial sale...

If you intend to mass produce this.. I suggest building a prototype unit first..For the sake of programming the unit and understanding it... Then later you can pre-programm the chips so you could further reduce its size and cost to perhaps to mere 50$ a unit.
 

Zenock

Joined Jun 1, 2009
36
Ok here's what I'm thinking...

PIC chip with internal clock and internal flash storage.

You store only the amount of time in minutes since the last change (Door can't be opened without closing, door can't close without opening). If number of minutes since last change exceeds a certain ammount store the time instead. For example you could have a storage size of 1 byte for minutes So you could have 0 followed by 7 bits for up to 128 minutes of storage. If you exceed 128 minutes, then you have a 1 followed by 4 bits for the month 5 bits for the day 5 bits for the hour and 6 bits for the minutes. 21 bits... nearly 3 bytes. This way you can minimize memory usage. So in 3 months if someon sits and opens and closes the door once every second for the entire 3 months you would need approximately 8 Kbytes of storage space.

You use an infrared transmitter, receiver pair to determine if the door was opened/closed. Infrared also used for communication with computer. Run it off a 3V watch battery. I think you could get that down to the size of a bottle cap if you used surface mount components. With the infrared you could even build another device that you carry with you point at the door push a couple of buttons and download the data as well as clear the memory.

Good luck.
Z
 

Thread Starter

TheRyad

Joined Jun 4, 2009
7
...Then later you can pre-programm the chips so you could further reduce its size and cost to perhaps to mere 50$ a unit.
Thanks for your input franz, but I am afraid $50 is still too high for what I am looking for. I will certainly look at that venue and see how much the price can be reduced by.

Ok here's what I'm thinking...

PIC chip with internal clock and internal flash storage.

You store only the amount of time in minutes since the last change (Door can't be opened without closing, door can't close without opening). If number of minutes since last change exceeds a certain ammount store the time instead. For example you could have a storage size of 1 byte for minutes So you could have 0 followed by 7 bits for up to 128 minutes of storage. If you exceed 128 minutes, then you have a 1 followed by 4 bits for the month 5 bits for the day 5 bits for the hour and 6 bits for the minutes. 21 bits... nearly 3 bytes. This way you can minimize memory usage. So in 3 months if someon sits and opens and closes the door once every second for the entire 3 months you would need approximately 8 Kbytes of storage space.

You use an infrared transmitter, receiver pair to determine if the door was opened/closed. Infrared also used for communication with computer. Run it off a 3V watch battery. I think you could get that down to the size of a bottle cap if you used surface mount components. With the infrared you could even build another device that you carry with you point at the door push a couple of buttons and download the data as well as clear the memory.

Good luck.
Z
Thanks a lot for the break down of memory storage and the infrared alternative, Zenock. The potential for a very user-friendly method of data retrieval is very encouraging. Much appreciated.
 

Propaganda

Joined Jun 3, 2009
22
Thank you for a thorough response, Propaganda!
I have researched the keywords you used and am now, at least at a very basic level, aware of their purposes.
Memory size not being a major obstacle is encouraging.

Few questions, if you dont mind.
What criteria did you use to select the PIC16F688? Is it the absolute minimum that is capabale of pulling the job?

Also, When looking up the PIC 16F688 here: http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=1002&mid=10&lang=en&pageId=74, one of the columns mentions EEPROM. Does it mean it comes included with one? If yes, will an external EEPROM be necessary?

Also, thank you for the RS232/USART method of communication. That seems user-friendly. Although, so far, I am not sure if I would need the PC to communicate to the device, will that be possible as well? Also, can you think of other methods of communication? In this case, if a specialized pricey "reader" is required, that is not a problem. Is magnetically an option? Scanner?
THe suggestion of the 16f866 was in haste... it had enough pins to support the needed connections, it has USART, it is small, and it is cheap.... there are dozens of PICs all with little differences..I figured it a good simple place to start.

I am unsure off hand, I am at work, about if the 16F688 has internal EEPROM... but if it does, that particular model with only have roughly 256byes... which would be only 18 door cycles... some pics may have up to 1k internal EEPROM but yet that is only 24ish days of data capacity.

The USART connection is used only when the data needs to be retrieved... you can connect the PIC to the PC's RS232 port using a 'level translator'... I use a MAX232, which is simple simple to connect. There are three wires to connect which you can get a simple conector for...
 
Last edited:

THE_RB

Joined Feb 11, 2008
5,438
8pin SMD PIC, 12F629 (or 675)
8pin SMD 24LC256 eeprom
IR TX/RX pair
3v cell

Not many other parts needed, maybe 1 button to start the IR data output.
That would fit easy in the bottle cap size and cost about $3 in parts without battery.
 

Zenock

Joined Jun 1, 2009
36
8pin SMD PIC, 12F629 (or 675)
8pin SMD 24LC256 eeprom
IR TX/RX pair
3v cell

Not many other parts needed, maybe 1 button to start the IR data output.
That would fit easy in the bottle cap size and cost about $3 in parts without battery.
If the IR receiver is watching for door open or door close anyway. No reason not to have it also watch for patter to start data output, I'd leave the button off and be creative in my programming.

Z
 
Top