===== file: Main.bas
            Option Explicit
            '===================================List of Files========================================
            
            'Main contains the main control loops
            'IO contains Rooomba sensory and motor control routines
            'Config contains Roomba configuration (on and off) routines
            'Init contains all variables and constants (is rather convoluted do to many generations of variables)
            'Sensors contains routines for nonRoomba sensors
            'Control contains all calculates for corrections and wall following
            
            '===================================List Of Functions====================================
            
            '--Core IO---
            
            'Function GetDanger() as byte
            'Returns a 1 if there are any bumps or Drops
            'Fills Bumps with 1 if left bump, 2 if right bump, 3 if both
            'Fills Drops with 1 if left drop, 2 if right drop, or 4 if front drop (and any other combinations)
            
            'Sub Getsensors() as byte
            'Fills Sonar(1 to 4) (representing sonar sensors from left to right) with data in inches to closest object
            'Fills LFIR and RFIR with IR data for rangefinding, RotPot with rotation pot and Slide pot with linear pot
            
            'Sub Putmotor as byte
            'Applies LeftMotor and Rightmotor to the roombas motors
            
            '--Second level control---
            
            'Sub GetMasterSpeed()
            'Fills MasterSpeed with base speed for both motors based on slide pot over time
            
            'Sub GetMagnitude()
            'Determines forces from objects and fills MagnitudeVector with desired turn
            
            'Sub PutMovement()
            'Applies corrections to motors with overflows from one motor subtracting from the opposite motors
            
            'Sub GetProximity()
            'Fills GetProximityAlert if there is an object that should break wall following
            
            'Sub RightWallFollow()
            'Fills WallFollowCorrect with necesary corrections for wall following
            
            '===================================Main Function============================
            
0000 100b02      LODSP          0x020b (523)
0003 ebcb00      INIT_VAR       0x00cb (203)
0006 1b1400      PSHI_W         0x0014 (20)
0009 1b0b02      PSHI_W         0x020b (523)
000c 1b0000      PSHI_W         0x0000 (0)
000f fe4a        SCALL          TASK_START
0011 01fdff      BRA            0011

            Sub Main()
            
            Call ComChannels(2, 19200)					'Prep two com ports
0014 1a02        PSHI_B         0x02 (2)
0016 1b004b      PSHI_W         0x4b00 (19200)
0019 fe43        SCALL          COM_PARM
            Call InitRoomba								'Turn roomba on
001b 05a303      CALL           03a3
            Call PutPowerLED(255,0)						'Indicate roomba is on
001e 1aff        PSHI_B         0xff (255)
0020 1a00        PSHI_B         0x00 (0)
0022 057303      CALL           0373
            
            '---------------------------------Main loop-------------------------------
            
            Do
            Call GetSensors								'Read All Sensors
0025 056404      CALL           0464
            Call GetMasterSpeed							'Determine base motor speed
0028 05a506      CALL           06a5
            Call GetMagnitude							'Determine push forces using sonar
002b 05f606      CALL           06f6
            Call GetProximity							'Determine closest object
002e 05ef07      CALL           07ef
            
            If (RFIR < WallFollowIRThresh) AND (Sonar4 < WallFollowSonarThresh) AND (Twistpot < 0) AND _	'Check for wall follow
            (ClearLoops > ClearLoopsThreshold) AND (GetProximityAlert = 0) Then
0031 1ee201      PSHA_W         0x01e2 (482)
0034 1b1900      PSHI_W         0x0019 (25)
0037 b7          CMPLT_I
0038 1ddf01      PSHA_B         0x01df (479)
003b 1a41        PSHI_B         0x41 (65)
003d a5          CMPLT_B
003e 6c          AND_B
003f 1ee601      PSHA_W         0x01e6 (486)
0042 1b0000      PSHI_W         0x0000 (0)
0045 b7          CMPLT_I
0046 6c          AND_B
0047 1efd01      PSHA_W         0x01fd (509)
004a 1b0300      PSHI_W         0x0003 (3)
004d b4          CMPGT_I
004e 6c          AND_B
004f 1df001      PSHA_B         0x01f0 (496)
0052 7c          CVTX_B
0053 69          COM_B
0054 6c          AND_B
0055 043300      BRA_F          008b
            	Call PutPlayLED(1)																			'Indicate wall follow
0058 1a01        PSHI_B         0x01 (1)
005a 053d03      CALL           033d
            	Call RightWallFollow																		'Get WallFollowcorrect
005d 053308      CALL           0833
            	RightMotor = MasterSpeed + (WallFollowCorrect*Clng(PercentSpeed))\100				'Apply correction to motors
0060 1fe801      PSHA_D         0x01e8 (488)
0063 1ff501      PSHA_D         0x01f5 (501)
0066 1fec01      PSHA_D         0x01ec (492)
0069 41          MUL_L
006a 1c64000000  PSHI_D         0x00000064 (100)
006f 47          DIV_L
0070 37          ADD_D
0071 224601      POPA_D         0x0146 (326)
            	LeftMotor = MasterSpeed - (WallFollowCorrect*Clng(PercentSpeed))\100
0074 1fe801      PSHA_D         0x01e8 (488)
0077 1ff501      PSHA_D         0x01f5 (501)
007a 1fec01      PSHA_D         0x01ec (492)
007d 41          MUL_L
007e 1c64000000  PSHI_D         0x00000064 (100)
0083 47          DIV_L
0084 3b          SUB_D
0085 224001      POPA_D         0x0140 (320)
0088 017d00      BRA            0108
            Else																						'If not in wall follow state
            	Call PutPlayLED(0)																			'Indicate no follow
008b 1a00        PSHI_B         0x00 (0)
008d 053d03      CALL           033d
            	LeftMotor = Masterspeed + (Clng(MagnitudeVector)*Clng(PercentSpeed))\100					'Apply forces to motors
0090 1fe801      PSHA_D         0x01e8 (488)
0093 1e0902      PSHA_W         0x0209 (521)
0096 8c          CVTL_I
0097 1fec01      PSHA_D         0x01ec (492)
009a 41          MUL_L
009b 1c64000000  PSHI_D         0x00000064 (100)
00a0 47          DIV_L
00a1 37          ADD_D
00a2 224001      POPA_D         0x0140 (320)
            	RightMotor = Masterspeed - (Clng(MagnitudeVector)*Clng(PercentSpeed))\100
00a5 1fe801      PSHA_D         0x01e8 (488)
00a8 1e0902      PSHA_W         0x0209 (521)
00ab 8c          CVTL_I
00ac 1fec01      PSHA_D         0x01ec (492)
00af 41          MUL_L
00b0 1c64000000  PSHI_D         0x00000064 (100)
00b5 47          DIV_L
00b6 3b          SUB_D
00b7 224601      POPA_D         0x0146 (326)
            	If NOT ((MagnitudeVector < -150) OR (MagnitudeVector > 150)) Then						'Check for handle twist
00ba 1e0902      PSHA_W         0x0209 (521)
00bd 1b6aff      PSHI_W         0xff6a (65386)
00c0 b7          CMPLT_I
00c1 1e0902      PSHA_W         0x0209 (521)
00c4 1b9600      PSHI_W         0x0096 (150)
00c7 b4          CMPGT_I
00c8 6f          OR_B
00c9 033c00      BRA_T          0108
            		LastReading = 0
00cc 1b0000      PSHI_W         0x0000 (0)
00cf 21f901      POPA_W         0x01f9 (505)
            		RightMotor = RightMotor + (Clng(Twistpot)*TwistPotFactor*Clng(PercentSpeed))\10000	'Turn robot by twist
00d2 1f4601      PSHA_D         0x0146 (326)
00d5 1c37000000  PSHI_D         0x00000037 (55)
00da 1ee601      PSHA_W         0x01e6 (486)
00dd 8c          CVTL_I
00de 41          MUL_L
00df 1fec01      PSHA_D         0x01ec (492)
00e2 41          MUL_L
00e3 1c10270000  PSHI_D         0x00002710 (10000)
00e8 47          DIV_L
00e9 37          ADD_D
00ea 224601      POPA_D         0x0146 (326)
            		LeftMotor = LeftMotor - (Clng(Twistpot)*TwistPotFactor*Clng(PercentSpeed))\10000
00ed 1f4001      PSHA_D         0x0140 (320)
00f0 1c37000000  PSHI_D         0x00000037 (55)
00f5 1ee601      PSHA_W         0x01e6 (486)
00f8 8c          CVTL_I
00f9 41          MUL_L
00fa 1fec01      PSHA_D         0x01ec (492)
00fd 41          MUL_L
00fe 1c10270000  PSHI_D         0x00002710 (10000)
0103 47          DIV_L
0104 3b          SUB_D
0105 224001      POPA_D         0x0140 (320)
            	End If
            End If
            
            
            
            If (RFIR < WallFollowIRThresh) AND (Sonar4 < WallFollowSonarThresh) Then		'Is object to side
0108 1ee201      PSHA_W         0x01e2 (482)
010b 1b1900      PSHI_W         0x0019 (25)
010e b7          CMPLT_I
010f 1ddf01      PSHA_B         0x01df (479)
0112 1a41        PSHI_B         0x41 (65)
0114 a5          CMPLT_B
0115 6c          AND_B
0116 040600      BRA_F          011f
            	ClearLoops = ClearLoops + 1							'Incriment counter used to determine if should wall follow
0119 e5fd01      INCA_W         01fd
011c 010600      BRA            0125
            Else
            	Clearloops = 0										'Reset counter
