Join us today!

Notifications
Clear all

Custom Flash Timer

8 Posts
3 Users
3 Reactions
527 Views
twinControls
Posts: 115
Admin
Topic starter
(@twincontrols)
Member
Joined: 2 years ago

Create a custom flash timer which would allow users to control the inputs below: 

  • On time
  • Off time
  • Pause time
  • Total time
  • Number of Flashing Before Pausing 

A sample function block and the output can be seen below: 

 fbCustomFlash(
            bStart:= bStart, 
            tOnDuration:= T#2s, 
            tOffDuration:= T#1s, 
            tPauseDuration:= T#4s, 
            tTotalDuration:= T#20s, 
            nBlinkCountBeforePause:= 3, 
            bOut=> bPWM);

 

customFlashTimer

 

Sample output for the values below: 

  • On time = 1s
  • Off time = 500ms
  • Pause time = 3s
  • Total time = 35s
  • Number of Flashing Before Pausing = 4
timerOutput

 

Happy coding! 

Reply
7 Replies
Posts: 30
 Alex
(@alex)
Eminent Member
Joined: 2 years ago

Like this :

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

Member
Posts: 115

@alex Thanks for sharing! Could you plot your output signal using these values :

  • On time = 1s
  • Off time = 500ms
  • Pause time = 3s
  • Total time = 35s
  • Number of Flashing Before Pausing = 4
Reply
Posts: 30
 Alex
(@alex)
Eminent Member
Joined: 2 years ago
Chart01

Here it is, 

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

Member
Posts: 115

@alex The output should look like this: 

timerOutput
Reply
ehixenbaugh
Posts: 33
(@ehixenbaugh)
Trusted Member
Joined: 2 years ago

Here is my Custom Flash Timer

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

The video is a bit messy but it functions correctly I believe

Let me know of any errors or criticism.

-Evan H.

fbCustonTimer MAIN
fbCustonTimer code

 

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

Member
Posts: 115

@ehixenbaugh Nice! Maybe instead of having one FB, you could extend the function block from this example.

Could you also take a screenshot and share your output signal? It was a bit difficult to understand from the video that if the output becomes off when the total time has been reached. 

The output signal for the values in the challenge: 

timerOutput
Reply
ehixenbaugh
Posts: 33
(@ehixenbaugh)
Trusted Member
Joined: 2 years ago

Here is are my images. I had an error in my first post (I forgot to turn off the Function Block when the input signal is not active by having b_InputSignal be a condition for the IF statement in the FB), that is why in my video there is a continuous loop of pulsed signals. 

In my PWM, the output signal turns off immediately when the total duration timer is has reached PT. That is why there is no signal cutoff and I have this reflected in the live snapshot of my function block.

fbCustomTimer scope
fbCustonTimer code
Reply
Share: