Hello Everyone,
I'm trying to build a nerf FDL-3 semi auto for my son, but I can't get the code to work with my ESC's. My ESC is a Favourite BLHeli_S Little Bee spring Dshot. The ESC Project FDL were using is a Spedix GS30 30A 2-4s BLHeli_32 Dshot ESC, could the problem be that they both have different protocols? When I power up the electronics the ESC's startup but they don't give the "armed beep". This is the original sketch projectfdl were using:
#include <Servo.h>
int escPin = A3;
int speedPin = A2;
int limiterPin = A1;
int triggerPin = A0;
Servo flywheelESC;
int currentSpeed = 1000;
int spindownRate = 10; //units per 10ms
unsigned long lastSpindownCheck = 0;
unsigned long elapsedTime = 0;
void setup() {
pinMode(triggerPin, INPUT_PULLUP);
pinMode(speedPin, INPUT);
flywheelESC.attach(escPin);
flywheelESC.writeMicroseconds(1000);
}
// the loop function runs over and over again forever
void loop() {
if(triggerDown()){
int readSpeed = analogRead(speedPin);
int limSpeed = analogRead(limiterPin);
int maxSpeed = map(limSpeed, 0, 1023, 1285, 2000);
int txSpeed = map(readSpeed, 0, 1023, 1285, maxSpeed);
flywheelESC.writeMicroseconds(txSpeed);//1750);
currentSpeed = txSpeed;
elapsedTime = 0;
lastSpindownCheck = millis();
}
else{
//flywheelESC.writeMicroseconds(1000);
spinDown();
}
//delay(2);
}
void spinDown(){
int flipSpindown = (16 - spindownRate) * 2;
if(currentSpeed > 1000){
if(spindownRate == 0){
currentSpeed = 1000;
}
else{
elapsedTime = lastSpindownCheck == 0 ? 0 : elapsedTime + millis() - lastSpindownCheck;
lastSpindownCheck = millis();
int spindown = elapsedTime / 10 * flipSpindown;
elapsedTime %= 10;
currentSpeed -= spindown;
}
}
flywheelESC.writeMicroseconds(currentSpeed);
}
boolean triggerDown(){
return digitalRead(triggerPin) == LOW;
}
Ive been doing a lot of reading and I don't understand why the esc is connected to A3, I found a Dshot sketch and there the ESC is connected to D0 to D7. I'm not good with coding so forgive my ignorance. Hope someone could help me figure this out so I can learn and understand more about creating Arduino sketches. This is the Dshot sketch I found:
#include <DShot.h>
/*
redefine DSHOT_PORT if you want to change the default PORT
Defaults
UNO: PORTD, available pins 0-7 (D0-D7)
Leonardo: PORTB, available pins 4-7 (D8-D11)
e.g.
#define DSHOT_PORT PORTD
*/
DShot esc1(DShot::Mode::DSHOT300);
uint16_t throttle = 0;
uint16_t target = 0;
void setup() {
Serial.begin(115200);
// Notice, all pins must be connected to same PORT
esc1.attach(7);
esc1.setThrottle(throttle);
}
void loop() {
if (Serial.available()>0){
target = Serial.parseInt();
if (target>2047)
target = 2047;
Serial.print(target, HEX);
Serial.print("\t");
}
if (throttle<48){
throttle = 48;
}
if (target<=48){
esc1.setThrottle(target);
}else{
if (target>throttle){
throttle ++;
esc1.setThrottle(throttle);
}else if (target<throttle){
throttle --;
esc1.setThrottle(throttle);
}
}
delay(10);
}

