Chieftain kit arrival

Forum for discussion relating to the Chietain MBT
Stephen White
Site Admin
Posts: 3108
Joined: Sat Oct 11, 2008 7:05 pm
Location: Dorset
Has liked: 1022 times
Been liked: 2091 times
Contact:

Re: Chieftain kit arrival

Post by Stephen White »

Vince Cutajar wrote:
Sun Jun 07, 2020 10:44 am

Always amazed at how fast the turret and barrel moved.
Vince
They didn’t (move that fast).

Vince Cutajar
Posts: 2180
Joined: Wed Nov 15, 2017 1:43 pm
Location: Malta
Has liked: 762 times
Been liked: 1738 times

Re: Chieftain kit arrival

Post by Vince Cutajar »

I guess so. Still it is fun to see it moving at that rate.

Vince

User avatar
Brian Ostlind
Posts: 1466
Joined: Sat Oct 28, 2017 6:56 am
Location: Oregon, USA
Has liked: 968 times
Been liked: 2066 times

Re: Chieftain kit arrival

Post by Brian Ostlind »

You are lucky to be able to drive around town. If I took to the streets with my tank I would probably get killed by police.

User avatar
John Clarke
Posts: 1631
Joined: Sun Oct 17, 2010 10:06 pm
Location: Staffordshire
Been liked: 1729 times

Re: Chieftain kit arrival

Post by John Clarke »

Vince, you have to picture what the tank turret crew would be going though. :lol:
11.JPG
11.JPG (33.66 KiB) Viewed 4503 times
Oh Man, I only ride em I don't know what makes them work,
Definatley an Anti-Social type

User avatar
Youngjae Bae
Posts: 274
Joined: Sun Jan 27, 2019 12:01 am
Location: South Korea
Has liked: 747 times
Been liked: 594 times

Re: Chieftain kit arrival

Post by Youngjae Bae »

In the middle of the night when the rainy season began, my Chieftain returned to Korea after fulfilling his duty to protect the safety of the tribe.

Youngjae :mrgreen:
Attachments
IMG_10062020_214526_(2500_x_1183_픽셀).jpg
IMG_10062020_214825_(2500_x_1183_픽셀).jpg
IMG_10062020_214624_(2500_x_1183_픽셀).jpg
IMG_10062020_214724_(2500_x_1183_픽셀).jpg
IMG_10062020_214547_(2500_x_1183_픽셀).jpg

Vince Cutajar
Posts: 2180
Joined: Wed Nov 15, 2017 1:43 pm
Location: Malta
Has liked: 762 times
Been liked: 1738 times

Re: Chieftain kit arrival

Post by Vince Cutajar »

fulfilling his duty to protect the safety of the tribe
:D :D

Vince

User avatar
Youngjae Bae
Posts: 274
Joined: Sun Jan 27, 2019 12:01 am
Location: South Korea
Has liked: 747 times
Been liked: 594 times

Re: Chieftain kit arrival

Post by Youngjae Bae »

I have to thank Vince again today.
I work at a research institute that makes model ships and conducts experiments.
So I did not have it in my house, but there is a 3D printer here, so I asked the company for understanding and printed the file that Vince sent me.
And what's even more pleasant is that I succeeded in the withdrawal of the figures by compiling the Arduino sketch that Vince sent me the other day perfectly on the Arduino Mega and MPU9250.
(For your information, many of the mpu9250 head-up files on the market have caused errors :twisted: )

I can use this value to control the DC motor for stabilization of the pitch and turret of the main gun to sabertooth, the motion controller B.
It's very fun to make one by one. And Vince, thank you. :mrgreen:

Youngjae
Attachments
5.jpg
4.jpg
3.jpg
2.jpg
1.jpg

Vince Cutajar
Posts: 2180
Joined: Wed Nov 15, 2017 1:43 pm
Location: Malta
Has liked: 762 times
Been liked: 1738 times

Re: Chieftain kit arrival

Post by Vince Cutajar »

You are welcome Youngjae. Happy to help out.
Vince

