Notifications
Clear all

[Solved] Pulling resistance Unit App In Torque mode

Page 1 / 2
Forum 1
(@amitmaziel)
Eminent Member

Hi Milad

i am working on a power resistance unit in toque mode, meaning, the motor rotates in torque mode and an external force is resisting its rotation by rotating its shaft to opposite direction.

2 problems found:

1. when external force rotating shaft to opposite direction , connection is lost -do i need to protect the hardware from BMF ?

2. cant seem to reach desired torque at required velocity via motion terminal.

tnx.

Amit 

 

Quote
Topic starter Posted : 27/04/2022 7:35 am
SOLO Team
(@milad)
Chief Member Moderator

Hi @amitmaziel,

Posted by: @amitmaziel

1. when external force rotating shaft to opposite direction , connection is lost -do i need to protect the hardware from BMF ?

if you want to make the system work in harsh conditions, I highly recommend you to use the CAN bus on SOLO taking advantage of CANopen's robustness and reliability, we just published a new fully merged library for CANopen for Arduino devices, it has the exact same interface as the UART library, so I believe you should be able to easily migrate between the two.

https://github.com/Solo-FL/SOLO-motor-controllers-ARDUINO-library

SOLO UNO CANsheild Connection CANopen
Posted by: @amitmaziel

2. cant seem to reach desired torque at required velocity via motion terminal.

How much is the Iq that you require to reach and how much is the current limit?

Can we have the Iq readings at max Torque situation ( may be the monitored one)

Regards
Milad

 

 

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.

ReplyQuote
Posted : 28/04/2022 6:39 am
Forum 1
(@amitmaziel)
Eminent Member

@milad 

didn't quite understand how the can protocol protects the hardware from  motor  regeneration (BMF) .

Iq is 10, the same as the current limit

ReplyQuote
Topic starter Posted : 28/04/2022 8:16 am
SOLO Team
(@milad)
Chief Member Moderator

@amitmaziel 

Posted by: @amitmaziel

didn't quite understand how the can protocol protects the hardware from  motor  regeneration (BMF) .

I believe the BEMF is actually not the main cause of that issue, since the BEMF has a direct relation with speed and in deceleration ( abrupt direction change) the speed is reducing thus BEMF is reducing, however, the BUS voltage can rise due to returned energy from the MOTOR due to Regeneration that can cause issues if too much high, in general, the main cause of that issue can be the fact that due to abrupt deceleration, some noise due to regeneration disturbs the USB which is a weak signal (leveled at 3.3v) to the PC and PC disconnects the USB, now with CAN-bus with much higher voltage level and more robust data-transfer you have higher chance to mitigate the issue with noise.

if you strictly need to use the Motion terminal you can have two options:

  1. Convert the UART of SOLO to RS232/RS485 using a UART to RS232/RS485 converter,  and then use an RS232/RS485 to USB converter on the PC side, like this by using the RS232/RS485 protocols, the chance that the USB connection gets lost reduces as RS232/RS485 have higher voltage levels, with RS232 you can use the max-baudrate of 115200, if you want higher baud rates like 937500 you need to use RS485 protocol instead of RS2322, once you use SOLO to have the highest performance with the motor, it's highly recommended to use highest data-rates possible. (eg. 937500 for UART)
  2. Insulate the USB while using also high-quality USB cables, for the insulation of the USB you can use modules like the below one ( make sure the insulator-module has a built-in isolated DC-DC converter):

    https://eu.mouser.com/ProductDetail/Seeed-Studio/114991949?qs=P1JMDcb91o6Z7ld6yCt%2FVQ%3D%3D&vip=1&gclid=CjwKCAjw9qiTBhBbEiwAp-GE0fXIIRXeQTmQ0DESowvaR5QJEDJHKsdevgJQa1F5cr8h0U0L-HPdKhoCY8IQAvD_BwE

Let me know if this could be helpful.

Milad

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.

