Servo к attiny85 и(или) attiny13

Доброго времени суток.
Нужно вращать сервой.

Есть Digispark ATtiny85 (потом будут “голые” 85)
image

#include <SoftRcPulseOut.h>
SoftRcPulseOut servo;

void setup() {
  servo.attach(1);
  servo.setMaximumPulse(2200);
}

void loop() {
  servo.write(0);
  delay(2000);
  servo.write(90);
  delay(2000);
  servo.write(180);
  delay(2000);
  SoftRcPulseOut::refresh();
}

Серва не крутится и не дёргается. (серва рабочая, проверил на уно)

Этот код, аналогично (но работает только на 16MHZ 16,5 не компилируется)

#include <Servo.h>
Servo servo;

void setup() {
  servo.attach(1);
  servo.write(0);
}

void loop() {
  servo.write(0);
  delay(2000);
  servo.write(90);
  delay(2000);
  servo.write(180);
  delay(2000);
}

Подскажите пожалуйста рабочий код на тини85 и тини13.
85 и 13, потому что нужно два разных проекта, а в наличии одна 13 и одна 85.

Поднимай ногу с сервой на 1500мкс, например

а посмотреть пример пользования библиотекой религия не позволяет?

  myservo.write(val);                  // sets the servo position according to the scaled value 
  delay(REFRESH_PERIOD_MS);            // waits for the servo to get there 
  SoftRcPulseOut::refresh();            // generates the servo pulse

Отпаял 85

В уно залил ArduinoISP
Скачал ATTinyCore

avrdude: Expected signature for ATtiny85 is 1E 93 0B
         Double check chip, or use -F to override this check.
Ошибка при записи загрузчика.
Спойлер
         Using Port                    : COM15
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
         AVR Part                      : ATtiny85
         Chip Erase delay              : 400000 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    12     4    0 no        512    4      0  4000  4500 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65     6    32    0 yes      8192   64    128 30000 30000 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
avrdude: Send: A [41] . [80]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [02] 
avrdude: Recv: . [10] 
avrdude: Send: A [41] . [81]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [01] 
avrdude: Recv: . [10] 
avrdude: Send: A [41] . [82]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [12] 
avrdude: Recv: . [10] 
avrdude: Send: A [41] . [98]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [00] 
avrdude: Recv: . [10] 
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
avrdude: Send: A [41] . [84]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [00] 
avrdude: Recv: . [10] 
avrdude: Send: A [41] . [85]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [00] 
avrdude: Recv: . [10] 
avrdude: Send: A [41] . [86]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [00] 
avrdude: Recv: . [10] 
avrdude: Send: A [41] . [87]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [00] 
avrdude: Recv: . [10] 
avrdude: Send: A [41] . [89]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [00] 
avrdude: Recv: . [10] 
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: Send: A [41] . [81]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [01] 
avrdude: Recv: . [10] 
avrdude: Send: A [41] . [82]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [12] 
avrdude: Recv: . [10] 
avrdude: Send: B [42] . [14] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00] @ [40] . [02] . [00] . [00] . [00]   [20] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude: PAGEL and BS2 signals not defined in the configuration file for part ATtiny85, using dummy values
avrdude: Send: E [45] . [05] . [04] . [d7] . [a0] . [01]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude: Send: P [50]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude: AVR device initialized and ready to accept instructions

Reading | avrdude: Send: V [56] 0 [30] . [00] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] 
avrdude: Recv: . [10] 
avrdude: Send: V [56] 0 [30] . [00] . [01] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [00] 
avrdude: Recv: . [10] 
################avrdude: Send: V [56] 0 [30] . [00] . [02] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] 
avrdude: Recv: . [10] 
################################## | 100% 0.02s

avrdude: Device signature = 0xff00ff
avrdude: Expected signature for ATtiny85 is 1E 93 0B
         Double check chip, or use -F to override this check.
avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.

Ошибка при записи загрузчика.

И так тоже не работает. Пробовал.

конденсаторов нет, не взлетит, ставь

Имеете ввиду на gnd и reset ?

да, иначе то шьётся то не шьётся

Направление работы пина библиотека сама устанавливает ?

uint8_t SoftRcPulseOut::attach(int pinArg)
{
    pin = pinArg;
    angle = NO_ANGLE;
    pulse0 = 0;
    next = first;
    first = this;
    digitalWrite(pin,0);
    pinMode(pin,OUTPUT);
    return 1;
}