011f 1b0000      PSHI_W         0x0000 (0)
0122 21fd01      POPA_W         0x01fd (509)
            End If
            
            If GetDanger = 1 Then									'Check for bumps and edges
0125 16          DUP_B
0126 05c401      CALL           01c4
0129 1a01        PSHI_B         0x01 (1)
012b a0          CMPEQ_B
012c 040300      BRA_F          0132
            	Exit Do												'cease and desist
012f 010600      BRA            0138
            End If
            
            Call PutMovement																'Apply corrections to motors
0132 057807      CALL           0778
            
            Loop
0135 01edfe      BRA            0025
            
            '-------------------------------End Main loop-------------------
            
            
            End Sub
0138 06          RET
            
            
            
            
            
            
            
            
            
            

===== file: IO.bas
            Option Explicit
            
            
            '-----------------------Motor Control Subroutines-------------------
            Sub PutMotor()
            
            If RightMotor < 0 then								'If speed is negative
0139 1f4601      PSHA_D         0x0146 (326)
013c 1c00000000  PSHI_D         0x00000000 (0, 0.0)
0141 bd          CMPLT_L
0142 040c00      BRA_F          0151
            	RightMotor = (65535 + RightMotor) + 1			'Convert to 2's compliment
0145 1c00000100  PSHI_D         0x00010000 (65536)
014a 1f4601      PSHA_D         0x0146 (326)
014d 37          ADD_D
014e 224601      POPA_D         0x0146 (326)
            End If
            
            Motor1Low = cByte(RightMotor mod 256)				'seperate low byte
0151 1f4601      PSHA_D         0x0146 (326)
0154 1c00010000  PSHI_D         0x00000100 (256)
0159 4d          MOD_L
015a fe02        SCALL          CBYTE_D
015c 204501      POPA_B         0x0145 (325)
            Motor1High = cByte(RightMotor \ 256)				'seperate high byte
015f 1f4601      PSHA_D         0x0146 (326)
0162 1a08        PSHI_B         0x08 (8)
0164 9a          SHR_L
0165 fe02        SCALL          CBYTE_D
0167 204401      POPA_B         0x0144 (324)
            
            If LeftMotor < 0 then								'If speed is negative
016a 1f4001      PSHA_D         0x0140 (320)
016d 1c00000000  PSHI_D         0x00000000 (0, 0.0)
0172 bd          CMPLT_L
0173 040c00      BRA_F          0182
            	LeftMotor = (65535 + LeftMotor) + 1				'Convert to 2's compliment
0176 1c00000100  PSHI_D         0x00010000 (65536)
017b 1f4001      PSHA_D         0x0140 (320)
017e 37          ADD_D
017f 224001      POPA_D         0x0140 (320)
            End If
            
            Motor2Low = cByte(LeftMotor mod 256)				'seperate low byte
0182 1f4001      PSHA_D         0x0140 (320)
0185 1c00010000  PSHI_D         0x00000100 (256)
018a 4d          MOD_L
018b fe02        SCALL          CBYTE_D
018d 204b01      POPA_B         0x014b (331)
            Motor2High = cByte(LeftMotor \ 256)					'seperate high byte
0190 1f4001      PSHA_D         0x0140 (320)
0193 1a08        PSHI_B         0x08 (8)
0195 9a          SHR_L
0196 fe02        SCALL          CBYTE_D
0198 204a01      POPA_B         0x014a (330)
            
            Data(1) = 145							'Motor Speed Direct
019b 1a91        PSHI_B         0x91 (145)
019d 209201      POPA_B         0x0192 (402)
            Data(2) = Motor1High
01a0 1d4401      PSHA_B         0x0144 (324)
01a3 209301      POPA_B         0x0193 (403)
            Data(3) = motor1Low
01a6 1d4501      PSHA_B         0x0145 (325)
01a9 209401      POPA_B         0x0194 (404)
            Data(4) = Motor2High
01ac 1d4a01      PSHA_B         0x014a (330)
01af 209501      POPA_B         0x0195 (405)
            Data(5) = Motor2Low
01b2 1d4b01      PSHA_B         0x014b (331)
01b5 209601      POPA_B         0x0196 (406)
            Call PutQueue(OQ, data, 5) 				'placing lowest bit first of array into the Roomba
01b8 1b4c01      PSHI_W         0x014c (332)
01bb 1b9201      PSHI_W         0x0192 (402)
01be 1b0500      PSHI_W         0x0005 (5)
01c1 fe40        SCALL          Q_PUT
            End Sub
01c3 06          RET
            '---------------------------------------------------------------------
            
            
            '------------------------------Sensory Subroutines------------------------------
            Function GetDanger() as byte
fffb -5    ret:GetDanger (1)
            
            Call ClearQueue(IQ)
01c4 1b6a01      PSHI_W         0x016a (362)
01c7 fe3b        SCALL          Q_CLR
            
            Data(1) = 149
01c9 1a95        PSHI_B         0x95 (149)
01cb 209201      POPA_B         0x0192 (402)
            Data(2) = 5
01ce 1a05        PSHI_B         0x05 (5)
01d0 209301      POPA_B         0x0193 (403)
            Data(3) = 7
01d3 1a07        PSHI_B         0x07 (7)
01d5 209401      POPA_B         0x0194 (404)
            Data(4) = 9
01d8 1a09        PSHI_B         0x09 (9)
01da 209501      POPA_B         0x0195 (405)
            Data(5) = 10
01dd 1a0a        PSHI_B         0x0a (10)
01df 209601      POPA_B         0x0196 (406)
            Data(6) = 11
01e2 1a0b        PSHI_B         0x0b (11)
01e4 209701      POPA_B         0x0197 (407)
            Data(7) = 12
01e7 1a0c        PSHI_B         0x0c (12)
01e9 209801      POPA_B         0x0198 (408)
            Call PutQueue(OQ, Data, 7)
01ec 1b4c01      PSHI_W         0x014c (332)
01ef 1b9201      PSHI_W         0x0192 (402)
01f2 1b0700      PSHI_W         0x0007 (7)
01f5 fe40        SCALL          Q_PUT
            Call GetQueue(IQ, DataIn(1), 1, 0.2, erflag)
01f7 1b6a01      PSHI_W         0x016a (362)
01fa 1b9f01      PSHI_W         0x019f (415)
01fd 1b0100      PSHI_W         0x0001 (1)
0200 1b6600      PSHI_W         0x0066 (102)
0203 1ba901      PSHI_W         0x01a9 (425)
0206 fe3f        SCALL          Q_GET
            Call GetQueue(IQ, DataIn(2), 1, 0.2, erflag)
0208 1b6a01      PSHI_W         0x016a (362)
020b 1ba001      PSHI_W         0x01a0 (416)
020e 1b0100      PSHI_W         0x0001 (1)
0211 1b6600      PSHI_W         0x0066 (102)
0214 1ba901      PSHI_W         0x01a9 (425)
0217 fe3f        SCALL          Q_GET
            Call GetQueue(IQ, DataIn(3), 1, 0.2, erflag)
0219 1b6a01      PSHI_W         0x016a (362)
021c 1ba101      PSHI_W         0x01a1 (417)
021f 1b0100      PSHI_W         0x0001 (1)
0222 1b6600      PSHI_W         0x0066 (102)
0225 1ba901      PSHI_W         0x01a9 (425)
0228 fe3f        SCALL          Q_GET
            Call GetQueue(IQ, DataIn(4), 1, 0.2, erflag)
022a 1b6a01      PSHI_W         0x016a (362)
022d 1ba201      PSHI_W         0x01a2 (418)
0230 1b0100      PSHI_W         0x0001 (1)
0233 1b6600      PSHI_W         0x0066 (102)
0236 1ba901      PSHI_W         0x01a9 (425)
0239 fe3f        SCALL          Q_GET
            Call GetQueue(IQ, DataIn(5), 1, 0.2, erflag)
023b 1b6a01      PSHI_W         0x016a (362)
023e 1ba301      PSHI_W         0x01a3 (419)
0241 1b0100      PSHI_W         0x0001 (1)
0244 1b6600      PSHI_W         0x0066 (102)
0247 1ba901      PSHI_W         0x01a9 (425)
024a fe3f        SCALL          Q_GET
            
            BumpRight = DataIn(1) Mod 2
024c 1d9f01      PSHA_B         0x019f (415)
024f 1a02        PSHI_B         0x02 (2)
0251 49          MOD_B
0252 20af01      POPA_B         0x01af (431)
            BumpLeft = DataIn(1) Mod 4 - BumpRight
0255 1d9f01      PSHA_B         0x019f (415)
0258 1a04        PSHI_B         0x04 (4)
025a 49          MOD_B
025b 1daf01      PSHA_B         0x01af (431)
025e 39          SUB_B
025f 20b001      POPA_B         0x01b0 (432)
            WheelDropRight = DataIn(1) Mod 8 - BumpLeft - BumpRight
0262 1d9f01      PSHA_B         0x019f (415)
0265 1a08        PSHI_B         0x08 (8)
0267 49          MOD_B
0268 1db001      PSHA_B         0x01b0 (432)
026b 39          SUB_B
026c 1daf01      PSHA_B         0x01af (431)
026f 39          SUB_B
0270 20b201      POPA_B         0x01b2 (434)
            WheelDropLeft = DataIn(1) Mod 16 - WheeldropRight - BumpLeft - BumpRight