User avatar
Youngjae Bae
Posts: 274
Joined: Sun Jan 27, 2019 12:01 am
Location: South Korea
Has liked: 747 times
Been liked: 594 times

Re: Chieftain kit arrival

Post by Youngjae Bae »

This morning I finally completed a program to control the main gun and turret stabilizers.
So I successfully finished coding and uploading Arduino Mega.
Of course, I have to test it over the weekend, but l'm happy with this moment when l've spent a lot of time trying to get results.

Let's wait and see what happens. :mrgreen:

Youngjae
Attachments
20200611_194142.jpg

User avatar
Youngjae Bae
Posts: 274
Joined: Sun Jan 27, 2019 12:01 am
Location: South Korea
Has liked: 747 times
Been liked: 594 times

Re: Chieftain kit arrival

Post by Youngjae Bae »

During the weekend, I did some tests.

The configuration of RC + ARDUINO + SABERTOOTH + MPU9250 is the final configuration of the hardware.

1. RC + ARDUINO + SABERTOOTH = Program upload and run very well.

2. ARDUINO + MPU9250 = Program upload and run very well.

3. RC + ARDUINO + SABERTOOTH + MPU9250 = Program uploads are good. However, the desired stabilization has not yet been achieved.

3-1. First of all, if I do not construct a Stabilization command in the void loop statement, it will function normally when the sensor is measured and the RC signal is processed.

3-2. When the Stabilization command phrase is created to fit SABERTOOTH in the above 3-1 state, no operation is performed and the motor will float at 0.5 second intervals when the MPU9250 returns a measurement.

To solve these 3-2 problems

3-2-1.I used MPU9250's measurement and stabilization as the main tasks of void loop syntax, and when I sent two RC signals to Arduino that changed the position of turret or Gun, I coded on interrupt condition.
Although coding and uploading were well done, MPU9250 did not operate due to continuous floating of RC signals that occurred without the operation of the transmitter, so I gave up this process.

3-2-2. SABERTOOTH's method uses a single pin to handle the direction and intensity of the motor rotation.
As the floatig of the motor that sprays when the stabilization command is added is due to the direction of the continuous pulse change and the PWM change, I ordered a three-pin motor controller that Vince uses.
In other words, I decided to accept the manufacturer's explanation that the direction of the output operation of the two digital pins and the way the output of the motor is controlled by one PWM is not affected by unnecessary noise.

3-2-3. Debugging to find out why the instructions I processed to execute on the source file I received from Vince before the motor controller arrived. One discovery I made yesterday was that if I insert a stabilization phrase at the bottom of the void loop sentence, it will not work in the process.
So today I'm going to continue to look at the scope and the reasons why it's being executed and ignored from where it's being ignored.

I am not a C language or program expert.
It's been a little over two months since I started studying Arduino.
But I'm praising myself for not coming to this situation from turning the LED on and off.

The configuration of the hardware for stabilization of the main gun and turret is complete.
Later, by reducing the end-poins of the channel that controls the transmitter's turret and Gun, the manoeuvring speed can be slow.
However, I believe that Arduino's control of the speed and force for stabilization will be fast and sufficient.

I won't give up even if the final result for stabilization can be a little slow.



Youngjae

Vince Cutajar
Posts: 2180
Joined: Wed Nov 15, 2017 1:43 pm
Location: Malta
Has liked: 762 times
Been liked: 1738 times

Re: Chieftain kit arrival

Post by Vince Cutajar »

This is the motor driver board I was using.
https://lastminuteengineers.com/l298n-d ... -tutorial/
It can control two dc motors independently. Each channel is maximum 2A so that might affect you.

Vince

User avatar
Youngjae Bae
Posts: 274
Joined: Sun Jan 27, 2019 12:01 am
Location: South Korea
Has liked: 747 times
Been liked: 594 times

Re: Chieftain kit arrival

Post by Youngjae Bae »

I did various tests last night with the same motor drive that Vince has.
I found that there was a problem when I wrote a phrase that used both the transmitter command (manual adjustment of GUN & TURRET) and stabilization in the void loop syntax.

