1/16 Elefant Ludwig/Asiatam

This section is for builds that are not strictly Tamiya or Heng Long. For instance, replacing the electronics from a WSN or Matorro, or even a scratch-build.
User avatar
xrad
Warrant Officer 2nd Class
Posts: 1075
Joined: Tue Aug 18, 2009 2:15 am
Location: Ohio, USA

Re: 1/16 Elefant Ludwig/Asiatam

Post by xrad »

Code for engine sounds almost done. Got through the tough spot! :)
User avatar
c.rainford73
Major
Posts: 6104
Joined: Thu Aug 25, 2016 7:34 pm
Location: Connecticut USA

Re: 1/16 Elefant Ludwig/Asiatam

Post by c.rainford73 »

It's amazing the clarity and crisp sounding effects you have achieved. Well done.
Tanks alot.... :wave:
User avatar
xrad
Warrant Officer 2nd Class
Posts: 1075
Joined: Tue Aug 18, 2009 2:15 am
Location: Ohio, USA

Re: 1/16 Elefant Ludwig/Asiatam

Post by xrad »

Thx CRainford. These are just practice files. I will clean them up for the final version. For those of you interested in the code, I used a boolean state (true/ false) but in this case with 1 and 0. As you enter the PWM case for certain throttle stick positions, you initialize the command once (this was the first problem to solve), and then when you leave that particular case, the bool for the initial case is reset by the next case. As well as resetting the bool to T or F, the wav tracks have to loop-play-fade-stop appropriately. So it looks something like this (not the best solution but it works for my needs):

Code: Select all

case 0:

bool maxrpm = 0

//in the loop
// so for case 0, track 12 is the max rpm sound wav (planned engine tracks to be 1-12)
// and accel 5 would be track 11 (or whatever, but in some ordered structure)
// etc.....

    case 0:
   
      Serial.print("MAX RPM");
      digitalWrite(WAV2, HIGH); // not necessary, just for testing stick location w LED
      if (maxrpm == 0) {
        tsunami.trackLoop(12, 1);
        tsunami.trackPlayPoly(12, 0, true);     
        maxrpm = 1; // allows only ONE loop play on the wav track  even if stick held in same position
      }
      break;

    case 1:
    
      Serial.print("ACCEL5");
      tsunami.trackStop(12);       
      if (maxrpm = = 1) {
        maxrpm = 0;  // this resets the bool to allow case 0 to trigger again
      }
      break; 
User avatar
xrad
Warrant Officer 2nd Class
Posts: 1075
Joined: Tue Aug 18, 2009 2:15 am
Location: Ohio, USA

Re: 1/16 Elefant Ludwig/Asiatam

Post by xrad »

Well, I got to a point where I can't go any further due to insufficient experience with coding. I really need bit counting to run the Tsunami at it's best and to decode the sbus input. Without byte code, using the sbus to PWM decode method has reached its limits in my program. The problem is that everything works just fine, but due to very short transitions from one PWM duration to the next, some parts of the serial commands to the Tsunami get lost. So I am currently teaming up with Open Panzer to create some cool tank sounds. You will need a Teensy 3.2, some type of sound board, and a way to read your Rx signals either through sBus or direct pin inputs, Teensy downloader program, Tsunami library, and arduino IDE. My code is pretty simple so any of you who want to mess around with it feel free. Tsunami files already set for Teensy serial out 1. You could easily adapt it to do other things with Tx Rx. My next electronic project should be pretty cool, a hand held lidar room scanner with display screen (if it ever gets off the drawing board). More to come on the Elefant build!

Code: Select all


#include <Tsunami.h>

Tsunami tsunami;

//these are all the PWM pin inputs from the RMILEC sBus decoder
//pin #s do not necessarily correlate with RC Tx channels
//but kept in order from 1-16 w/RMILEC pin outs to Teensy pin in's
#define PWM1 2
#define PWM2 3 //engine throttle stick input
#define PWM3 4
#define PWM4 5
#define PWM5 6// CANFIRE
#define PWM6 7// MGFIRE

// none of these are necessary, just for testing
#define WAV1 14
#define WAV2 15//Engine rpm sounds
#define WAV3 16
#define WAV4 17
#define WAV5 18// CANFIRE
#define WAV6 19// MGFIRE

const int durationMin = 1000;
const int durationMax = 1950;
unsigned long duration;

unsigned long engineIdleTime;
unsigned long engineIdle = 5;
unsigned long MGFireTime;
unsigned long MGDelayTime = 250;
unsigned long reloadTime = 3000;
unsigned long startMillis;
unsigned long currentMillis;

