DALI commands reading

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

DALI commands reading

2,463件の閲覧回数
Chish
Contributor II

Hello! Posting again

I'm working on DALI to monitor the hours of LEDs connected to DALI slave. I'm using LPC1114/302 MCU. 
According to Standard DALI protocol I can only send 8 bits to DALI Master. I'm trying to separate the logic by using Modulus operator and send it to the DALI master but it doesn't work. I've attached the in which i applied different logics to separate the digits and send it over. 

The stunde is hour, whose value is 329 and I need to split them into 3 digits \

MSB 3,

MIDB 2,

LSB 9

Chish_0-1636023714655.png

 

タグ(1)
0 件の賞賛
返信
3 返答(返信)

2,456件の閲覧回数
Chish
Contributor II

Actually, I've just started programming in C and since it's related to DALI and I'm working on NXP MCU that's why

 

0 件の賞賛
返信

2,449件の閲覧回数
converse
Senior Contributor V

Assuming that you are trying to extract the decimal digits, here is a bit of code that may help you:

int val = 329 ; // the value to  convert

int result[3] ; // an array containing each decimal digit.
// the least significant digit is in result[0]
int digits = 0 ;
while(val > 0){
result[digits++] = val % 10 ;
val = val / 10 ;
}

This will convert a number containing up to 3 decimal digits and place the result into the result[] array (in reverse order). To simplify the code, there is no error checking, so if the value is larger than 999, the result array will overflow and corruption will occur!!! You can modify this code to suit your particular circumstances. 

0 件の賞賛
返信

2,457件の閲覧回数
carstengroen
Senior Contributor II

Not to be rude, but what has this to do with "NXP microprocessors" ?

It is a simple beginner C question (in fact, a general programming beginner question).

0 件の賞賛
返信