RCcontrolプログラム

※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

html plugin Error : このプラグインを使うにはこのページの編集権限を「管理者のみ」に設定してください。 に使っているプログラムのサンプルです。
あくまでサンプルです。使用改変は自由ですが、動かない、ソースが汚いなどの苦情は>nulへ。



'RC PROPO CONTROL PROGRAM BY SHING FOR RD6000
' 2006.1.14 VER 6.1

' Ver 6.1 User motion added.
' Ver 5.1 GWS PG-03 added. Gravity sencor added. Serial communication terminal added.
' Ver 4.1 KRG gyro command test
' Ver 3.3 New Gyro test
' Ver 3 Gyro added
' Ver 2 CONTOROL CODE MODIFIED.
'
'RD6000 DATA
'1ch: L-UD(U+), 2ch R-LR(L+), 3ch R-UD(U+), 4ch L-LR(L+)
'CENTER :0
'UP :1
'DOWN :2
'LEFT :3
'RIGHT :4
'LEFT-UP :5
'RIGHT-UP :6
'LEFT-DOWN :7
'RIGHT-DOWN :8
'RSV :9

'##DEF INPUT RC_CH
DIM RCH1 AS BYTE
DIM RCH2 AS BYTE
DIM RCH3 AS BYTE
DIM RCH4 AS BYTE

'##DEF JUMP VARIABLE
DIM STICKPOS AS BYTE
DIM LSTICK AS BYTE
DIM RSTICK AS BYTE
DIM A16 AS BYTE
DIM A26 AS BYTE

'##DEF WAIT TIME
CONST WAITTIME = 10

'##DEF THURESHOLD VALUE
'1ch: L-UD(U+), 2ch R-LR(R+), 3ch R-UD(U+), 4ch L-LR(L+)
CONST RCH1MIN = 40
CONST RCH1MAX = 140
CONST RCH2MIN = 40
CONST RCH2MAX = 140
CONST RCH3MIN = 40
CONST RCH3MAX = 140
CONST RCH4MIN = 40
CONST RCH4MAX = 140

'##DEF VALUE STICK POS.
CONST TOP = 100
CONST DOWN = 0
CONST LEFT = 0
CONST RIGHT = 100
CONST CENTER = 50

'##DEF GYRO
'For GWS Gyro
GYROSET G6A, 0, 1, 1, 1, 0, 0
GYROSET G6D, 0, 1, 1, 1, 0, 0

GYRODIR G6A, 0, 1, 1, 1, 0, 0
GYRODIR G6D, 0, 1, 1, 1, 0, 0

GYROSENSE G6A, 0, 100, 100, 100, 0, 0
GYROSENSE G6D, 0, 100, 100, 100, 0, 0

'==========================================
'--- AUTO MAIN ---
STICKPOS = 0
PTP SETON
PTP ALLON

'== motor diretion setting
DIR G6A,1,0,0,1,0,0
DIR G6B,1,1,1,1,1,1
DIR G6C,0,0,0,0,0,0
DIR G6D,0,1,1,0,1,0

'== motor start position read
GETMOTORSET G24,1,1,1,1,1,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1,1,0
TEMPO 230
MUSIC "CDE"
DELAY 2000

'== motor power on
SPEED 5
MOTOR G24
GOSUB standard_pose

'==========================================
'--- MAIN ROUTINE ---
MAIN:
DELAY WAITTIME

GOSUB RCDATACALC
GOSUB CALCSTICKPOS

IF LSTICK = 0 AND RSTICK = 0 THEN
		GOTO MAIN
	ELSEIF RSTICK = 0 THEN
		STICKPOS = LSTICK
	ELSEIF RSTICK = 1 THEN
		STICKPOS = LSTICK + 10
	ELSEIF RSTICK = 2 THEN
		STICKPOS = LSTICK + 20
	ELSEIF LSTICK = 0 THEN
		STICKPOS = RSTICK + 30