In other words, I found out that the motor floats when I included a condition statement for stabilization after the motor operation statement that I normally use.
So whether the motor drier is L298N or SABRTOOTH, it's not a hardware issue, it's a program sketch.
Because the pattern of floating sent by the motor is constant every 0.5 seconds, I think it can be solved.

In addition, in the program sketch that Vince provided me, when the first condition of the "if(!AHRS)" condition statement, "if(myIMU.delt_t > 500)" was true, the Euler formula and the stevilizer conditions were required to know the desired action.

Stabilization is now well done by annotating the syntax for manually operating the motor by receiving the transmitter signal.
From now on, when I send a signal from the transmitter, I'm going to carry out my command first, and I'm thinking about sketching a program in which the Stevilizer works when my transmitter command is idling.

Thank you again Vince for supporting various information.

Youngjae
Attachments
20200617_084223.jpg

User avatar
Youngjae Bae
Posts: 274
Joined: Sun Jan 27, 2019 12:01 am
Location: South Korea
Has liked: 747 times
Been liked: 594 times

Re: Chieftain kit arrival

Post by Youngjae Bae »

The YouTube link below is a video showing small progress up to yesterday.
The output of the actuator is being tested at 47%, and calibration of the response speed will continue.
For easy adjustment, the sentences in this part are treated as variables.

Today, I will use two types of condition statements and timer interrupts to separate radio control and stabilization.
When the results are obtained later, the program source code will also be prepared to operate by replacing the motor controller with SABRTOOTH (motion controller B).

Finally, I am going to create an integrated control package that includes driving and sound by reading all six or more of my receiver panels from Arduino.



Youngjae

User avatar
Youngjae Bae
Posts: 274
Joined: Sun Jan 27, 2019 12:01 am
Location: South Korea
Has liked: 747 times
Been liked: 594 times

Re: Chieftain kit arrival

Post by Youngjae Bae »



Good news!

I finally got the perfect move I wanted.
From now on, the response to the controller's stick is handled perfectly without delay, with variables that can promote the sensitivity of stabilization.

Youngjae
Attachments
20200619_084832.jpg

User avatar
Youngjae Bae
Posts: 274
Joined: Sun Jan 27, 2019 12:01 am
Location: South Korea
Has liked: 747 times
Been liked: 594 times

Re: Chieftain kit arrival

Post by Youngjae Bae »

/* 2020-06-19
* This source code was written by Bae Young-jae to reduce unnecessary elements and stabilize
* the main gun and turret of the big-scale model tank by referring to the code of
* Kris Winer and the condition statement of Vince.
*
* Based on the Arduino Mega, the power of the transmitter must be turned on by dust and
* supplied by the receiver and Arduino, and when switched off,
* the power of the transmitter must be shut off at the end.
*/


///////////////////////////////////////////////////////////////////////////////////////

// Main Control Parameters
#define PitchPower 120
#define YawPower 127
#define PitchAngle 1 //A dead band of 1 degree is created so that
#define YawAngle 1 //the dc motor will not hunt when reaching desired pitch
#define CheckTime 10 //milliseconds
#define deadzone 50 // Anything between -50 and 50 is stop

///////////////////////////////////////////////////////////////////////////////////////

#include "MPU9250.h"
#include "quaternionFilters.h"

// MPU9250 setup
#define SCL 400000
#define SDA Wire
#define MPU9250_ADDRESS 0x68
MPU9250 myIMU(MPU9250_ADDRESS, SDA, SCL);

// Transmitter connections
#define THRO_PIN 22
#define RUDD_PIN 23

//Motor driver pins
#define AIN1_PIN 3
#define AIN2_PIN 4
#define APWM_PIN 2
#define BIN1_PIN 5
#define BIN2_PIN 6
#define BPWM_PIN 7

//Variables for system control
float OldPitch, NewPitch, DiffPitch;
float OldYaw, NewYaw, DiffYaw;
int THRO, RUDD = 0;

// Set to true to get Serial output for debugging
#define SerialDebug true