0273 1d9f01      PSHA_B         0x019f (415)
0276 1a10        PSHI_B         0x10 (16)
0278 49          MOD_B
0279 1db201      PSHA_B         0x01b2 (434)
027c 39          SUB_B
027d 1db001      PSHA_B         0x01b0 (432)
0280 39          SUB_B
0281 1daf01      PSHA_B         0x01af (431)
0284 39          SUB_B
0285 20b101      POPA_B         0x01b1 (433)
            WheelDropCenter = DataIn(1) Mod 32 - WheeldropLeft - WheeldropRight - BumpLeft - BumpRight
0288 1d9f01      PSHA_B         0x019f (415)
028b 1a20        PSHI_B         0x20 (32)
028d 49          MOD_B
028e 1db101      PSHA_B         0x01b1 (433)
0291 39          SUB_B
0292 1db201      PSHA_B         0x01b2 (434)
0295 39          SUB_B
0296 1db001      PSHA_B         0x01b0 (432)
0299 39          SUB_B
029a 1daf01      PSHA_B         0x01af (431)
029d 39          SUB_B
029e 20b301      POPA_B         0x01b3 (435)
            
            GetDanger = 0
02a1 1a00        PSHI_B         0x00 (0)
02a3 26fbff      POPR_B         bp-5
            If DataIn(1) <> 0 OR (DataIn(2) = 1) OR (DataIn(3) = 1) OR (DataIn(4) = 1) OR (DataIn(5) = 1) then
02a6 1d9f01      PSHA_B         0x019f (415)
02a9 7c          CVTX_B
02aa 1da001      PSHA_B         0x01a0 (416)
02ad 1a01        PSHI_B         0x01 (1)
02af a0          CMPEQ_B
02b0 6f          OR_B
02b1 1da101      PSHA_B         0x01a1 (417)
02b4 1a01        PSHI_B         0x01 (1)
02b6 a0          CMPEQ_B
02b7 6f          OR_B
02b8 1da201      PSHA_B         0x01a2 (418)
02bb 1a01        PSHI_B         0x01 (1)
02bd a0          CMPEQ_B
02be 6f          OR_B
02bf 1da301      PSHA_B         0x01a3 (419)
02c2 1a01        PSHI_B         0x01 (1)
02c4 a0          CMPEQ_B
02c5 6f          OR_B
02c6 040500      BRA_F          02ce
            	GetDanger = 1
02c9 1a01        PSHI_B         0x01 (1)
02cb 26fbff      POPR_B         bp-5
            End If
            
            Bumps = 0
02ce 1a00        PSHI_B         0x00 (0)
02d0 20ad01      POPA_B         0x01ad (429)
            If BumpLeft <> 0 Then
02d3 1db001      PSHA_B         0x01b0 (432)
02d6 7c          CVTX_B
02d7 040500      BRA_F          02df
            	Bumps = Bumps + 1
02da 1a01        PSHI_B         0x01 (1)
02dc 20ad01      POPA_B         0x01ad (429)
            End If
            If BumpRight <> 0 Then
02df 1daf01      PSHA_B         0x01af (431)
02e2 7c          CVTX_B
02e3 040800      BRA_F          02ee
            	Bumps = Bumps + 2
02e6 1dad01      PSHA_B         0x01ad (429)
02e9 ca          INC_B
02ea ca          INC_B
02eb 20ad01      POPA_B         0x01ad (429)
            End If
            
            Drops = 0
02ee 1a00        PSHI_B         0x00 (0)
02f0 20ae01      POPA_B         0x01ae (430)
            If (WheelDropLeft <> 0) OR (DataIn(2) = 1) Then
02f3 1db101      PSHA_B         0x01b1 (433)
02f6 7c          CVTX_B
02f7 1da001      PSHA_B         0x01a0 (416)
02fa 1a01        PSHI_B         0x01 (1)
02fc a0          CMPEQ_B
02fd 6f          OR_B
02fe 040500      BRA_F          0306
            	Drops = Drops + 1
0301 1a01        PSHI_B         0x01 (1)
0303 20ae01      POPA_B         0x01ae (430)
            End If
            If (WheelDropRight <> 0) OR (DataIn(5) = 1) Then
0306 1db201      PSHA_B         0x01b2 (434)
0309 7c          CVTX_B
030a 1da301      PSHA_B         0x01a3 (419)
030d 1a01        PSHI_B         0x01 (1)
030f a0          CMPEQ_B
0310 6f          OR_B
0311 040800      BRA_F          031c
            	Drops = Drops + 2
0314 1dae01      PSHA_B         0x01ae (430)
0317 ca          INC_B
0318 ca          INC_B
0319 20ae01      POPA_B         0x01ae (430)
            End If
            If (WheelDropCenter = 1) OR (DataIn(3) = 1) OR (DataIn(4) = 1) Then
031c 1db301      PSHA_B         0x01b3 (435)
031f 1a01        PSHI_B         0x01 (1)
0321 a0          CMPEQ_B
0322 1da101      PSHA_B         0x01a1 (417)
0325 1a01        PSHI_B         0x01 (1)
0327 a0          CMPEQ_B
0328 6f          OR_B
0329 1da201      PSHA_B         0x01a2 (418)
032c 1a01        PSHI_B         0x01 (1)
032e a0          CMPEQ_B
032f 6f          OR_B
0330 040900      BRA_F          033c
            	Drops = Drops + 4
0333 1a04        PSHI_B         0x04 (4)
0335 1dae01      PSHA_B         0x01ae (430)
0338 35          ADD_B
0339 20ae01      POPA_B         0x01ae (430)
            End If
            
            End Function
033c 06          RET
            
            
            
            Sub GetEncoders()
            
            Call ClearQueue(IQ)
            
            Data(1) = 142
            Data(2) = 19
            Call PutQueue(OQ, Data, 2)
            Call GetQueue(IQ, DataIn(1), 1, 0.2, erflag)
            Call GetQueue(IQ, DataIn(2), 1, 0.2, erflag)
            
            Distance = Cint((DataIn(1)))*256+Cint((DataIn(2)))
            
            Call ClearQueue(IQ)
            
            Data(1) = 142
            Data(2) = 20
            Call PutQueue(OQ, Data, 2)
            Call GetQueue(IQ, DataIn(1), 1, 0.2, erflag)
            Call GetQueue(IQ, DataIn(2), 1, 0.2, erflag)
            
            Angle = Cint((DataIn(1)))*256+Cint((DataIn(2)))
            
            End Sub
            
            '--------------------------------------------------------------------
            
            '-----------------------Output Subroutines-------------------------------
            
            Sub PutPlayLED(ByVal Desired as byte)
fffb -5    par:Desired (1)
            If Desired <> 0 Then
033d 23fbff      PSHR_B         bp-5
0340 7c          CVTX_B
0341 040500      BRA_F          0349
            	Desired = 2
0344 1a02        PSHI_B         0x02 (2)
0346 26fbff      POPR_B         bp-5
            End If
            Data(1) = 139
0349 1a8b        PSHI_B         0x8b (139)
034b 209201      POPA_B         0x0192 (402)
            Data(2) = Desired
034e 23fbff      PSHR_B         bp-5
0351 209301      POPA_B         0x0193 (403)
            Data(3) = PowerLEDColor
0354 1dac01      PSHA_B         0x01ac (428)
0357 209401      POPA_B         0x0194 (404)
            Data(4) = PowerLED
035a 1dab01      PSHA_B         0x01ab (427)
035d 209501      POPA_B         0x0195 (405)
            
            Call PutQueue(OQ, data, 4)
0360 1b4c01      PSHI_W         0x014c (332)
0363 1b9201      PSHI_W         0x0192 (402)
0366 1b0400      PSHI_W         0x0004 (4)
0369 fe40        SCALL          Q_PUT
            PlayLED = Desired
036b 23fbff      PSHR_B         bp-5
036e 20aa01      POPA_B         0x01aa (426)
            End Sub
0371 0701        RET_B          0x01 (1)
            
            Sub PutPowerLed(ByVal Desired as byte, ByVal Color as Byte)
fffa -6    par:Desired (1)
fffb -5    par:Color (1)
            Data(1) = 139
0373 1a8b        PSHI_B         0x8b (139)
0375 209201      POPA_B         0x0192 (402)
            Data(2) = PlayLED
0378 1daa01      PSHA_B         0x01aa (426)
037b 209301      POPA_B         0x0193 (403)
            Data(3) = Color
037e 23fbff      PSHR_B         bp-5
0381 209401      POPA_B         0x0194 (404)
            Data(4) = Desired
0384 23faff      PSHR_B         bp-6
0387 209501      POPA_B         0x0195 (405)
            
            Call PutQueue(OQ, data, 4)
038a 1b4c01      PSHI_W         0x014c (332)
038d 1b9201      PSHI_W         0x0192 (402)
0390 1b0400      PSHI_W         0x0004 (4)
0393 fe40        SCALL          Q_PUT
            PowerLED = Desired
0395 23faff      PSHR_B         bp-6
0398 20ab01      POPA_B         0x01ab (427)
            PowerLEDColor = Color
039b 23fbff      PSHR_B         bp-5
039e 20ac01      POPA_B         0x01ac (428)
            End Sub
03a1 0702        RET_B          0x02 (2)

===== file: Config.bas
            Option explicit
            
            
            '-----------------------Turn roomba on and prepare for com-------------------------
            Sub InitRoomba()
            
            'Call Delay(0.25)
            
            Call PutPin(17,0)						'Turn Roomba on
03a3 1a11        PSHI_B         0x11 (17)
03a5 1a00        PSHI_B         0x00 (0)
03a7 d4          PUTPIN
            Call Delay(0.25)
