coding for multiple steppers

i'm coding for multiple stepper motors (12) which can be addressed over 1 serial line. It is possible to address the motors individualy by their channel number.

the initialisation code looks like this:

SoftwareSerial ticSerial(10, 11); TicSerial tic1(ticSerial, 14); //for motor 1 TicSerial tic2(ticSerial, 15); //for motor 2 ..etc

and then a command for a specific motor looks like:

** tic2.resetCommandTimeout();**

there's a long list of possible commands. my question is how to code without having to write separate lines for every possible motor and every possible command.

something like the following is not acceptable for the compiler:

char name = names[2];//array with names for the motors ** TicSerial name(ticSerial, nn);** error: conflicting declaration 'TicSerial& name' note: previous declaration as 'char name'

any help appreciated

rolf

You could have an array of TicSerial objects:

TicSerial things[] = {
   TicSerial(ticSerial, 14),
   TicSerial(ticSerial, 15),
   TicSerial(ticSerial, 16),
   TicSerial(ticSerial, 17),
   TicSerial(ticSerial, 18),
   TicSerial(ticSerial, 19),
   TicSerial(ticSerial, 20),
   TicSerial(ticSerial, 21)
};

However, this appears to have all instances of the class listening to the same serial port. How will any given instance know that it is it's turn to be listening?

You need to provide more details about this mysterious class.

I suspect that none of the instances should be listening to the serial port. Your sketch should, and it should determine which instance of the class is to do something with the data, based on the data received.

@PaulS indeed all steppers are on 1 serial line. The stepper-controler is a Tic834 from Pololu. The Tic library expects an initialisation of a stream for every stepper. The number is the identifier which ties the stream to a specific stepper. The solution you suggest doesn't give compile errors. AND seems to be working, great.