Number of variables throug CAN
5 years 6 months ago #29533487
by hernajou
Number of variables throug CAN was created 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.
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.
5 years 6 months ago #29533489
by blake
Replied by blake on topic Number of variables throug CAN
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.
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.
5 years 6 months ago - 5 years 6 months ago #29533491
by hernajou
Replied by hernajou on topic Number of variables throug CAN
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?
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.
- Gabriel_Isko
5 years 6 months ago #29533496
by Gabriel_Isko
Replied by Gabriel_Isko on topic Number of variables throug CAN
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.
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.
Please Log in or Create an account to join the conversation.
Moderators: tonysantoni
Time to create page: 0.075 seconds