Code Monkey home page Code Monkey logo

servotimer2's People

Contributors

irubio282 avatar nabontra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

servotimer2's Issues

New feature: Arduino simulation page for the library

Hi there

Thank you for the library which is useful in cases of a Timer1 conflict. I have created an Arduino simulation page. Here is the link.
This will give an instant preview to the users of your library.

https://wokwi.com/arduino/projects/300615873789428234

I appreciate it if you could add this to your ReadMe file. Please let me know If I can create a PR for that. also, if you have time, it will be awesome, if you can share the feedback on the overall Arduino simulator as well.
Please let me know if you have any questions :)

Thanks!
Matititam

Compiling with MEGA 2560

When I try to use the library with my arduino Mega 2560 it says it won't compile, but when I try it with a nano it does. I also might have downloaded the library incorrectly. I am also trying to use Servo.h with this library, I'm not sure if that is causing issues.

Library doesn't work with AVR 32u4 (Arduino Pro Micro)

Hi, I tried to run the ServoTimer2 library on an Sparkfun Pro Micro board, (also on a Adafruit feather 32u4) with a 32u4 cpu 8 MHz, but doesn't work. The errors are:
Arduino:1.8.12 (Windows 10), Scheda:"SparkFun Pro Micro, ATmega32U4 (3.3V, 8 MHz)"

