0
\$\begingroup\$

Understanding: DALI uses Async data decoding using 1 start bit and 2 stop bits. The 1 start bit is logical one (1), also encoded during Manchester encoding and the 2 stop bits(Signal is HIGH for long periods, at least 2*833us) designate the idle_signal.

Now, if I am decoding this data using the measured pulse width method or sampling method, I will not have a closing interrupt for last bit "1"!! I am specifically using pulse-width method decoding for Manchester decoding.

I can solve this problem by checking the LSB bit during Manchester encoding. If LSB is 1, I will include a short reset-set signal at the end. I will make sure that I will ignore the rest of the data after I have received my required frame. Anyway, this short reset-set signal will not fall in my long or short range and I can also stop my timer to respond to any other interrupt after the required frame is received!

Question:

  1. Is it valid according to DALI standard?? What could go wrong with my approach?
  2. In general, which method is used for DALI standard? Sampling-based or pulse-width based??
  3. The lack of preamble, does it cause any problems?

Thanks in advance!

PS:

  • I am not sure of the terminology "Asynch data decoding", what I meant is that there is no preamble data involved giving the decoder enough time to sync!
  • Sampling-based [page 7], pulse-width based [page 6] methods are described in this app-note.
  • Image from this source.

EDIT: My logic of Manchester_Decoding is here.

EDIT2: enter image description here

Yeah! It is a clear misunderstanding, as soon as I put the logic on Paper, I got it figured! I was thinking how the last pulse will end if the SIGNAL is high for longer times but as we can see from the figure the last 1 will be decoded before itself.

Still, I wish to know about the general implementation standard for DALI and problems caused by lack of preamble data in DALI context.

\$\endgroup\$
  • \$\begingroup\$ I'm not really sure I understand what you're asking and I'm not sure you understand what a one is with Manchester encoding.Let's start with: Do you understand that Manchester signals have to change half way through the bit period? Whether it is a one or a zero? \$\endgroup\$ – DiBosco Dec 7 '17 at 14:17
  • \$\begingroup\$ Yes ! I know that but during data recovery(decoding), I will be comparing the pulse widths, I will not be taking values at 3/4T!! I will edit my question to include my logic as well! and the method I am using is described in the app-note referenced! \$\endgroup\$ – charansai Dec 7 '17 at 14:21
  • \$\begingroup\$ IIRC I ended up doing edge interrupts, measuring how long between edges with a timer and working out whether it was a one or a zero. Then once all 8 or 16 bits had been received, check the line is high for two bit periods. There's more than one way to do it though. I've not looked through your code. TBH I'm still not sure what you're unclear about, I don't understand what you mean by a closing interrupt for last bit one, but if you really don't get one, then your algorithm is not robust enough. \$\endgroup\$ – DiBosco Dec 7 '17 at 14:35
  • \$\begingroup\$ How do you check that the line is high for a two-bit period with the timer and interrupts? \$\endgroup\$ – charansai Dec 7 '17 at 14:38
  • \$\begingroup\$ I am trying to put my logic as easy as possible and will upload that image soon as EDIT. \$\endgroup\$ – charansai Dec 7 '17 at 14:45
1
\$\begingroup\$

There's no need for a preamble, this is a very simple protocol. There is a minimum time between frames which means you can very easily detect when the line is idle. Then, once the line goes low during idle time, you measure to make sure the line is high at 3/4T and you know you've had a start bit.

It's asynchronous because there is only a data line, not clock and data. That's nothing to do with DALI per se, that's just a standard communications term.

If you look at the Atmel apps note you referenced, it talks about two different ways of doing the decoding. Ensure your sampling time is quick enough for your chosen sample based method. Personally, I think the mixture of edge interrupts and timer interrupts is less of an overhead as you're not having so many timer interrupts to ensure your sampling time is fast enough. Which leads nicely on to...

..."how the standard does it". It doesn't specify how it is implemented, just that it must be done in a robust way to ensure it works under all circumstances.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Can you provide any resources for implementation of Decoder using "mixture of edge interrupts and timer interrupts" ?? I am using timer in input capture mode and timer pin is the edge interrupt pin!! Thank you! \$\endgroup\$ – charansai Dec 7 '17 at 15:20
  • 1
    \$\begingroup\$ If you look at that Atmel apps note it talks about a timing based method in section 4.1. It's saying that you record the lengths of time between edges by using timers triggered from edge interrupts. That time reveals whether there has been a half clock period or full clock between edges, which means you can track zeros and ones. You need to be aware of where you are in the receiving byte. \$\endgroup\$ – DiBosco Dec 7 '17 at 15:28
  • \$\begingroup\$ So, for example, the first edge, you know is the mid bit of the start bit. If there is a half bit period for the next edge, you know it should be a zero as it will be going high to low. If there is a full bit period you know it will be going low to high and be a 1 as the first bit of data. It is fairly straightforward to work out when there is an error by keeping track of what possible time periods could come next. Also, at the end of receiving the last bit, you can set a time out for a timer and as long as you don't receive an edge within that period, you know you have your stop bits. \$\endgroup\$ – DiBosco Dec 7 '17 at 15:31
  • \$\begingroup\$ To answer your last question in your question above. Yes, polling continually and finding no pin change is exactly right. You have to do that anyway to find the start bit. By keeping track of number of samples between changes means you know exactly where you are in the word receive (including stop bit) or that you're between frames. \$\endgroup\$ – DiBosco Dec 7 '17 at 15:36
  • \$\begingroup\$ Setting timeout is what I am looking for! Anyways this whole confusion because I am using timer_pin in input_capture_interrupt mode, I think it will be more convenient if I use edge interrupt detector and timer separately i.e separate pin for interrupt detector and independent timer! Thanks for your time and patience \$\endgroup\$ – charansai Dec 7 '17 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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