PWMServo examples compile failure

Status
Not open for further replies.
I just received the Teensy 3.1 (so far I love that stuff compared to the Uno I used before)
Win 8.1 x64
Arduino IDE: 1.6.0
latest Beta package for teensyduino (installed yesterday) likely 1.21-beta-6
no specific anti-virus package besides the standard stuff coming from Windows. (windows defender).

Building blink for instance works without problems. Same for the RTC samples.
But the PWMServo samples, knob and sweep fail to compile.
They get stuck in "comp[iling sketch". with the progress bar about 1/3 in. Verbose output below.

Code:
Build options changed, rebuilding all
Using library PWMServo in folder: E:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\PWMServo (legacy)

E:\Program Files (x86)\Arduino/hardware/tools/arm/bin/arm-none-eabi-g++ -c -g -Os -Wall -ffunction-sections -fdata-sections -MMD -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -D__MK20DX256__ -DTEENSYDUINO=121 -DARDUINO=10600 -DF_CPU=24000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IE:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3 -IE:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\PWMServo C:\Users\Thierry\AppData\Local\Temp\build4817677075450476343.tmp\Knob.cpp -o C:\Users\Thierry\AppData\Local\Temp\build4817677075450476343.tmp\Knob.cpp.o 
E:\Program Files (x86)\Arduino/hardware/tools/arm/bin/arm-none-eabi-g++ -c -g -Os -Wall -ffunction-sections -fdata-sections -MMD -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -D__MK20DX256__ -DTEENSYDUINO=121 -DARDUINO=10600 -DF_CPU=24000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IE:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3 -IE:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\PWMServo -IE:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\PWMServo\utility E:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\PWMServo\PWMServo.cpp -o C:\Users\Thierry\AppData\Local\Temp\build4817677075450476343.tmp\PWMServo\PWMServo.cpp.o 
E:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\PWMServo\PWMServo.cpp: In static member function 'static void PWMServo::seizeTimer1()':
I can see the following happening:
arm-none-eabi-g++.exe is still running and so is cc1plus.exe
So compilation is "in progress" (and not making progress).

I'll attach the content of the temp folder created by the build process View attachment build4817677075450476343.tmp.zip. (knob was the sketch I tried, no modifications.) as a zip file. It shows the output file (knob.cpp.o) and the .d file (symbols) created (at least partially).
The buildprefs.txt file in the temp folder is
Code:
build.arch = AVR
build.board = TEENSY31
build.command.ar = arm-none-eabi-ar
build.command.g++ = arm-none-eabi-g++
build.command.gcc = arm-none-eabi-gcc
build.command.objcopy = arm-none-eabi-objcopy
build.command.objdump = arm-none-eabi-objdump
build.command.size = arm-none-eabi-size
build.core = teensy3
build.core.path = E:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3
build.fcpu = 24000000
build.flags.S = -x assembler-with-cpp
build.flags.c = 
build.flags.common = -g -Os -Wall -ffunction-sections -fdata-sections -MMD -nostdlib
build.flags.cpp = -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti
build.flags.cpu = -mthumb -mcpu=cortex-m4
build.flags.defs = -D__MK20DX256__ -DTEENSYDUINO=121
build.flags.ld = -Os -Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} --specs=nano.specs "-T{build.core.path}/mk20dx256.ld"
build.flags.libs = -larm_cortexM4l_math -lm
build.keylayout = US_ENGLISH
build.mcu = mk20dx256
build.path = C:\Users\Thierry\AppData\Local\Temp\build4817677075450476343.tmp
build.project_name = Knob.cpp
build.system.path = E:\Program Files (x86)\Arduino\hardware\teensy\avr\system
build.toolchain = hardware/tools/arm/bin/
build.usbtype = USB_SERIAL
build.variant.path = 
build.verbose = true
build.warn_data_percentage = 75
compiler.elf2hex.flags = -O ihex -R .eeprom
compiler.objcopy.eep.flags = -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.path = {runtime.ide.path}/

I tried the pwmservo library from the prjc.com site directly, without any difference.
I tried running the arduino IDE as an administrator (no difference).
I (of course) killed the compiler(s) processes, deleted the temp folders, restarted an arduino IDE... These sketches still fail, while other sketches have no problems compiling. So I'm out of ideas here and I would appreciate any help.

