TPS Aufzug-Modell             

von Jos van den Enden                 
Elektronik-Labor  Literatur  Projekte  Lernpakete  TPS


   
Video: https://drive.google.com/file/d/0B2B88PP8FVeZV01MQ2ttTHNhbmc/view?usp=sharing
 
Der Aufzug hat vier Stockwerke und wird über vier Tasten an den Eingängen PA0 bis PA4 bedient.  Die Position und die Bewegung des Aufzugs werden über vier LEDs an den digitalen Ausgängen PA4 bis PA7 angezeigt.

Wenn der Aufzug in einem Stockwerk steht, leuchtet die zugehörige LED dauerhaft. Wenn man von diesem Stockwerk abfährt, blinkt die LED. Die Bewegung nach oben oder unten wird durch ein Lauflicht mit allen vier LEDs angezeigt. Wird ein Stockwerk erreicht, dann blinkt die zugehörige LED.

Das Programm verwendet die TPS-Register wie folgt:
Reg. A    reserviert als “Akku”
Reg. B   Zwischenspeicher
Reg. C   Angefordertes Stockwerk
Reg. D   Aktuelles Stockwerk

Das Register D ändert sich während der Aufzug in Bewegung  ist:
          
D = 0001 (Erdgeschoss)           
D = 0010 (1. Stock)                       
D = 0100 (2. Stock)                       
D = 1000 (3. Stock)                       

Genauso werden die Positionen an den vier LEDs angezeigt:   
Dout = 0001 (Erdgeschoss)           
Dout = 0010 (1. Stock)                       
Dout = 0100 (2. Stock)                       
Dout = 1000 (3. Stock)     
         
Die Anforderungstasten schalten jeweils einen der vier digitalen Eingänge herunter.   
Din = 1110 (fahre zum Erdgeschoss)                       
Din = 1101 (fahre zum 1. Stock)                       
Din = 1011 (fahre zum 2. Stock)                       
Din = 0111 (fahre zum 3. Stock)       

Das Programm steht im auf 
https://docs.google.com/spreadsheets/d/1PuvDTSEbKpD6nAsJ6Wtp6x9n9X5uLCThXwGoOOMrQgo/edit?usp=sharing


Das Programm im Spreadsheet kann verändert werden. Ändern Sie nur die Inhalte der Spalten C (Mnemonics), D (Sprünge) und F-H (Kommentare).  Die Spalte A (Adressen) wird automatisch gefüllt.

