Need help reading shift register via SPI









up vote
0
down vote

favorite
1












I am trying to decode the signals going to shift registers in my washing machine. The registers are STP16CPC05 which also happen to be LED drivers. I am trying to get status from my washing machine like time left, which cycle, check if its done, etc. with an ESP12. If I can read the signals going to the LED drivers, I can determine which bits are for which LED and then determine status in my program.



My first thought was to use a custom shiftin but I had no luck with that (and supposedly digitalread() is too slow anyway) and I was reading everywhere that I should "just use SPI" since it's faster. I have been able to successfully read the signals using a logic analyzer and even made a script for an arduino pro mini that emulates the register signals so that I can more easily debug my ESP12 without running the washer all day. Writing an SPI master is relatively easy but the slave is the hard part. Here is the code for the Arduino Pro mini so it can emulate the washer signals:



// SPI master code for Arduino Pro Mini "washing machine clone"

#include <SPI.h>


void setup (void)


SPI.begin ();

SPI.setClockDivider(SPI_CLOCK_DIV8);




void loop (void)

delayMicroseconds(200);
SPI.transfer(0x00); //00 00 11 01 08 01 08 02 02 00 00 0C 67 66 80
SPI.transfer(0x00);
SPI.transfer(0x11);
SPI.transfer(0x01);
SPI.transfer(0x08);
delayMicroseconds(180);
SPI.transfer(0x01);
SPI.transfer(0x08);
SPI.transfer(0x02);
SPI.transfer(0x02);
SPI.transfer(0x00);
delayMicroseconds(180);
SPI.transfer(0x00);
SPI.transfer(0x0C);
SPI.transfer(0x67);
SPI.transfer(0x66);
SPI.transfer(0x80);
delayMicroseconds(200);



enter image description here



Does anyone have any idea on how to make a simple SPI slave on esp? Or is there a better way to sniff this shift register bus? The clock signal is 1 MHZ so it isn't terribly fast. I only need to read 15 bytes at a time.



This was promising but it's been alot of work stripping it down to what I want: https://github.com/JiriBilek/WiFiSpi. I can get it to print out the data once but then I think it is having issues resetting the receive interrupt because it is expecting an interactive master.










