Menu

Topic-icon Number of variables throug CAN

More
9 months 4 days ago #29533487 by hernajou

Hello,

currently I have a microScript to controll one single Motor, and sending through CAN some variables resulting from the Operation of this motor (Position, Current, Voltage, number of cycles, number of error Signal 1, number of error Signal 2, mode), but know I would like to add a second Motor and send also all its resulting signals as for the first one, that would mean 14 variables in total through TPDO. As per specification, the Limit are 8 variables. Is there any way to make possible sending more than 8 variables?

Regards.

Please Log in or Create an account to join the conversation.

More
9 months 3 days ago #29533489 by blake

Each VAR is 4 bytes

You can use 2 bytes for one variable and 2 for another and thus making the variables more. Of course this depends on the value range of each variable.

The following user(s) said Thank You: hernajou

Please Log in or Create an account to join the conversation.

More
9 months 2 days ago - 9 months 2 days ago #29533491 by hernajou

Thank you blake. I could send two different values through one single variable as per your recommendation. Now I would like to know if there is a "more elegant" or cleaner way to do this, because what I have is something like:

Value1 = x
Value1 = Value1 << 16
Value2 = y
Value12 = Value1 OR Value2
setcommand(_VAR, 1, Value12)

And my second doubt is about the sign for each value. Since I have two different values contained in one single variable, what happend if I try to combine positive and negative values?

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #29533496 by Gabriel_Isko

The code snippet you posted looks pretty correct. I would recommend sticking with that approach. You can use the <<= operator to clean it up a tad, but that is a minor adjustment.

In terms of sign value, I recommend checking out Wikipedia's page on byte representations of signed numbers. Integers in MicroBasic are signed four byte variables.

The following user(s) said Thank You: hernajou

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.085 seconds
Go to top