How to send 32 bit command to programmable PWM controller?

조회 수: 1 (최근 30일)
Alexey Onischenko
Alexey Onischenko . 2016년 1월 1일
댓글: Alexey Onischenko . 2016년 1월 14일
Hello! I have Allegro A6281 programmable PWM led controller. Below is the PWM command format, where each PWM counter corresponds each color of LED (r, g, b).
Each color has 10 bits of the 32 bit command word, as shown in the above diagram. The 10 bits allow PWM control of LED brightness to 1024 possible levels. This is only true if the remaining 2 bits are set to zero. I trying to send data directly through raspberry SPI interface. Here is my code:
clear all;
becky = raspi('', 'pi', ....);
latchPin = 17;
bSPIdev = spidev(becky, 'CE0');
writeDigitalPin(becky, latchPin, 0);
writeDigitalPin(becky, latchPin, 1);
spi_response = writeRead(bSPIdev, [1023 1023 0 0]) %trying to light up just two colors
writeDigitalPin(becky, latchPin, 0);
%The LI (Latch Input) pin causes the LED controller to accept whatever is in its shift register as a new %command. If you send the LI pin high and then low after 32 clocks, the first ShiftBar in the chain has all %new data from the DI pin.
But nothing happens =(
What I'm doing wrong?

답변 (1개)

Venkatachala Sarma
Venkatachala Sarma 2016년 1월 14일
편집: Venkatachala Sarma 님. 2016년 1월 14일
The process of writing data to the SPI Device is okay. But the data format which writes the control registers may not be right. Try to follow the code available in the following links :
This should be able to help you in setting the data in a proper format in the PWM and current control registers.
Venkatachala Sarma
  댓글 수: 2
Alexey Onischenko
Alexey Onischenko 2016년 1월 14일
Yes, I really hope, that you will come back)

댓글을 달려면 로그인하십시오.


더 많은 답변 보기:  Power Electronics Community


Help CenterFile Exchange에서 Simulink Support Package for Raspberry Pi Hardware에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by