void setup() {

// Define a Pin Using Arduano
pinMode(THRO_PIN, INPUT);
pinMode(THRO_PIN, INPUT);
pinMode(AIN1_PIN, OUTPUT);
pinMode(AIN2_PIN, OUTPUT);
pinMode(APWM_PIN, OUTPUT);
pinMode(BIN1_PIN, OUTPUT);
pinMode(BIN2_PIN, OUTPUT);
pinMode(BPWM_PIN, OUTPUT);

// Settings for MPU9250 Usage
myIMU.initAK8963(myIMU.factoryMagCalibration);
myIMU.initMPU9250();
myIMU.getAres();
myIMU.getGres();
myIMU.getMres();

Serial.begin(115200);

}

void loop() {

myIMU.readAccelData(myIMU.accelCount); // Read the x/y/z adc values
myIMU.ax = (float)myIMU.accelCount[0] * myIMU.aRes; // - myIMU.accelBias[0];
myIMU.ay = (float)myIMU.accelCount[1] * myIMU.aRes; // - myIMU.accelBias[1];
myIMU.az = (float)myIMU.accelCount[2] * myIMU.aRes; // - myIMU.accelBias[2];

myIMU.readGyroData(myIMU.gyroCount); // Read the x/y/z adc values
myIMU.gx = (float)myIMU.gyroCount[0] * myIMU.gRes;
myIMU.gy = (float)myIMU.gyroCount[1] * myIMU.gRes;
myIMU.gz = (float)myIMU.gyroCount[2] * myIMU.gRes;

myIMU.readMagData(myIMU.magCount); // Read the x/y/z adc values
myIMU.mx = (float)myIMU.magCount[0] * myIMU.mRes * myIMU.factoryMagCalibration[0] - myIMU.magBias[0];
myIMU.my = (float)myIMU.magCount[1] * myIMU.mRes * myIMU.factoryMagCalibration[1] - myIMU.magBias[1];
myIMU.mz = (float)myIMU.magCount[2] * myIMU.mRes * myIMU.factoryMagCalibration[2] - myIMU.magBias[2];

myIMU.updateTime();// Must be called before updating quaternions!

// conversion to quaternions
MahonyQuaternionUpdate(myIMU.ax, myIMU.ay, myIMU.az, myIMU.gx * DEG_TO_RAD, myIMU.gy * DEG_TO_RAD, myIMU.gz * DEG_TO_RAD, myIMU.my, myIMU.mx, myIMU.mz, myIMU.deltat);

myIMU.delt_t = millis() - myIMU.count;

if (myIMU.delt_t > CheckTime)
{

myIMU.yaw = atan2(2.0f * (*(getQ()+1) * *(getQ()+2) + *getQ()* *(getQ()+3)), *getQ() * *getQ() + *(getQ()+1)* *(getQ()+1) - *(getQ()+2) * *(getQ()+2) - *(getQ()+3)* *(getQ()+3));
myIMU.pitch = -asin(2.0f * (*(getQ()+1) * *(getQ()+3) - *getQ()* *(getQ()+2)));
myIMU.pitch *= RAD_TO_DEG;
myIMU.yaw *= RAD_TO_DEG;

// Read pulse width from receiver
THRO = pulseIn(THRO_PIN, HIGH);
RUDD = pulseIn(RUDD_PIN, HIGH);

// Convert to PWM value (-255 to 255)
THRO = pulseToPWM(THRO);
RUDD = pulseToPWM(RUDD);

if(SerialDebug) {

Serial.print(THRO);
Serial.print(" ");
Serial.print(RUDD);
Serial.println("This value is a GUN position.");
Serial.println();
Serial.print(RUDD);
Serial.print(" ");
Serial.print(RUDD);
Serial.println("This value is a TURRET position.");
Serial.println();

}

if( THRO != 0 || RUDD != 0 ) {

// THRO and RUDD Drive motor move
drive(THRO, RUDD);

} else {

//pitch stabilization
NewPitch = myIMU.pitch;
DiffPitch = NewPitch - OldPitch;

if (DiffPitch > PitchAngle) {

do {

digitalWrite(AIN1_PIN, HIGH);
digitalWrite(AIN2_PIN, LOW);
analogWrite(APWM_PIN, PitchPower);
}

while (DiffPitch < PitchAngle);

} else if (DiffPitch < -PitchAngle) {

do {

digitalWrite(AIN1_PIN, LOW);
digitalWrite(AIN2_PIN, HIGH);
analogWrite(APWM_PIN, PitchPower);

}

while (DiffPitch > -PitchAngle);

}else {

digitalWrite(AIN1_PIN, LOW);
digitalWrite(AIN2_PIN, LOW);

}

if(SerialDebug) {

Serial.print(DiffPitch);
Serial.print(" ");
Serial.print(DiffPitch);
Serial.println("This is Pitch difference..");
Serial.println();

}

OldPitch = NewPitch;

//Yaw stabilization
NewYaw = myIMU.yaw;
DiffYaw = NewYaw - OldYaw;

if (DiffYaw > YawAngle) {

do {

digitalWrite(BIN1_PIN, HIGH);
digitalWrite(BIN2_PIN, LOW);
analogWrite(BPWM_PIN, YawPower);
}

while (DiffYaw < YawAngle);

} else if (DiffYaw < -YawAngle) {

do {

digitalWrite(BIN1_PIN, LOW);
digitalWrite(BIN2_PIN, HIGH);
analogWrite(BPWM_PIN, YawPower);

}

while (DiffYaw > -YawAngle);

}else {

digitalWrite(BIN1_PIN, LOW);
digitalWrite(BIN2_PIN, LOW);

}

if(SerialDebug) {

Serial.print(DiffYaw);
Serial.print(" ");
Serial.print(DiffYaw);
Serial.println("This is Yaw difference.");
Serial.println();

}

OldYaw = NewYaw;

}

myIMU.count = millis();
myIMU.sumCount = 0;
myIMU.sum = 0;

}
}
// Positive for forward, negative for reverse
void drive(int THRO, int RUDD) {

// Limit speed between -255 and 255
THRO = constrain(THRO, -255, 255);
RUDD = constrain(RUDD, -255, 255);

// Set direction for motor A
if ( THRO == 0 ) {

digitalWrite(AIN1_PIN, LOW);
digitalWrite(AIN2_PIN, LOW);

}

else if ( THRO > 0 ) {

digitalWrite(AIN1_PIN, HIGH);
digitalWrite(AIN2_PIN, LOW);

} else {
digitalWrite(AIN1_PIN, LOW);
digitalWrite(AIN2_PIN, HIGH);
}

// Set direction for motor B
if ( RUDD == 0 ) {

digitalWrite(BIN1_PIN, LOW);
digitalWrite(BIN2_PIN, LOW);

} else if ( RUDD > 0 ) {

digitalWrite(BIN1_PIN, HIGH);
digitalWrite(BIN2_PIN, LOW);

} else {

digitalWrite(BIN1_PIN, LOW);
digitalWrite(BIN2_PIN, HIGH);

}

// Set speed
analogWrite(APWM_PIN, abs(THRO));
analogWrite(BPWM_PIN, abs(RUDD));

}

// Convert RC pulse value to motor PWM value
int pulseToPWM(int pulse) {

// If we're receiving numbers, convert them to motor PWM
if ( pulse > 900 ) {

pulse = constrain(map(pulse, 1058, 1877, -500, 500), -255, 255);

} else {

pulse = 0;

}

// Anything in deadzone should stop the motor
if ( abs(pulse - 0) <= deadzone ) {

pulse = 0;

}

return pulse;

}


=========================================================================================================
The above code is a result of considerable effort.
I'm going to share it up to here first, so I hope everyone who thinks of stabilizing the main gun and turret can use it comfortably and improve it even more.
And I'm going to introduce a crash prevention system for main gun for this next phase of program development.

I am going to test the turret and main gun in a wooden model and attach it to my chieftin.

Youngjae
Last edited by Youngjae Bae on Wed Jun 24, 2020 1:47 am, edited 1 time in total.

Post Reply