ReplyQuote
Posted : 28/04/2022 8:35 am
SOLO Team
(@milad)
Chief Member Moderator

@amitmaziel:

BTW,

  1. please let me know what is your device's firmware version? ( you might need to update your firmware as in the latest firmware we put some error-handling in the USB and UART protocols)
  2. The use of RS232/RS485 solutions above is better than USB insulation as they are more robust for harsh situations.

Milad

 

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.

ReplyQuote
Posted : 28/04/2022 8:41 am
Forum 1
(@amitmaziel)
Eminent Member

ok, thanks 

so i need to get the can open  shield for arduino as shown in the picture?

BTW

Ive notice there is an example code for torque control via arduino for BLDC with hole sensors. 

is there also an available code for controlling a BLDC with encoder?

tnx. again

ReplyQuote
Topic starter Posted : 28/04/2022 2:58 pm
SOLO Team liked
SOLO Team
(@milad)
Chief Member Moderator
Posted by: @amitmaziel

so i need to get the can open  shield for arduino as shown in the picture?

Yes, The library works with all the chips from the Microchip family of SPI to CAN converters including MCP2515 and MCP2551 used in various Arduino shields like CAN-BUS Shield V2.0 or Arduino MKR CAN Shield.

Posted by: @amitmaziel

Ive notice there is an example code for torque control via arduino for BLDC with hole sensors. 

is there also an available code for controlling a BLDC with encoder?

Unfortunately not yet, however you can use the following example which is done for Brushless motors with Encoder as below:

https://github.com/Solo-FL/SOLO-motor-controllers-ARDUINO-library/blob/main/examples/uart/Position_control_Brushless_Motor.ino

In this example you need to do a couple of things:

  1. put the feedback mode on Hall sensors:
    SOLO_Obj1->SetFeedbackControlMode(SOLOMotorControllers::encoders);
  2. put the control mode on Torque mode:
    SOLO_Obj1->SetControlMode(SOLOMotorControllers::torqueMode);
  3. Now you can give the desired torque ( current ) setpoint using the following command:
    SetTorqueReferenceIq(float yourdesireCurrentInAMPs);

Let me know if you have other questions.

Regards
Milad

 

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.

ReplyQuote
Posted : 29/04/2022 11:32 am
Forum 1
(@amitmaziel)
Eminent Member

Hi milad

it didnt work and i am not quit sure that i fully understand the library syntax.

is there any guide that i can use besides the examples?

ReplyQuote
Topic starter Posted : 03/05/2022 2:44 pm
SOLO Team
(@milad)
Chief Member Moderator

Hi @amitmaziel,

Ok, Can I have the code you made here to have a look?

To understand what happens behind the scene you can have a look at the following article that explains how the pieces are placed together, if you have some specific doubts or questions surely we'd be available to clarify them all for you.

https://www.solomotorcontrollers.com/blog/setup-tune-motors-using-solo-motion-terminal/

 

Regards
Milad

 

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.

ReplyQuote
Posted : 04/05/2022 12:37 pm
Forum 1
(@amitmaziel)
Eminent Member

@milad 

the attachment failed so i have pasted the code here.

what i want to do is just set the driver to control  the motor on torque mode (torque ref Iq=4 amps) using a 2048 ppr encoder.

about the library syntax guide , i guess my meaning wasn't clear enough so i will set an example:

 when written in the code "SOLO_Obj1->SetControlMode(3);" how can i know what No. represent  torque mode??

what 1 stands for in "SOLO_Obj1->SetIdentification(1);"?

 

tnx.

 

* Author: SOLOMOTORCONTROLLERS
* Date: 2021
* Code version: 1.0.0
* Availability:  https://github.com/Solo-FL/SOLO-motor-controllers-ARDUINO-library 
* Please make sure you are applying the right wiring between SOLO and your ARDUINO
* The Code below has been tested on Arduino UNO
* The Motor used for Testings: teknic m-2310P-LN-04K
* Read more about this code here: https://www.solomotorcontrollers.com/position-control-brushless-arduino-and-solo/ 
*/

