Join us today!

Notifications
Clear all

[Solved] Adjustable Flowing LEDs - PLC Programming Challenge

16 Posts
5 Users
10 Reactions
1,114 Views
twinControls
Posts: 115
Admin
Topic starter
(@twincontrols)
Member
Joined: 2 years ago

The goal is to create adjustable flowing LEDs PLC program. You will have 16 LEDs total. Users will provide how many flowing LEDs they want, the minimum and maximum flow time from one end to the other and they will be able to control the speed on the fly. 

-Max 15 flowing LEDs are allowed. 

-Start button is used to start the program when all the settings are provided by the user. 

-If a user enter 5s for the slowest time and set the speed bar to 0%, it will take LEDs to flow 5s from one end to the other. 

-If a user enter 1s for the fastest time and set the speed bar to 100%, it will take LEDs to flow 1s from one end to the other. 

A running program can be seen in the video below. You need to write the PLC logic for this HMI, but you are welcome to develop the HMI program as well. 

Share your implementation with the community! Good luck and happy coding! 😊 

Reply
15 Replies
9 Replies
ehixenbaugh
(@ehixenbaugh)
Joined: 2 years ago

Trusted Member
Posts: 33

@twincontrols

Here is my solution. Attached is a video and pictures of my code, as well as a link to the archive with my project in it

https://github.com/evanhixenbaugh/TwinCAT-Projects/blob/main/AdjustableFlowingLEDs_ehixenbaugh.tnzip

- Evan H.

AdjustableFlowingLEDs variables
AdjustableFlowingLEDs MAIN
Reply
twinControls
Admin
(@twincontrols)
Joined: 2 years ago

Member
Posts: 115

@ehixenbaugh Great job and you even did the HMI part as well!!   In the video, when you selected 2 and 1 Led, it seems like Led doesn't flow one by one, it appeared to be jumping, I am not sure if it's because of the video or something else. 

Well done!! 

Reply
ehixenbaugh
(@ehixenbaugh)
Joined: 2 years ago

Trusted Member
Posts: 33

@twincontrols Its not the video, but I think the HMI program. When you look at the array of BOOLs that represent the output LEDs in the MAIN program, it functions normally. I notice that the change of LEDs look a lot less smooth when the program is running at a really fast speed (~1 s). At that speed, it looks like LEDs are skipping over on the HMI screen. I don't know if there is a feature for increasing refresh rate on the HMI or what.

Reply
twinControls
Admin
(@twincontrols)
Joined: 2 years ago

Member
Posts: 115

@ehixenbaugh That's right. You'd need to change your HMI Response. This might help you: 

HMI Response

Reply
(@joris)
Joined: 2 years ago

Eminent Member
Posts: 17

@ehixenbaugh I'm not really sure that is an HMI issue, I think it's your code.

I have 2 questions:

  • Why did you a delay off line 18?
  • In normal mode when i_index >0 your piece of code manage only 1 led each PLC's cycle, why not all in one cycle?
Reply
(@jthyge)
Joined: 2 years ago

New Member
Posts: 2

@twincontrols 

My take on the challenge, made in ST in Siemens TIA.

Feedback on code is appriciated... 🙂 

FlowingLEDProgram

 - Jesper Thygesen

Reply
twinControls
Admin
(@twincontrols)
Joined: 2 years ago

Member
Posts: 115

@jthyge Thanks for sharing! From my understanding, each PLC cycle you're clearing your whole array, then filling your LED array again with using the current led position and the number of the flowing LEDs. I think it would work as well, however we wouldn't want to turn on the each LED one by one for this application. Let's say we have 5 flowing LEDs, we want to turn on the first 5 LEDs at the same time, then flow them together by one. You could maybe look at the shift registers in TIA 🙂

Reply
(@jthyge)
Joined: 2 years ago

New Member
Posts: 2

@twincontrols Thanks for your comment. 

"Clearing and filling" the array is done in one PLC cycle, so the LEDs are not turned on one by one.  

Reply
twinControls
Admin
(@twincontrols)
Joined: 2 years ago

Member
Posts: 115

@jthyge That's correct! What I meant is there might be an alternative way without needing to clear everything, then fill each PLC cycle. Your code looks clean and organized!

Reply
Posts: 17
(@joris)
Eminent Member
Joined: 2 years ago

Siemens Version. No HMI

Reply
2 Replies
twinControls
Admin
(@twincontrols)
Joined: 2 years ago

Member
Posts: 115

@joris Works really well! Great job! Would you mind sharing your implementation or screenshots from your code with the community when we have a few more answers?

Reply
(@joris)
Joined: 2 years ago

Eminent Member
Posts: 17

@twincontrols yes for sure. It will be a pleasure. 😁

Reply
raoliveira
Posts: 27
(@raoliveira)
Eminent Member
Joined: 2 years ago

Really nice to all

Reply
Posts: 17
(@joris)
Eminent Member
Joined: 2 years ago
Capture

 

Capture1

 

Capture2
Reply
1 Reply
twinControls
Admin
(@twincontrols)
Joined: 2 years ago

Member
Posts: 115

@joris Thank you for sharing your implementation! Well done!! 

Let's say if the customer is not sure about the total number of the LEDs at the beginning, how would you design your program today so that you won't have to change a lot of things when the customer wants to have N number of LEDs or N set of N number of LEDs in the future ? 🙂 

Reply
Share: