2024-11-20 04:38 AM - edited 2024-11-20 04:39 AM
Friends, which algorithm do you use to control the LEDs in this structure? I need your ideas. I have prepared a table of the LEDs' turn on order.
2024-11-20 07:49 AM
@unsigned_char_array wrote:The groups are connected in parallel. So you cannot have:
Ah yes - you're right.
2024-11-20 07:50 AM
@XooM What is driving you to use this board - which, apparently, has inadequate documentation and no support??
2024-11-20 08:06 AM
Friends, I will give you the document you want in a moment, but I do not understand how this forum works. In the country where I speak my own language, we can understand what we mean very quickly without giving too much detail. Here, people either have poor electronics knowledge or want to know everything.
I just made a simplified drawing to ask for help from the algorithm.
The missing parts are not relevant to the question I asked.
I assumed that everything was complete and wanted to talk about the algorithm. There is no deficiency or error in the design of the circuit. The circuit is an actively working circuit.
Since every programmer has a different perspective, I asked to learn your perspective on the event.
I will explain the missing parts of the circuit and my own coding in a way you can understand.
I will share it in 30 minutes.
2024-11-20 08:17 AM - edited 2024-11-20 08:32 AM
@XooM wrote:The missing parts are not relevant to the question I asked.
Again, we had no way to know whether the missing parts were simply omitted from the diagram for clarity, or were an actual design error.
@XooM wrote:Friends, I will give you the document you want in a moment, but I do not understand how this forum works. In the country where I speak my own language, we can understand what we mean very quickly without giving too much detail. .
I think the real difference is between when you're discussing with people face-to-face, and when using a forum.
When you discuss face-to-face, people can actually see what you're talking about - it's there in the room with them.
So they have a lot more information & context than just what you say.
When you post on a forum, we can see nothing other than what you put in your posts.
We don't get any of that non-verbal context.
That's why you need to give a lot more detail.
And explain what you've omitted - and why.
2024-11-20 08:29 AM
2024-11-20 09:54 AM - edited 2024-11-20 10:35 AM
You image in question make more problem as info. Missed transistors is then on right side and left 8bit is connected to LED direct. Then your code need
array uint16_t LEDs[3] = { 0x0080, 0x0040, 0x0020 };
for set leds 0-7 manage
LEDs[0] |= (8bitled) <<8 ; you can manage this all 8 led
for 8-15
LEDs[1] |=(8bitled) <<8 ;
then your led manager timer every 5ms show one of this
timer 5ms code
static uint8_t qoutposition=0;
HC4094write(LEDs[qoutposition]);
qoutposition++;
if(qoutposition==3) qoutposition=0;
...
//code for write
void HC4094write(uint16_t data)
{
HAL_GPIO_WritePin(RCLK_PORT, RCLK_PIN, GPIO_PIN_RESET);
for(int i=0; i<16; i++)
{
if(data & (1<<i))
{
HAL_GPIO_WritePin(SER_PORT, SER_PIN, GPIO_PIN_SET);
}
else
{
HAL_GPIO_WritePin(SER_PORT, SER_PIN, GPIO_PIN_RESET);
}
HAL_GPIO_WritePin(SRCLK_PORT, SRCLK_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(SRCLK_PORT, SRCLK_PIN, GPIO_PIN_SET);
}
HAL_GPIO_WritePin(RCLK_PORT, RCLK_PIN, GPIO_PIN_SET);
}
2024-11-20 10:05 AM - edited 2024-11-20 10:30 AM
#define SER_PIN GPIO_PIN_4 // SER_PIN
#define SER_PORT GPIOB
#define SRCLK_PIN GPIO_PIN_12 // SRCLK_PIN
#define SRCLK_PORT GPIOA
#define RCLK_PIN GPIO_PIN_5 // RCLK_PIN
#define RCLK_PORT GPIOB
void HC4094write()
{
HAL_GPIO_WritePin(RCLK_PORT, RCLK_PIN, GPIO_PIN_RESET);
for(int i=0; i<16; i++)
{
if(currentVal & (1<<i))
{
HAL_GPIO_WritePin(SER_PORT, SER_PIN, GPIO_PIN_SET);
}
else
{
HAL_GPIO_WritePin(SER_PORT, SER_PIN, GPIO_PIN_RESET);
}
HAL_GPIO_WritePin(SRCLK_PORT, SRCLK_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(SRCLK_PORT, SRCLK_PIN, GPIO_PIN_SET);
}
//HAL_GPIO_WritePin(RCLK_PORT, RCLK_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(RCLK_PORT, RCLK_PIN, GPIO_PIN_SET);
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if(htim->Instance==TIM17) // 250us
{
if(input1==0)
{
currentVal=0b1000000010000000; //led1
HC4094write();
}
if(input2==0)
{
currentVal=0b1000000001000000; // led2
HC4094write();
}
if(input3==0)
{
currentVal=0b1000000000100000; //led3
HC4094write();
}
if(input4==0)
{
currentVal=0b0100000010000000; //led4
HC4094write();
}
}
}
2024-11-20 10:13 AM - edited 2024-11-20 10:15 AM
No your code isnt ok , because led light if more as one input active only some us . if Only one input is active led light relative ok only one data is send to one led and repeat in time input is selected.
But i mean your real situation not guarantie only one input selected ?
TRY in timer only my code and set values in main based for all 24 leds.
2024-11-20 10:27 AM - edited 2024-11-20 10:31 AM
Too your code send into 595 LSB first, but normal logic is MSB first. Then maybe try change
if(data & (1<<(15-i)))
and swap bytes in array
uint16_t LEDs[3] = { 0x0100, 0x0200, 0x0400 };
for set leds then
LEDs[0]|=8leds;...
2024-11-20 01:12 PM
@XooM wrote:
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if(htim->Instance==TIM17) // 250us
{
if(input1==0)
{
currentVal=0b1000000010000000; //led1
HC4094write();
}
if(input2==0)
{
currentVal=0b1000000001000000; // led2
HC4094write();
}
if(input3==0)
{
currentVal=0b1000000000100000; //led3
HC4094write();
}
if(input4==0)
{
currentVal=0b0100000010000000; //led4
HC4094write();
}
}
}
I haven't checked HC4094write, but I assume it works. I would only change it to not use a global and take a parameter Why are you bitbanging and why aren't you using SPI?
As for your timer function: