Problem with creatint small sub

I am trying to get a routine into a singe INT but get a error i dont get.

#define SPEED_DEG_1 = 200;
int newAxis = 1230;
int rotorXAxis = 0;

  int XrotationSpeed = rotorSpeed(abs(newXAxis - rotorXAxis));

int rotorSpeed(int toMove) {
  int Speed;

  if(toMove >= SPEED_DEG_1) { 
    Speed = rotationSpeed4;  }
  else {
    Speed = rotationSpeed1;  }

  return Speed;
}

This is the error i get : error: expected primary-expression before '=' token

Any help?

Please post all of your code. I suspect that you don't mean

get a routine into a singe INT

but rather are trying to get a function to return an int.

#define SPEED_DEG_1 = 200;Wrong. Do you really want SPEED_DEG_1 replaced by = 200; in your code when it is compiled ?

UKHeliBob: #define SPEED_DEG_1 = 200;Wrong. Do you really want SPEED_DEG_1 replaced by = 200; in your code when it is compiled ?

Yes

Yes

Where are you using SPEED_DEG_1? It seems highly unlikely that you want the name SPEED_DEG_1 replaced by the value " = 200;" everywhere that SPEED_DEG_1 is used.

Which line of the code generates the error ?

You reference an apparent variable newXAxis which doesn't seem to be declared anywhere.

newAxis and rotorAxis are both a int and here's the defining part:

/****************************************************************************************
 * These values define the speed trajectory to reach a certain position.            *
 * The higher the difference the higher the speed to move the antenna.          *
 * Range from 180-20-8-2-0 degrees                      */
#define SPEED_DEG_1 = 200;
#define SPEED_DEG_2 = 80;
#define SPEED_DEG_3 = 20;
/****************************************************************************************/
int newXAxis;
int newYAxis;
int rotorXAxis;
int rotorYAxis;

The routine should do the following: if the distance lies belowe the 200 then go go full speed, between 200 and 80 use 3/4 speed, between 80 and 20 half speed and below 20 use the minimum speed.

I think that you'll find http://snippets-r-us.com more willing to deal with your snippets of code.

Ignoring the last post i was in the meantime looking at the #define statement be-course it would work in a other part of the same code. So altered the definitions part accordantly:

/******************** Units for system  with 6V motors *************************************/
#define SUPPLY_VOLTAGE 1350		// System supply between 6-24V DC in mV	*
#define MOTOR_VOLTAGE 600		// Motor operating voltage in mV			*
#define MOTOR_MIN_VOLTAGE 250	// Minimum used motor voltage in mV		*
/******************** Units for system with 24V motors ************************************/
//#define SUPPLY_VOLTAGE 2450	// System supply between 6-24V DC in mV	*
//#define MOTOR_VOLTAGE 2400	// Motor normal operating voltage in mV		*
//#define MOTOR_MIN_VOLTAGE 1000	// Minimum desirable motor voltage in mV		*
/******************** Calculate different voltages used ********************************
 * We now can calculate the voltages used to control speed using PWM			*
 * The formula = (PWM_resolution/supply_voltage)*desired_voltage = PWM_value		*/
const long RotationSpeed4 = ((25500/SUPPLY_VOLTAGE)*MOTOR_VOLTAGE)/100;
const long RotationSpeed3 = ((25500/SUPPLY_VOLTAGE)*(MOTOR_VOLTAGE/4)*3)/100;
const long RotationSpeed2 = ((25500/SUPPLY_VOLTAGE)*(MOTOR_VOLTAGE/2))/100;
const long RotationSpeed1 = ((25500/SUPPLY_VOLTAGE)*MOTOR_MIN_VOLTAGE)/100;
/****************************************************************************************
 * These values define the speed trajectory to reach a certain position. 			*
 * The higher the difference the higher the speed to move the antenna. 			*
 * Range from 180-20-8-2-0 degrees						*/
const int SPEED1 = 200;
const int SPEED2 = 80;
const int SPEED3 = 20;
/****************************************************************************************/
int newXAxis;
int newYAxis;
int rotorXAxis;
int rotorYAxis;

changing from #define to a constant with type. The code looks now:

int rotorSpeed(int toMove) {
  int Speed;

  if(toMove >= SPEED1) {
    Speed = RotationSpeed4;
  }
  if(toMove >= SPEED2 && toMove < SPEED1) {
    Speed = RotationSpeed3;
  }
  if(toMove >= SPEED3 && toMove < SPEED2) {
    Speed = RotationSpeed2;
  }
  else {
    Speed = RotationSpeed1;
  }
  return Speed;
}

tries again #define SPEED_DEG_1 = 200;

You want SPEDD_DEG_1 TO BE "200" NOT "= 200" there is no = in a define.

Mark

and no semi-colon at the end of #define

Well, if you want to be really silly, you can put a semi-colon at the end of a #define

#define A Serial.println("This came from a define");
void setup() 
{
  Serial.begin(115200);
  A
}

void loop() 
{
}

Ignoring the last post

So, you want us to ignore you? Fine, I'll start as soon as I hit Post.