Arduino Noobe Needs help.

Boyntonstu

10 kW
Joined
Mar 7, 2015
Messages
549
Location
Boynton Beach, Florida
This is all new to me:

I have a Hobbyking 150A 1/8 scale controller and a 213 KV 59mm Turnigy motor and I don't want to burn anything up.



I have this nano Arduino:

Arduino_zpszbkb9oh2.jpg




This 3 wire Throttle Thumb control:
Thumb%20throttle_zpsk5p4qmw8.jpg


Also:: Hobbywing 3A Switch Mode UBEC 5V 6V Max 5A Lowest RF Noise Brand New US

And this Sketch code given to me by a friend who says that it is on/off only and not variable.
#include <Servo.h>

Servo ESC;

int Button;

int Speed = 1500;

void setup()
{
ESC.attach(9);

pinMode(13, OUTPUT);

pinMode(A5, INPUT);
digitalWrite(A5, HIGH);
}

void loop()
{
delay(25);

Button = digitalRead(A5);

if(Button == LOW)
{
digitalWrite(13, HIGH);
Speed = 2000;
}

else if(Button == HIGH)
{
digitalWrite(13, LOW);
Speed = 1500;
}

ESC.writeMicroseconds(Speed);
}

Wiring advice:

Arduino pin
5V - Ubec + Throttle red
GND - Ubec + throttle white + battery ground
9 - ESC signal
A5 - Throttle green


------------------------------------

First: Please double check the wiring advice.

Second: Please advise modification to Arduino sketch to enable speed control.

I really would appreciate your help.
 
Also what voltage is your battery? What type of battery? Lithium or lead? Link to battery?
 
I just saw the price of that motor and the esc. Have you already purchased them? You can get a better, ebike specific, motor and controller for less.
 
TECH_GEEK10 said:
I just saw the price of that motor and the esc. Have you already purchased them? You can get a better, ebike specific, motor and controller for less.

Interesting: What do you recommend for a 6S 20+ MPH direct can friction combo?

BTW My 12 A 6S battery cost is almost zero.
 
I have a bunch of concerns that I am seeing in that video, and would like to go over a bunch of stuff that a forum really is not suited for. Do you have a skype account? I don't need to use the camera feature of skype just the instant messaging part.
 
TECH_GEEK10 said:
I have a bunch of concerns that I am seeing in that video, and would like to go over a bunch of stuff that a forum really is not suited for. Do you have a skype account? I don't need to use the camera feature of skype just the instant messaging part.

Sure what is your skype name?
 
complete solution using a arduino


throttle control
http://endless-sphere.com/forums/viewtopic.php?f=2&t=61004

watt meter
http://endless-sphere.com/forums/viewtopic.php?f=2&t=61407
 
gwhy! said:
complete solution using a arduino


throttle control
http://endless-sphere.com/forums/viewtopic.php?f=2&t=61004

watt meter
http://endless-sphere.com/forums/viewtopic.php?f=2&t=61407

Thanks, but I am not knowledgeable to choose from all the solutions posted on the thread.

I need to 1> Verify the wiring.
2> Modify the code to allow speed control.
Thanks
 
The second lot of code in the first link is what you need.. you un rem all the rc esc parts and rem all the ebike contoller parts. The code does a lot more that just the speed contol if you want to wire the current sensor but its not needed for basic speed control.
 
gwhy! said:
The second lot of code in the first link is what you need.. you un rem all the rc esc parts and rem all the ebike contoller parts. The code does a lot more that just the speed contol if you want to wire the current sensor but its not needed for basic speed control.

A minimalist code for speed control and a wiring diagram to the Arduino would be greatly appreciated.
 
Boyntonstu said:
gwhy! said:
The second lot of code in the first link is what you need.. you un rem all the rc esc parts and rem all the ebike contoller parts. The code does a lot more that just the speed contol if you want to wire the current sensor but its not needed for basic speed control.

A minimalist code for speed control and a wiring diagram to the Arduino would be greatly appreciated.

I have stripped just the speed control out,, but I have not tested it .. but it looks ok..

D3 on the nano is the output to the esc
A7 is the input from the throttle

the grounds joint together, ( throttle,esc,nano ) and all the +5v join together ( throttle,esc,nano ) .
the nano needs to be powered from +5v

Code:
// set servo for 1.1ms min - 1.8ms max ( or auto range )
/********************************************************
 * A7 (throttle input)
 * D3 (control) (throttle output) , RC filter is required on output for e-bike controller,, no rc filter for rc esc 
 *******************************************************/

// #include <Servo.h>   

const int Throttle_Input_pin = 7;  // Throttle input A7
const int Throttle_Output_pin = 3;  //Throttle output D3.. 

const int Set_Min_Servo = 1000;  // esc start with this as min throttle  // (rc esc)
const int Set_Max_Servo = 1800;  // esc end with this as max throttle  // (rc esc)
int Servo_time = 1000;   // (rc esc)                                                 


int Throttle_Value=0;
int Throttle_Pulse=0;
int Set_Throt_Min = 55; // this needs to be the min value to remove dead band from throttle output , around 55
int Set_Throt_Max = 180; // this needs to be the max value to achive full throttle without cutting out , around 180
int Cal_Throt_Min = 176; // this needs to be set to the real value of the throttle when fully closed;
int Cal_Throt_Max = 842; // this needs to be set to the real value of the throttle when fully open;

void setup()
{ //--- initialize serial communication at 9600 bits per second:
Serial.begin(9600); 
analogWrite(Throttle_Output_pin,0);  // (e-bike)
Servo_Pulse.attach(6);      // Attach Servo_Pulse to pin 3  //  (rc esc)
Servo_Pulse.writeMicroseconds(Servo_time);  //  (rc esc)
delay(1000);

}

void loop()
{

Throttle_Value = analogRead(Throttle_Input_pin);
Throttle_Pulse = constrain(map(Throttle_Value,Cal_Throt_Min,Cal_Throt_Max,0,1023),0,1023); // set range on throttle 
Servo_time = map(Throttle_Pulse,0,1023,Set_Min_Servo,Set_Max_Servo); // scale output  
Servo_Pulse.writeMicroseconds(Servo_time); //output servo signal to controller     

}
 
Back
Top