03a8 1c80000000  PSHI_D         0x00000080 (128)
03ad fe57        SCALL          DELAY
            Call PutPin(17,1)
03af 1a11        PSHI_B         0x11 (17)
03b1 1a01        PSHI_B         0x01 (1)
03b3 d4          PUTPIN
            Call Delay(0.25)
03b4 1c80000000  PSHI_D         0x00000080 (128)
03b9 fe57        SCALL          DELAY
            Call PutPin(17,0)
03bb 1a11        PSHI_B         0x11 (17)
03bd 1a00        PSHI_B         0x00 (0)
03bf d4          PUTPIN
            
            Call PutPin(18, 1)						'Set into our baud rate
03c0 1a12        PSHI_B         0x12 (18)
03c2 1a01        PSHI_B         0x01 (1)
03c4 d4          PUTPIN
            Call Delay(0.1)
03c5 1c33000000  PSHI_D         0x00000033 (51)
03ca fe57        SCALL          DELAY
            Call PutPin(18,0)
03cc 1a12        PSHI_B         0x12 (18)
03ce 1a00        PSHI_B         0x00 (0)
03d0 d4          PUTPIN
            Call Delay(0.1)
03d1 1c33000000  PSHI_D         0x00000033 (51)
03d6 fe57        SCALL          DELAY
            Call PutPin(18, 1)
03d8 1a12        PSHI_B         0x12 (18)
03da 1a01        PSHI_B         0x01 (1)
03dc d4          PUTPIN
            Call Delay(0.1)
03dd 1c33000000  PSHI_D         0x00000033 (51)
03e2 fe57        SCALL          DELAY
            Call PutPin(18,0)
03e4 1a12        PSHI_B         0x12 (18)
03e6 1a00        PSHI_B         0x00 (0)
03e8 d4          PUTPIN
            Call Delay(0.1)
03e9 1c33000000  PSHI_D         0x00000033 (51)
03ee fe57        SCALL          DELAY
            Call PutPin(18, 1)
03f0 1a12        PSHI_B         0x12 (18)
03f2 1a01        PSHI_B         0x01 (1)
03f4 d4          PUTPIN
            Call Delay(0.1)
03f5 1c33000000  PSHI_D         0x00000033 (51)
03fa fe57        SCALL          DELAY
            Call PutPin(18,0)
03fc 1a12        PSHI_B         0x12 (18)
03fe 1a00        PSHI_B         0x00 (0)
0400 d4          PUTPIN
            Call Delay(0.1)
0401 1c33000000  PSHI_D         0x00000033 (51)
0406 fe57        SCALL          DELAY
            Call PutPin(18, 1)
0408 1a12        PSHI_B         0x12 (18)
040a 1a01        PSHI_B         0x01 (1)
040c d4          PUTPIN
            Call Delay(0.1)
040d 1c33000000  PSHI_D         0x00000033 (51)
0412 fe57        SCALL          DELAY
            
            Call OpenQueue(OQ, SizeOf(OQ))
0414 1b4c01      PSHI_W         0x014c (332)
0417 1b1e00      PSHI_W         0x001e (30)
041a fe3a        SCALL          Q_OPEN
            Call OpenQueue(IQ, SizeOf(IQ))
041c 1b6a01      PSHI_W         0x016a (362)
041f 1b2800      PSHI_W         0x0028 (40)
0422 fe3a        SCALL          Q_OPEN
            Call ClearQueue(OQ) 					'Clears the output queue
0424 1b4c01      PSHI_W         0x014c (332)
0427 fe3b        SCALL          Q_CLR
            Call ClearQueue(IQ) 					'Clears the input queue
0429 1b6a01      PSHI_W         0x016a (362)
042c fe3b        SCALL          Q_CLR
            
            Call DefineCom(3,TM, FM, bx0000_1000)
042e 1a03        PSHI_B         0x03 (3)
0430 1a13        PSHI_B         0x13 (19)
0432 1a14        PSHI_B         0x14 (20)
0434 1a08        PSHI_B         0x08 (8)
0436 fe44        SCALL          COM_DEF
            
            Call OpenCom(3, 19200, IQ, OQ)
0438 1a03        PSHI_B         0x03 (3)
043a 1c004b0000  PSHI_D         0x00004b00 (19200)
043f 1b6a01      PSHI_W         0x016a (362)
0442 1b4c01      PSHI_W         0x014c (332)
0445 fe46        SCALL          COM_OPEN
            Data(1) = 128 						'SETDC command
0447 1a80        PSHI_B         0x80 (128)
0449 209201      POPA_B         0x0192 (402)
            Data(2) = 132 						'MMC default address of 1
044c 1a84        PSHI_B         0x84 (132)
044e 209301      POPA_B         0x0193 (403)
            Call PutQueue(OQ, data, 2) 				'placing lowest bit first of array into the MMC
0451 1b4c01      PSHI_W         0x014c (332)
0454 1b9201      PSHI_W         0x0192 (402)
0457 1b0200      PSHI_W         0x0002 (2)
045a fe40        SCALL          Q_PUT
            
            Call Delay(2.0)
045c 1c00040000  PSHI_D         0x00000400 (1024)
0461 fe57        SCALL          DELAY
            
            End Sub
0463 06          RET
            '-------------------------------------------------------------------
            
            
            
            '--------------------------Terminate and turn roomba off-----------------------
            Sub EndRoomba()
            Call Delay(0.1)
            Call CloseCom(3, IQ, OQ)
            
            Call PutPin(17,0)						'Turn Roomba Off
            Call Delay(0.1)
            Call PutPin(17,1)
            Call Delay(0.1)
            Call PutPin(17,0)
            End Sub
            '----------------------------------------------------------------------

===== file: Init.bas
            '-------------------------------Core variables-----------------------
            
            Public LeftMotor as Long				'Variables used for motor controll
0140 320   var:LeftMotor (4 bytes)
            Public Motor1High as Byte
0144 324   var:Motor1High (1 byte)
            Public Motor1Low as Byte
0145 325   var:Motor1Low (1 byte)
            Public RightMotor as Long
0146 326   var:RightMotor (4 bytes)
            Public Motor2High as Byte
014a 330   var:Motor2High (1 byte)
            Public Motor2Low as Byte
014b 331   var:Motor2Low (1 byte)
            Public OQ(1 to 30) as byte 				'Set up Queues for Serial Com
014c 332   var:OQ (30 bytes)
            Public IQ(1 to 40) as byte
016a 362   var:IQ (40 bytes)
            Public data(1 to 13) as byte 			'Define Data array for dumping into outpute queue
0192 402   var:data (13 bytes)
            Public datain(1 to 10) as byte
019f 415   var:datain (10 bytes)
            public erflag as boolean
01a9 425   var:erflag (1 byte)
            
            Public PlayLED as byte					'Used to store desired Roomba LED values
01aa 426   var:PlayLED (1 byte)
            Public PowerLED as byte
01ab 427   var:PowerLED (1 byte)
            Public PowerLEDColor as byte
01ac 428   var:PowerLEDColor (1 byte)
            
            Public Bumps as byte					'Get Danger Output variables
01ad 429   var:Bumps (1 byte)
            Public Drops as byte
01ae 430   var:Drops (1 byte)
            Public BumpRight as byte				'Used in intermidiary getdanger routines
01af 431   var:BumpRight (1 byte)
            Public BumpLeft as byte
01b0 432   var:BumpLeft (1 byte)
            Public WheelDropLeft as byte
01b1 433   var:WheelDropLeft (1 byte)
            Public WheelDropRight as byte
01b2 434   var:WheelDropRight (1 byte)
            Public WheelDropCenter as byte
01b3 435   var:WheelDropCenter (1 byte)
            
            Public Const TM as byte = 19			'Pins used for roomba communication
=19
            Public Const FM as Byte = 20
=20
            
            Public oq3(1 to 10) as Byte				'Queues for sonar com
01b4 436   var:oq3 (10 bytes)
            Public iq3(1 to 30) as Byte
01be 446   var:iq3 (30 bytes)
            
            Public Const rxPin1 as Byte = 9				'Pins for sonar communication
=9
            Public Const txPin1 as Byte = 10
=10
            Public Const rxPin2 as Byte = 11
=11
            Public Const txPin2 as Byte = 12
=12
            Public Const rxPin3 as Byte = 5
=5
            Public Const txPin3 as Byte = 6
=6
            Public Const rxPin4 as Byte = 7
=7
            Public Const txPin4 as Byte = 8
=8
            
            Public Sonar1 as Byte					'Variables for sensor values
01dc 476   var:Sonar1 (1 byte)
            Public Sonar2 as Byte
01dd 477   var:Sonar2 (1 byte)
            Public Sonar3 as Byte
01de 478   var:Sonar3 (1 byte)
            Public Sonar4 as Byte
01df 479   var:Sonar4 (1 byte)
            Public LFIR as Integer
01e0 480   var:LFIR (2 bytes)
            Public RFIR as Integer
01e2 482   var:RFIR (2 bytes)
            Public SlidePot as Integer
01e4 484   var:SlidePot (2 bytes)
            Public TwistPot as Integer
01e6 486   var:TwistPot (2 bytes)
            
            
            
            '=======================Calibration variables========================
            
            Public Const FrontSonarMagnitude as Integer = 22500		'Magnitudes for force corrections of objects in front sonar
=22500
            Public Const SidesonarMagnitude as Integer = 22500		'Magnitudes for force corrections of objects in side sonar
=22500
            Public Const FrontObjectMagnitude as Integer = 160000	'Magnitudes for force corrections of objects in both sonar
