Teensy 3.2, Turbine EDF27 and Turnigy Plush 6A speed controller  - Page 1
Forum section: electronics / beginners

author: Nexo
author_rank: Regular Contributor
timestamp: October 05, 2017, 02:26:35 pm
content: Hello everyone!I'm building a line following using a Teensy 3.2 (which can be programmed with the Arduino's IDE) and I want to implement the turbine showed below:Turbine EDF27:https://hobbyking.com/en_us/edf27-with-11000kv-motor-assembled.htmlTurnigy Plush:https://hobbyking.com/en_us/turnigy-plush-6a-8bec-6g-speed-controller.htmlNothing I've found on forums seem to work so I'm here asking you guys.The code I show below is the one I'm using but is not working. A friend of mine connected a potentiometer and started moving it and the turbine worked but I don't know how to do it merely by code. Any idea will be very appreciated.Code:/*Coded by Marjan OleschSketch from Insctructables.comOpen source - do what you want with this code!*/#include <Servo.h>int value = 0; // set values you need to zeroServo firstESC, secondESC; //Create as much as Servoobject you want. You can controll 2 or more Servos at the same timevoid setup() {firstESC.attach(6); // attached to pin 6 I just do this with 1 ServoSerial.begin(9600); // start serial at 9600 baud}void loop() {//First connect your ESC WITHOUT Arming. Then Open Serial and follow InstructionsfirstESC.writeMicroseconds(value);if(Serial.available())value = Serial.parseInt(); // Parse an Integer from Serial}NOTE: I don't want it to vary its speed yet, I only want it to work at a set speed.Thanks in advance!

author: Nexo
author_rank: Regular Contributor
timestamp: October 05, 2017, 07:04:24 pm
content: I've done it! I found a site where there was a code and used it:(Site:https://www.instructables.com/id/How-to-run-an-ESC-with-Arduino/)//This code can be used for any purpose.#include <Servo.h>Servo ESC1;int pos = 0; //Sets position variablevoid arm(){setSpeed(0); //Sets speed variabledelay(1000);}void setSpeed(int speed){int angle = map(speed, 0, 100, 0, 180); //Sets servo positions to different speedsESC1.write(angle);}void setup() {ESC1.attach(6); //Adds ESC to certain pin.arm();}void loop() {int speed; //Implements speed variablefor(speed = 0; speed <= 70; speed += 5) { //Cycles speed up to 70% power for 1 secondsetSpeed(speed); //Creates variable for speed to be used in in for loopdelay(1000);}delay(4000); //Stays on for 4 secondsfor(speed = 70; speed > 0; speed -= 5) { // Cycles speed down to 0% power for 1 secondsetSpeed(speed);delay(1000);}setSpeed(0); //Sets speed variable to zero no matter whatdelay(1000); //Turns off for 1 second}I hope it helps someone. Have a great day!

author: Leev
author_rank: Newbie
timestamp: February 21, 2018, 07:11:38 am
content: Hey!Can confirm this code works with my particular ESC. Was having problems arming a Turnigy ESC Plush30a for a brushless motor before running this code. I added a longer delay at the start which also may have given my ESC enough time to arm.void arm(){setSpeed(0); //Sets speed variabledelay(8000);}Thanks to Nexo for the help. If you ever come to Australia I'll shout you a beer

author: Nexo
author_rank: Regular Contributor
timestamp: September 01, 2018, 07:53:31 pm
content: Glad it worked for you!Looking forward to that beer