0
\$\begingroup\$

I'm trying to write a complete algorithm for assigning short addresses to input devices on a DALI bus. At the start I don't know how many input devices are installed on a DALI bus. The procedure in order is: INITIALISE, RANDOMISE and then SEARCHADDRH(data), SEARCHADDRM(data), SEARCHADDRL(data), before doing PROGRAM SHORT ADDRESS (data). The PROGRAM can be done only if randomAddress is equal to searchaddress. For the search, how can I do for find searchaddress equal to randomAddress if I have 2^24 possible combinations? It's too long. Is there a possible operation for doing this in a short time?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

You're missing the COMPARE command. It works by comparing the randomAddress (which is very likely unique per each recipient of the RANDOMISE) with the searchAddress (that you control throw SEARCHADDRH/SEARCHADDRM/SEARCHADDRL). When the control gear has initializationState ENABLED, then IEC 62386-102:2014 says that it shall:

  • if randomAddresssearchAddress: send YES
  • in all other cases, send NO.
\$\endgroup\$
8
  • \$\begingroup\$ Yes , I know, but my questions are: you have to do a bynary search, right? And the COMPARE command gives an only answer in a loop? For example, could I write a simple code like this? array_device[64] for(i=0; i<len(array_device);i++){ min=0 max=2^24 – 1 medium_value=(min+max)/2 while(medium_value != random_address){ SEARCHADDRH(x) SEARCHADDRM(y) SEARCHADDRL(z) ret=COMPARE if(ret == “YES”){ max=medium_value }else if(ret==”NO”){ min=medium_value }else{ TIMEOUT “collision” } medium_value=(min+max)/2 } PROGRAM SHORT ADDRESS (data) VERIFY SHORT ADDRESS (data) WITHDRAW } \$\endgroup\$ Commented Feb 16 at 10:41
  • \$\begingroup\$ @NicolaBellini - Hi, (a) As you're new here, please see the tour & help center as site rules differ from typical forums. (b) You originally posted the above comment as a new answer, using the box below labeled "Your Answer". However it was clearly a reply to this answer and not the solution (answer) to your original question. Therefore I moved your post to here. (Please review the links I gave regarding the Q&A format of the site.) (c) Unfortunately you have hit some limits of the site. You are trying to include more proposed code and, as you see, the formatting/layout is removed in comments. \$\endgroup\$
    – SamGibson
    Commented Feb 16 at 11:10
  • \$\begingroup\$ (continued) Also, a question should not be changed, after someone has answered the original question - otherwise readers will see an apparent mismatch where the answer does not seem to answer the (updated) question. (This is a situation referred to as a "chameleon question" i.e. it keeps changing.) Therefore adding your proposed code into the question now should be avoided, as it would make this answer look wrong. (There are complex approaches we can try to handle that kind of situation, but changing questions often deteriorate into an unsolved mess.) Let's see if this user above can help. \$\endgroup\$
    – SamGibson
    Commented Feb 16 at 11:12
  • 1
    \$\begingroup\$ @JanKundrát - Hi, I know the new code from the OP is rather unreadable and I didn't like moving it from the OP's non-answer that way. That deliberate lack of formatting is a limitation of comments :( But adding it into the question as an update would mean that your answer (to the original version of the question) may look like it's a non-answer and get downvoted, due to it not answering the then updated version of the question. I hope you see what I mean. || Your suggestion for the OP to post a new question (as you answered the original version) sounds fine. :) \$\endgroup\$
    – SamGibson
    Commented Feb 16 at 14:49
  • 1
    \$\begingroup\$ You might be missing the fact that in DALI, a NO response is no response, so although COMPARE is broadcast, you should only see one clean YES response since all the other control gears stay silent. Unless you have two or more with the same random address, then you would get a collision response. Also see electronics.stackexchange.com/a/529867/2110 \$\endgroup\$
    – Martin
    Commented Feb 29 at 9:01

Your Answer

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

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