=160000
            
            Public Const TwistPotCenter as Integer = 525			'where the center value of the rotation pot is
=525
            Public Const TwistPotScalar as Integer = 150				'Multiplier for the twist pot values, how accutely to respond
=150
            
            Public Const SlideCenter as Integer = 508
=508
            Public Const SlideScalar as Integer = 3
=3
            
            Public Const FrontSonarThresh as Integer = 18	'How close an object can get to front sonar before breaking wall follow
=18
            Public Const SideSonarThresh as Integer = 12	'How close an object can get to side sonar before breaking wall follow
=12
            Public Const SideIRThresh as Integer = 8		'How close an object can get to side IR before breaking wall follow
=8
            
            Public Const VectorFactor as Integer = 325			'Precent number of how to apply vector to motors
=325 [not used]
            Public Const WallFollowDistance as Integer = 15		'Desired distance from the wall
=15
            Public Const WallFollowAngleFactor as long = 35		'Multiplier for wall following angle corrections
=35
            Public Const DistanceFactor as Integer  = 6			'Multiplier for wall following distance corrections
=6
            Public Const WallFollowCorrectMax as Long = 150		'Bracket on wall follow corrections
=150
            
            Public Const ClearLoopsThreshold as Integer = 3		'Number of loops with wall before wall following
=3
            
            Public Const WallFollowIRThresh as Integer = 25		'Used to determine if there is wall to follow
=25
            Public Const WallFollowSonarThresh as Byte = 65
=65
            
            Public Const TwistPotFactor as Long = 55 			'How handle twisting is applied to motors
=55
            
            '=======================Control Variables==========================
            
            Public MasterSpeed as Long				'0 to 500 as the users movement speed from slide sensors
01e8 488   var:MasterSpeed (4 bytes)
            Public PercentSpeed as Long				'0 to 100 corrected value as above
01ec 492   var:PercentSpeed (4 bytes)
            
            Public GetProximityAlert as byte		'Is there in object near robot to break wall following
01f0 496   var:GetProximityAlert (1 byte)
            
            
            Public Sonar1a as Integer						'Versions of all sensors used when calculations required
           var:Sonar1a (2 bytes) [not used]
            Public Sonar2a as Integer
           var:Sonar2a (2 bytes) [not used]
            Public Sonar3a as Integer
           var:Sonar3a (2 bytes) [not used]
            Public Sonar4a as Integer
           var:Sonar4a (2 bytes) [not used]
            Public RFIRa as Integer
           var:RFIRa (2 bytes) [not used]
            Public LFIRa as Integer
           var:LFIRa (2 bytes) [not used]
            
            Public LFIRraw as Integer						'Versions of IR sensors unscaled for greater accurcay
01f1 497   var:LFIRraw (2 bytes)
            Public RFIRraw as Integer
01f3 499   var:RFIRraw (2 bytes)
            
            Public WallFollowCorrect as Long				'Amount added and subtracted from right and left motors
01f5 501   var:WallFollowCorrect (4 bytes)
            Public LastReading as Integer					'
01f9 505   var:LastReading (2 bytes)
            Public DistanceCorrect as Integer
01fb 507   var:DistanceCorrect (2 bytes)
            
            Public Distance as Integer						'Distance from encoders
           var:Distance (2 bytes) [not used]
            Public Angle as Integer							'Angle from encoders
           var:Angle (2 bytes) [not used]
            
            Public ClearLoops as Integer					'Number of loops with wall to side of robot
01fd 509   var:ClearLoops (2 bytes)
            
            Public Sonar1mag as Integer						'Push magnitudes from all sensors
01ff 511   var:Sonar1mag (2 bytes)
            Public Sonar2mag as Integer
0201 513   var:Sonar2mag (2 bytes)
            Public Sonar3mag as Integer
0203 515   var:Sonar3mag (2 bytes)
            Public Sonar4mag as Integer
0205 517   var:Sonar4mag (2 bytes)
            Public FrontObjectmag as Integer				'Push magnitude from objects in both front sensors
0207 519   var:FrontObjectmag (2 bytes)
            
            Public MagnitudeVector as Integer				'Master variable for forces on robot
0209 521   var:MagnitudeVector (2 bytes)
            
            
            Sub Init()
            End Sub

===== file: Sensors.bas
            Sub GetSensors()
            
            Call PutPin(6,0)						'Shut off all pinging
0464 1a06        PSHI_B         0x06 (6)
0466 1a00        PSHI_B         0x00 (0)
0468 d4          PUTPIN
            Call PutPin(8,0)
0469 1a08        PSHI_B         0x08 (8)
046b 1a00        PSHI_B         0x00 (0)
046d d4          PUTPIN
            Call PutPin(10,0)
046e 1a0a        PSHI_B         0x0a (10)
0470 1a00        PSHI_B         0x00 (0)
0472 d4          PUTPIN
            Call PutPin(12,0)
0473 1a0c        PSHI_B         0x0c (12)
0475 1a00        PSHI_B         0x00 (0)
0477 d4          PUTPIN
            
            
            Call OpenQueue(iq3, SizeOf(iq3))		'Open sonar control queues
0478 1bbe01      PSHI_W         0x01be (446)
047b 1b1e00      PSHI_W         0x001e (30)
047e fe3a        SCALL          Q_OPEN
            Call OpenQueue(oq3, SizeOf(oq3))
0480 1bb401      PSHI_W         0x01b4 (436)
0483 1b0a00      PSHI_W         0x000a (10)
0486 fe3a        SCALL          Q_OPEN
            
            
            'Begin specific sensor by sensor scan
            
            '--------------Sensor 1----------------
            Call DefineCom(4, rxPin1, 0, bx1000_1000)		'Prep Com Line
0488 1a04        PSHI_B         0x04 (4)
048a 1a09        PSHI_B         0x09 (9)
048c 1a00        PSHI_B         0x00 (0)
048e 1a88        PSHI_B         0x88 (136)
0490 fe44        SCALL          COM_DEF
            Call OpenCom(4, 9600, iq3, oq3)
0492 1a04        PSHI_B         0x04 (4)
0494 1c80250000  PSHI_D         0x00002580 (9600)
0499 1bbe01      PSHI_W         0x01be (446)
049c 1bb401      PSHI_W         0x01b4 (436)
049f fe46        SCALL          COM_OPEN
            
            
            Call ClearQueue(iq3)							'Erase anything in queue
04a1 1bbe01      PSHI_W         0x01be (446)
04a4 fe3b        SCALL          Q_CLR
            Call ClearQueue(oq3)
04a6 1bb401      PSHI_W         0x01b4 (436)
04a9 fe3b        SCALL          Q_CLR
            
            Call PutPin(txPin1, 1)							'Trigger reading
04ab 1a0a        PSHI_B         0x0a (10)
04ad 1a01        PSHI_B         0x01 (1)
04af d4          PUTPIN
            Call PutPin(txPin1, 0)
04b0 1a0a        PSHI_B         0x0a (10)
04b2 1a00        PSHI_B         0x00 (0)
04b4 d4          PUTPIN
            
            Call Getqueue(iq3, Data, 5, 0.1, erflag)		'Pull bytes of queues
04b5 1bbe01      PSHI_W         0x01be (446)
04b8 1b9201      PSHI_W         0x0192 (402)
04bb 1b0500      PSHI_W         0x0005 (5)
04be 1b3300      PSHI_W         0x0033 (51)
04c1 1ba901      PSHI_W         0x01a9 (425)
04c4 fe3f        SCALL          Q_GET
            
            Sonar1 =  (Data(2)-48)*100+(Data(3)-48)*10+(Data(4)-48)*1		'Combine different ASCII Bytes
04c6 1a64        PSHI_B         0x64 (100)
04c8 1ad0        PSHI_B         0xd0 (208)
04ca 1d9301      PSHA_B         0x0193 (403)
04cd 35          ADD_B
04ce 3d          MUL_B
04cf 1a0a        PSHI_B         0x0a (10)
04d1 1ad0        PSHI_B         0xd0 (208)
04d3 1d9401      PSHA_B         0x0194 (404)
04d6 35          ADD_B
04d7 3d          MUL_B
04d8 35          ADD_B
04d9 1ad0        PSHI_B         0xd0 (208)
04db 1d9501      PSHA_B         0x0195 (405)
04de 35          ADD_B
04df 35          ADD_B
04e0 20dc01      POPA_B         0x01dc (476)
            
            Call Closecom(4, iq3, oq3)						'Close Com for next reading
04e3 1a04        PSHI_B         0x04 (4)
04e5 1bbe01      PSHI_W         0x01be (446)
04e8 1bb401      PSHI_W         0x01b4 (436)
04eb fe45        SCALL          COM_CLOSE
            Register.Timer2Busy = False						'Fix firmware error (reset busy line)
04ed 1a00        PSHI_B         0x00 (0)
04ef 201801      POPA_B         0x0118 (280)
            
            '--------------Sensor 2----------------
            Call DefineCom(4, rxPin2, 0, bx1000_1000)		'Prep Com Line
04f2 1a04        PSHI_B         0x04 (4)
04f4 1a0b        PSHI_B         0x0b (11)
04f6 1a00        PSHI_B         0x00 (0)
04f8 1a88        PSHI_B         0x88 (136)
04fa fe44        SCALL          COM_DEF
            Call OpenCom(4, 9600, iq3, oq3)