Program "Elevator" for the HT46F47 microcontroller(vs. 20160310)
addr.instr.mnemonicsjmps&cllsaddr.highcomments
Initialize
0041A = 0001Elevator on ground floor
0111Port = 0001Set the 4 leds accordingly
0253D = AKeep track of elevator in register D
02
02Main loop
0382Page = 22Set addr.high
0490Jump 20Jump 20Wait for user input - return choice in register C
04
0581Page = 11User input returns here----------------Set addr.high
06D3Call 13Call 13Show departure from current floor by flashing several times
06
0763A = DGet current and chosen floor to determine direction to go
0851B = AStore current floor in B
0962A = CStore chosen floor in A
09
0A83Page = 33Set addr.high
0BC2Skip if A<BIs chosen floor above or below current floor?
0C9CJump 3CJump 3CAbove, go up
0D85Page = 55Set addr.high
0E9EJump 5EJump 5EBelow, go down
0E
0F63A = DWe arrived at chosen floor('Up' and 'Down' returns here)
1054Dout = AGet floor and show in the 4 leds
10
1180Page = 00Set addr.high
1293Jump 03Jump 03Loop back to get new floor choice
12
12Show current floor
1362A = CSave chosen floor
1451B = Ain register B
14
1543A = 3Set counter to 4 - 1 = 3
1652C = Ato flash 4 times
1763A = DPut current floor in A
17
1810Port = 0000Flash leds current floor ------------All leds off
1927Wait 200 msWait some time
1A54Dout = ALed current floor on
1B27Wait 200 msWait some time
1CA8C-Jump 18Jump 18Do this another C times
1C
1D61A = BRestore chosen floor
1E52C = Ain register C
1FE0ReturnReturn
1F
1FGet floor choice (invoked by main loop - addr.04; return - addr.05)
20C8Skip if Din.0 = 0Ground floor button pressed?If ...
2194Jump 24Jump 24No, test 1st floor buttonElse ...
2241A = 0001Yes, set A accordinglyThen ...
239FJump 2FJump 2Fand leave loopThen ...
24C9Skip if Din.1 = 0First floor button pressed?If ...
2598Jump 28Jump 28No, test 2nd floor buttonElse ...
2642A = 0010Yes, set A accordinglyThen ...
279FJump 2FJump 2Fand leave loopThen ...
28CASkip if Din.2 = 0Second floor button pressed?If ...
299CJump 2CJump 2CNo, test 3st floor buttonElse ...
2A44A = 0100Yes, set A accordinglyThen ...
2B9FJump 2FJump 2Fand leave loopThen ...
2CCBSkip if Din.3 = 0Third floor button pressed?If ...
2D90Jump 20Jump 20No, jump backElse ...
2E48A = 1000Yes, set A accordinglyThen ...
2F51B = AStore choice in register B for nowThen ...
2F
3063A = DTest need to move -------------------Get current floor
3183Page = 33Set addr.high
32C3Skip if A = BAre we on chosen floor?
3398Jump 38Jump 38No, continue
3481Page = 11Set addr.high
35D3Call 13Call 13Yes, signalize we are already there - stay where we are
3682Page = 22Set addr.high
3790Jump 20Jump 20and jump back to wait for new choice
37
3861A = BGet user choice
3952C = AChosen floor is stored in C
3A80Page = 00Set addr.high
3B95Jump 05Jump 05Jump back to main loop to depart from floor
3B
3BGo up (invoked by main loop - addr.0C; return - addr.0F)
3C84Page = 44Set addr.high
3DDDCall 4DCall 4DSimulate going up
3D
3E42A = 2We are one floor higher ------------Get 2
3F51B = AB = 2
4063A = DGet old current floor
4175A = AxBmultiplicate by 2 -- shift left
4253D = AStore new current floor in register D
42
4381Page = 11Set addr.high
44D3Call 13Call 13Show arrival on new floor
44
4563A = DCompare floors ------------------------Get current floor
4651B = AB = (new) current floor
4762A = CGet chosen floor
47
4883Page = 33Set addr.high
49C3Skip if A = BTest wether we arrived at chosen floor
4A9CJump 3CJump 3CNo, another floor up
4B80Page = 00Yes, we are on chosen floor
4C9FJump 0FJump 0FJump back to finish main loop
4C
4CSimulate going up
4D62A = CSave chosen floor
4E51B = Ain B
4E
4F42A = 2Set counter to 3 - 1 = 2
5052C = Ain order to signalize ‘up’ 3 times
50
5185Page = 55Set addr.high
5211Port = 0001Simulate going up -------------------Low
5327Wait 200 msWait
5412Port = 0010Higher
5527Wait 200 msWait
5614Port = 0100Higher
5727Wait 200 msWait
5818Port = 1000High
5927Wait 200 msWait
5AA2C-Jump 52Jump 52Jump back C times
5A
5B61A = BRestore chosen floor
5C52C = Ain C
5DE0ReturnReturn
5D
5DGo down (invoked by main loop - addr.0E; return - addr.0F)
5E86Page = 66Set addr.high
5FDFCall 6FCall 6FSimulate going down
5F
6042A = 2We are one floor lower -------------Get 2
6151B = AB = 2
6263A = DGet old current floor
6376A = A/Bdivide by 2 -- shift right
6453D = AStore new current floor in register D
64
6581Page = 11Set addr.high
66D3Call 13Call 13Show arrival on new floor
66
6763A = DCompare floors ------------------------Get current floor
6851B = AB = (new) current floor
6962A = CGet chosen floor
69
6A85Page = 55Set addr.high
6BC3Skip if A = BTest wether we arrived at chosen floor
6C9EJump 5EJump 5ENo, another floor down
6D80Page = 00Yes, we are on chosen floor
6E9FJump 0FJump 0FJump back to finish main loop
6E
6ESimulate going down
6F62A = CSave chosen floor
7051B = Ain register B
70
7142A = 2Set counter to 3 - 1 = 2
7252C = Ain order to signalize ‘down’ 3 times
72
7387Page = 77Set addr.high
7418Port = 1000Simulate going down ---------------High
7527Wait 200 msWait
7614Port = 0100Lower
7727Wait 200 msWait
7812Port = 0010Lower
7927Wait 200 msWait
7A11Port = 0001Low
7B27Wait 200 msWait
7CA4C-Jump 74Jump 74Jump back C times
7C
7D61A = BRestore chosen floor
7E52C = Ain C
7FE0ReturnReturn
7F


Siehe auch:  TPS Google Spreadsheet   


Elektronik-Labor  Literatur  Projekte  Lernpakete  TPS