‹ f08ch f0neo ›

f0led

2017-05-14 12:43 electronics

Here is another project built around the ESP8266. It's a wireless OSC controlled 100W led. As the led should act as a stroboscope and not be kept on for long durations of time, I could save space and cost using a smaller sized heatsink. Via WiFi and OSC (Open Sound Control) the led can be turned on/off, the level, attack and release times adjusted etc. There is also a push-button trigger input as well as a microphone input. So the strobe can be either triggered manually by the musician, by the sound of the nearby instrument or remotely by a computer.

The strobe also sends out OSC data from the button and mic so it can, in turn, be used to trigger additional sounds in the computer.

SuperCollider example code...

OSCFunc.trace(true)
OSCFunc.trace(false)

n= NetAddr("192.168.1.10", 15555);
n.sendMsg(\led, 0.5, 0.1);  //val, fade
n.sendMsg(\led, 0.0, 0.01);  //val, fade
n.sendMsg(\micMode, 1);  //mic on/off
n.sendMsg(\micFade, 1.0, 0.1);  //mic atk rel
n.sendMsg(\butFade, 1.0, 0.1);  //but atk rel

OSCdef(\oscin, {|msg| msg.postln}, \f0led, NetAddr("192.168.1.10", 15555));
first f0led test setup
first f0led test setup
first f0led test setup

The battery is a 12V sealed lead-acid and I measured up toward 8A current draw. It weights about 0.5Kg.

f0led circuit schematics
f0led circuit schematics
f0led circuit schematics

Bill of material...

1 ESP8266-01
1 4x2 socket
1 heatsink
2 100uF cap
1 100 resistor
1 10K resistor
1 10K log pot (Reichelt ACP 6-L 10K)
1 regulator (Reichelt LF 33 CV)
1 MOSFET (Reichelt IRLZ 34N)
1 mic (Reichelt MCE 101)
4 screwterminals (Reichelt AKL 101-02)
1 12V lead-acid (pollin 94‑271194)
1 heatsink (ebay 2.4x2.4inch Aluminum Alloy Heat Sink for 1W/3W/5W/10W LED Silver White)
1 DCDC (ebay "DC DC boost converter Constant Current Mobile Power supply 250W")
1 100W led (ebay 100W Cool White High Power LED LIGHT SMD chip Panel 9000-10000LM)
thick wires
heat paste
screws and nuts

Arduino code...

// * install OSC from https://github.com/CNMAT/OSC
// * edit where it says EDIT below
// * choose board: "Generic ESP8266 Module" 160 MHz

//TODO: gamma correction

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <OSCMessage.h>
#include <OSCData.h>

//pin3 (URXD) can do PWM out
//pin2 and pin0 can not do PWM
//pin2 and pin0 have to be 3V3 at powerup

#define ID 10  //EDIT device id (also static ip)
#define PINMIC 0
#define PINBUT 2
#define PINPWM 3
#define PORT 15555
#define UPDATERATE 16
#define TRIES 100  //how many times try check for wifi connection at startup
#define PINGRATE 600
#define STATICIP 1  //optional - 0 or 1

const char *ssid = "mywlan";  //EDIT your accessPoint network name
const char *password = "mypass123";  //EDIT your password
const char *espname = "f0led";
const unsigned int outPort = 57120;
#if STATICIP==1
IPAddress ip(192, 168, 1, ID);  //EDIT optional static ip
IPAddress gateway(192, 168, 1, 1);  //EDIT optional router
IPAddress subnet(255, 255, 255, 0);
#endif
float micFadeAtk = 1.0, micFadeRel = 0.1;  //default fade times
float butFadeAtk = 1.0, butFadeRel = 0.1;  //default fade times
float val = 0.0, valTarget = 0.0, fade = 1.0;
unsigned long nextTime;
byte micMode = 0;  //allow mic trigger led on/off
byte micState = 1;
byte butState = 1;
int cnt;
IPAddress outIp;
WiFiUDP Udp;
OSCMessage msgPing("/f0led");
OSCMessage msgMic("/f0led");