04fc 1a04        PSHI_B         0x04 (4)
04fe 1c80250000  PSHI_D         0x00002580 (9600)
0503 1bbe01      PSHI_W         0x01be (446)
0506 1bb401      PSHI_W         0x01b4 (436)
0509 fe46        SCALL          COM_OPEN
            
            
            Call ClearQueue(iq3)							'Erase anything in queue
050b 1bbe01      PSHI_W         0x01be (446)
050e fe3b        SCALL          Q_CLR
            Call ClearQueue(oq3)
0510 1bb401      PSHI_W         0x01b4 (436)
0513 fe3b        SCALL          Q_CLR
            
            Call PutPin(txPin2, 1)							'Trigger reading
0515 1a0c        PSHI_B         0x0c (12)
0517 1a01        PSHI_B         0x01 (1)
0519 d4          PUTPIN
            Call PutPin(txPin2, 0)
051a 1a0c        PSHI_B         0x0c (12)
051c 1a00        PSHI_B         0x00 (0)
051e d4          PUTPIN
            
            Call Getqueue(iq3, Data, 5, 0.1, erflag)		'Pull bytes of queues
051f 1bbe01      PSHI_W         0x01be (446)
0522 1b9201      PSHI_W         0x0192 (402)
0525 1b0500      PSHI_W         0x0005 (5)
0528 1b3300      PSHI_W         0x0033 (51)
052b 1ba901      PSHI_W         0x01a9 (425)
052e fe3f        SCALL          Q_GET
            
            Sonar2 =  (Data(2)-48)*100+(Data(3)-48)*10+(Data(4)-48)*1		'Combine different ASCII Bytes
0530 1a64        PSHI_B         0x64 (100)
0532 1ad0        PSHI_B         0xd0 (208)
0534 1d9301      PSHA_B         0x0193 (403)
0537 35          ADD_B
0538 3d          MUL_B
0539 1a0a        PSHI_B         0x0a (10)
053b 1ad0        PSHI_B         0xd0 (208)
053d 1d9401      PSHA_B         0x0194 (404)
0540 35          ADD_B
0541 3d          MUL_B
0542 35          ADD_B
0543 1ad0        PSHI_B         0xd0 (208)
0545 1d9501      PSHA_B         0x0195 (405)
0548 35          ADD_B
0549 35          ADD_B
054a 20dd01      POPA_B         0x01dd (477)
            
            Call Closecom(4, iq3, oq3)						'Close Com for next reading
054d 1a04        PSHI_B         0x04 (4)
054f 1bbe01      PSHI_W         0x01be (446)
0552 1bb401      PSHI_W         0x01b4 (436)
0555 fe45        SCALL          COM_CLOSE
            Register.Timer2Busy = False						'Fix firmware error (reset busy line)
0557 1a00        PSHI_B         0x00 (0)
0559 201801      POPA_B         0x0118 (280)
            
            '--------------Sensor 3----------------
            Call DefineCom(4, rxPin3, 0, bx1000_1000)		'Prep Com Line
055c 1a04        PSHI_B         0x04 (4)
055e 1a05        PSHI_B         0x05 (5)
0560 1a00        PSHI_B         0x00 (0)
0562 1a88        PSHI_B         0x88 (136)
0564 fe44        SCALL          COM_DEF
            Call OpenCom(4, 9600, iq3, oq3)
0566 1a04        PSHI_B         0x04 (4)
0568 1c80250000  PSHI_D         0x00002580 (9600)
056d 1bbe01      PSHI_W         0x01be (446)
0570 1bb401      PSHI_W         0x01b4 (436)
0573 fe46        SCALL          COM_OPEN
            
            
            Call ClearQueue(iq3)							'Erase anything in queue
0575 1bbe01      PSHI_W         0x01be (446)
0578 fe3b        SCALL          Q_CLR
            Call ClearQueue(oq3)
057a 1bb401      PSHI_W         0x01b4 (436)
057d fe3b        SCALL          Q_CLR
            
            Call PutPin(txPin3, 1)							'Trigger reading
057f 1a06        PSHI_B         0x06 (6)
0581 1a01        PSHI_B         0x01 (1)
0583 d4          PUTPIN
            Call PutPin(txPin3, 0)
0584 1a06        PSHI_B         0x06 (6)
0586 1a00        PSHI_B         0x00 (0)
0588 d4          PUTPIN
            
            Call Getqueue(iq3, Data, 5, 0.1, erflag)		'Pull bytes of queues
0589 1bbe01      PSHI_W         0x01be (446)
058c 1b9201      PSHI_W         0x0192 (402)
058f 1b0500      PSHI_W         0x0005 (5)
0592 1b3300      PSHI_W         0x0033 (51)
0595 1ba901      PSHI_W         0x01a9 (425)
0598 fe3f        SCALL          Q_GET
            
            Sonar3 =  (Data(2)-48)*100+(Data(3)-48)*10+(Data(4)-48)*1		'Combine different ASCII Bytes
059a 1a64        PSHI_B         0x64 (100)
059c 1ad0        PSHI_B         0xd0 (208)
059e 1d9301      PSHA_B         0x0193 (403)
05a1 35          ADD_B
05a2 3d          MUL_B
05a3 1a0a        PSHI_B         0x0a (10)
05a5 1ad0        PSHI_B         0xd0 (208)
05a7 1d9401      PSHA_B         0x0194 (404)
05aa 35          ADD_B
05ab 3d          MUL_B
05ac 35          ADD_B
05ad 1ad0        PSHI_B         0xd0 (208)
05af 1d9501      PSHA_B         0x0195 (405)
05b2 35          ADD_B
05b3 35          ADD_B
05b4 20de01      POPA_B         0x01de (478)
            
            Call Closecom(4, iq3, oq3)						'Close Com for next reading
05b7 1a04        PSHI_B         0x04 (4)
05b9 1bbe01      PSHI_W         0x01be (446)
05bc 1bb401      PSHI_W         0x01b4 (436)
05bf fe45        SCALL          COM_CLOSE
            Register.Timer2Busy = False						'Fix firmware error (reset busy line)
05c1 1a00        PSHI_B         0x00 (0)
05c3 201801      POPA_B         0x0118 (280)
            
            '--------------Sensor 4----------------
            Call DefineCom(4, rxPin4, 0, bx1000_1000)		'Prep Com Line
05c6 1a04        PSHI_B         0x04 (4)
05c8 1a07        PSHI_B         0x07 (7)
05ca 1a00        PSHI_B         0x00 (0)
05cc 1a88        PSHI_B         0x88 (136)
05ce fe44        SCALL          COM_DEF
            Call OpenCom(4, 9600, iq3, oq3)
05d0 1a04        PSHI_B         0x04 (4)
05d2 1c80250000  PSHI_D         0x00002580 (9600)
05d7 1bbe01      PSHI_W         0x01be (446)
05da 1bb401      PSHI_W         0x01b4 (436)
05dd fe46        SCALL          COM_OPEN
            
            
            Call ClearQueue(iq3)							'Erase anything in queue
05df 1bbe01      PSHI_W         0x01be (446)
05e2 fe3b        SCALL          Q_CLR
            Call ClearQueue(oq3)
05e4 1bb401      PSHI_W         0x01b4 (436)
05e7 fe3b        SCALL          Q_CLR
            
            Call PutPin(txPin4, 1)							'Trigger reading
05e9 1a08        PSHI_B         0x08 (8)
05eb 1a01        PSHI_B         0x01 (1)
05ed d4          PUTPIN
            Call PutPin(txPin4, 0)
05ee 1a08        PSHI_B         0x08 (8)
05f0 1a00        PSHI_B         0x00 (0)
05f2 d4          PUTPIN
            
            Call Getqueue(iq3, Data, 5, 0.1, erflag)		'Pull bytes of queues
05f3 1bbe01      PSHI_W         0x01be (446)
05f6 1b9201      PSHI_W         0x0192 (402)
05f9 1b0500      PSHI_W         0x0005 (5)
05fc 1b3300      PSHI_W         0x0033 (51)
05ff 1ba901      PSHI_W         0x01a9 (425)
0602 fe3f        SCALL          Q_GET
            
            Sonar4 =  (Data(2)-48)*100+(Data(3)-48)*10+(Data(4)-48)*1		'Combine different ASCII Bytes
0604 1a64        PSHI_B         0x64 (100)
0606 1ad0        PSHI_B         0xd0 (208)
0608 1d9301      PSHA_B         0x0193 (403)
060b 35          ADD_B
060c 3d          MUL_B
060d 1a0a        PSHI_B         0x0a (10)
060f 1ad0        PSHI_B         0xd0 (208)
0611 1d9401      PSHA_B         0x0194 (404)
0614 35          ADD_B
0615 3d          MUL_B
0616 35          ADD_B
0617 1ad0        PSHI_B         0xd0 (208)
0619 1d9501      PSHA_B         0x0195 (405)
061c 35          ADD_B
061d 35          ADD_B
061e 20df01      POPA_B         0x01df (479)
            
            Call Closecom(4, iq3, oq3)						'Close Com for next reading
0621 1a04        PSHI_B         0x04 (4)
0623 1bbe01      PSHI_W         0x01be (446)
0626 1bb401      PSHI_W         0x01b4 (436)
0629 fe45        SCALL          COM_CLOSE
            Register.Timer2Busy = False						'Fix firmware error (reset busy line)
062b 1a00        PSHI_B         0x00 (0)
062d 201801      POPA_B         0x0118 (280)
            
            '------------Finished reading--------------
            
            RFIR = GetADC(16)									'Get Right Facing IR sensor
