Menu

Darklight90 with LED lightning

Issues
2023-07-23
2023-12-07
  • Andrew Wall

    Andrew Wall - 2023-07-23

    HI Nathan and all,

    I recently got my Dust cover Flap device working again and wondered if it was possible to control LED lights via PWM instead of an EL panel? I use an external flat panel currently using modified arduino code for Alnitak LED driver. It uses an Arduino nano, a MOS circuit. A IRF520 MOSFET Driver Module (HCMODU0083) and a light panel, controlled via pin 3. I would like to control via the Darklight driver as it has the option for both opening a shutter and controlling the light. Currently I cannot see a way for the Alnitak driver to operate a flap. I think having an option between EL panel and LED driver would be a huge plus for this project. If there is a way to do it, can you please let me know.

    Regards,

    Andrew Wall
    South Australia.
    http://brightskyobservatory.bsch.com.au/

    The current code I am using is this one below.

    /*
      What: LEDLightBoxAlnitak - PC controlled lightbox implmented using the
        Alnitak (Flip-Flat/Flat-Man) command set found here:
        http://www.optecinc.com/astronomy/pdf/Alnitak%20Astrosystems%20GenericCommandsR3.pdf
    
      Who:
        Created By: Jared Wellman - jared@mainsequencesoftware.com
        Modified By: Robert Pascale - implemented the PWM code for 31kHz - reverted from the V4 protocol as it was flaky.
    
      When:
        Last modified:  2020/March/12
    
    
      Typical usage on the command prompt:
      Send     : >S000\n      //request state
      Recieve  : *S19000\n    //returned state
    
      Send     : >B128\n      //set brightness 128
      Recieve  : *B19128\n    //confirming brightness set to 128
    
      Send     : >J000\n      //get brightness
      Recieve  : *B19128\n    //brightness value of 128 (assuming as set from above)
    
      Send     : >L000\n      //turn light on (uses set brightness value)
      Recieve  : *L19000\n    //confirms light turned on
    
      Send     : >D000\n      //turn light off (brightness value should not be changed)
      Recieve  : *D19000\n    //confirms light turned off.
    */
    
    volatile int ledPin = 3;      // the pin that the LED is attached to, needs to be a PWM pin.
    int brightness = 0;
    
    enum devices
    {
      FLAT_MAN_L = 10,
      FLAT_MAN_XL = 15,
      FLAT_MAN = 19,
      FLIP_FLAT = 99
    };
    
    enum motorStatuses
    {
      STOPPED = 0,
      RUNNING
    };
    
    enum lightStatuses
    {
      OFF = 0,
      ON
    };
    
    enum shutterStatuses
    {
      UNKNOWN = 0, // ie not open or closed...could be moving
      CLOSED,
      OPEN
    };
    
    
    int deviceId = FLAT_MAN;
    int motorStatus = STOPPED;
    int lightStatus = OFF;
    int coverStatus = UNKNOWN;
    
    void setup()
    {
      //----- PWM frequency for D3 & D11 -----
      // Timer2 divisor = 2, 16, 64, 128, 512, 2048
      TCCR2B = TCCR2B & B11111000 | B00000001;    // 31KHz
      //TCCR2B = TCCR2B & B11111000 | B00000010;    // 3.9KHz
      //TCCR2B = TCCR2B & B11111000 | B00000011;    // 980Hz
      //TCCR2B = TCCR2B & B11111000 | B00000100;    // 490Hz (default)
      //TCCR2B = TCCR2B & B11111000 | B00000101;    // 245Hz
      //TCCR2B = TCCR2B & B11111000 | B00000110;    // 122.5Hz
      //TCCR2B = TCCR2B & B11111000 | B00000111;    // 30.6Hz
    
      // initialize the serial communication:
      Serial.begin(9600);
      // initialize the ledPin as an output:
      pinMode(ledPin, OUTPUT);
      analogWrite(ledPin, 0);
    }
    
    void loop()
    {
      handleSerial();
    }
    
    
    void handleSerial()
    {
      if ( Serial.available() >= 6 ) // all incoming communications are fixed length at 6 bytes including the \n
      {
        char* cmd;
        char* data;
        char temp[10];
    
        int len = 0;
    
        char str[20];
        memset(str, 0, 20);
    
        // I don't personally like using the \n as a command character for reading.
        // but that's how the command set is.
        Serial.readBytesUntil('\r', str, 20);
    
        cmd = str + 1;
        data = str + 2;
    
        // useful for debugging to make sure your commands came through and are parsed correctly.
        if ( false )
        {
          sprintf( temp, "cmd = >%c%s;", cmd, data);
          Serial.println(temp);
        }
    
    
    
        switch ( *cmd )
        {
          /*
            Ping device
            Request: >P000\n
            Return : *Pii000\n
              id = deviceId
          */
          case 'P':
            sprintf(temp, "*P%dOOO\n", deviceId); // MADE CHANGE FROM PRINTLN TO PRINT HERE
            Serial.print(temp);
            break;
    
          /*
            Open shutter
            Request: >O000\n
            Return : *Oii000\n
            id = deviceId
    
            This command is only supported on the Flip-Flat!
          */
          case 'O':
            sprintf(temp, "*O%dOOO\n", deviceId); // MADE CHANGE FROM PRINTLN TO PRINT HERE
            SetShutter(OPEN);
            Serial.print(temp);
            break;
    
    
          /*
            Close shutter
            Request: >C000\n
            Return : *Cii000\n
            id = deviceId
    
            This command is only supported on the Flip-Flat!
          */
          case 'C':
            sprintf(temp, "*C%dOOO\n", deviceId); // MADE CHANGE FROM PRINTLN TO PRINT HERE
            SetShutter(CLOSED);
            Serial.print(temp);
            break;
    
          /*
            Turn light on
            Request: >L000\n
            Return : *Lii000\n
              id = deviceId
          */
          case 'L':
            sprintf(temp, "*L%dOOO\n", deviceId);     // MADE CHANGE FROM PRINTLN TO PRINT HERE
            Serial.print(temp);
            lightStatus = ON;
            analogWrite(ledPin, brightness);
            break;
    
          /*
            Turn light off
            Request: >D000\n
            Return : *Dii000\n
              id = deviceId
          */
          case 'D':
            sprintf(temp, "*D%dOOO\n", deviceId); // MAKING TEST CHANGE HERE WITH THE REMOVAL OF PRINTLN AND REPLACING WITH JUST THE NEW LINE CHARACTER
            Serial.print(temp);
            lightStatus = OFF;
            analogWrite(ledPin, 0);
            break;
    
          /*
            Set brightness
            Request: >Bxxx\n
              xxx = brightness value from 000-255
            Return : *Biiyyy\n
              id = deviceId
              yyy = value that brightness was set from 000-255
          */
          case 'B':
            brightness = atoi(data);
            if ( lightStatus == ON ) 
              analogWrite(ledPin, brightness);
            sprintf( temp, "*B%d%03d\n", deviceId, brightness ); // MADE CHANGE FROM PRINTLN TO PRINT HERE
            Serial.print(temp);
            break;
    
          /*
            Get brightness
            Request: >J000\n
            Return : *Jiiyyy\n
              id = deviceId
              yyy = current brightness value from 000-255
          */
          case 'J':
            sprintf(temp, "*J%d%03d\n", deviceId, brightness); // MADE CHANGE FROM PRINTLN TO PRINT HERE
            Serial.print(temp);
            break;
    
          /*
            Get device status:
            Request: >S000\n
            Return : *SidMLC\n
              id = deviceId
              M  = motor status( 0 stopped, 1 running)
              L  = light status( 0 off, 1 on)
              C  = Cover Status( 0 moving, 1 closed, 2 open)
          */
          case 'S':
            sprintf( temp, "*S%d%d%d%d\n", deviceId, motorStatus, lightStatus, coverStatus); // MADE CHANGE FROM PRINTLN TO PRINT HERE
            Serial.print(temp);
            break;
    
          /*
            Get firmware version
            Request: >V000\n
            Return : *Vii001\n
              id = deviceId
          */
          case 'V': // get firmware version
            sprintf(temp, "*V%d001\n", deviceId);   // MADE CHANGE FROM PRINTLN TO PRINT HERE
            Serial.print(temp);
            break;
        }
    
        while ( Serial.available() > 0 )
          Serial.read();
    
      }
    }
    
    void SetShutter(int val)
    {
      if ( val == OPEN && coverStatus != OPEN )
      {
        coverStatus = OPEN;
        // TODO: Implement code to OPEN the shutter.
      }
      else if ( val == CLOSED && coverStatus != CLOSED )
      {
        coverStatus = CLOSED;
        // TODO: Implement code to CLOSE the shutter
      }
      else
      {
        // TODO: Actually handle this case
        coverStatus = val;
      }
    
    }
    
     
  • Andrew Wall

    Andrew Wall - 2023-07-24

    Ok had a look at the code a little closer, it seems the EL panel PWM is adjusted via pin 3, the same as the Alnitak code. So my assumption would be that the Darklight Controller along with a MOS driver, the controller should be able to operate it. I will be testing this thory this week. If so this will make this project so much easier for me to use. :)

     
  • Nathan Woelfle

    Nathan Woelfle - 2023-07-24

    Hi Andrew,

    Thank you for your question. It's possible to control LEDs instead of an EL Panel. My design has a maximum voltage output of 12V to the light source; you need to find LEDs that support this voltage or add some components to reduce it.

    R/
    Nathan

     
  • Peter Johanson

    Peter Johanson - 2023-11-03

    Hello, i am sorry if this is not the right thrrad to ask my question.
    i have followed instructions, soldered everything togather. When i connect arduino via usb to my pc i am able to upload the sketch to it but when i try to use the cover/panel via app nothing works, nothing is happening. Now i will admit, i did not cut my usb cable, i did not see enough images nor explanations about that and i figured i already have usb cable from my arduino to pc. now that might be where issue lies, i dont know. i hope to get some help.
    thank you.

     
    • Nathan Woelfle

      Nathan Woelfle - 2023-11-03

      Hi Peter,
      I'm sorry to hear you've hit a snag in your development.

      It's OK not to cut the USB cable if you can connect directly to your Arduino. The purpose of a larger USB cable was to maintain comparable sizing to other equipment. The instructions for cutting the cable and the pinout can be found on page 12 of the manual.

      Regarding your setback, unfortunately, you don't provide many details, so it's hard to offer advice at this time. When you say you "try to use the cover/panel via app nothing works, nothing is happening," what do you mean? Are you able to successfully connect to the Arduino? If you're connected, what are you seeing for the status of the panel position and state of the light? Are they connected to the Arduino? Please provide more details; I'll be more than happy to try and assist.

      R/
      Nathan

       
  • Peter Johanson

    Peter Johanson - 2023-11-04

    Thank you for replying. You are correct, i did not provide much details. Here are the images of my board. I switched arduino position because i wanted to be able to plug usb directly inside the box. When i connect only 12v power, arduino does not light up, it only lights up when i ppug it into the pc. When i connect usb to pc, EL panel to the appropriate cable and servo motor to its plug and open the app, i am able to connect the app to the device, or so i think because there is no error message when i do connect it. When i click on the open button/close button app shows how status has changed, same for the light, but nothing happens, servo does not move, EL panel does not light up. I am not sure if i have connected NPN and PNP correctly.
    Id be willing to answer any additional question in order to solve this issue i am having.

     
    • Nathan Woelfle

      Nathan Woelfle - 2023-11-04

      Hi, Peter; thanks for the additional information and the picture. You definitely have a power issue because, at minimum, without the USB connected, the Arduino should be getting power, and it would also explain why neither the EL panel doesn't light up nor the servo move. Could you provide a picture of the bottom of your circuit board so I can attempt to trace all of your connections? Also, what is the rating of your power supply?

      R/
      Nathan

       
  • Peter Johanson

    Peter Johanson - 2023-11-04

    Makes sense. In all previous projects, arduino would light up when power is connected even though it has not been plugged into pc.
    is the first big diode connected in the right direction?

     
    • Nathan Woelfle

      Nathan Woelfle - 2023-11-04

      The first big diode is in the right direction.

      Looking at the two images and solving why there is no power going to the Arduino first, the circuit seems correct. What is the power supply you are using? 12V # Amps? Do you have a voltmeter? Unplug the USB before starting, and let's walk through the components. Check the voltage at the beginning before the first diode. Are you getting a reading? What is it? Keep the ground lead on the input ground; are you getting a voltage after the first diode? After the first resistor, tied to the Zener diode, are you also getting a voltage? What is it?

       
  • Peter Johanson

    Peter Johanson - 2023-11-05

    I have managed to get the servo motor to work. LM1084IT-ADJ was wired wrong. NPN transistor was also wired wrong and i hoped that would solve my problems but nope. Still cant get EL panel to light up. I checked the wires leading from the board and they are live, all the time but EL panel doesnt want to light up. I am missing something here. i checked the EL panel itself by wiring it back to its little (buzzing while turned on) power transformer which came with the EL panel.
    I dont know if EL panel is suppose to work without that little box, hooked directly with two lead wired onto the board?

     
    • Nathan Woelfle

      Nathan Woelfle - 2023-11-05

      Peter,
      I'm glad you've gotten it partially resolved. The EL Panel will not work if connected directly to the board. You need the little box; it's an inverter and converts from DC to AC. If it still doesn't work after that, check the PNP and verify it is connected correctly. If that still doesn't work, I'd recommend changing the NPN and/or the PNP; one or both may have gone bad if it was initially wired incorrectly. I've done that myself a time or two. Let me know the results, and we'll go from there.

       

      Last edit: Nathan Woelfle 2023-11-05
  • Peter Johanson

    Peter Johanson - 2023-11-05

    Hey Nathan, i have not been able to resolve it yet. I did not know that i wouod need that small box DC-AC converter as well in the mix.
    So ive looked at the schematics in the manual and from what ive gathered while watching youtube videos on NPN and PNP, it seems that you have switched them up or at least labled them up wrongly in the image of your board, where you have servo and EL panel electronics devided by the color.
    First NPN should be closer to the EL panel plug. I did that. ive switched PNP and NPN like your schematics shows but still no luck.
    I checked exit power plug for EL panel which should go to little box. it has 11.5v of power all the time regardless of whether i have panel turned on or off in the app.
    Maybe the issue is so easy but i am just missing it.

     
    • Nathan Woelfle

      Nathan Woelfle - 2023-11-07

      Peter,
      You are correct; I did mislabel the two transistors in the image. Great catch, thank you! I will have to update. The schematic, though, is correct and should be what it followed.

      If you've installed the transistors correctly, as shown in the schematic, which is correct, then one or both transistors may have been damaged or are faulty. Here's a video for how to check them to make sure they are both functioning correctly. https://youtu.be/93bO2nBrptM?feature=shared
      Let me know the results.

      R/
      Nathan

       
  • Peter Johanson

    Peter Johanson - 2023-11-07

    Yeah, i did everything according to schematics with brand new components -no luck.
    ive recreated just the flat panel portion on protoboard.
    Still wont turn EL panel on.
    i have power at the little box for the EL panel regardless of what app is saying whether its on or off...
    IMG-20231107-183950
    IMG-20231107-184014

     
    • Nathan Woelfle

      Nathan Woelfle - 2023-11-08

      Peter,
      Thanks for posting the pictures. Everything appears connected correctly, so it's odd that it isn't working for you. Please provide the model #s for the two transistors you're using so I can doublecheck the pinout to be more confident, though.

      I want to clarify a couple of things. When you say you "have power at the little box," is what looks like the audio jack on the left side of the image, is the little box you're referring to? Is that the inverter? What voltage are you getting, and at which point in the circuit are you measuring? If you don't have the inverter physically connected or something to provide a load, like a resistor, when you initially check the voltage, if, at the audio jack, it most likely would read ~12V. The capacitors will charge up and show a voltage, which may slowly drain when a voltmeter is connected.

      I also understand when you say the EL panel won't turn on even though you're getting a voltage at the little box. Have you directly connected the inverter up to 12V and verified the EL Panel does come on? Do you have a make/model for those parts that you can provide?

      I'm very intrigued by the situation and sorry for the frustration and time it's taking for us to get this resolved, but I look forward to tracking down our issue.

       
  • Peter Johanson

    Peter Johanson - 2023-11-21

    Okay, electronics do work.
    i was blindly following the image of the board, rather than schematics. My PNP and NPN were not placed correctly but now it finally works.
    At first i was quite worried that EL panel was way too dim but after testing it, its working quite well.
    Next part is to print out the EL panel holder/cover for my 150P Newtonian.
    This is such a nice project and huge thanks to the maker Nathan who has been quite helpful and active in quick replies. Without him i would be stuck hehe.
    Thank you and i hope everyone makes this for their own telescope.

     
    • Nathan Woelfle

      Nathan Woelfle - 2023-11-22

      Awesome Peter! I'm glad you got it working. Thank you for the kind words. It was my pleasure to be able to assist. I hope to see pictures of your build and future photos here or on one of the web forums.

       

Log in to post a comment.