D:\Programmi\Arduino\arduino-builder -dump-prefs -logger=machine -hardware D:\Programmi\Arduino\hardware -hardware C:\Users\Paolo\AppData\Local\Arduino15\packages -hardware D:\D\Arduino_doc\sorgenti101\hardware -tools D:\Programmi\Arduino\tools-builder -tools D:\Programmi\Arduino\hardware\tools\avr -tools C:\Users\Paolo\AppData\Local\Arduino15\packages -built-in-libraries D:\Programmi\Arduino\libraries -libraries D:\D\Arduino_doc\sorgenti101\libraries -fqbn=SparkFun:avr:promicro:cpu=8MHzatmega32U4 -ide-version=10812 -build-path C:\Users\Paolo\AppData\Local\Temp\arduino_build_819664 -warnings=all -build-cache C:\Users\Paolo\AppData\Local\Temp\arduino_cache_287673 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.arduinoOTA-1.1.1.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.avrdude.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.avrdude-6.3.0-arduino9.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.avr-gcc.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.avr-gcc-4.9.2-atmel3.5.4-arduino2.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -verbose D:\D\Arduino_doc\sorgenti101\Libraries\ServoTimer2\examples\threeservos\threeservos.ino
D:\Programmi\Arduino\arduino-builder -compile -logger=machine -hardware D:\Programmi\Arduino\hardware -hardware C:\Users\Paolo\AppData\Local\Arduino15\packages -hardware D:\D\Arduino_doc\sorgenti101\hardware -tools D:\Programmi\Arduino\tools-builder -tools D:\Programmi\Arduino\hardware\tools\avr -tools C:\Users\Paolo\AppData\Local\Arduino15\packages -built-in-libraries D:\Programmi\Arduino\libraries -libraries D:\D\Arduino_doc\sorgenti101\libraries -fqbn=SparkFun:avr:promicro:cpu=8MHzatmega32U4 -ide-version=10812 -build-path C:\Users\Paolo\AppData\Local\Temp\arduino_build_819664 -warnings=all -build-cache C:\Users\Paolo\AppData\Local\Temp\arduino_cache_287673 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.arduinoOTA-1.1.1.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.avrdude.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.avrdude-6.3.0-arduino9.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.avr-gcc.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.avr-gcc-4.9.2-atmel3.5.4-arduino2.path=C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -verbose D:\D\Arduino_doc\sorgenti101\Libraries\ServoTimer2\examples\threeservos\threeservos.ino
Using board 'promicro' from platform in folder: C:\Users\Paolo\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.12
Using core 'arduino' from platform in folder: C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21
Detecting libraries used...
"C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=8000000L -DARDUINO=10812 -DARDUINO_AVR_PROMICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x1b4f -DUSB_PID=0x9204 "-DUSB_MANUFACTURER="Unknown"" "-DUSB_PRODUCT="SparkFun Pro Micro"" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.12\variants\promicro" "C:\Users\Paolo\AppData\Local\Temp\arduino_build_819664\sketch\threeservos.ino.cpp" -o nul
Alternatives for ServoTimer2.h: [ServoTimer2]
ResolveLibrary(ServoTimer2.h)
-> candidates: [ServoTimer2]
"C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=8000000L -DARDUINO=10812 -DARDUINO_AVR_PROMICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x1b4f -DUSB_PID=0x9204 "-DUSB_MANUFACTURER="Unknown"" "-DUSB_PRODUCT="SparkFun Pro Micro"" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.12\variants\promicro" "-ID:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2" "C:\Users\Paolo\AppData\Local\Temp\arduino_build_819664\sketch\threeservos.ino.cpp" -o nul
"C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=8000000L -DARDUINO=10812 -DARDUINO_AVR_PROMICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x1b4f -DUSB_PID=0x9204 "-DUSB_MANUFACTURER="Unknown"" "-DUSB_PRODUCT="SparkFun Pro Micro"" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.12\variants\promicro" "-ID:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2" "D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp" -o nul
Generating function prototypes...
"C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=8000000L -DARDUINO=10812 -DARDUINO_AVR_PROMICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x1b4f -DUSB_PID=0x9204 "-DUSB_MANUFACTURER="Unknown"" "-DUSB_PRODUCT="SparkFun Pro Micro"" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.12\variants\promicro" "-ID:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2" "C:\Users\Paolo\AppData\Local\Temp\arduino_build_819664\sketch\threeservos.ino.cpp" -o "C:\Users\Paolo\AppData\Local\Temp\arduino_build_819664\preproc\ctags_target_for_gcc_minus_e.cpp"
"D:\Programmi\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Paolo\AppData\Local\Temp\arduino_build_819664\preproc\ctags_target_for_gcc_minus_e.cpp"
Sto compilando lo sketch...
"C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega32u4 -DF_CPU=8000000L -DARDUINO=10812 -DARDUINO_AVR_PROMICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x1b4f -DUSB_PID=0x9204 "-DUSB_MANUFACTURER="Unknown"" "-DUSB_PRODUCT="SparkFun Pro Micro"" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.12\variants\promicro" "-ID:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2" "C:\Users\Paolo\AppData\Local\Temp\arduino_build_819664\sketch\threeservos.ino.cpp" -o "C:\Users\Paolo\AppData\Local\Temp\arduino_build_819664\sketch\threeservos.ino.cpp.o"
Compiling libraries...
Compiling library "ServoTimer2"
"C:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega32u4 -DF_CPU=8000000L -DARDUINO=10812 -DARDUINO_AVR_PROMICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x1b4f -DUSB_PID=0x9204 "-DUSB_MANUFACTURER="Unknown"" "-DUSB_PRODUCT="SparkFun Pro Micro"" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\Paolo\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.12\variants\promicro" "-ID:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2" "D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp" -o "C:\Users\Paolo\AppData\Local\Temp\arduino_build_819664\libraries\ServoTimer2\ServoTimer2.cpp.o"
In file included from D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:4:0:

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp: In function 'void TIMER2_OVF_vect()':

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:24:6: warning: 'TIMER2_OVF_vect' appears to be a misspelled signal handler, missing __vector prefix [-Wmisspelled-isr]

ISR (TIMER2_OVF_vect)

  ^

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:29:2: error: 'TCNT2' was not declared in this scope

TCNT2 = servos[Channel].remainder; // yes, set count for overflow after remainder ticks

^

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:39:2: error: 'TCNT2' was not declared in this scope

TCNT2 = 0; // reset the clock counter register

^

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp: In function 'void initISR()':

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:124:2: error: 'TIMSK2' was not declared in this scope

TIMSK2 = 0; // disable interrupts

^

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:125:2: error: 'TCCR2A' was not declared in this scope

TCCR2A = 0; // normal counting mode

^

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:126:2: error: 'TCCR2B' was not declared in this scope

