Page 2 of 6
Re: Implementing a non blocking delay
Posted: Tue Jan 20, 2026 5:50 pm
by mvictor
I have v9. Lemme try that out tomorrow and I shall get back to you. Thanks for this help for now.
Re: Implementing a non blocking delay
Posted: Tue Jan 20, 2026 6:04 pm
by chipfryer27
Hi
I should have a bit more time tomorrow so could possibly assist further. Is your trigger a one-shot or can it go high numerous times during the time-frame?
Could you perhaps use PortB for trigger and Port A for delayed output? I ask as PortB has IOC which would make things a lot easier.
Regards
Re: Implementing a non blocking delay
Posted: Tue Jan 20, 2026 6:23 pm
by mvictor
As it detects signal from my PLC, the trigger will go high. It will go high only when there is a signal from my input end (the PLC). So it is a one shot.
To use port B as trigger would be a little challenging as my pcb tracks are designed as Port A for inputs and port B is output.
Re: Implementing a non blocking delay
Posted: Tue Jan 20, 2026 6:28 pm
by chipfryer27
Hi
OK, it was just a thought but as you have one-shot then implementing a timed period based on your trigger is quite straight forward.
Regards
Re: Implementing a non blocking delay
Posted: Wed Jan 21, 2026 7:04 pm
by mvictor
Hello again,
I have attempted putting a timer interrupt in my main to increment count1. But in my case it is not calling my required macro. Perhaps I might be missing something out. Uploading my program to get further assistance.
Re: Implementing a non blocking delay
Posted: Wed Jan 21, 2026 7:58 pm
by chipfryer27
Hi
You only need to initialse the Timer Interrupt once, before the Main loop. No need to keep initialising/disabling it.
I'll reply more later (assuming nobody else jumps in) as I'm pushed for time just now.
Regards
Re: Implementing a non blocking delay
Posted: Wed Jan 21, 2026 9:28 pm
by mnfisher
I've done a simple example - with a single LED and button to activate the timer - this will allow you to run in simulation (in v9) and hopefully follow the logic.
When the button is pressed - a countdown for the LED is set (I've used arbitary values) - and the ISR counts down - and either lights the LED - and sets a timer until off or turns the LED off.
As set here - the button is ignored until the LED is off.
Depending on the ISR timing (which will depend on clock etc) - I've allowed up to 65535 pulses before lighting and turning off - and you can adjust the counts to suit.
To extend to 3 LEDs - add extra LED / Button pairs - and duplicate the code with new time and state variables...
Martin
Re: Implementing a non blocking delay
Posted: Wed Jan 21, 2026 9:41 pm
by mnfisher
As an aside - I've done a little work in the ISR - and in general ISRs should be as short and fast as possible. I've set it to as slow as possible interrupt rate (1:256) (I used timer 0) - but if it runs at 75Hz (maybe using a different timer?) - then the small amount of code here would be fine.
Also - as I used v11 - Flowcode will complain that it was created using a newer version - click YES.
A very good feature of FC - create a property and set to 'single digital pin' - then you can assign input / output pins in properties.
In a calculation you can do pin = 1 (output) or (.input = pin) - which is neater than using input output blocks (especially if you ever want to change pins!)
Martin
Re: Implementing a non blocking delay
Posted: Thu Jan 22, 2026 7:25 am
by mvictor
I downloaded the program, but it is throwing two error of missing component which is LEDMono1::Setstate and Switchpushbutton. Are these components unavailable in V9 ?
Re: Implementing a non blocking delay
Posted: Thu Jan 22, 2026 8:02 am
by mnfisher
Possibly - sorry, i don't have v9 on my pc at the moment..
You could swap to another led component and a momentary push button - or just use input and output - and then view->digital pins.