#include

//For this Test, make sure you have calibrated your Encoder before
//to know more please read:  https://www.solomotorcontrollers.com/how-to-connect-calibrate-incremental-encoder-with-solo/ 

//instanciate a SOLO object:
SOLOMotorController *SOLO_Obj1;

//the device address of SOLO:
unsigned char SOLO_address1=0;

//Desired Switching or PWM Frequency at Output
long pwmFrequency=40;

//Motor's Number of Poles
long numberOfPoles = 28;

//Motor's Number of Encoder Lines (PPR pre-quad)
long numberOfEncoderLines = 2048;

//Select the Normal BLDC_PMSM motor type
long motorType= 1;

//Speed controller Kp
float speedControllerKp = 0.5;
//Speed controller Ki
float speedControllerKi = 0.001;

//Position controller Kp
float positionControllerKp = 2;

//Position controller Ki
float positionControllerKi = 0.03;

// Current Limit of the Motor
float currentLimit= 9.5;

// Battery or Bus Voltage
float busVoltage = 48;

// Desired Speed Limit[RPM] 
long desiredSpeedLimit =3000;

// Desired Position Reference
long desiredPositionReference =0;

// Motor speed feedback
long actualMotorSpeed = 0;

// Motor position feedback
long actualMotorPosition = 0;

void setup() {
//In this example, make sure you put SOLO into Closed-Loop by
// pressing the Piano Switch NO# 5 DOWN. in SOLO UNO

//High Speed High Performance Baudrate (Recommended)
//Use this baudrate to have the best and real performance
//of SOLO under all conditions.
//Serial.begin(937500);

//Low Speed Low Performance Baudrate
//Use this baudrate only for devices that don't support
//937500 or 921600 baudrates.
Serial.begin(115200);

//Initialize the SOLO object
SOLO_Obj1 = new SOLOMotorController(SOLO_address1);
delay(2000);

busVoltage = SOLO_Obj1->GetBusVoltage();
while(busVoltage <=0){
busVoltage = SOLO_Obj1->GetBusVoltage();
//wait here till communication is established
Serial.println("\n Trying to Connect To SOLO");
delay(1000);
}

Serial.println("\n Communication Established succuessfully!");

//dummy read after Serial.println to open the UART line
SOLO_Obj1->GetBusVoltage();
// Initial Configurations
SOLO_Obj1->SetPWMFrequency(pwmFrequency);
SOLO_Obj1->SetCurrentLimit(currentLimit);
SOLO_Obj1->SetEncoderLines(numberOfEncoderLines);

//select Digital Mode
SOLO_Obj1->SetCommandMode(1);

SOLO_Obj1->SetMotorType(motorType);

//run the motor identification
//run ID. always after selecting the Motor Type!
SOLO_Obj1->SetIdentification(1);

Serial.println("\n Identifying the Motor");

//wait at least for 2sec till ID. is done
delay(2000);

//dummy read after Serial.println to open the UART line
SOLO_Obj1->GetBusVoltage();

//Operate while using Quadrature Encoder

//Control The Torque Mode
SOLO_Obj1->SetControlMode(3);

//Speed Controller Tunings
SOLO_Obj1->SetSpeedControllerKp(speedControllerKp);
SOLO_Obj1->SetSpeedControllerKi(speedControllerKi);

//Position Controller Tunings
SOLO_Obj1->SetPositionControllerKp(positionControllerKp);
SOLO_Obj1->SetPositionControllerKi(positionControllerKi);

//the device address of SOLO:
unsigned char SOLO_address1 = 0;

//Desired Switching or PWM Frequency at Output
long pwmFrequency = 40;

//Motor's Number of Poles
long numberOfPoles = 28;

//Motor's Number of Encoder Lines (PPR pre-quad)
long numberOfEncoderLines = 2048;

//Speed controller Kp
float speedControllerKp = 0.15;

//Speed controller Ki
float speedControllerKi = 0.03;

//Position controller Kp
float positionControllerKp = 0.12;

//Position controller Ki
float positionControllerKi = 0.02;

// Current Limit of the Motor
float currentLimit = 9.5;

// Battery or Bus Voltage
float busVoltage = 0;

// Desired Speed Limit[RPM]
long desiredSpeedLimit = 1000;

// Desired Position Reference
long desiredPositionReference = 0;

// Motor speed feedback
long actualMotorSpeed = 0;

// Motor position feedback
long actualMotorPosition = 0;
float desiredTorque_Iq = 3;
}
void loop() {

//set a desired Speed Limit for trajectory in RPM
//dummy read after Serial.println to open the UART line
SOLO_Obj1->GetBusVoltage();
//set a desired Speed Limit for trajectory in RPM
SOLO_Obj1->SetSpeedLimit(desiredSpeedLimit);
SOLO_Obj1->SetTorqueReference(4);
SOLO_Obj1->GetBusVoltage();
}
ReplyQuote
Topic starter Posted : 04/05/2022 3:54 pm
SOLO Team
(@milad)
Chief Member Moderator

 