попробуй поменять пин на 3

Конденсатор не помогает. не прошивается, может это не 85, а подделка?

Я пробовал все пины, аналогично.

если были чистые, то поможет это:

приведи скетч, что пробовал, так как беру скетч из примеров, заливаю, всё работает!!!

// Sweep
// by BARRAGAN <http://barraganstudio.com> 
// Adapted to SoftRcPulseOut library by RC Navy (http://p.loussouarn.free.fr)
// This sketch can work with ATtiny and Arduino UNO, MEGA, etc...
// This example code is in the public domain.

#include <SoftRcPulseOut.h> 
 
SoftRcPulseOut myservo;  // create servo object to control a servo 
                        // a maximum of eight servo objects can be created 
#define SERVO_PIN         3

#define REFRESH_PERIOD_MS 20

#define NOW               1

int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
  myservo.attach(SERVO_PIN);  // attaches the servo on pin defined by SERVO_PIN to the servo object 
} 
 
 
void loop() 
{ 
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(REFRESH_PERIOD_MS);        // waits 20ms for refresh period 
    SoftRcPulseOut::refresh(NOW);    // generates the servo pulse Now
  } 
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(REFRESH_PERIOD_MS);        // waits 20ms for for refresh period 
    SoftRcPulseOut::refresh(NOW);    // generates the servo pulse Now
  } 
} 

Спасибо. Вылезла ещё проблема.
Впаял обратно 85

C:\Users\Vlad\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5/bin/avr-gcc-ar: Cannot find plugin 'liblto_plugin-0.dll'
exit status 1
Ошибка компиляции для платы Digispark (Default - 16.5mhz).

Удалил всю папку IDE, установил заново, и вот такая ошибка. (это после ночных установок различных ядер для 85)

Это верное ядро для дигиспарк?

Большое спасибо.
Дело было в ядре, или в программе.
Чистая установка решила проблему.

Спойлер
// Sweep
// by BARRAGAN <http://barraganstudio.com> 
// Adapted to SoftRcPulseOut library by RC Navy (http://p.loussouarn.free.fr)
// This sketch can work with ATtiny and Arduino UNO, MEGA, etc...
// This example code is in the public domain.

#include <SoftRcPulseOut.h> 
 
SoftRcPulseOut myservo;  // create servo object to control a servo 
                        // a maximum of eight servo objects can be created 
#define SERVO_PIN         3

#define REFRESH_PERIOD_MS 20

#define NOW               1

int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
  myservo.attach(SERVO_PIN);  // attaches the servo on pin defined by SERVO_PIN to the servo object 
} 
 
 
void loop() 
{ 
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(REFRESH_PERIOD_MS);        // waits 20ms for refresh period 
    SoftRcPulseOut::refresh(NOW);    // generates the servo pulse Now
  } 
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(REFRESH_PERIOD_MS);        // waits 20ms for for refresh period 
    SoftRcPulseOut::refresh(NOW);    // generates the servo pulse Now
  } 
}

Этот код работает.
Получается что нельзя просто задать угол на который серва повернётся?

myservo.write(90);    
delay(2000);
myservo.write(0);   
delay(2000);

в этой библиотеке задавать именно так, так в примере скетча, если хотите одной строкой используйте просто servo.h

Спасибо. Попробую чуть позже.
Ещё по attiny13 пару вопросов.

#define SERVO_PIN 3

void setup() {
  pinMode(3, OUTPUT);
}

void loop() {
  for (uint8_t pos = 0; pos < 180; pos++) {
    pulseOut(SERVO_PIN, pos);
    delay(20);
  }
}

void pulseOut(uint8_t pin, uint8_t p) {
  digitalWrite(pin, HIGH);
  //delayMicroseconds(300 + p * (2500 / 180));
  digitalWrite(pin, LOW);
}

Установил ядро MicroCore

Спойлер

Этот текст будет скрыт

delayMicroseconds() написано что реализовано
А по факту ругается на delayMicroseconds(300 + p * (2500 / 180));

C:\Users\Vlad\AppData\Local\Temp\cc0e9KF2.s: Assembler messages:
C:\Users\Vlad\AppData\Local\Temp\cc0e9KF2.s:98: Error: register r24, r26, r28 or r30 required
lto-wrapper.exe: fatal error: C:\Users\Vlad\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc returned 1 exit status
compilation terminated.
c:/users/Vlad/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
exit status 1
Ошибка компиляции для платы ATtiny13.