Audio and ESC don't work together

Status
Not open for further replies.

18Turbo

New member
Hello everybody,

This is my first message in this forum. Sorry for my english.

I have a problem, but first, i use:

- Ubuntu 18.04
- Teensy 3.6
- ESC Tsky 120A (with DC engine)
- Ampli 2x4W (with speaker)

Libraries:
- Servo
- ESC
-

When I only use the ESC, the engine works.
When I only use the Audio (in DAC0), the music works.
If I use two WAVs in mixer (both in DAC0), the 2 music works together.

Code:
#include <Audio.h>
#include <Wire.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Servo.h>                                                          // Librería para controlar el ESC y los servos
#include "ESC.h"

ESC esc;

  // GUItool: begin automatically generated code
  AudioPlaySdWav           canal1;     //xy=262,142
  AudioPlaySdWav           canal2;     //xy=262,198
  AudioMixer4              mezclador;         //xy=544,256
  AudioOutputAnalogStereo  dacs1;          //xy=668,144
  AudioConnection          patchCord1(canal1, 0, mezclador, 0);
  AudioConnection          patchCord2(canal2, 0, mezclador, 1);
  AudioConnection          patchCord3(mezclador, 0, dacs1, 0);
  // GUItool: end automatically generated code


  #define SDCARD_CS2_PIN    43
  #define SDCARD_MISI2_PIN  44
  #define SDCARD_MISO2_PIN  45
  #define SDCARD_SCK2_PIN   46

void setup() 
{ 
    esc.attach(38);
    
} 
 
void loop() 
{ 
	for (int i=400; i<800; i=i+1)
    	{esc.setSpeed(i);
    		delay(10);}
}

But when I try to operate both at the same time, only the audio works.

If I commented the lines:

Code:
AudioPlaySdWav           canal1;     //xy=262,142
  AudioPlaySdWav           canal2;     //xy=262,198
  AudioMixer4              mezclador;         //xy=544,256
  AudioOutputAnalogStereo  dacs1;          //xy=668,144
  AudioConnection          patchCord1(canal1, 0, mezclador, 0);
  AudioConnection          patchCord2(canal2, 0, mezclador, 1);
  AudioConnection          patchCord3(mezclador, 0, dacs1, 0);

then the ESC works

Any ideas?

Thank you very much.
 

Wow!!

Thank you very much.

It works perfectly.

I use Platformio and Sublime Text (in Ubuntu 18.04 LTS), so I did:

First, in [home]/[user]/.platformio/packages/framework-arduinoteensy/libraries/Servo, and find servo.cpp, open and find this:

Code:
#elif defined(__arm__) && (defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__))
// ******************************************************************************
// Teensy 3.0 implementation, using Programmable Delay Block
// ******************************************************************************

so change it to this:

Code:
#elif 0
// ******************************************************************************
// Teensy 3.0 implementation, using Programmable Delay Block
// ***
***************************************************************************

Then find this:

Code:
#elif defined(__arm__) && defined(__MKL26Z64__)
// ******************************************************************************
// Teensy-LC implementation, using Low Power Timer
// ******************************************************************************

You do want to use LPTRM, so change it to this:

Code:
#elif 1
// ******************************************************************************
// Teensy-LC implementation, using Low Power Timer
// ******************************************************************************
 
Status
Not open for further replies.
Back
Top