ENDIF

'---DECIDE MOTION ---
MUSIC "C"
ON STICKPOS GOTO K0,K1,K2,K3,K4,K5,K6,K7,K8,K9,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29, K30, K31, K32, K33, K34, K35, K36, K37, K38, K39
GOTO MAIN

'---MAIN ROUTINE EXIT ---
MAIN_EXIT:

STICKPOS = 0
GOTO MAIN

'==========================================
'--- GET STICK POSITION ---
RCDATACALC:

RCH1 = RCIN (0)
RCH2 = RCIN (1)
RCH3 = RCIN (2)
RCH4 = RCIN (3)

'##INPUT VALUE DEPEND ON STICK POSITION
IF RCH1 < RCH1MIN THEN
		RCH1 = DOWN
	ELSEIF RCH1 > RCH1MAX THEN
		RCH1 = TOP
	ELSE
		RCH1 = CENTER
ENDIF

IF RCH2 < RCH2MIN THEN
		RCH2 = RIGHT
	ELSEIF RCH2 > RCH2MAX THEN
		RCH2 = LEFT
	ELSE
		RCH2 = CENTER
ENDIF

IF RCH3 < RCH3MIN THEN
 		RCH3 = DOWN
 	ELSEIF RCH3 > RCH3MAX THEN
 		RCH3 = TOP
 	ELSE
 		RCH3 = CENTER
ENDIF


IF RCH4 < RCH4MIN THEN
 		RCH4 = RIGHT
	ELSEIF RCH4 > RCH4MAX THEN
		RCH4 = LEFT
	ELSE
		RCH4 = CENTER
ENDIF
RETURN

'==========================================
'--- CALCULATE STICKPOSITION ---
CALCSTICKPOS:
IF RCH1 = CENTER AND RCH4 = CENTER THEN
		LSTICK = 0
	ELSEIF RCH1 = CENTER AND RCH4 = LEFT THEN
		LSTICK = 3
	ELSEIF RCH1 = CENTER AND RCH4 = RIGHT THEN
		LSTICK = 4
	ELSEIF RCH1 = TOP AND RCH4 = CENTER THEN
		LSTICK = 1
	ELSEIF RCH1 = TOP AND RCH4 = LEFT THEN
		LSTICK = 5
	ELSEIF RCH1 = TOP AND RCH4 = RIGHT THEN
		LSTICK = 6
	ELSEIF RCH1 = DOWN AND RCH4 = CENTER THEN
		LSTICK = 2
	ELSEIF RCH1 = DOWN AND RCH4 = LEFT THEN
		LSTICK = 7
	ELSEIF RCH1 = DOWN AND RCH4 = RIGHT THEN
		LSTICK = 8		
ENDIF


IF  RCH3 = DOWN AND RCH2 = CENTER THEN
		RSTICK = 2
	ELSEIF RCH3 = DOWN AND RCH2 = LEFT THEN
		RSTICK = 7
	ELSEIF RCH3 = DOWN AND RCH2 = RIGHT THEN
		RSTICK= 8
	ELSEIF RCH3 = TOP AND RCH2 = CENTER THEN
		RSTICK = 1
	ELSEIF RCH3 = TOP AND RCH2 = LEFT THEN
		RSTICK = 5
	ELSEIF RCH3 = TOP AND RCH2 = RIGHT THEN
		RSTICK = 6
	ELSEIF RCH3 = CENTER AND RCH2 = LEFT THEN
		RSTICK = 3
	ELSEIF RCH3 = CENTER AND RCH2 = RIGHT THEN
		RSTICK = 4
	ELSEIF RCH3 = CENTER AND RCH2 = CENTER THEN
		RSTICK = 0
ENDIF
RETURN

名前:
コメント:


-
|新しいページ|検索|ページ一覧|RSS|@ウィキご利用ガイド | 管理者にお問合せ
|ログイン|