bool runTimeA = 0;
bool runTimeB = 0;
bool runTimeC = 0;
bool runTimeD = 0;
bool runTimeE = 0;
bool runTimeF = 0;
bool runTimeG = 0;
bool runTimeH = 0;
bool runTimeI = 0;

void setup()
{
  Serial.begin(57600);

  tsunami.start();
  delay(10);
  tsunami.stopAllTracks();

  startMillis = millis();

  //each PWM channel is assigned to one pin input
  //pin #s do not necessarily correlate with RC Tx channels
  //but kept in order from 1-16 w/RMILEC pin outs
  pinMode(PWM1, INPUT);
  pinMode(PWM2, INPUT);
  pinMode(PWM3, INPUT);
  pinMode(PWM4, INPUT);
  pinMode(PWM5, INPUT);
  pinMode(PWM6, INPUT);

  //none of these are necessary, just for testing
  pinMode(WAV1, OUTPUT);
  pinMode(WAV2, OUTPUT);
  pinMode(WAV3, OUTPUT);
  pinMode(WAV4, OUTPUT);
  pinMode(WAV5, OUTPUT);
  pinMode(WAV6, OUTPUT);
}

void loop() {

  currentMillis = millis();

  duration = pulseIn(PWM1, HIGH);
  Serial.print ("PWM1  ");
  Serial.print (duration);
  digitalWrite(WAV2, LOW);

  duration = pulseIn(PWM2, HIGH);
  Serial.print ("\tPWM2  ");
  int range = map(duration, durationMin, durationMax, 0, 8);

  switch (range) {
    
    case 0:
      Serial.print("ACCEL4");
      digitalWrite(WAV2, HIGH);
      tsunami.trackStop(1);
      tsunami.trackStop(2);
      tsunami.trackStop(3);
      tsunami.trackStop(10);


      if (runTimeA == 0) {
        tsunami.trackLoop(4, 1);
        tsunami.trackPlayPoly(4, 0, true);
        runTimeA = 1;

        if (runTimeB == 1) {
          runTimeB = 0;
       }
      }
      break;

    case 1:
      Serial.print("ACCEL3");
      tsunami.trackStop(4);
      tsunami.trackStop(2);

      if (runTimeB == 0) {
        tsunami.trackLoop(3, 1);
        tsunami.trackPlayPoly(3, 0, true);
        runTimeB = 1;

        if (runTimeA == 1) {
          runTimeA = 0;

          if (runTimeC == 1) {
            runTimeC = 0;
          }
        }
      }
      break;

    case 2:
      Serial.print("ACCEL2");
      tsunami.trackStop(3);
      tsunami.trackStop(1);


      if (runTimeC == 0) {
        tsunami.trackLoop(2, 1);
        tsunami.trackPlayPoly(2, 0, true);
        runTimeC = 1;

        if (runTimeB == 1) {
          runTimeB = 0;

          if (runTimeD == 1) {
            runTimeD = 0;
          }
        }
      }

      break;

    case 3:
      Serial.print("ACCEL1");
      tsunami.trackStop(2);
      tsunami.trackStop(10);

      if (runTimeD == 0) {
        tsunami.trackLoop(1, 1);
        tsunami.trackPlayPoly(1, 0, true);
        runTimeD = 1;

        if (runTimeC == 1) {
          runTimeC = 0;

          if (runTimeE == 1) {
            runTimeE = 0;
          }
        }
      }

      break;

    case 4:
      Serial.print("IDLE");
      tsunami.trackStop(1);
      tsunami.trackStop(2);
      tsunami.trackStop(3);
      tsunami.trackStop(4);



      if (runTimeE == 0) {
        tsunami.trackLoop(10, 1);
        tsunami.trackPlayPoly(10, 0, true);
        runTimeE = 1;

        if (runTimeD == 1) {
          runTimeD = 0;

          if (runTimeF == 1) {
            runTimeF = 0;
          }
        }
      }

      break;

    case 5:
      Serial.print("ACCEL1");
      tsunami.trackStop(10);
      tsunami.trackStop(2);

      if (runTimeF == 0) {
        tsunami.trackLoop(1, 1);
        tsunami.trackPlayPoly(1, 0, true);
        runTimeF = 1;

        if (runTimeE == 1) {
          runTimeE = 0;

          if (runTimeG == 1) {
            runTimeG = 0;
          }
        }
      }
      break;

    case 6:
      Serial.print("ACCEL2");
      tsunami.trackStop(1);
      tsunami.trackStop(3);

      if (runTimeG == 0) {
        tsunami.trackLoop(2, 1);
        tsunami.trackPlayPoly(2, 0, true);
        runTimeG = 1;

        if (runTimeF == 1) {
          runTimeF = 0;

          if (runTimeH == 1) {
            runTimeH = 0;
          }
        }
      }
      break;



    case 7:
      Serial.print("ACCEL3");

      tsunami.trackStop(2);
      tsunami.trackStop(4);

      if (runTimeH == 0) {
        tsunami.trackLoop(3, 1);
        tsunami.trackPlayPoly(3, 0, true);
        runTimeH = 1;

        if (runTimeG == 1) {
          runTimeG = 0;

          if (runTimeI == 1) {
            runTimeI = 0;
          }
        }
      }
      break;

    case 8:
      Serial.print("ACCEL4");
      tsunami.trackStop(1);
      tsunami.trackStop(2);
      tsunami.trackStop(3);
      tsunami.trackStop(10);


      if (runTimeI == 0) {
        tsunami.trackLoop(4, 1);
        tsunami.trackPlayPoly(4, 0, true);
        runTimeI = 1;

        if (runTimeH == 1) {
          runTimeH = 0;
       }
      }
      break;
  }


  duration = pulseIn(PWM3, HIGH);
  Serial.print ("\tPWM3  ");
  Serial.print (duration);


  duration = pulseIn(PWM4, HIGH);
  Serial.print ("\tPWM4  ");
  Serial.print (duration);


  duration = pulseIn(PWM5, HIGH);
  Serial.print ("\tPWM5  ");
  if (currentMillis - startMillis < reloadTime) {
    Serial.print("RELOAD");
    digitalWrite(WAV5, LOW);
  }
  else if (duration >= 1800) {
    startMillis = currentMillis;
    Serial.print("CANFIRE");
    digitalWrite(WAV5, HIGH);
    delay(5);
    tsunami.trackPlayPoly(19, 0, true);

  }
  else if (duration <= 1799)
  {
    Serial.print(duration);
    digitalWrite(WAV5, LOW);
  }

  duration = pulseIn(PWM6, HIGH);
  Serial.print ("\tPWM6  ");

  if  (currentMillis - MGFireTime > MGDelayTime) {
    tsunami.trackStop(20);

    if (duration > 1800) {
      MGFireTime = currentMillis;
      tsunami.trackPlayPoly(20, 0, true);
      tsunami.trackLoop(20, true);
      digitalWrite(WAV6, HIGH);
      Serial.println("MGFIRE");
    }
  }

  else (duration < 1799);{
    digitalWrite(WAV6, LOW);
    Serial.println(duration);
  }
}


