1 / 14

Pseudo-Code Group 111

Pseudo-Code Group 111. Electronic Lock Boris Barreto Anthony Cappetto Stephen Kwon Nahom Tewolde. Overall Design. - Enable Interrupts (for Debug) - Loop Through main.c - Get key inputs (From keypad.asm) - Constantly check inputs until a good one is found - Enter appropriate function

remedy
Download Presentation

Pseudo-Code Group 111

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pseudo-Code Group 111 Electronic Lock Boris Barreto Anthony Cappetto Stephen Kwon NahomTewolde

  2. Overall Design • - Enable Interrupts (for Debug) • - Loop Through main.c • - Get key inputs (From keypad.asm) • - Constantly check inputs until a good one is found • - Enter appropriate function • - Perform appropriate function (ASM or C) • This is the overall design for what the program will be doing constantly, in simple terms.

  3. main.c • Initialize all variables (including char[6] vInput, and intvCount, num) • //Function definitions (pseudocode for each function in future slides) • For (;;) • While (vCount != 100) • input = keypad_debounce(1000); // This is not vInput, this is just one character • If (inputvalid == true) • vInput[vCount--] = input; • ++num; • CheckInput(vInput, num); • Else • Do nothing (Loop and check again) • If (vCount == 0) (If it reached the end of its input and its still not a valid code, restart it) • Clear vInput[]; • vCount = 5; • // Should never exit this while loop.

  4. keypad.asm • Push registers used onto the stack • If (PTAD has been set up) branch endif • Else set up PTAD • DO • Output each row code // Starting from Row3 • Read each col code (col[j]) for every row • While (I > 0) // Where I is row[i] • If (I = 0 && j = 0) // End of the keypad, no key pressed • clearB • Pull variables • Return • Else // KeyPressed • Check if the key pressed is valid • If (valid) • Load b with appropriate ascii value for button pressed • Pull variables • Return • Else // Not valid • clearB • Pull variables • Return

  5. spin.asm • // Controls the motor just as in labs: • XREF Direction,Speed • Push registers to stack • Sequence: DC.B (Stepping Sequence) • LDY with Direction (To check it to see which direction to go in) • LDX Sequence • LDY Speed (Not sure how to control speed yet, my lab seven isn’t able to go fast yet. • If CW • LDAA 1,X- • Else • LDAA 1,X+ • Pull registers from stack • Return

  6. Keypad_debounce(intbouncelength) • getkey = hex_key_scan(); • Count = bouncelength/2; • While (count between 0 and bouncelength) • Delay • Newkey = hex_key_scan(); • If (newkey = getkey) • Increment count • Else • Decrement count • If (count == bouncelength) return getkey • Else • Return newkey

  7. CheckCodes(unsigned char * vInput, num) • // This one is gonna get messy with a lot of if statements, to hopefully optimize when the code will recognize a faulty code and reset its input. • If (num== 1) • If (vInput[5] = ‘*’) • Lock(); • If (vCount = 2) • if (((vInput[5] <= ‘9’ && vInput[5] >= ‘0’) || (vInput[5] >= ‘A’ && vInput[5] <= ‘D’)) && (vInput[4] == ‘#’ || vInput[4] == ‘*’)) • // Invalid Input • Clear vInput; • vCount = 5; • num = 0; • ETC (Check all the commands one by one, and run the appropriate command.) • Commands to be included are: Lock, DisplayUnlockCodes, OpenProgrammingMode (This might have CloseProgrammingModeInside it to check for when to close), Unlock, EraseCode) • // Notice no Debug, this is on the interrupt, so it will happen without being checked.

  8. Lock • Direction = ‘1’ (CW) • Speed = (90 times a minute) • spin(); • Clear vInput[]; • num = 0; // Restore the input to its original state (POR) • vCount = 5;

  9. OpenProgrammingMode // Im still not sure how to implement this one. Need to test ideas • Variables used which are defined in main: • char vUnlockCodes[9] • Unsigned intvCodesnum (Starting at 0); • If (vCodesnum == 9) • LCDPutString (“FULL”); • If ((vInput[3] >= ‘0’ && vInput[3] <= ‘9’) && vInput[2] >= ‘0’ && vInput[2] <= ‘9’) && (vInput[1] >= ‘0’ && vInput[1] <= ‘9’)) • // Valid Number Sequence • vInput[3] = vUnlockCodes[vCodesnum++]; • LCDPut • vInput[2] = vUnlockCodes[vCodesnum++]; • LCDPut • vInput[1] = vUnlockCodes[vCodesnum++]; • LCDPut • Else • Retry with a new number;

  10. Display Unlock Codes • LCDPutString(First three numbers in vUnlockCodes[]); • DELAY • LCDPutString(Next three numbers); • DELAY • LCDPutString(LastThreeNumbers); • Reset vInput, num, and vCount

  11. Unlock • Check the numbers input (from vInput[3-1]) with the numbers in vUnlockCodes[8-6,5-3,2-0]. • If (Any Match in the three numbers) • Unlock • LCDPut (OK) • Else • DontUnlock • LCDPut(NOTVALID) • Reset vInput, vCount, and num

  12. EraseCode • LCDPut(ERASED); • Clear vUnlockCodes[]; • Reset vCodesNum = 0;

  13. Clear (unsigned char * x, int length) • For (inti = 0, i <= length, i++) • X[i] = ‘J’; // Random letter for a place holder.

  14. Debug • PTT_PT7 = 1; • LCDPut(DEBUG); • While (PB1 == 1) • DELAY • While (POT is Range 1 && PB1 == 1) • Direction = CCW • Spin(); • Delay • While (POT is Range 2 && PB == 1) • Direction = CCW • Spin(); • Delay • While (POT is Range 3 && PB == 1) • Direction = Stopped • Spin(); • Delay • LEDS = OFF • LCDPUt(POR); • PTT_PTT7 = 0;

More Related