Menu

Changing the code for dimming

Ben Clark
2023-12-07
2023-12-11
  • Ben Clark

    Ben Clark - 2023-12-07

    Hi Nathan,

    I am currently using Dave Allmon's solution (https://davidallmon.com/projects/telescope-flat-field-box-5) to dim my EL panel. The electronics are slightly different for it but I thought I would try to use your code anyway. The panel managed to turn on, but only at the maximum brightness meaning it didn't dim. Is there anyway I could implement the dimming code into your solution as I really like the interface and ASCOM compatability you have designed (plus the servo code is really useful for a beginner like me). I do not have much Arduino coding experience so hopefully you can point me in a direction. If it is not possible then prehaps you could give me some insight into making an ASCOM interface from the arduino code?

    Thank you and best regards,

    Ben Clark

     
    • Nathan Woelfle

      Nathan Woelfle - 2023-12-07

      Hi Ben,

      Thank you for the compliments on my design.

      I'm assuming you designed yours exactly as his schematic shows, with the light on pin 10, and you changed my Arduino code to use that pin?

      It is possible to edit my design and incorporate his table. Set the maxBrightness = 255, and include his table in the turnPanelTo() function. A few more coding changes will also be required to ensure you report your values correctly to ASCOM, but that should get you pointed in the right direction. Also, remember, if you share your project, include credit where due.

      Good luck!

      R/
      Nathan

       
      • Ben Clark

        Ben Clark - 2023-12-08

        Hi Nathan,

        Thank you for the quick reply.

        Mine is designed exactly as the schematic shows and I have changed the pin to 10 in your Arduino code.

        For the analogWrite function would it need to be changed to analogWrite16 like it is in Dave's code?

        I've also hit a roadblock into where I need to go once I add the lookup table into the turnPanelTo() function. I changed the lightValue to include the lookup (just within the turnPanelTo() function) but I'm not convinced that was the correct move. I'll attach the code to see if you can spot any errors. I'll always include credit whenever I share it.

        Kind regards,

        Ben

        void turnPanelTo(){
          int lightValue = 0;
          uint16_t lookup[256] = {
            832, 888, 922, 934, 978, 1006, 1012, 1040, 1062, 1104, 1110, 1116, 1146, 1162, 1170, 1190,
            1200, 1210, 1230, 1260, 1270, 1282, 1310, 1328, 1348, 1376, 1378, 1380, 1482, 1484, 1488, 1492,
            1494, 1496, 1498, 1538, 1556, 1578, 1580, 1596, 1628, 1630, 1642, 1644, 1668, 1710, 1720, 1766,
            1774, 1790, 1814, 1828, 1850, 1870, 1908, 1920, 1932, 1948, 1954, 1960, 1982, 1996, 2000, 2036,
            2060, 2068, 2086, 2112, 2126, 2140, 2152, 2164, 2192, 2202, 2220, 2228, 2244, 2256, 2294, 2320,
            2372, 2400, 2414, 2464, 2492, 2504, 2518, 2540, 2556, 2582, 2598, 2612, 2636, 2652, 2690, 2692,
            2722, 2738, 2774, 2812, 2814, 2828, 2866, 2868, 2880, 2882, 2896, 2974, 2976, 3000, 3016, 3054,
            3070, 3110, 3134, 3174, 3176, 3188, 3244, 3246, 3308, 3318, 3320, 3334, 3336, 3350, 3386, 3426,
            3428, 3466, 3468, 3508, 3600, 3636, 3676, 3678, 3728, 3756, 3822, 3832, 3858, 3860, 4148, 4156,
            4224, 4226, 4276, 4278, 4328, 4356, 4470, 4498, 4560, 4588, 4640, 4818, 4870, 5092, 5154, 5426,
            5642, 5734, 5796, 5824, 6040, 6068, 6094, 6376, 6594, 6722, 6812, 6888, 7234, 7362, 7554, 7656,
            7720, 7784, 8398, 8858, 9088, 9140, 9460, 9768, 10486, 10512, 10640, 10846, 11000, 11720, 11978, 12326,
            12804, 13062, 13152, 13488, 13566, 13902, 14252, 14810, 15548, 15730, 15782, 16188, 16344, 16524, 16566, 17020,
            17114, 17688, 17712, 17780, 18460, 18798, 18984, 19796, 19822, 19980, 20830, 21738, 21896, 21988, 22080, 22290,
            23026, 25290, 25988, 26094, 26740, 27546, 27982, 28588, 28892, 28974, 29288, 29486, 29764, 30414, 30612, 32242,
            32284, 32576, 32892, 32972, 34710, 35108, 36516, 36888, 38894, 39334, 40716, 41406, 42202, 42894, 53426, 65535
          };
          if(lightValue != 0){
            lightValue = lightValue * brightnessSteps;
            analogWrite(lightPanel, lookup[lightValue]);
          }
          else{
            lightValue = previousPanelValue;
            analogWrite(lightPanel, lookup[lightValue]);
          }
          savePanelValue();
          calibratorState = 2;
        }//end turnPanelON
        
         
        • Nathan Woelfle

          Nathan Woelfle - 2023-12-09

          Ben,

          I'm sorry for the misinterpretation. I didn't mean to literally put the table in the turnPanelTo() function, but make the calls to the table from that function. Arduino has two main parts: setup () and loop(). The variables you declare need to go before those, so you'll need to adjust the table accordingly. You'll also need to transfer his other functions and adapt the usage of the analogWrite. It won't be a simple matter of copying and pasting from his to mine; you'll have to make some edits. You should compare the structure and work to align it from there.

          R/
          Nathan

           
          • Ben Clark

            Ben Clark - 2023-12-11

            Hi Nathan,

            I'm sure it wasn't your fault, just my poor beginner level understanding. Thank you for taking the time to explain it to me. I'll have a crack at it for a couple of days then get back to you.

            Best regards,

            Ben

             

Log in to post a comment.