I am struggeling to find my error in my script. I ran this script with servo 0 only and it worked fine. I am now adding the second servo and need it to work the exact opposite as servo 0 with button presses. I have built a 10 in flip screen for my car dash and want servos on each side for opening, tilting,closing functions. I’m sure its a simple error on my part but I could use some help. Thanks to all who do help. Error was 0040 over/underflow. This is the script I am trying to make work.
Servos are 0 +1 Switch is 2
0000: – # Uses Wait_for_button_press to allow user to step thru sript
0000: – # of positions on servo 0 and servo 1
0000: 04021E002D – 30 0 acceleration
0005: 040264002C – 100 0 speed
000A: 04021E012D – 30 1 acceleration
000F: 040264012C – 100 1 speed
0014: – begin
0014: 0304C00E00002A80 – 3776 0 servo frame
001C: 0304402001002A80 – 8256 1 servo frame
0024: 0304402000002A80 – 8256 0 servo frame
002C: 0304C00E01002A80 – 3776 1 servo frame
0034: 0304B01D00002A80 – 7600 0 servo frame
003C: 0304501101002A80 – 4432 1 servo frame
0044: 0304D01B00002A80 – 7120 0 servo frame
004C: 0304301301002A80 – 4912 1 servo frame
0054: 0304C00E00002A80 – 3776 0 servo frame
005C: 0304402001002A80 – 8256 1 servo frame
0064: 061400 – repeat
0067: – sub frame
0067: 82 – wait_for_button_press
0068: 02002A – 0 servo
006B: 02012A – 1 servo
006E: 05 – return
006F: – # Returns 1 if the button is pressed, 0 otherwise
006F: – sub button
006F: 02022E01F40128 – 2 get_position 500 less_than
0076: 05 – return
0077: – # Waits for a button press, with debouncing
0077: – #(Requires the Button subroutine)
0077: – sub wait_for_button_press
0077: 83 – wait_for_button_open_10ms
0078: 84 – wait_for_button_closed_10ms
0079: 05 – return
007A: – # wait for the button to be not pressed for at least 10 ms
007A: – sub wait_for_button_open_10ms
007A: 09 – get_ms # put the current time on the stack
007B: – begin
007B: – # reset the time on the stack if it is pressed
007B: 81 – button
007C: 078400 – if
007F: 0B09 – drop get_ms
0081: 068F00 – else
0084: 090D1D020A29 – get_ms over minus 10 greater_than
008A: 078F000B05 – if drop return endif
008F: – endif
008F: 067B00 – repeat# wait for the button to be pressed for at least 10 ms
0092: – sub wait_for_button_closed_10ms
0092: 09 – get_ms
0093: – begin
0093: – # reset the time on the stack if it is pressed
0093: 81 – button
0094: 07A500 – if
0097: 090D1D020A29 – get_ms over minus 10 greater_than
009D: 07A2000B05 – if drop return endif
00A2: 06A700 – else
00A5: 0B09 – drop get_ms
00A7: – endif
00A7: 069300 – repeat
00AA: –
Subroutines:
Hex Decimal Address Name
00 000 0067 FRAME
01 001 006F BUTTON
02 002 0077 WAIT_FOR_BUTTON_PRESS
03 003 007A WAIT_FOR_BUTTON_OPEN_10MS
04 004 0092 WAIT_FOR_BUTTON_CLOSED_10MS