Implementing a non blocking delay

For general Flowcode discussion that does not belong in the other sections.
Post Reply
mvictor
Posts: 2
http://meble-kuchenne.info.pl
Joined: Thu Aug 25, 2022 7:46 am

Implementing a non blocking delay

Post by mvictor »

Hello,

Flowcode version v4, PIC16F88.

I am trying to implement a non blocking delay to power ports B5, B6 and B7 with the required delay in seconds on receiving a hi signal from input ports A4, A0 and A1. I was able to use TMR0 interrupt to create a delay for the first B5 output but whilst using TMR1 as interrupt for B6 output it is just not calling my macro.

The thing behind this is that the port B outputs must turn hi after respective seconds on receiving respective hi inputs from port A. Non blocking delay is needed because i need the program to run continously to record the inputs. Attaching my macros, the Main is only calling my REJECT macro in a while loop.

Could use some help please?
Thermaltimingjan26 Macro - TIMERSERVICE2.JPG
Thermaltimingjan26 Macro - TIMERSERVICE2.JPG (32.75 KiB) Viewed 148 times
Thermaltimingjan26 Macro - TIMERSERVICE.JPG
Thermaltimingjan26 Macro - TIMERSERVICE.JPG (32.32 KiB) Viewed 148 times
Thermaltimingjan26 Macro - REJECT.JPG
Thermaltimingjan26 Macro - REJECT.JPG (23.28 KiB) Viewed 148 times

mnfisher
Valued Contributor
Posts: 1791
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 151 times
Been thanked: 847 times

Re: Implementing a non blocking delay

Post by mnfisher »

Flowcode v4 is now no longer supported - can I suggest you try v11 - you will find a lot has changed for the better...

If you need a non blocking delay you will need to get rid of the delays in your code... A timer interrupt could handle things (and must not contain delays)

Martin

mvictor
Posts: 2
Joined: Thu Aug 25, 2022 7:46 am

Re: Implementing a non blocking delay

Post by mvictor »

I did try using timer interrupt. I am able to work TMR0 and it calls my macro TIMERSERVICE, but in case of TMR1 it does not call my macro TIMERSERVICE2 which is linked to TMR1.

mnfisher
Valued Contributor
Posts: 1791
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 151 times
Been thanked: 847 times

Re: Implementing a non blocking delay

Post by mnfisher »

It might be missing the interrupt - you have a 300ms delay in the first macro shown (which i assume is the ISR) - this would likely cause your program to fail.
It is very hard to tell from screen shots (no macro names etc) - so please upload your code - however, as version 4 is now no longer supported I would suggest upgrading to v11 (it is free for personal use) then it will be easier to help...

Martin

chipfryer27
Valued Contributor
Posts: 1825
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 404 times
Been thanked: 627 times

Re: Implementing a non blocking delay

Post by chipfryer27 »

Hi

Have to strongly agree with Martin above that you should seriously consider v11 as it is "free" for hobbyist use. Few on this forum will even remember or have v4. I still have a copy on a machine somewhere, but where....?

V11 won't open your program. It would need to be converted into something modern versions can use by using v7. I definitely have v7 so could try for you.

Without seeing your program it is difficult to assist, but could you perhaps just have one timer? Enable it once and leave it running. In the ISR Macro it increments one (or two counters) every second.

In your main loop when you want to start a time period, reset the appropriate counter then in your main loop test for it's desired value. You can either leave it running to proviode second value or start / test a seperate counter. Keep your ISRs as short as possible and avoid delays in them. Have your Main loop do any tests etc.

Regards

Post Reply