0630 1a10        PSHI_B         0x10 (16)
0632 e0          STARTADC
0633 e1          GETADC
0634 21e201      POPA_W         0x01e2 (482)
            RFIRraw = RFIR										'Dump raw value for later user
0637 1ee201      PSHA_W         0x01e2 (482)
063a 21f301      POPA_W         0x01f3 (499)
            RFIR = (585-RFIR)\14								'Rough linearizer
063d 1b4902      PSHI_W         0x0249 (585)
0640 1ee201      PSHA_W         0x01e2 (482)
0643 3a          SUB_W
0644 1b0e00      PSHI_W         0x000e (14)
0647 46          DIV_I
0648 21e201      POPA_W         0x01e2 (482)
            LFIR = GetADC(15)									'Get Left Facing IR sensor
064b 1a0f        PSHI_B         0x0f (15)
064d e0          STARTADC
064e e1          GETADC
064f 21e001      POPA_W         0x01e0 (480)
            LFIRraw = LFIR										'Dump raw value for later user
0652 1ee001      PSHA_W         0x01e0 (480)
0655 21f101      POPA_W         0x01f1 (497)
            LFIR = (585-LFIR)\14								'Rough linearizer
0658 1b4902      PSHI_W         0x0249 (585)
065b 1ee001      PSHA_W         0x01e0 (480)
065e 3a          SUB_W
065f 1b0e00      PSHI_W         0x000e (14)
0662 46          DIV_I
0663 21e001      POPA_W         0x01e0 (480)
            
            SlidePot = GetADC(14)								'Get slide pot value
0666 1a0e        PSHI_B         0x0e (14)
0668 e0          STARTADC
0669 e1          GETADC
066a 21e401      POPA_W         0x01e4 (484)
            
            TwistPot = GetADC(13)								'Get value from twist pot sensor in stick
066d 1a0d        PSHI_B         0x0d (13)
066f e0          STARTADC
0670 e1          GETADC
0671 21e601      POPA_W         0x01e6 (486)
            TwistPot = TwistPot - TwistPotCenter				'Center the twist pot at 0
0674 1ee601      PSHA_W         0x01e6 (486)
0677 1b0d02      PSHI_W         0x020d (525)
067a 3a          SUB_W
067b 21e601      POPA_W         0x01e6 (486)
            If Not ((TwistPot > 46) Or (TwistPot < -46)) Then	'Create dead zone for twist sensor
067e 1ee601      PSHA_W         0x01e6 (486)
0681 1b2e00      PSHI_W         0x002e (46)
0684 b4          CMPGT_I
0685 1ee601      PSHA_W         0x01e6 (486)
0688 1bd2ff      PSHI_W         0xffd2 (65490)
068b b7          CMPLT_I
068c 6f          OR_B
068d 030600      BRA_T          0696
            	TwistPot = 0
0690 1b0000      PSHI_W         0x0000 (0)
0693 21e601      POPA_W         0x01e6 (486)
            End If
            
            Twistpot = (Twistpot*TwistpotScalar)\100			'Scale twist pot
0696 1b9600      PSHI_W         0x0096 (150)
0699 1ee601      PSHA_W         0x01e6 (486)
069c 40          MUL_I
069d 1b6400      PSHI_W         0x0064 (100)
06a0 46          DIV_I
06a1 21e601      POPA_W         0x01e6 (486)
            
            End Sub
06a4 06          RET

===== file: control.bas
            '=============================Subroutines======================
            
            'Sub GetMotorBaseSpeed()
            'Calculates base speed form 0 to 500 on how fast motors should be turning based on stick position over time
            'Fills BaseMotorSpeed with 0 to 500 value
            
            'Sub GetSpeedScalar()
            'Calulates speed multiplier to apply to basemotorspeed based on minimum distances to either side
            'Filles SpeedScalar with a value from 0 to 100 with 100 representing no objects
            
            'Sub GetTurnScalar()
            'Calculates amount to turn based on front objects
            'Fulls TurnScalar with a value from 0 to maxturnscalar
            
            'Sub PutMovement()
            'Corrects for turn values over 500 by applying to other motor and uses putmotor to tell roomba
            
            '============================Code==========================
            
            '----------------------------------------------------------------------------------------
            Sub GetMasterSpeed()
            
            SlidePot = SlidePot - SlideCenter 								'Center the slide pot value
06a5 1ee401      PSHA_W         0x01e4 (484)
06a8 1bfc01      PSHI_W         0x01fc (508)
06ab 3a          SUB_W
06ac 21e401      POPA_W         0x01e4 (484)
            MasterSpeed = MasterSpeed + CLng((SlidePot)\SlideScalar)		'Add/Subtract from speed based on position
06af 1fe801      PSHA_D         0x01e8 (488)
06b2 1ee401      PSHA_W         0x01e4 (484)
06b5 1b0300      PSHI_W         0x0003 (3)
06b8 46          DIV_I
06b9 8c          CVTL_I
06ba 37          ADD_D
06bb 22e801      POPA_D         0x01e8 (488)
            If Masterspeed > 500 Then										'Bracket values
06be 1fe801      PSHA_D         0x01e8 (488)
06c1 1cf4010000  PSHI_D         0x000001f4 (500)
06c6 ba          CMPGT_L
06c7 040b00      BRA_F          06d5
            	MasterSpeed = 500
06ca 1cf4010000  PSHI_D         0x000001f4 (500)
06cf 22e801      POPA_D         0x01e8 (488)
06d2 011400      BRA            06e9
            ElseIf	MasterSpeed < 0 Then
06d5 1fe801      PSHA_D         0x01e8 (488)
06d8 1c00000000  PSHI_D         0x00000000 (0, 0.0)
06dd bd          CMPLT_L
06de 040800      BRA_F          06e9
            	MasterSpeed = 0
06e1 1c00000000  PSHI_D         0x00000000 (0, 0.0)
06e6 22e801      POPA_D         0x01e8 (488)
            End If
            
            PercentSpeed = MasterSpeed\5									'Calculate speed percentage out of 100
06e9 1fe801      PSHA_D         0x01e8 (488)
06ec 1c05000000  PSHI_D         0x00000005 (5)
06f1 47          DIV_L
06f2 22ec01      POPA_D         0x01ec (492)
            
            End Sub
06f5 06          RET
            '------------------------------------------------------------------------------------------
            Sub GetMagnitude()
            
            Sonar1mag = (SideSonarMagnitude)\(Cint(Sonar1)^2)								'Calculate inverse of distance squared
06f6 1be457      PSHI_W         0x57e4 (22500)
06f9 1ddc01      PSHA_B         0x01dc (476)
06fc 88          CVTI_B
06fd 17          DUP_W
06fe 3e          MUL_W
06ff 46          DIV_I
0700 21ff01      POPA_W         0x01ff (511)
            Sonar2mag = (FrontSonarMagnitude)\(Cint(Sonar2)^2)
0703 1be457      PSHI_W         0x57e4 (22500)
0706 1ddd01      PSHA_B         0x01dd (477)
0709 88          CVTI_B
070a 17          DUP_W
070b 3e          MUL_W
070c 46          DIV_I
070d 210102      POPA_W         0x0201 (513)
            Sonar3mag = (FrontSonarMagnitude)\(Cint(Sonar3)^2)
0710 1be457      PSHI_W         0x57e4 (22500)
0713 1dde01      PSHA_B         0x01de (478)
0716 88          CVTI_B
0717 17          DUP_W
0718 3e          MUL_W
0719 46          DIV_I
071a 210302      POPA_W         0x0203 (515)
            Sonar4mag = (SideSonarMagnitude)\(Cint(Sonar4)^2)
071d 1be457      PSHI_W         0x57e4 (22500)
0720 1ddf01      PSHA_B         0x01df (479)
0723 88          CVTI_B
0724 17          DUP_W
0725 3e          MUL_W
0726 46          DIV_I
0727 210502      POPA_W         0x0205 (517)
            
            If Sonar1 < Sonar4	Then														'Calculate force from obhects in front
072a 1ddc01      PSHA_B         0x01dc (476)
072d 1ddf01      PSHA_B         0x01df (479)
0730 a5          CMPLT_B
0731 041800      BRA_F          074c
            	FrontObjectMag = (FrontObjectMagnitude)\(((Cint(Sonar2)+Cint(Sonar3))\2)^2)
0734 1b0071      PSHI_W         0x7100 (28928)
0737 1ddd01      PSHA_B         0x01dd (477)
073a 88          CVTI_B
073b 1dde01      PSHA_B         0x01de (478)
073e 88          CVTI_B
073f 36          ADD_W
0740 1a01        PSHI_B         0x01 (1)
0742 99          SHR_I
0743 17          DUP_W
0744 3e          MUL_W
0745 46          DIV_I
0746 210702      POPA_W         0x0207 (519)
0749 011500      BRA            0761
            Else
            	FrontObjectMag = -(FrontObjectMagnitude)\(((Cint(Sonar2)+Cint(Sonar3))\2)^2)
074c 1b008f      PSHI_W         0x8f00 (36608)
074f 1ddd01      PSHA_B         0x01dd (477)
0752 88          CVTI_B
0753 1dde01      PSHA_B         0x01de (478)
0756 88          CVTI_B
0757 36          ADD_W
0758 1a01        PSHI_B         0x01 (1)
075a 99          SHR_I
075b 17          DUP_W
075c 3e          MUL_W
075d 46          DIV_I
075e 210702      POPA_W         0x0207 (519)
            End If
            
            MagnitudeVector = Sonar1mag + Sonar2mag - Sonar3mag - Sonar4mag + FrontObjectMag	'Add up forces