Hi @amitmaziel,

As I can see you are still using our old Arduino library version, you need to download our most recent library from the Git if you want to take advantage of the abstractions on the syntax, for instance, now the following syntax is used for putting the system to take the feedback from the Encoder:

  //Operate while using Quadrature Encoder
  SOLO_Obj1->SetFeedbackControlMode(SOLOMotorControllersencoders);

The code you put has some considerations to be taken into the account, for instance, the below part of the code should stay in the setup() function, but now it seems it's outside:

Posted by: @amitmaziel

Serial.println("\n Communication Established succuessfully!"); //dummy read after Serial.println to open the UART line SOLO_Obj1->GetBusVoltage(); // Initial Configurations SOLO_Obj1->SetPWMFrequency(pwmFrequency); SOLO_Obj1->SetCurrentLimit(currentLimit); SOLO_Obj1->SetEncoderLines(numberOfEncoderLines); //select Digital Mode SOLO_Obj1->SetCommandMode(1); SOLO_Obj1->SetMotorType(motorType); //run the motor identification //run ID. always after selecting the Motor Type! SOLO_Obj1->SetIdentification(1); Serial.println("\n Identifying the Motor"); //wait at least for 2sec till ID. is done delay(2000); //dummy read after Serial.println to open the UART line SOLO_Obj1->GetBusVoltage(); //Operate while using Quadrature Encoder //Control The Torque Mode SOLO_Obj1->SetControlMode(3); //Speed Controller Tunings SOLO_Obj1->SetSpeedControllerKp(speedControllerKp); SOLO_Obj1->SetSpeedControllerKi(speedControllerKi); //Position Controller Tunings SOLO_Obj1->SetPositionControllerKp(positionControllerKp); SOLO_Obj1->SetPositionControllerKi(positionControllerKi); //the device address of SOLO: unsigned char SOLO_address1 = 0; //Desired Switching or PWM Frequency at Output long pwmFrequency = 40; //Motor's Number of Poles long numberOfPoles = 28; //Motor's Number of Encoder Lines (PPR pre-quad) long numberOfEncoderLines = 2048; //Speed controller Kp float speedControllerKp = 0.15; //Speed controller Ki float speedControllerKi = 0.03; //Position controller Kp float positionControllerKp = 0.12; //Position controller Ki float positionControllerKi = 0.02; // Current Limit of the Motor float currentLimit = 9.5; // Battery or Bus Voltage float busVoltage = 0; // Desired Speed Limit[RPM] long desiredSpeedLimit = 1000; // Desired Position Reference long desiredPositionReference = 0; // Motor speed feedback long actualMotorSpeed = 0; // Motor position feedback long actualMotorPosition = 0; float desiredTorque_Iq = 3;

Below I try to put for you an example of how to change the given example code for position controlling to Torque controlling using our latest Arduino Library and Incremental encoders:

