0
\$\begingroup\$

I'm currently stuck using DALI protocol with D4i drivers. I want to access the memory bank of one driver and read the energy parameters.

I know the opcode to read memory locations is 0xC5, since the description of this opcode is "Returns the content of the memory location stored in DTR0 that is located within the memory bank listed in DTR1"

My problem is that, since I'm implementing DALI protocol using C, at basic level, I'm not really sure how to send a DALI command that uses the opcode, states that the memory location is DTR0 and the memory bank is DTR1. I attach a snippet of code that states how I'm sending DALI commands:

        // Logic 1 (0-->1)
        void sendDaliHigh(void)
        {
            nrf_gpio_pin_clear(BOARD_DALI_TX_PIN);
            waitTEus();
            nrf_gpio_pin_set(BOARD_DALI_TX_PIN);
            waitTEus();
        }
        
        // Logic 1 (0-->1)
        void sendDaliStartBit(void)
        {
            nrf_gpio_pin_clear(BOARD_DALI_TX_PIN);
            waitTEus();
            nrf_gpio_pin_set(BOARD_DALI_TX_PIN);
            waitTEus();
        }
    
    uint32_t sendDaliV1ForwardFrame(uint8_t command)
    {
        sendDaliStartBit();
    
        sendDaliHigh();
        sendDaliHigh();
        sendDaliHigh();
        sendDaliHigh();
    
        sendDaliHigh();
        sendDaliHigh();
        sendDaliHigh();
        sendDaliHigh();
    
        // Check every bit and
        for (uint8_t i = 0; i < 8; i++)
        {
            // Mask to check every bit
            if ((command & (128 >> i)) != 0)
            {
                sendDaliHigh();
                // LOG(LVL_INFO, "1");
            }
            else
            {
                sendDaliLow();
                // LOG(LVL_INFO, "0");
            }
        }
    
        sendStopBit();
        sendStopBit();
        return 95 * 100;
    }

So basically, if I want to send the command STEP DOWN AND OFF, all I have to write is:

    sendDaliV1ForwardFrame(0x07);

But since all I do is sending an opcode, I'm not really sure on how to access memory banks. Basically, I want to retrieve the Active Energy from this driver. According to DiiA Spectification DALI Part 252, accessing memory bank is this table: I want to retrieve addresses 0x04 to 0x0A

I read all the different DALI documents (201, 202, various user guides), but they never specify on how to send the commands or access the memory banks at byte or logical level.

How I should proceed in order to retrieve memory locations in bank?

\$\endgroup\$
1
  • \$\begingroup\$ This specification only tells you which memory bank and which address within memory bank contains the data you need. The protocol how to read a certain address of a certain memory bank are in the IEC standard for DALI. Unfortunately, those standards are not freely available, and for legal/copyright reasons it may not be a good idea to copy relevant information from the standards here. Consider purchasing the standards you need. \$\endgroup\$
    – Justme
    Apr 18 at 9:50

1 Answer 1

2
\$\begingroup\$

DALI frame format is specified in parts 102 and 103 for control gear and control devices respectively. These also list the commands you need to set and read the DTRs and to read memory banks.

Note that a part 102 control gear frame is 16 bits, but your code has assumed the first 8 bits are fixed so you can only send broadcast commands. As soon as you expand your system beyond one driver this will not work because you will get collisions in responses.

To work with DALI commands, you need to obtain a copy of IEC 62386-101 and -102 at the least.

The command for reading memory banks is 197 READ MEMORY LOCATION (DTR1, DTR0) which is opcode 0xC5. The memory location is identified by DTR0 and the memory bank by DTR1. Each read auto increments DTR0 until it hits 0xFF, so you do not need to keep setting DTR0 after the first time.

Setting DTR0 uses command 257, which has the format Address byte = 0xA3, opcode byte = data i.e. value you want to set DTR0 to.

Setting DTR1 uses command 273, which has the format Address byte = 0xC3, opcode bytes = data i.e. value you want to set DTR1 to.

So your current code which fixes the first 8 bits needs to be changed to be able to send the DTR commands, since the first byte is not always the address. DTR commands are inherently broadcast, but this is not a problem because the command that uses the DTRs are addressed.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you very much for your response. Since I was trying to understand DALI protocol, I was using only one driver and didn't want to worry about addresses at this point. So, basically, the idea is in order to check the version of the memory bank (0x03) to send the following bit frame: 1 101C CCC1 0000 0011 11 (being C the value 0xC5) ¿Am I right? Again, thank you, I think that I understand better the problem \$\endgroup\$ Apr 18 at 10:42
  • \$\begingroup\$ You'll need more than one command to read a location in a memory bank, see the updated answer. \$\endgroup\$
    – Martin
    Apr 20 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.