Scan inputs and drive outputs after delay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 06:30 AM - edited ‎2024-11-12 10:00 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 07:34 AM
Well, that was totally missing from your initial post & schematic!
So, for each 3-bit pattern that you clock into the right-hand shift register on 'x', you have to clock an 8-bit pattern into the left-hand shift register on 'DATA' ?
What, exactly, are you trying to achieve by that?
It seems excessively complicated!
Again, I think you need to take just getting the LEDs to work as a project on its own before doing anything else!
Start by drawing a truth table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 07:50 AM
Thank you for your answers and interest in the subject.I got stuck while coding the device I wanted to control. and I am struggling with some problems. I think my algorithm is wrong, I am trying to find a solution for this.I made the coding that will control all my LEDs.If information comes from 14 inputs or any of the 8 outputs are active, the LEDs are scanned with a timer and work. I have no problem here.
I can't express myself. I couldn't find how to explain the problem. I want to create some delay without interrupting the timers and use it wherever I want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 08:01 AM
@XooM wrote:I got stuck while coding the device
It sounds like you have jumped into coding before you've fully thought-through your design.
The secret to solving big problems is to break them down into smaller problems that you can solve.
@XooM wrote:I couldn't find how to explain the problem.
If you can't even describe the problem, how can you even design a solution to that problem.
Go back and think about what you're trying to achieve - make sure you have that thoroughly understood before leaping into a solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 08:10 AM - edited ‎2024-11-11 08:14 AM
4094 require SPI data stream ... start with this. From schematics showed is unreadable ... if DATA and CLK is connected to right SPI pins on MCU.
WARNING your LEDS dont have current limiter and max 4094 is 25mA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 08:26 AM - edited ‎2024-11-11 08:27 AM
This is how I control the LEDs. I don't use SPI.
#define SER_PIN GPIO_PIN_4 // SER_PIN
#define SER_PORT GPIOB
#define SRCLK_PIN GPIO_PIN_12 // (SRCLK)
#define SRCLK_PORT GPIOA
#define RCLK_PIN GPIO_PIN_5 // SRCLK_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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 08:41 AM - edited ‎2024-11-11 08:49 AM
@XooM ,
You still not answering my question:
What STM32 device you are using? what board you are using? and the schematics you shared is it just schematics or you are using it for simulation?
I know that software and tested it and it's not efficient for ARM MCUs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 09:07 AM - edited ‎2024-11-11 09:07 AM
I have a special design PCB that I use Stm32f030C6T6 and STM32F100C6T6. There is no design error in the PCB. The PCBs are actively used on a working system. So I can't change the design.
I am trying to reprogram these cards.
I used the Proteus program to explain my problem here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 09:23 AM
@XooM wrote:The PCBs are actively used on a working system. .
So use the same software that is used in those working systems to do your basic scanning.
Get support from the people already using the boards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 09:36 AM
Make a table of tasks, decrement a count in SysTick_Handler(), and when you hit zero call the action function.
Set the count to 500 for your delayed execution.
Or make a table you check in main() loop, where you delta a time stamp off of HAL_GetTick(), and check your trigger point.
You don't need to block, just be aware of time and when the timeout will expire.
Need to move beyond linear/sequential code execution and delays
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 10:58 AM
ooM ok this work too , but isnt very effective. Seems you be hero of timers use, but dont use hw SPI ?
Primary show code where you see your point of trouble, Write here
I have 8 outputs. I read them with timer17 at 1ms intervals. is ... FYI output isnt read but writed...
And how delay you mean HAL_Delay? If you read docu , you see dont use it in ISR except when you setup priorities for ISR right...