Further to 'ALARM ADDITION'

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Further to 'ALARM ADDITION'

Post by christoph »

Hi Martin,
Hope you dont mind me posting this directly to you but the system (your last flowchart postied under heading 'ALARM ADDITION' - for the benefit of other forum users) unexpectedly needs an output to light a dedicated LED 500 mS AFTER
port B LEDs are displayed (having pressed push button C3) and lit for only one second regardless of whether C3 is relaesed immediately (inside or outside of that one second time) or not. This needs to happen at every C3 press/release.
I have tried to do this but whilst I understand the flowchart in general, I am not quite getting the 'mechanism' behind the decision box if: ((Port_Old=8)!!(Port.Old=13))&&(Disable Test=0) and the calculation: 'Port_Old=5' although I guess there is a tie-up there?
I have been getting various interactions between the push buttons and the LEDs in trying to do this unsuccessfully, so would greatly appreciate it if you could possibly tweak the flowchart to make this work.

Best regards,
Chris

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by medelec35 »

Hi Chris,
christoph wrote: ((Port_Old=8)!!(Port.Old=13))&&(Disable Test=0)
The !! you asked about is not really ! is the pipe key ( | ) that is next to the z (on the same key as backward slash ) on a uk keyboard.
|| means Logical OR
&& means Logical AND

So in pseudocode:
If Port_Old=8 or Port.Old=13 and (Disable Test=0) then check if Test is equal to 0

You can look at the & | and even ! since it can be used on this post
Or this article

I have attached a tweaked flowchart that will light LED connected to C1 500ms every time C3 is pressed.
LED will extinguish 1 second later.
You did not say if the LED was to be locked out if data is received?
I have used timer 1 interrupt for the timing.
Basically TimerInt macro is accessed every 100ms.
This simplifies the flowchart, since after it has been accessed 5 times, you know that 500ms has elapsed.

Important:
Both timer1 and RX interrupts don't simulate.
So only for running Flowcode simulator, both interrupts will need to be moved up anywhere within the Main loop, then back outside the main loop before compiling flowchart.

Martin
Attachments
Alarm addition 1e.fcf
(24.18 KiB) Downloaded 552 times
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by christoph »

Hi Martin,
Thankyou for the response and explanation - I get it now and I found the 'vertical bar ' but it is on the key next to the 1 on my machine and there are 3 symbols on it so I can do ` and ¬ but not figured out a way of getting that one!
I moved the interrupts for simulation but I couldn't get the C1 LED to light ( yes, it does need to be overriden by an incoming data signal - sorry I forgot to mention that ). I tried moving them again and having a look over everything but I couldn't find the reason for that....

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by medelec35 »

christoph wrote:I tried moving them again and having a look over everything but I couldn't find the reason for that....
Oops, sorry I have interrupts on the brain.
I should have said call macros, and not interrupts:
Here for simulation.png
(10.73 KiB) Downloaded 14138 times
christoph wrote:I found the 'vertical bar ' but it is on the key next to the 1 on my machine and there are 3 symbols on it so I can do ` and ¬
So long as its the solid
You need to look out for a solid bar not a broken bar.
On my keyboard the symbol that's next to the 1 is ¦
So it's the wrong symbol.

To print that symbol its Ctrl Alt then that key.
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by christoph »

Symbol|||| sorted - thanks Martin.
Have moved the call macro's as indicxated for simulation but my C1 still not lighting..?

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by medelec35 »

christoph wrote:ave moved the call macro's as indicxated for simulation but my C1 still not lighting..?
This is because the simulation is probably running too fast.
Rather then timer1 interrupt being accessed every 100ms, interrupt macro is being called at the end of each loop.
To get round this you can set your simulation speed lower.
Try setting it to 1000 from View, Project Options :
Chang simulation speed1.png
(45.78 KiB) Downloaded 14129 times
As you can see from this:
Chang simulation speed2.png
(50.27 KiB) Downloaded 14129 times
The MilliSeconds100s is showing 6 so 600ms has elapsed since pressing C3, therefore LED would have been lit for 100ms.
Don't forget you can pause or set a breakpoint to stop the simulation and view the variables.
After simulation you will need to move two icon as mention earlier, before compiling and using either real hardware, or a third party simulator mentioned here
To check that LED is only on for 1 second.
Flowcode simulator is unable to run the timer interrupts in real time.

Martin
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by christoph »

OK, cool - I understand all that now and will put it onto chip in the morning (as I got diverted from checking earlier and it's got late this evening).
Many thanks, Martin - will let you know result tomorrow :)
Cheers,
Chris

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by christoph »

Hi Martin,
I programmed successfully but C1 not outputting on hardware. Did thorough check and everything else works fine but nothing out of the 767 Pin 12 C1.
Checked the flowchart operation and was getting the C1 output coming on and going off (after quite a few seconds; say 30 secs or so) LAST NIGHT, I found that my copy was not doing that any more so I went back to the forum and ran your same updated 'e' version and neither did IT give any C1 output for some reason!? It's a bit odd but have you any ideas...!?

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by christoph »

Sorry Martin - I totally forgot that I should have run it at 1000 and not 'as fast as possible'.
However, the problem is C1 doesn't light on the hardware - having put the two macro call ups back in their correct position. Have checked hardware and LED etc and everything is correct. Would it help or/and simplify the flowsheet if I say that the one second delay for C1 coming on is not important in itself (the quicker the better actually) but what IS important is that the binary number on the LEDs is definitevly established BEFORE C1 outputs

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by medelec35 »

Hi Chris,
It looks like using timer1 inhibits C1, I had not remembered about this.
Can you try something.?
In your flowchart within TimerInt macro change both outputs from C1 to C4
Then rewire LED from C1 to C4.
It should then work correctly.

Let me know if using C4 is an issue then I can just try with timer0 instead of timer1 interrupt.


Martin
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by christoph »

Hi Martin,
Yes C4 was available and that works a treat now - was that something which I might have found in the PIC data sheet or is it just one of those things which come to light with experience?
Just noticed that PB1 will not now operate L1 LED and PB3 works haphazardly however long or short the press whilst PB2 and L2 work perfectly - is this anything to do with C4 - another of those odd reactions? Maybe it could go onto another port but the trouble is nothing else available on port C or B. Only got port A1,3,4,6 & 7.
Have checked PB1 and PB3 in the PB" position and they are OK in that position and wiring is same as always.

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by christoph »

Hi Martin,
I have got round the problem hardware-wise, so am using the pre-C1/C4 addition flowchart but many thanks for your help and adding to my learning curve!

Best regards,

Chris

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by medelec35 »

No problem.
Getting the LED to come on for a set time is proving to be a real pain in the backside.

It looks like the RX interrupt and timer interrupts are conflicting with each other, and no experienced that before.
If I can work out how to stop the confliction then I will post something.
If remove the RX interrupt, then LED that's connected to C port does light up as normal.

Martin
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by christoph »

Hi Martin,

Thanks for your feed back - yes that is strange but would be interested to hear if you were able to sort it out but dont worry on my account because the work-around is ok though less 'neat'.

Many thanks again though for your help.

Very best regards,

Chris

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Further to 'ALARM ADDITION'

Post by medelec35 »

Hi Chris,
Had a bit of time spare and attached flowchart works ok on hardware for me.
Here are the timings in relation to C3 i/p and C1 o/p:
Modified version 1F.png
(131.54 KiB) Downloaded 13944 times
Ports A and B appear to be working correctly as well.

Hopefully all will work for you to.


Martin
Attachments
Alarm addition 1f.fcf
(22.59 KiB) Downloaded 492 times
Martin

Post Reply