#include "SOLOMotorControllersUart.h"

//For this Test, make sure you have calibrated your Encoder before
//to know more please read:  https://www.solomotorcontrollers.com/how-to-connect-calibrate-incremental-encoder-with-solo/ 

//instanciate a SOLO object:
SOLOMotorControllers *SOLO_Obj1;

//the device address of SOLO:
unsigned char SOLO_address1 = 0;

//Desired Switching or PWM Frequency at Output
long pwmFrequency = 30;

//Motor's Number of Poles
long numberOfPoles = 8;

//Motor's Number of Encoder Lines (PPR pre-quad)
long numberOfEncoderLines = 1000;

// Current Limit of the Motor
float currentLimit = 15.0;

// Battery or Bus Voltage
float busVoltage = 0;

void setup() {
//In this example, make sure you put SOLO into Closed-Loop by
// pressing the Piano Switch NO# 5 DOWN. in SOLO UNO

//High Speed High Performance Baudrate (Recommended)
//Use this baudrate to have the best and real performance
//of SOLO under all conditions.
//Serial.begin(937500);

//Low Speed Low Performance Baudrate
//Use this baudrate only for devices that don't support
//937500 or 921600 baudrates.
Serial.begin(115200);

//Initialize the SOLO object
SOLO_Obj1 = new SOLOMotorControllersUart(SOLO_address1);
delay(1000);

Serial.println("\n Trying to Connect To SOLO");
delay(1000);
//wait here till communication is established
while(SOLO_Obj1->CommunicationIsWorking() == false)
{
delay(500);
}

Serial.println("\n Communication Established succuessfully!");

// Initial Configurations
SOLO_Obj1->SetOutputPwmFrequencyKhz(pwmFrequency);
SOLO_Obj1->SetCurrentLimit(currentLimit);
SOLO_Obj1->SetIncrementalEncoderLines(numberOfEncoderLines);

//select Digital Mode
SOLO_Obj1->SetCommandMode(SOLOMotorControllersdigital);

//set the motor type
SOLO_Obj1->SetMotorType(SOLOMotorControllersbldcPmsm);

//Operate while using Quadrature Encoder
SOLO_Obj1->SetFeedbackControlMode(SOLOMotorControllersencoders);

//Control The Torque
SOLO_Obj1->SetControlMode(SOLOMotorControllerstorqueMode);

}

void loop() {
SOLO_Obj1->SetTorqueReferenceIq(4.0);
delay(1000);
SOLO_Obj1->SetTorqueReferenceIq(2.0);
delay(1000);
}

Let me know if you have further questions

Milad

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.

ReplyQuote
Posted : 05/05/2022 10:36 am
SOLO Team
(@milad)
Chief Member Moderator

It seems the forum is changing the code, pls refer to the text file attached above, sorry for the inconvenience.

Milad

 

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.

ReplyQuote
Posted : 05/05/2022 10:42 am
Forum 1
(@amitmaziel)
Eminent Member

@milad 

latest library version doesnt include the following source file:

#include "SOLOMotorControllersUart.h"

pls. advise

ReplyQuote
Topic starter Posted : 07/05/2022 3:49 pm
SOLO Team
(@milad)
Chief Member Moderator

Hi @amitmaziel 

Have you tried to update your local library folder for the Arduino libraries with the latest Git source files on your PC?

https://github.com/Solo-FL/SOLO-motor-controllers-ARDUINO-library/tree/main/src

To learn more about how to add and use the latest Arduino library that includes CANopen too you can read the following piece:

https://www.solomotorcontrollers.com/blog/arduino-library-hello-world/

Let me know please more specifically if you have other issues.

Milad

 

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.

ReplyQuote
Posted : 08/05/2022 10:09 am
Forum 1
(@amitmaziel)
Eminent Member

@milad 

i will try

tnx.

ReplyQuote
Topic starter Posted : 08/05/2022 10:43 am
Page 1 / 2
Share: