IOC PortB Interupt

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

IOC PortB Interupt

Post by acestu »

Hi,

Would I be right in thinking that , Interrupt On Change Port B will operate when any pin on port B changes ie +5v is applied ?

thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: IOC PortB Interupt

Post by Benj »

Hi Stu,

Hmm no that's not the complete picture. For example the "IOC Port B" interrupt on a 16F877A only applies to the upper nibble of the port.

Would be nice if the properties button was always available to show you which pins are associated with the interrupt. I'll ask Jonny and see if we can do something here as the info is in the target definition file.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Hi Benj,


The upper nibble being B4,B5,B6 and B7 ?


thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: IOC PortB Interupt

Post by medelec35 »

Hi Stu,
acestu wrote:The upper nibble being B4,B5,B6 and B7 ?
A nibble is four bits.
So upper nibble = upper most bits which are B4, B5,B6 & B7,
So you are correct.
If you also look in the datasheet for a microcontroller, and look at the pin functions,
It should show all the pins that support IOC.
Benj wrote:ould be nice if the properties button was always available to show you which pins are associated with the interrupt.
I like that idea.
Martin
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Hi Martin,

I have used pin B5, but for some reason in simulation it only works once, I thought it reset itself after the selected macro had been called ?

thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: IOC PortB Interupt

Post by medelec35 »

Hi Stu
No it should not reset itself after using once.
Would you like to post your flowchart, I can see if its same issue for me as well?
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Hi Martin,

I am enclosing my chart, it is for my car alarm using the pir sensor and microwave sensor that I bought some time ago, when you spot the obvious mistakes don't laugh too loud because I have a very bad head cold lol..
CarAlarm.fcfx
(24.33 KiB) Downloaded 388 times
cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: IOC PortB Interupt

Post by medelec35 »

Hi Stu,
Problem you had with your Flowchart was not the interrupt as that's working as expected.
Issue was caused by having a infinite loop in Armed Macro.
So when you disarm macro, Flowchart would jump from Armed to disarm, then back to Armed. So as soon as armed LED goes off, as soon as port interrupt macro is exited, your alarm will be armed again.
Removed loop, and now is working as expected?

Martin
Attachments
CarAlarm V1a.fcfx
(24.6 KiB) Downloaded 333 times
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Hi Martin,

That's interesting, so the interrupt can't stop the loop ?,

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: IOC PortB Interupt

Post by medelec35 »

You can used an interrupt to set a flag to stop a loop.
Eg. if within interrupt you have a variable called MacroAccessed. that is set to 1.
then you can have:
Loop until MacroAccessed = 1
An interrupt once triggered, causes the flowchart, to remember where it currently is.
Interrupt macro is accessed, then exits when reaches the end, then flowchart continues from where it was left off.

Hope I have explained it ok?
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Hi Martin,

Now that the loop has gone from the armed macro, you can't set the alarm off by pressing the pir and microwave buttons, so am I looking at doing this a different way?

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: IOC PortB Interupt

Post by medelec35 »

Yes, and I can help you with that if you get stuck.
:)
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Ok Martin,

Thanks, I will have a mess and see what I can come up with first... :?

Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: IOC PortB Interupt

Post by medelec35 »

no worries,
Thats the best way to be.
Learn more from your own trial and error than if towel is thrown in straight away.

Martin
Martin

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

Re: IOC PortB Interupt

Post by medelec35 »

One thing I would do if it was me, it to have the alarm sensors connected to IOC, so if only briefly activated, then alarm will trigger.

Martin
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Hi Martin,

I think I might need some ideas because it is not as straight forward as it sounds because of these points:

1. The alarm will not go off unless the pir and the microwave unit switch on at the same time
2. If the alarm is triggered then it must only sound for 20 mins and then rearm itself (to make it legal in this area)

thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: IOC PortB Interupt

Post by medelec35 »

Hi Stu,
He is my attempt with not using ioc for both triggers yet as not sure if thats what you require?
sounder will go on only if alarm is armed and both PIR and Microwave sensors are both triggered.
Sounder will shut off after 20mins.
Seems strange to say this but simulator is much faster than real time (unlike previous versions of flowcode). But thats a big advantage in my opinion.
Attachments
CarAlarm V1b.fcfx
(30.31 KiB) Downloaded 280 times
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Hi Martin,

I will have a look at your chart, and I will post my last attempt, I couldn't work out how to disarm it...

cheers
Acestu
CarAlarm V2.fcfx
(22.25 KiB) Downloaded 313 times
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Hi Martin,

I think that's pretty much it except for automatic rearming after the 20 mins sounder time has expired, am I right that after the 20 mins the alarm resets and is not armed ?

I am not bothered about using IOC for triggers Martin, I was just trying different ways to get it working.

thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: IOC PortB Interupt

Post by medelec35 »

Morning Stu,
acestu wrote:am I right that after the 20 mins the alarm resets and is not armed ?
Yes thats how I have coded your alarm.
I have modified flowchart so If alarm is triggered, sounder is on for 20 mins, off for 20mins (alarm is still armed), back on for 20mins etc.
If you want the off time to be different, then can change that for you.
Since I have to get ready for work, don't have much time, so it may not be fully working the way you want it, as not fully tested.

Martin
Attachments
CarAlarm V3.fcfx
(30.59 KiB) Downloaded 296 times
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Hi Martin,

Thanks for doing that, \i will have a look when I finish work later...

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Hi Martin,

This looks fine so I think it's time to build it and see how it performs......thanks for your help.....I will post the schematic etc when I have finished

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: IOC PortB Interupt

Post by medelec35 »

Sounds good to me :)
One suggestion rather then on for 20mins then off for 20 mins:
Would it be better if on for 20 mins and off for a set time that's contained within a variable at the start of flowchart?
Or do you think off for 20mins is fine?

Martin
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: IOC PortB Interupt

Post by acestu »

Hi Martin,

Yes thats a brill idea, I just didn't want to make any more work for you..

thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: IOC PortB Interupt

Post by medelec35 »

Not a problem.
There was only minor changes required.
Its better to state all the functions you require, rather than not saying because you don't want to make any more work for me.
I don't mind :)

Martin
Attachments
CarAlarm V4.fcfx
(31.71 KiB) Downloaded 303 times
Martin

Post Reply