TCCR2B = _BV(CS21); // set prescaler of 8

^

In file included from c:\users\paolo\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\avr\include\avr\io.h:99:0,

             from c:\users\paolo\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\avr\include\avr\interrupt.h:38,

             from D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:4:

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:126:15: error: 'CS21' was not declared in this scope

TCCR2B = _BV(CS21); // set prescaler of 8

           ^

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:127:2: error: 'TCNT2' was not declared in this scope

TCNT2 = 0; // clear the timer2 count

^

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:128:2: error: 'TIFR2' was not declared in this scope

TIFR2 = _BV(TOV2); // clear pending interrupts;

^

In file included from c:\users\paolo\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\avr\include\avr\io.h:99:0,

             from c:\users\paolo\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\avr\include\avr\interrupt.h:38,

             from D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:4:

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:128:14: error: 'TOV2' was not declared in this scope

TIFR2 = _BV(TOV2); // clear pending interrupts;

          ^

D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2\ServoTimer2.cpp:129:16: error: 'TOIE2' was not declared in this scope

TIMSK2 = _BV(TOIE2) ; // enable the overflow interrupt

            ^

Uso la libreria ServoTimer2 nella cartella: D:\D\Arduino_doc\sorgenti101\libraries\ServoTimer2 (legacy)
exit status 1
Errore durante la compilazione per la scheda SparkFun Pro Micro.

Library doesn't work with ESP8266

When I try to use this with an ESP8266 with platformio, I get the following error:

Compiling .pioenvs/default/libf18/ServoTimer2_ID1305/ServoTimer2.cpp.o
.piolibdeps/ServoTimer2_ID1305/ServoTimer2.cpp:4:29: fatal error: avr/interrupt.h: No such file or directory
#include <avr/interrupt.h>
^
compilation terminated.
*** [.pioenvs/default/libf18/ServoTimer2_ID1305/ServoTimer2.cpp.o] Error 1

detach() seems to work opposite of <servo.h> library

Hey nabonta,

Glad I found this library. I needed to use Timer1 on my uno for other things but also drive one servo. Wanted to keep my design simple and drive the servo with one pin and software. While using Timer1 and ServoTimer2, after I do my write(xxxx) I delay a bit to let the servo move, then issue detach() to let the servo "relax". If I want the servo to HOLD the position, then I do not detach(). This is how the <Servo.h> library works, but yours is acting just the opposite. I looked at your code compared to the other library but can't see why it's behaving this way. Have you run into this?

Add support for 8A

Replace this

TIMSK2 = 0; // disable interrupts TCCR2A = 0; // normal counting mode TCCR2B = _BV(CS21); // set prescaler of 8 TCNT2 = 0; // clear the timer2 count TIFR2 = _BV(TOV2); // clear pending interrupts; TIMSK2 = _BV(TOIE2) ; // enable the overflow interrupt

With this
`#if defined (AVR_ATmega8) || defined (AVR_ATmega8A)

TIMSK = 0;  // disable interrupts 
bitClear(TCCR2,WGM20);
bitClear(TCCR2,WGM21);
TCCR2 = _BV(CS21);
TCNT2 = 0;      // clear the timer2 count 
TIFR = _BV(TOV2);
TIMSK =  _BV(TOIE2) ; // enable the overflow interrupt	  

#else
TIMSK2 = 0; // disable interrupts
TCCR2A = 0; // normal counting mode
TCCR2B = _BV(CS21); // set prescaler of 8
TCNT2 = 0; // clear the timer2 count
TIFR2 = _BV(TOV2); // clear pending interrupts;
TIMSK2 = _BV(TOIE2) ; // enable the overflow interrupt
#endif
`
This is a noob code :) It will need a proper coding

Conflict with tinyGPS++ (still)

Using a SG90 servo with this library and tinyGPS++, I still get jitter and erratic motor movement. As so as I add the gps begin, the motion of the motor no longer works correctly, mainly it moves back and forth and is not smooth. I take out the begin and the motor works fine. This is on a Elegoo UNO R3.

Any suggestions? I can add movie if necessary of motor action.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.