My project is mostly an animatronic project: make a plastic 'realistic' owl move (2 servos) somewhat randomely, make some owl noise (audio DAC library + a small amp circuit I'll build) particularly around sunset for an hour or two (so using the RTC library). A woodpecker scaring device basically :) (eventually with a small solar panel, charging circuit, temperature control for the batteries...)
 
Adding the pwmservo example folder I'm trying to build (so someone could diff the files maybe).
View attachment PWMServo.zip

Note that I've the arduino (and therefore teensyduino) installed in e:\Program Files(x86)\Arduino
i.e. not on the default C:\ drive.
But even complex samples like the audio samples build without problems. So something is specific to PWMServo.
thx
 
Do you have a sample somewhere of something similar you ported? I might be able to do it myself and contribute the changes if I get some info on where to start.
thx
 
This library uses AVR registers.

An alternative library to look at, might be PulsePosition
 
Doing my own answers...
- no time/knowledge to mess up with the pwm servo code to adapt it to the timers used by the Teensy 3.1
- but the PulsePosition library should do what I want. Only I haven't been really successful: the servo gets some signal, but changes from 1.0 to 2.0ms do not seem to do anything: the servo is driven to one extreme direction and stays there.

Here is my code (serial stuff was to make sure the values were changing well. Starts at 1500 micro seconds (so 1.5ms, should be center), then go to 2ms, then back to 1ms adn so forth. So a sweep.
Code:
#include <PulsePosition.h>

PulsePositionOutput myOut;
bool increment = true;
float microSeconds = 1500.0f;
const int steppingAmount = 100;

void setup() {
  //  Serial.begin(9600); // USB is always 12 Mbit/sec
  myOut.begin(9); // Tx PIN is 9 Can be  5, 6, 9, 10, 20, 21, 22, or 23
}


void loop() {
  //  Serial.print("microSeconds = ");
  //  Serial.println(microSeconds);

  // set the new ppm signal value
  myOut.write(1, microSeconds);

  // a servo takes 1.5 milli seconds as center, and 1ms to 2ms max for its signal.
  // so that's a range of 1000-2000 micro seconds.
  if (microSeconds >= 2000.0f || microSeconds <= 1000.0f)
  {
    // reverse the direction
    increment = !increment;
  }
  if (increment == true)
  {
    microSeconds += steppingAmount;
  }
  else
  {
    microSeconds -= steppingAmount;
  }
  delay(250); // wait
}
I tried with various cpu speed from 24MHz to 96MHz, in case that would influence the timing.
I'm taking the possibility of a bug in my code very seriously. Either that, or I need a 3V to 5V logic shifter - or make something with a transistor, to have a 5V signal instead of 3.3V the servo might not 'get'.
 
The Servo library does use the PDB timer, which is also used by parts of the Audio library. If you use both, you might get a conflict. Maybe?

Let me know if you do. Those 2 are a pair I really want to be able to work together. I have some ideas there....
 
using servo.h and the audio library doesn't work.
this
Code:
AudioOutputAnalog        dac1;
is what makes the servo not work. i.e. the sketch compiles and load just fine. No errors are generated, but at least with
Code:
  myservo.attach(9);
the servo will not move.
The includes were not a problem (so just including the library is not a problem).

Any suggestion to get:
- audio working (I'm hoping for dac1) so I can play a decent mono sound. (16 bits 44.1KHz would be awesome). (making my owl play some real owl sounds). I plan to build at least a poor man's SD card adapter* to use for the audio sounds. (right now I tested using sweep and some headphones).
- a couple of servos working at the same time. (moving the body and head of my plastic owl)

I do not need to get control a servo and play a sound at the same time, but I need to be playing a sound and controlling some servos in the same sketch, hopefully without too much of a wait in-between.

Thanks!
Thierry

* soldering the wires from the teensy to a microSD card adapter, so I can then insert a micro-SD card in that adapter.
 
to clarify, the servo library is supposed to work with pins 9 or 10 only. I tried with both. Enabling the DAC pin disables both pins 9 and 10 - at least as far as servo.h is concerned.
 
I meant 12 bits. i.e. the max that the native DAC can do. But honestly even 8 bits would likely be decent enough. and 22 kHz would also work.
For now, getting the servos code and audio code working together is my priority :)
thanks.
 
Yeah, both Servo and AudioOutputAnalog are using the PDB timer.

I recently edited Servo to use the LPTMR on Teensy-LC, because the smaller chip doesn't have the PDB timer. This new Servo is in 1.21-beta7. Probably the easiest path forward would be trying to use the LPTMR-based code on Teensy 3.1. In theory, this should just involve editing Servo.cpp, either edit the #ifdef lines to use the Teensy-LC code on Teensy 3.1, or just delete the AVR and PDB based code.

Also, the Servo library can attach to any digital pin. Up to 12 pins can be used simultaneously. Many years ago, ancient versions of Servo were limited to only pins 9 and 10. Michael Margolis rewrote the Servo library in 2009 to remove those limitations. I believe Michael's version replaced the old Servo library in Arduino around version 0017 or 0018.
 
Thanks, I'll go find the latest beta you have, install it and try to force it to use the Teensy-LC code. I'll report the findings here :)
Thanks.
 
ok, the latest works. I didn't try to figure out what the right defines were, and deleted all but the Teensy-LC code.
I can now get audio and servo working. i.e. one line might play an audio sweep, and another line can set a servo position. :)
Now on to building...
 