share|improve this question



























    up vote
    0
    down vote

    favorite
    1












    I am trying to decode the signals going to shift registers in my washing machine. The registers are STP16CPC05 which also happen to be LED drivers. I am trying to get status from my washing machine like time left, which cycle, check if its done, etc. with an ESP12. If I can read the signals going to the LED drivers, I can determine which bits are for which LED and then determine status in my program.



    My first thought was to use a custom shiftin but I had no luck with that (and supposedly digitalread() is too slow anyway) and I was reading everywhere that I should "just use SPI" since it's faster. I have been able to successfully read the signals using a logic analyzer and even made a script for an arduino pro mini that emulates the register signals so that I can more easily debug my ESP12 without running the washer all day. Writing an SPI master is relatively easy but the slave is the hard part. Here is the code for the Arduino Pro mini so it can emulate the washer signals:



    // SPI master code for Arduino Pro Mini "washing machine clone"

    #include <SPI.h>


    void setup (void)


    SPI.begin ();

    SPI.setClockDivider(SPI_CLOCK_DIV8);




    void loop (void)

    delayMicroseconds(200);
    SPI.transfer(0x00); //00 00 11 01 08 01 08 02 02 00 00 0C 67 66 80
    SPI.transfer(0x00);
    SPI.transfer(0x11);
    SPI.transfer(0x01);
    SPI.transfer(0x08);
    delayMicroseconds(180);
    SPI.transfer(0x01);
    SPI.transfer(0x08);
    SPI.transfer(0x02);
    SPI.transfer(0x02);
    SPI.transfer(0x00);
    delayMicroseconds(180);
    SPI.transfer(0x00);
    SPI.transfer(0x0C);
    SPI.transfer(0x67);
    SPI.transfer(0x66);
    SPI.transfer(0x80);
    delayMicroseconds(200);



    enter image description here



    Does anyone have any idea on how to make a simple SPI slave on esp? Or is there a better way to sniff this shift register bus? The clock signal is 1 MHZ so it isn't terribly fast. I only need to read 15 bytes at a time.



    This was promising but it's been alot of work stripping it down to what I want: https://github.com/JiriBilek/WiFiSpi. I can get it to print out the data once but then I think it is having issues resetting the receive interrupt because it is expecting an interactive master.










    share|improve this question

























      up vote
      0
      down vote

      favorite
      1









      up vote
      0
      down vote

      favorite
      1






      1





      I am trying to decode the signals going to shift registers in my washing machine. The registers are STP16CPC05 which also happen to be LED drivers. I am trying to get status from my washing machine like time left, which cycle, check if its done, etc. with an ESP12. If I can read the signals going to the LED drivers, I can determine which bits are for which LED and then determine status in my program.



      My first thought was to use a custom shiftin but I had no luck with that (and supposedly digitalread() is too slow anyway) and I was reading everywhere that I should "just use SPI" since it's faster. I have been able to successfully read the signals using a logic analyzer and even made a script for an arduino pro mini that emulates the register signals so that I can more easily debug my ESP12 without running the washer all day. Writing an SPI master is relatively easy but the slave is the hard part. Here is the code for the Arduino Pro mini so it can emulate the washer signals:



      // SPI master code for Arduino Pro Mini "washing machine clone"

      #include <SPI.h>


      void setup (void)


      SPI.begin ();

      SPI.setClockDivider(SPI_CLOCK_DIV8);




      void loop (void)

      delayMicroseconds(200);
      SPI.transfer(0x00); //00 00 11 01 08 01 08 02 02 00 00 0C 67 66 80
      SPI.transfer(0x00);
      SPI.transfer(0x11);
      SPI.transfer(0x01);
      SPI.transfer(0x08);
      delayMicroseconds(180);
      SPI.transfer(0x01);
      SPI.transfer(0x08);
      SPI.transfer(0x02);
      SPI.transfer(0x02);
      SPI.transfer(0x00);
      delayMicroseconds(180);
      SPI.transfer(0x00);
      SPI.transfer(0x0C);
      SPI.transfer(0x67);
      SPI.transfer(0x66);
      SPI.transfer(0x80);
      delayMicroseconds(200);



      enter image description here



      Does anyone have any idea on how to make a simple SPI slave on esp? Or is there a better way to sniff this shift register bus? The clock signal is 1 MHZ so it isn't terribly fast. I only need to read 15 bytes at a time.



      This was promising but it's been alot of work stripping it down to what I want: https://github.com/JiriBilek/WiFiSpi. I can get it to print out the data once but then I think it is having issues resetting the receive interrupt because it is expecting an interactive master.










      share|improve this question















      I am trying to decode the signals going to shift registers in my washing machine. The registers are STP16CPC05 which also happen to be LED drivers. I am trying to get status from my washing machine like time left, which cycle, check if its done, etc. with an ESP12. If I can read the signals going to the LED drivers, I can determine which bits are for which LED and then determine status in my program.



      My first thought was to use a custom shiftin but I had no luck with that (and supposedly digitalread() is too slow anyway) and I was reading everywhere that I should "just use SPI" since it's faster. I have been able to successfully read the signals using a logic analyzer and even made a script for an arduino pro mini that emulates the register signals so that I can more easily debug my ESP12 without running the washer all day. Writing an SPI master is relatively easy but the slave is the hard part. Here is the code for the Arduino Pro mini so it can emulate the washer signals:



      // SPI master code for Arduino Pro Mini "washing machine clone"

      #include <SPI.h>


      void setup (void)


      SPI.begin ();

      SPI.setClockDivider(SPI_CLOCK_DIV8);




      void loop (void)

      delayMicroseconds(200);
      SPI.transfer(0x00); //00 00 11 01 08 01 08 02 02 00 00 0C 67 66 80
      SPI.transfer(0x00);
      SPI.transfer(0x11);
      SPI.transfer(0x01);
      SPI.transfer(0x08);
      delayMicroseconds(180);
      SPI.transfer(0x01);
      SPI.transfer(0x08);
      SPI.transfer(0x02);
      SPI.transfer(0x02);
      SPI.transfer(0x00);
      delayMicroseconds(180);
      SPI.transfer(0x00);
      SPI.transfer(0x0C);
      SPI.transfer(0x67);
      SPI.transfer(0x66);
      SPI.transfer(0x80);
      delayMicroseconds(200);



      enter image description here



      Does anyone have any idea on how to make a simple SPI slave on esp? Or is there a better way to sniff this shift register bus? The clock signal is 1 MHZ so it isn't terribly fast. I only need to read 15 bytes at a time.



      This was promising but it's been alot of work stripping it down to what I want: https://github.com/JiriBilek/WiFiSpi. I can get it to print out the data once but then I think it is having issues resetting the receive interrupt because it is expecting an interactive master.







      arduino esp8266 arduino-esp8266






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 20:43

























      asked Nov 10 at 18:50









      dreed75

      5819




      5819






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          There is a SPISlave library in the esp8266 Arduino package. With examples. (Jiri Bilek's firmware has only a modified copy of it.)






          share|improve this answer




















          • Right, I tried that one before I found Jiri's and I had a similar problem. With that one, some of the bytes would end up in a status register and some would end up in the data register and I couldn't figure out how to retrieve them consistently. If the IDE had a debugger, I could probably figure it out but I'm too much of a noob. I need to see what is happening in the memory.
            – dreed75
            Nov 10 at 21:30










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242313%2fneed-help-reading-shift-register-via-spi%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          There is a SPISlave library in the esp8266 Arduino package. With examples. (Jiri Bilek's firmware has only a modified copy of it.)






          share|improve this answer




















          • Right, I tried that one before I found Jiri's and I had a similar problem. With that one, some of the bytes would end up in a status register and some would end up in the data register and I couldn't figure out how to retrieve them consistently. If the IDE had a debugger, I could probably figure it out but I'm too much of a noob. I need to see what is happening in the memory.
            – dreed75
            Nov 10 at 21:30














          up vote
          0
          down vote













          There is a SPISlave library in the esp8266 Arduino package. With examples. (Jiri Bilek's firmware has only a modified copy of it.)






          share|improve this answer




















          • Right, I tried that one before I found Jiri's and I had a similar problem. With that one, some of the bytes would end up in a status register and some would end up in the data register and I couldn't figure out how to retrieve them consistently. If the IDE had a debugger, I could probably figure it out but I'm too much of a noob. I need to see what is happening in the memory.
            – dreed75
            Nov 10 at 21:30












          up vote
          0
          down vote










          up vote
          0
          down vote









          There is a SPISlave library in the esp8266 Arduino package. With examples. (Jiri Bilek's firmware has only a modified copy of it.)






          share|improve this answer












          There is a SPISlave library in the esp8266 Arduino package. With examples. (Jiri Bilek's firmware has only a modified copy of it.)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 10 at 21:04









          Juraj

          298110




          298110











          • Right, I tried that one before I found Jiri's and I had a similar problem. With that one, some of the bytes would end up in a status register and some would end up in the data register and I couldn't figure out how to retrieve them consistently. If the IDE had a debugger, I could probably figure it out but I'm too much of a noob. I need to see what is happening in the memory.
            – dreed75
            Nov 10 at 21:30
















          • Right, I tried that one before I found Jiri's and I had a similar problem. With that one, some of the bytes would end up in a status register and some would end up in the data register and I couldn't figure out how to retrieve them consistently. If the IDE had a debugger, I could probably figure it out but I'm too much of a noob. I need to see what is happening in the memory.
            – dreed75
            Nov 10 at 21:30















          Right, I tried that one before I found Jiri's and I had a similar problem. With that one, some of the bytes would end up in a status register and some would end up in the data register and I couldn't figure out how to retrieve them consistently. If the IDE had a debugger, I could probably figure it out but I'm too much of a noob. I need to see what is happening in the memory.
          – dreed75
          Nov 10 at 21:30




          Right, I tried that one before I found Jiri's and I had a similar problem. With that one, some of the bytes would end up in a status register and some would end up in the data register and I couldn't figure out how to retrieve them consistently. If the IDE had a debugger, I could probably figure it out but I'm too much of a noob. I need to see what is happening in the memory.
          – dreed75
          Nov 10 at 21:30

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242313%2fneed-help-reading-shift-register-via-spi%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党