Hi! I tried to control my esc with digispark, but I failed. First I tried to use Servo.h library - but it doesn't work with attiny 85. Then I tried SimpleServo.h - that's just like Servo.h, but for attiny, if I understand it right. So, this library works with servos, but it doesn't work with ESC. I tried to "writeMicroseconds(800);", but it doesn't work and esc doesn't turn on properly. What can I do and is it even possible to control esc with digispark? (Sorry for my English)
Welcome to the forum
A standard RC ESC should accept values sent from the Servo library but may need special startup values to arm and/or calibrate it
What do you mean by this ?
Note that servos and, by extension, ESCs usually work with microsecond values between 1000 and 2000 so your value of 800 sounds too low
Have you got any details of the ESC ?
What is ESC? Is it an Arduino -- if yes, then which Arduino?
Electronic Speed Controller (ESC)
Using an Attiny for commanding an ESC should not be a problem. I have used that combination quite a few times.
What are you input signals? Just serial data?
Here's how I set my DJI Opto 30A ESCs in void setup()
rSignalOut.attach(8);
lSignalOut.attach(10);
lSignalOut.writeMicroseconds(1000);
rSignalOut.writeMicroseconds(1000);
This is idle for that particular model, note that they are drone ESCs so they don't reverse. If the ESCs are from a car or something with reverse, the idle will sit somewhere around 1500uS
esc doesn't turn on properly - it make no sound it should, jusl like it receiving some signals, but signals aren't correct.
800 microseconds - as I know ESC's range is 800-2300, at least, it worked with UNO. But I'll try 1000.
Thanks!
What is the source of that information ?
I wrote the same, but instead of 1000 I wrote 800, will check if 1000 work.
Thanks !
I saw it on YouTube and it worked with my another esc and Arduino Uno.
But now I'm not sure if I'm right, will check it out
still doesn't work
, here's the code:
#include <SimpleServo.h>
SimpleServo motor;
void setup(){
motor.attach(1);
motor.writeMicroseconds(1000);
}
void loop(){
motor.writeMicroseconds(1000);
delay(3000);
motor.writeMicroseconds(2000);
delay(3000);
}
Lose those delays. Your code spends all its time in delay, meaning blocking code.
Which is almost certainly a problem
From the SimpleServo library documentation
The program can't do anything else while the servo is being signaled
ok, i made some changes (added timer with millis() ) and tried to upload sketch again, but for some reason computer stopped recognising it. Did I burn it somehow?
Post the sketch that you tried
Please post all the details: along with code, the circuit, how you're powering everything, what you're using to connect the Digispark to the ESC, what motors you're using, all that stuff
#define MY_PERIOD 3000 // period
uint32_t tmr1;
int set = 1000;
#include <SimpleServo.h>
SimpleServo motor;
void setup(){
motor.attach(1);
motor.writeMicroseconds(1000);
}
void loop(){
if (millis() - tmr1 >= MY_PERIOD) {
tmr1 = millis();
motor.writeMicroseconds(1000);
if (set == 1000) {set = 2000;} else {set = 1000;}
}
}
motor.writeMicroseconds(1000);
Shouldn't that be
motor.writeMicroseconds(set);
code sent higher, the circuit attached, connected all with wires for prototiping. ESC - HOBBYWING Skywalker 20A, battery for the ESC - Ministar 2S 750mah, motor - SunnySky X2204S 2300KV. I wasn't sure if +5 pin on digispark is input or output, so I powered it with one more battery to the Vin pin.
oops, you're right, fixed. But computer still doesn't want to recognise board
This User Manual may be of interest
Note the section on calibration