0761 1e0702      PSHA_W         0x0207 (519)
0764 1eff01      PSHA_W         0x01ff (511)
0767 1e0102      PSHA_W         0x0201 (513)
076a 36          ADD_W
076b 1e0302      PSHA_W         0x0203 (515)
076e 3a          SUB_W
076f 1e0502      PSHA_W         0x0205 (517)
0772 3a          SUB_W
0773 36          ADD_W
0774 210902      POPA_W         0x0209 (521)
            
            End Sub
0777 06          RET
            '-------------------------------------------------------------------------------------------
            Sub PutMovement()
            
            If LeftMotor > 500 then											'Check for individual motor overflow
0778 1f4001      PSHA_D         0x0140 (320)
077b 1cf4010000  PSHI_D         0x000001f4 (500)
0780 ba          CMPGT_L
0781 042f00      BRA_F          07b3
            	RightMotor = RightMotor - (LeftMotor - 500)					'Apply overflow to other motor (opposite direction)
0784 1f4601      PSHA_D         0x0146 (326)
0787 1c0cfeffff  PSHI_D         0xfffffe0c (4294966796)
078c 1f4001      PSHA_D         0x0140 (320)
078f 37          ADD_D
0790 3b          SUB_D
0791 224601      POPA_D         0x0146 (326)
            	LeftMotor = 500												'Bracket overflowing motor
0794 1cf4010000  PSHI_D         0x000001f4 (500)
0799 224001      POPA_D         0x0140 (320)
            	If RightMotor < -500 Then									'Check for underflow of other motor
079c 1f4601      PSHA_D         0x0146 (326)
079f 1c0cfeffff  PSHI_D         0xfffffe0c (4294966796)
07a4 bd          CMPLT_L
07a5 044300      BRA_F          07eb
            		RightMotor = -500
07a8 1c0cfeffff  PSHI_D         0xfffffe0c (4294966796)
07ad 224601      POPA_D         0x0146 (326)
            	End If
07b0 013800      BRA            07eb
            ElseIf RightMotor > 500 then									'Check for individual motor overflow
07b3 1f4601      PSHA_D         0x0146 (326)
07b6 1cf4010000  PSHI_D         0x000001f4 (500)
07bb ba          CMPGT_L
07bc 042c00      BRA_F          07eb
            	LeftMotor = LeftMotor - (RightMotor - 500)					'Apply overflow to other motor (opposite direction)
07bf 1f4001      PSHA_D         0x0140 (320)
07c2 1c0cfeffff  PSHI_D         0xfffffe0c (4294966796)
07c7 1f4601      PSHA_D         0x0146 (326)
07ca 37          ADD_D
07cb 3b          SUB_D
07cc 224001      POPA_D         0x0140 (320)
            	RightMotor = 500											'Bracket overflowing motor
07cf 1cf4010000  PSHI_D         0x000001f4 (500)
07d4 224601      POPA_D         0x0146 (326)
            	If LeftMotor < -500 Then									'Check for underflow of other motor
07d7 1f4001      PSHA_D         0x0140 (320)
07da 1c0cfeffff  PSHI_D         0xfffffe0c (4294966796)
07df bd          CMPLT_L
07e0 040800      BRA_F          07eb
            		LeftMotor = -500
07e3 1c0cfeffff  PSHI_D         0xfffffe0c (4294966796)
07e8 224001      POPA_D         0x0140 (320)
            	End If
            End If
            
            Call PutMotor													'Apply changes to motors
07eb 053901      CALL           0139
            
            End Sub
07ee 06          RET
            '--------------------------------------------------------------------------------------------------
            Sub GetProximity()
            
            If (Cint(Sonar1) <= SideSonarThresh) OR (Cint(Sonar4) <= SideSonarThresh) OR _		'Determine proximity alert
            	(Cint(Sonar2) <= FrontSonarThresh) OR (Cint(Sonar3) <= FrontSonarThresh) OR _
            		(RFIR <= SideIRThresh) OR (LFIR <= SideIRThresh) THEN
07ef 1ddc01      PSHA_B         0x01dc (476)
07f2 88          CVTI_B
07f3 1b0c00      PSHI_W         0x000c (12)
07f6 b5          CMPLE_I
07f7 1ddf01      PSHA_B         0x01df (479)
07fa 88          CVTI_B
07fb 1b0c00      PSHI_W         0x000c (12)
07fe b5          CMPLE_I
07ff 6f          OR_B
0800 1ddd01      PSHA_B         0x01dd (477)
0803 88          CVTI_B
0804 1b1200      PSHI_W         0x0012 (18)
0807 b5          CMPLE_I
0808 6f          OR_B
0809 1dde01      PSHA_B         0x01de (478)
080c 88          CVTI_B
080d 1b1200      PSHI_W         0x0012 (18)
0810 b5          CMPLE_I
0811 6f          OR_B
0812 1ee201      PSHA_W         0x01e2 (482)
0815 1b0800      PSHI_W         0x0008 (8)
0818 b5          CMPLE_I
0819 6f          OR_B
081a 1ee001      PSHA_W         0x01e0 (480)
081d 1b0800      PSHI_W         0x0008 (8)
0820 b5          CMPLE_I
0821 6f          OR_B
0822 040800      BRA_F          082d
            			GetProximityAlert = 1													'Flag variable
0825 1a01        PSHI_B         0x01 (1)
0827 20f001      POPA_B         0x01f0 (496)
082a 010500      BRA            0832
            Else
            			GetproximityAlert = 0													'Deflag variable
082d 1a00        PSHI_B         0x00 (0)
082f 20f001      POPA_B         0x01f0 (496)
            End If
            
            End Sub
0832 06          RET
            '-----------------------------------------------------------------------------------------------------
            Sub RightWallFollow()
            
            DistanceCorrect = ((RFIR-WallFollowDistance)*DistanceFactor)					'Calculate level of distance correction
0833 1b0600      PSHI_W         0x0006 (6)
0836 1ee201      PSHA_W         0x01e2 (482)
0839 1b0f00      PSHI_W         0x000f (15)
083c 3a          SUB_W
083d 40          MUL_I
083e 21fb01      POPA_W         0x01fb (507)
            
            If DistanceCorrect > 6 Then														'Bracket for indward turns
0841 1efb01      PSHA_W         0x01fb (507)
0844 1b0600      PSHI_W         0x0006 (6)
0847 b4          CMPGT_I
0848 040600      BRA_F          0851
            	DistanceCorrect = 6
084b 1b0600      PSHI_W         0x0006 (6)
084e 21fb01      POPA_W         0x01fb (507)
            End If
            
            
            If NOT (lastreading = 0) Then													'Make sure you have two data points
0851 1ef901      PSHA_W         0x01f9 (505)
0854 7d          CVTX_W
0855 042d00      BRA_F          0885
            	If  ((RFIRraw-Lastreading) < 40) then
0858 1ef301      PSHA_W         0x01f3 (499)
085b 1ef901      PSHA_W         0x01f9 (505)
085e 3a          SUB_W
085f 1b2800      PSHI_W         0x0028 (40)
0862 b7          CMPLT_I
0863 042700      BRA_F          088d
            		WallFollowCorrect = (Clng((RFIRraw-LastReading))*WallFollowAngleFactor*Clng(RFIR))\100 'Calculate correction
0866 1c23000000  PSHI_D         0x00000023 (35)
086b 1ef301      PSHA_W         0x01f3 (499)
086e 1ef901      PSHA_W         0x01f9 (505)
0871 3a          SUB_W
0872 8c          CVTL_I
0873 41          MUL_L
0874 1ee201      PSHA_W         0x01e2 (482)
0877 8c          CVTL_I
0878 41          MUL_L
0879 1c64000000  PSHI_D         0x00000064 (100)
087e 47          DIV_L
087f 22f501      POPA_D         0x01f5 (501)
            	End If
0882 010800      BRA            088d
            Else
            	WallFollowCorrect = 0										'If don't have two data points set correction at 0
0885 1c00000000  PSHI_D         0x00000000 (0, 0.0)
088a 22f501      POPA_D         0x01f5 (501)
            End If
            
            If WallFollowCorrect > WallFollowCorrectMax Then								'Bracket values
088d 1ff501      PSHA_D         0x01f5 (501)
0890 1c96000000  PSHI_D         0x00000096 (150)
0895 ba          CMPGT_L
0896 040b00      BRA_F          08a4
            	WallFollowCorrect = WallFollowCorrectMax
0899 1c96000000  PSHI_D         0x00000096 (150)
089e 22f501      POPA_D         0x01f5 (501)
08a1 011400      BRA            08b8
            ElseIf	WallFollowCorrect < -WallFollowCorrectMax Then
08a4 1ff501      PSHA_D         0x01f5 (501)
08a7 1c6affffff  PSHI_D         0xffffff6a (4294967146)
08ac bd          CMPLT_L
08ad 040800      BRA_F          08b8
            	WallFollowCorrect = -WallFollowCorrectMax
08b0 1c6affffff  PSHI_D         0xffffff6a (4294967146)
08b5 22f501      POPA_D         0x01f5 (501)
            End If
            
            
            LastReading = RFIRraw															'Save last data point
08b8 1ef301      PSHA_W         0x01f3 (499)
08bb 21f901      POPA_W         0x01f9 (505)
            
            End Sub
08be 06          RET

Code: 2239 bytes, RAM: 203 bytes, Persistent memory: 0 bytes
Target Device: ZX24a, Minimum VM version: v1.5.2
RAM size: 3584, heap size: 256
