Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
REVIEW Inverting output in NRZ to SK6812 (inverting optoc)
#1
Lightbulb 
I would like to use the 6N137 optocoupler to interface from ESP32 to SK6812 LEDs on one strip.

Page 5, figure 5 would be similar to what I was thinking about.

The 6N137 is inverting and I don't want to shunt the input. I would like to invert the output, hence the signal would be transmitted in inverted NRZ to the optocoupler and would be correct on the output after isolation between the 3.3 and 5V sections of my board.

Yes, there are other optocouplers available with adequate spec's, but these are the ones I have at hand and usually use.

Would this modification to machine_neopixel.c be sufficient?

Code:
STATIC mp_obj_t machine_neopixel_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args)
{

// Lines 85 - 128 left out

   // Set defaults
   self->px.brightness = 255;
   sprintf(self->px.color_order, "GRBW");

    self->px.timings.mark.level0 = 1;                // 0 instead of 1
    self->px.timings.mark.level1 = 0;                // 1 instead of 0
    self->px.timings.space.level0 = 1;                // 0 instead of 1
    self->px.timings.space.level1 = 0;                // 1 instead of 0
    self->px.timings.reset.level0 = 0;                // 1 instead of 0
    self->px.timings.reset.level1 = 0;                // 1 instead of 0
    self->px.timings.mark.duration0 = 12;

   if (wstype == 1) {
       self->px.nbits = 32;
       self->px.timings.mark.duration1 = 12;
       self->px.timings.space.duration0 = 6;
       self->px.timings.space.duration1 = 18;
       self->px.timings.reset.duration0 = 900;
       self->px.timings.reset.duration1 = 900;
   }
   else {
       self->px.nbits = 24;
       self->px.timings.mark.duration1 = 14;
       self->px.timings.space.duration0 = 7;
       self->px.timings.space.duration1 = 16;
       self->px.timings.reset.duration0 = 600;
       self->px.timings.reset.duration1 = 600;
   }

   // Allocate buffers
   self->px.pixels = (uint8_t *)malloc((self->px.nbits/8) * self->px.pixel_count);
   if (self->px.pixels == NULL) goto error_exit;

   if (neopixel_init(pin, rmtchan) != ESP_OK) goto error_exit;

   self->base.type = &machine_neopixel_type;

    np_clear(&self->px);
    np_show(&self->px, self->channel);

   return MP_OBJ_FROM_PTR(self);

error_exit:
    platform_rmt_release(rmtchan);
    if (self->px.pixels) free(self->px.pixels);
    self->px.pixels = NULL;

   nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Error initializing Neopixel interface"));
    return mp_const_none;
}

Or is there a more efficient way to implement this in code?

I purposely didn't post this as an issue, because it's specific to the parts I have left over from an older project.

Thanks

Br

chMK
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)