Great news.

I hope you'll post some photos or a youtube video when it's build. Sounds like it'll be a really fun project.
 
Hello
Im having a problem with;
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 + Td: 1.21-test2 (Windows 7), Board: "Teensy 3.1"
arm-none-eabi-g++: error: Button.cpp: No such file or directory
arm-none-eabi-g++: fatal error: no input files
compilation terminated.

any tips ?

Mike
 
so I am new to this programming - Is the problem in library location ?
and this;
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 + Td: 1.21-test2 (Windows 7), Board: "Teensy 3.1"
In file included from Screensaver.h:8:0,
from ReflowChateau.ino:15:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:47:7: error: redefinition of 'class TS_Point'
class TS_Point {
^
In file included from SplashScreen.h:8:0,
from ReflowChateau.ino:14:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:47:7: error: previous definition of 'class TS_Point'
class TS_Point {
^
In file included from Screensaver.h:8:0,
from ReflowChateau.ino:15:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:58:7: error: redefinition of 'class Adafruit_FT6206'
class Adafruit_FT6206 {
^
In file included from SplashScreen.h:8:0,
from ReflowChateau.ino:14:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:58:7: error: previous definition of 'class Adafruit_FT6206'
class Adafruit_FT6206 {
^
In file included from Button.h:8:0,
from ReflowChateau.ino:16:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:47:7: error: redefinition of 'class TS_Point'
class TS_Point {
^
In file included from SplashScreen.h:8:0,
from ReflowChateau.ino:14:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:47:7: error: previous definition of 'class TS_Point'
class TS_Point {
^
In file included from Button.h:8:0,
from ReflowChateau.ino:16:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:58:7: error: redefinition of 'class Adafruit_FT6206'
class Adafruit_FT6206 {
^
In file included from SplashScreen.h:8:0,
from ReflowChateau.ino:14:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:58:7: error: previous definition of 'class Adafruit_FT6206'
class Adafruit_FT6206 {
^
In file included from Graph.h:8:0,
from ReflowChateau.ino:17:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:47:7: error: redefinition of 'class TS_Point'
class TS_Point {
^
In file included from SplashScreen.h:8:0,
from ReflowChateau.ino:14:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:47:7: error: previous definition of 'class TS_Point'
class TS_Point {
^
In file included from Graph.h:8:0,
from ReflowChateau.ino:17:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:58:7: error: redefinition of 'class Adafruit_FT6206'
class Adafruit_FT6206 {
^
In file included from SplashScreen.h:8:0,
from ReflowChateau.ino:14:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:58:7: error: previous definition of 'class Adafruit_FT6206'
class Adafruit_FT6206 {
^
In file included from Setting.h:8:0,
from ReflowChateau.ino:18:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:47:7: error: redefinition of 'class TS_Point'
class TS_Point {
^
In file included from SplashScreen.h:8:0,
from ReflowChateau.ino:14:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:47:7: error: previous definition of 'class TS_Point'
class TS_Point {
^
In file included from Setting.h:8:0,
from ReflowChateau.ino:18:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:58:7: error: redefinition of 'class Adafruit_FT6206'
class Adafruit_FT6206 {
^
In file included from SplashScreen.h:8:0,
from ReflowChateau.ino:14:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:58:7: error: previous definition of 'class Adafruit_FT6206'
class Adafruit_FT6206 {
^
In file included from ReflowChateau.ino:20:0:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:47:7: error: redefinition of 'class TS_Point'
class TS_Point {
^
In file included from SplashScreen.h:8:0,
from ReflowChateau.ino:14:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:47:7: error: previous definition of 'class TS_Point'
class TS_Point {
^
In file included from ReflowChateau.ino:20:0:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:58:7: error: redefinition of 'class Adafruit_FT6206'
class Adafruit_FT6206 {
^
In file included from SplashScreen.h:8:0,
from ReflowChateau.ino:14:
C:\Users\MIKE\Documents\Arduino\ReflowChateau\libraries\Adafruit_FT6206/Adafruit_FT6206.h:58:7: error: previous definition of 'class Adafruit_FT6206'
class Adafruit_FT6206 {
^

Or where did I make mistake ?
Mike
 
I'm not sure about your problems, but you seem to be including the same header file (.h) multiple times.
I'm not clear that this would be related to the original thread problems, so I would recommend:
- start a new thread
- post your entire .ino file I believe this is something asked for all posts like that. (i my case, I was building some sample code).
- and of course the verbose output you have here too.

PWMServo was still not fixed, so in case you are trying to use it, try to see if you can use Servo instead.
 
Hi Paul, thanks for the update. How much is the frame rate of PWMServo ? Is there a way to set it to a certain value in the range of 20-400Hz ?

best regards Andi
 
Status
Not open for further replies.
Back
Top