User avatar
SteelBird
Corporal
Posts: 382
Joined: Sun Nov 15, 2015 7:03 am

Re: 1/16 Elefant Ludwig/Asiatam

Post by SteelBird »

xrad wrote:Thx Soeren. Here is convoy light in blue. 5mm LED heat shrink tube to aluminum tube holding the fiber. Luckily, it fit into body without hitting the subwoofer. The LED is plenty bright. I polished the inside ends of the fishing line w/1500 grit, but it was old poor quality line and not very reflective internally. But, I think it's scale brightness (in other words, dim).

I added some pics of the other convoy lights I made for other tanks on this site.
Hi, where did you get the convoy light?
H/L Pantiger, H/L Leopard 2A6, Mato Panzer III, Hybrid Tiger 1 and some tank wreckage
User avatar
c.rainford73
Major
Posts: 6104
Joined: Thu Aug 25, 2016 7:34 pm
Location: Connecticut USA

Re: 1/16 Elefant Ludwig/Asiatam

Post by c.rainford73 »

Tanks alot.... :wave:
User avatar
c.rainford73
Major
Posts: 6104
Joined: Thu Aug 25, 2016 7:34 pm
Location: Connecticut USA

Re: 1/16 Elefant Ludwig/Asiatam

Post by c.rainford73 »

He made it
Tanks alot.... :wave:
User avatar
xrad
Warrant Officer 2nd Class
Posts: 1075
Joined: Tue Aug 18, 2009 2:15 am
Location: Ohio, USA

Re: 1/16 Elefant Ludwig/Asiatam

Post by xrad »

Sorry, been busy. Hope to get the final elefant sounds for OPTCB sound board squared away in a few weeks. Yes, I make most of my Elefant parts. I put it on thingiverse near bottom of list. You will have to size it a bit for your needs:

https://www.thingiverse.com/thing:2993799/files
Post Reply

Return to “Other Builds”