void setup() {
  delay(10);
  WiFi.mode(WIFI_STA);
  WiFi.hostname(espname);
  WiFi.begin(ssid, password);
#if STATICIP==1
  WiFi.config(ip, gateway, subnet);
#endif
  cnt = 0;
  while ((WiFi.status() != WL_CONNECTED) && (cnt < TRIES)) {
    delay(100);
    cnt++;
  }
  outIp = WiFi.localIP();
  outIp[3] = 99;  //send to ip x.x.x.99 on same network (e.g. 192.168.1.99)
  Udp.begin(PORT);
  Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
  pinMode(PINMIC, INPUT);
  pinMode(PINBUT, INPUT_PULLUP);
  pinMode(PINPWM, OUTPUT);
  msgMic.add(ID);
  msgMic.add("mic");
  msgPing.add(ID);
  msgPing.add("ping");
}

void oscLed(OSCMessage &msg) {
  valTarget = msg.getFloat(0);
  fade = msg.getFloat(1);
}
void oscMicMode(OSCMessage &msg) {
  micMode = msg.getInt(0);
}
void oscMicFade(OSCMessage &msg) {
  micFadeAtk = msg.getFloat(0);
  micFadeRel = msg.getFloat(1);
}
void oscButFade(OSCMessage &msg) {
  butFadeAtk = msg.getFloat(0);
  butFadeRel = msg.getFloat(1);
}
void sendOscBut(byte val) {
  OSCMessage msg("/f0led");
  msg.add(ID);
  msg.add("but");
  msg.add(val);
  Udp.beginPacket(outIp, outPort);
  msg.send(Udp);
  Udp.endPacket();
  msg.empty();
}
void sendOscMic() {
  Udp.beginPacket(outIp, outPort);
  msgMic.send(Udp);
  Udp.endPacket();
}
void sendOscPing() {
  Udp.beginPacket(outIp, outPort);
  msgPing.send(Udp);
  Udp.endPacket();
}

void loop() {

  //--OSC input
  int packetSize = Udp.parsePacket();
  if (packetSize) {
    OSCMessage oscMsg;
    while (packetSize--) {
      oscMsg.fill(Udp.read());
    }
    if (!oscMsg.hasError()) {
      oscMsg.dispatch("/led", oscLed);
      oscMsg.dispatch("/micMode", oscMicMode);
      oscMsg.dispatch("/micFade", oscMicFade);
      oscMsg.dispatch("/butFade", oscButFade);
    }
  }

  //--mic input
  if (digitalRead(PINMIC) == 0) {
    if (micState == 0) {
      micState = 1;
    }
  }

  if (millis() >= nextTime) {
    nextTime = millis() + UPDATERATE;
    if (cnt % PINGRATE == 0) {
      sendOscPing();
    }
    cnt++;

    //--mic input2
    if (micState == 1) {
      micState = 2;
      sendOscMic();
      if (micMode == 1) {
        valTarget = 1.0;
        fade = micFadeAtk;
      }
    } else if (micState == 2) {
      if (digitalRead(PINMIC) == 1) {
        valTarget = 0.0;
        fade = micFadeRel;
        micState = 0;
      }
    }

    //--button input
    if (digitalRead(PINBUT) == 0) {
      if (butState == 0) {
        butState = 1;
        sendOscBut(1);
        valTarget = 1.0;
        fade = butFadeAtk;
      }
    } else {
      if (butState == 1) {
        butState = 0;
        sendOscBut(0);
        valTarget = 0.0;
        fade = butFadeRel;
      }
    }

    //--fade in/out
    if (val < valTarget) {
      val = val + fade;
      if (val > valTarget) {
        val = valTarget;
      }
    } else if (val > valTarget) {
      val = val - fade;
      if (val < valTarget) {
        val = valTarget;
      }
    }

    analogWrite(PINPWM, int(val * 1023));
  }
}
finished f0led box
finished f0led box
finished f0led box
f0led circuit board
f0led circuit board
f0led circuit board

Updates:

Attachments:


‹ f08ch f0neo ›