// Types
#define     ZERO	0x40
#define     BYTE	0x41
#define     WORD	0x42
#define     DWORD	0x43
#define     ERROR	0x44
#define		Test	0

// Colors
#define		BLACK	0x000000
#define		SILVER	0xC0C0C0
#define		GRAY	0x808080
#define		WHITE	0xFFFFFF
#define		MAROON	0x800000
#define		RED		0xFF0000
#define		ORANGE	0xFFA500
#define		PURPLE	0x800080
#define		FUCHSIA	0xFF00FF
#define		GREEN	0x008000
#define		LIME	0x00FF00
#define		OLIVE	0x808000
#define		YELLOW	0xFFFF00
#define		NAVY	0x000080
#define		BLUE	0x0000FF
#define		TEAL	0x008080
#define		AQUA	0x00FFFF

#define  UNITID_ACCDECRATE  SELECT(M2_P39)			\
{															\
	CASE 0:													\
		UNITID1001;											\
	CASE 1:													\
		UNITID359;											\
	CASE 2:													\
		UNITID1000;											\
}

#define  FREQ_MAX_SECTION  M1_P6

#define  NEG_FREQ_MAX_SECTION  IF (M1_P10 == 0)		\
{															\
	M1_P7;													\
}															\
ELSE														\
{															\
	(-1 * M1_P6);											\
}

#define MAX_SET_SPEED_RPM ((M1_P6 * M5_P8) / M5_P6)

#define MIN_SET_SPEED_RPM ((M1_P7 * M5_P8) / M5_P6)

#define  AC_VOLTAGE_SET_MAX_SECTION  SELECT (M11_P33)	\
{															\
	CASE 0:													\
		240;												\
	CASE 1:													\
		480;												\
	CASE 2:													\
		575;												\
	CASE 3:													\
		690;												\
}

#define  AC_VOLTAGE_MAX_SECTION  SELECT (M11_P33)		\
{															\
	CASE 0:													\
		309;												\
	CASE 1:													\
		618;												\
	CASE 2:													\
		741;												\
	CASE 3:													\
		886;												\
}

#define  DC_VOLTAGE_SET_MAX_SECTION  SELECT (M11_P33)	\
{															\
	CASE 0:													\
		400;												\
	CASE 1:													\
		800;												\
	CASE 2:													\
		950;												\
	CASE 3:													\
		1150;												\
}

#define  DC_VOLTAGE_MAX_SECTION  SELECT (M11_P33)		\
{															\
	CASE 0:													\
		415;												\
	CASE 1:													\
		830;												\
	CASE 2:													\
		995;												\
	CASE 3:													\
		1190;												\
}


#define  MOTOR_CURRENT_LIMIT_MAX_SECTION    IF (M5_P7 <= M11_P32)		\
	{																	\
		Test;															\
	}																	\
	ELSE																\
	{																	\
		1;															\
	}

#define  NEG_MOTOR_CURRENT_LIMIT_MAX_SECTION    IF (M5_P7 <= M11_P32)	\
	{																	\
		0;															\
	}																	\
	ELSE																\
	{																	\
		1;															\
	}	

#define  MOTOR2_CURRENT_LIMIT_MAX_SECTION    IF (M5_P7 <= M11_P32)		\
	{																	\
		0;															\
	}																	\
	ELSE																\
	{																	\
		1;															\
	}	

#define  NEG_MOTOR2_CURRENT_LIMIT_MAX_SECTION    IF (M5_P7 <= M11_P32)	\
	{																	\
		0;															\
	}																	\
	ELSE																\
	{																	\
		1;															\
	}	


#define  TORQUE_PROD_CURRENT_MAX_SECTION	MOTOR_CURRENT_LIMIT_MAX_SECTION
#define  NEG_TORQUE_PROD_CURRENT_MAX_SECTION	NEG_MOTOR_CURRENT_LIMIT_MAX_SECTION

#define  RATED_CURRENT_MAX_SECTION  (1.36 * M11_P32)

#define  DRIVE_CURRENT_MAX_SECTION  (M11_P32 * 2)
#define  NEG_DRIVE_CURRENT_MAX_SECTION  (-1 * (M11_P32 *2))

#define  USER_CURRENT_MAX_SECTION  M4_P24
#define  NEG_USER_CURRENT_MAX_SECTION  (-1 * M4_P24)

#define  POWER_MAX_SECTION	10000
#define  NEG_POWER_MAX_SECTION  -10000

#define  read_param_1(cmd_name, p1)				\
COMMAND cmd_name						\
{										\
	SLOT		0 ;						\
	INDEX		47 ;					\
	OPERATION	READ ;					\
	TRANSACTION							\
	{									\
		REQUEST							\
		{								\
		}								\
		REPLY							\
		{								\
			Reply_Reference,			\
			Reply_ID,					\
			Reply_Axis,					\
			Reply_Num_Of_Parameters,	\
			Reply_Format,				\
			Reply_Num_of_Words,			\
			p1							\
		}								\
	}									\
}

#define  write_param_1(cmd_name, hb_param_num, lb_param_num, data_type, p1)			\
COMMAND cmd_name						\
{										\
	SLOT		0 ;						\
	INDEX		47 ;					\
	OPERATION	WRITE ;					\
	TRANSACTION							\
	{									\
		REQUEST							\
		{								\
			0x01,						\
			0x02,						\
			0x00,						\
			0x01,						\
										\
			0x10,						\
			0x00,						\
			hb_param_num,				\
			lb_param_num,				\
			0x00,						\
			0x00,						\
										\
			data_type,					\
			0x01,						\
			p1							\
		}								\
		REPLY							\
		{								\
		}								\
	}									\
}