Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey everyone

I've been attempting to create a code-locked safe for a few days, and have come up with a schematic. The hardware is wrapping itself up, however I have hit a speed bump in my progress. I need help with the software. I am using a pic16f628a to drive a motor in two directions (open and close) and also to monitor the 11 buttons that will be pressed. (1-9) and a reset and lock button.

Due to my pin restrictions, I need to use the pics internal clock to manage the motor's time at which it stays on when the correct code has been entered.

Anyway, thats the project. If anyone knows anything about microcontroller software, please respond here, or email me at [Email deleted].

Thanks a ton.

p.s. here is the schematic.

http://img80.imageshack.us/img80/9417/safeschematic.jpg

[edit]Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email (like this one) to let you know.[/edit]
Posted
Updated 30-Jul-10 8:17am
v2

Google! "PIC Motor Control software" gives loads of hits - refine from there for your motor requirements and you are off.

It would also be a good idea to have a look at the PIC website - they have good code examples and some SD's too.
 
Share this answer
 
Comments
Sandeep Mewara 30-Jul-10 15:50pm    
Comment by OP: Thanks, but i have done this in the past, and all i can find are led blinkers and 7 segment led displays etc. nothing as specific as what i need to do
rawflewaffle 31-Jul-10 16:38pm    
Reason for my vote of 3
at least you were civil about it
Well, thanks for the vote of 1 but I cannot help you if you have no idea of what you expect for an answer. In my opinion my answer fits exactly to your question.
I am also a little shocked by your statement that as far as you understand there aren't if then statements in assembly. Well, do you mean literally "if then" constructions? No, it wouldn't be assembly if there are literal if statements because it would then be a more high level language already. Or does this mean that you have the idea that a higher computer language has a magic fairy delivered with the software that recognizes if statements and changes the instruction pointer accordingly?

The if statement is a simple compare/jump instruction and with a PIC this is:
BTFSS PIN_BUTTON_X, 1 	;Is bit 1 of PIN_BUTTON_X set. IF zero skip next instruction (so no jump).
GOTO PIN_ISNOTSET 	;Bit 1 is not zero so JUMP.
;Bit 1 is set so the button is pressed 


This is by the way very simple code and again as OriginalGriff did point out very easy to find using google. The solution here is simply to create a kind of subroutine that checks the pins and returns the number pressed or -1 as indicator that nothing happened. If something did happen you check it against the code and if it's the safe you open the vault. But since you have no idea of the assembly of a pic controller I would suggest to use c instead and let the compiler figure out the complex statements such as if. The c libraries also have code that would help you along and safe you time. But thanks again for voting 1 on the fact that the question you have probably isn't all that clear. It really gives people motivation to keep trying to helping you.
 
Share this answer
 
Comments
rawflewaffle 31-Jul-10 14:10pm    
no need to get defensive here
i just assumed that if someone was going to take the time to write an answer, they would actually write something useful, as opposed to telling me how simple my problem is, then not explaining how to go about tackling it. Despite your blunt responses, you actually did give me an idea as to what i can do, so thank you for that.

In the future, try being a little less harsh for new comers. (ive only written one assembly script so far, so obviously, im not as advanced as some of the users on this forum.)
E.F. Nijboer 31-Jul-10 17:02pm    
Well, I'm just a little harsh because your question mentions assembly only in the subject and in the question itself you don't mention it again, only if something knows micro controller software. It also wasn't very clear that you had problems finding the correct syntax for the if/then construction. Like you commented on the answer of OriginalGriff you needed something more specific to what you needed to do. That's why I posted the link to code that was practically ready to use but this was not in assembly. After this first answer you had already voted 1, but I actually knew (and could only knew then) your problem from the comment that was added. That's why I mention that in my reaction, maybe blunt but even though could help you out with some tips. My point of being a bit harsh is that if you would just have explained, because it maybe didn't come out in the question that good, that your problem is just a little different from the answer I gave, I would happily provided it without further mentioning anything. But what would be your reaction if I would ask you the color of grass, and you would answer "green" and I would simply say "no you dumb ass I mean the smell! what's the smell like?". I guess you would be somewhat ticked off yourself ;-)
Well, no hard feelings and good luck with that vault.
rawflewaffle 2-Aug-10 2:25am    
originally, i intended for my email to be given, as to be easily accessed by people who were attracted by the title, which you pointed out, has the word assembly in it. That is the reason for my unspecific post. I assumed that i could explain it to anyone who emailed me, in more depth. You can see in the OP, that there was an edit by an admin.

Thats my reason for being unspecific, however it no longer matters, for i have found a better direction in my project, with the help of another forum. I actually ended up using a similar method to checking the buttons state that you posted, so i must thank you for the subconscious idea.

Thanks
Honestly... OriginalGriff's answer has a good point. If you would want it all handed to you on a plate you should have got a kit. You could also change the schematic and use a LS7220 Digital Lock IC for example so no actual programming has to be done (except kinda programming in the 4 digit code)
http://www.aaroncake.net/circuits/combolock.asp[^]

Also, what you are trying to make is not that complicated because each button has its wire soldered directly on to a pin. So the led blinking examples are almost what you want to do except you want to read the port instead of write to it. But basically it's turning the set into a get. I would strongly advise you to ignore the rest below and for now keep it in the vault ;P The best way to learn a lot even though you might feel failing constantly is just try out some things yourself and see what happens. You learn much, much more that way. But if you must, can't control yourself and go insane knowing your secrets lie around unsafe then visit the link below and get that crypt for your exchequer ;)


The link to be kept under lock and key, but here exposed, unguarded, unprotected, just unconcealed:
http://www.rentron.com/PicBasic/Serial-Keys.htm[^]

Good luck!
 
Share this answer
 
Comments
rawflewaffle 30-Jul-10 18:00pm    
maybe i was unclear in my original post

I am not looking for a fully written script necessarily, however i am looking for an answer as to how i can check if the buttons being pressed are in the correct order.

I know and understand fully how to set up pins to input/output. I understand how to set an output pin high or low, i understand how to check if an input pin is high or low as well.

I do not understand how i can set in the program a specific order in which the input pins need to be pressed. As far as i understand, there aren't if then statements in assembly, so i would need some help learning how i could accomplish this.

Thanks
rawflewaffle 31-Jul-10 4:12am    
Reason for my vote of 1
didn't resolve anything, thanks for the thoughts though
E.F. Nijboer 31-Jul-10 11:25am    
You mean that this vote is actually for meant to vote your question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900