When my HC-06 module attached to my Arduino Nano is connected with another Bt device, my Brushless Motor (Samguk Wei) starts to jerk while running (work perfectly if I unplug it or cancel the Bt connection).
I checked the PWM outputs by monitoring them and also excluded the Bt radiation which I though t might has an impact on the wires by holding an Bt headset close to my construction. By having a closer look at it with an oszilluscope i realised that the interference make the impulse written by the ESC to the Motorr (see attachment) longer.
I don’t have any more Ideas but I hope someone mor experienced might have on
Florian
#include <Servo.h>
#include <SoftwareSerial.h>
SoftwareSerial hc06(2,3);
int inbyte[4];
int incomming;
int outbyte = 0;
int index = 0;
double wanted_pitch = 0;
double wanted_roll = 0;
int throttle = 0;
Servo ESC1;
Servo ESC2;// create servo object to control a servo
// twelve servo objects can be created on most boards
int pos1 = 0;
int state = 0;
int pos2 = 0;// variable to store the servo position
void setup() {
ESC1.attach(5, 1000 , 2000);
ESC2.attach(6, 1000 , 2000); // attaches the servo on pin 9 to the servo object
hc06.begin(9600);
Serial.begin(9600);
ESC1.write(0);
ESC2.write(0);
delay(5000);
}
void loop() {
if(hc06.available()){
incomming = hc06.read();
Serial.print("Reciving: ");
Serial.print(incomming);
if(incomming == 255){
index = 0;
/* Serial.print("roll: ");
Serial.print(inbyte[0]);
Serial.print(" | pitch: ");
Serial.print(inbyte[1]);
Serial.print(" | throttle: ");
Serial.print(inbyte[2]);
Serial.print(" | rotation: ");
Serial.print(inbyte[3]);
Serial.print(" | real_throttle: ");
Serial.print(throttle);
Serial.print(" | real_roll: ");
Serial.print(wanted_roll);
Serial.print(" | real_pitch: ");
Serial.print(wanted_pitch);
Serial.println("|||");
*/
wanted_roll = map(inbyte[0], 0, 120, -60, 60);
wanted_pitch = map(inbyte[1], 0, 120, 60, -60);
throttle = map(inbyte[2], 0, 120, 0, 180);
}else {
inbyte[index] = incomming;
index ++;
}
}
ESC1.write(throttle);
ESC2.write(throttle);
Serial.print("writing: ");
Serial.println(throttle);
}