Ultrasonic Transducer Module Car Alarm

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

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

Re: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

That's great news, the more the merrier, I think combined with the PIR module this would make a great little alarm system...

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
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi guys,

I have just bought one of these is any of you are interested, great price I thought.....

http://www.ebay.co.uk/itm/120895737622? ... 1439.l2648

and I think it will go nicely with the microwave unit.

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: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

That looks great!
Thanks
You have go a keen eye for a bargain!

That's a good idea for a new eblock, PIR Eblock as well as utrasonic transducer eblock:P
Martin

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times

Re: Ultrasonic Transducer Module Car Alarm

Post by Enamul »

Yes, Martin is right. These could be gathered in a handy Eblock. Good findings Stuart :)
Enamul
University of Nottingham
enamul4mm@gmail.com

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: Ultrasonic Transducer Module Car Alarm

Post by Benj »

Hello,
That's a good idea for a new eblock, PIR Eblock as well as utrasonic transducer eblock:P
We are currently working on sensor prototypes including PIR and Ultrasonic sensors which will be available to plug into our up and coming sensors board and robotics platforms. Probably looking at something like a summer release for these.

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: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

That sounds great Ben.
Will The new eblocks have there own component created in Flowcode so an update is required, or do we have use delays, inputs etc for the new eblocks to work?
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: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Guys,

I have started putting a program together for the car alarm, however I have just come to test the first bit of it and the output does not trigger, I think that I might have the wording wrong in the Decision in the Alarm On Macro, could somebody help me please ?

Thanks In Advance
Acestu
Car_Alarm.fcf
(17.64 KiB) Downloaded 300 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: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Guys,

I sussed this bit out I substituted + for AND.....

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: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Fellas,

Now that I have this alarm switching on, how do I implement the switching Off part, do I have to set up an Interupt ?

Thanks In Advance
Acestu
Car_Alarm.fcf
(18.44 KiB) Downloaded 369 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.

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: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

Hi Stuart, the alarm will only sound if both PIR AND Utrasonic alarms been detected.

If you want either then you can use | for OR.

| is the key which is shift backward slash.

As for the switching off.
Yes I would use a timer interrupt, so alarm not going of indefinitely which I believe is braking the law?

But could also annoy the neighbours, and could also flatten your battery.
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: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

Yes that is what I was trying to do ie only go off when the pir and the microwave trigger, and I put 2 delays in so that it will go off for a maximum of 20 mins which is law then wait 5 mins before it rearms, I think I posted the wrong file before so I will post it again...

Thanks
Acestu
Car_Alarm.fcf
(19.3 KiB) Downloaded 291 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: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

I just watched this youtube video about flowcode interupts: http://www.youtube.com/watch?v=oiEi_ZBc618

However when I followed the instructions and set to interrupt on port the properties box was grayed out, do you know why this is please ?


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: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

Hi Stuart,
IOC mask register does not exist on the 16F877A, so does not give options for the PORT interrupt.
The device you used that gave port B interrupt selection options would have IOC mask register.
You have to use software to decide if the interrupt was from a required pin by saving the port value from the last interrupt and using bit masking.
Just bear in mind only pins RB4-RB7 can generate the PORT interrupt on this device so RB0 to RB3 can't be used for this purpose.

Going to work now, but there are posts that use masking techniques for port interrupt detection.
If your still stuck then let us know I I will find something for you.

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: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

Do you think I am going down the right road here, ie should I be looking for a different device with this IOC masking ?

I looked for one before but you cannot search using this as criteria.

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: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

No you don't need to look for a device with the IOC register for your hardware to work the way you want it too.

you just need to add a little bit of code within the interrupt as stated earlier.

For instance have a look at this:
http://www.matrixmultimedia.com/mmforum ... 44&#p39310

I have illustrated how port interrupt detection can be achieved without IOC registor
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: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

Just before I do that, can I just ask you something, I have been looking at the example on youtube and I picked the same chip used to do a little experiment,

So am I right in thinking that if you have the device with IOC masking then you could set up an interrupt on port then in properties choose the port that you are going to use and set it to rising edge (which I take it means that it will trigger when you apply a voltage to the pin) then connect your switch to that port and when you press it the Macro that you created will be called, if this is so I wonder why my little program does not work ?


thanks
Acestu
Interupt_test.fcf
(10.5 KiB) Downloaded 242 times
EDIT:

Sorry I have new file working now
Interupt_test2.fcf
(10.5 KiB) Downloaded 219 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.

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: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

You have nearly got it.

Here what will happen:

Your program will be running normally.
port B Interrupt is detected.

You program temporarily pauses, all icons within interrupt is executed, program carries on from where it has paused from.

With your flowchart, you won't notice anything happerning because there are no instruction icons withing your interrupt, so what is happening:

Your program will be running normally.
port B Interrupt is detected.
You program temporarily pauses, nothing within portb interrupt so nothing different happens.
Program carries on from where it has paused from (which happened so quick, no difference can bee seen).

Try the attached file, It should simulate ok as well.
Attachments
Interupt_test2.fcf
(11 KiB) Downloaded 241 times
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: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

acestu wrote: EDIT:

Sorry I have new file working now
Yes you have spotted what you have done wrong.

Good job :)

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: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

I am not sure what the calculation LED_Enabled = !LED_Enabled is doing

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: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

Its just a bit wise toggle.

If LED_Enabled= 1
then after:

Code: Select all

LED_Enabled = !LED_Enabled is doing
LED_Enabled= 0

Likewise if:
LED_Enabled= 0
Then after:

Code: Select all

LED_Enabled = !LED_Enabled is doing
LED_Enabled= 1

Etc.

So each time interrupt is accessed:
If LED's flashing they will stop flashing.
If LED's had stop flashing then they will flash again.

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: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

I thought the program was just paused so when it starts again all should be well, so why the need for the bit toggle (I have it in my head that the interupt is going to terminate the program so why is the toggle important), or are you giving me an example if it were important ?


This is sort of hard to explain :)

Eventually what I want to do is use part of another project which will allow me to turn the car alarm on and off with the 433 mhz tranceiver, so I have got to figure out how to stop the main program loop and go back the unset state, I am thinking I have got to use the interupt to terminate the current process and not just pause it, does this sound logical ?

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: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

It was not essential to show toggle. I gave that toggle example just so you can see that your program is not paused as you think it might be?
Each time you activate the interrupt, after interrupt has finished,as stated earlier your program carries on from where is has pause from to service the interrupt.

Since your program is running all the time, I just wanted to show you a method of pause program when interrupt activated once, then carry on when interrupt was activated again.

In reality what would would do is use interrupt to activate alarm e.g activate=1
Then you would create a timer interrupt so when 20 mins has passed then activate=0 will be executed.

Perhaps this will help?
http://www.matrixmultimedia.com/mmforum ... =36&t=6390
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: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

I have looked at a few different articles on interrupts now, I found this one which is simple but I just can't see how it is working, could you have a look for me please and read the comments that I have put in it...

Thanks In Advance
Acestu
TUT_23.FCF
(14.54 KiB) Downloaded 261 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.

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: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

The program you posted just works with B0 interrupt.
Each time you press switch connected to B0, interrupt macro is serviced and 1 is added to your count variable.
Since in the main routine portA is using count then in effect every time interrupt is activated the LED's will count in binary
i.e
0
1
10
11
100
etc.
With only 4 LED's and count going from 0 to 255, you will not see the full effect.
If you want all four LEDs to light when interrupt is pressed then within interrupt change:

Code: Select all

COUNT = COUNT + 1
to

Code: Select all

COUNT = 15
Its also good practice to double click on your port component within flowchart and select use masking. Select 0 to 3 for all your four LED's.
That way all port thats not used (B4 to B7) will not be affected.

If you use COUNT = 15 then when switch is pressed all LEDs will light up, and stay lit until power is removed.
That's what it looks like you want to do.
If not then let me know what you are trying to do and I can assist further.

Not simulation is not working correctly. LED's should only be changed when switch is pressed in, and not again when released since interrupt on rising edge is used.

Martin

I
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: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

I am just trying to understand how interupts work by following what the program is doing, the way it first looked to me is that when I press the button the macro is called sending power to the whole of port A, so I am thinking all LEDS on port A should light up but they are not.

I think this is similar to the old school yard joke ie what is 2 add 2 and you say 4 and they say No it's 22, as in when it adds 1 to count it is not just 1 on its own , it is 1 plus whatever is already there , and I think what you are saying is that these numbers are sent to port a and it is showing in light the equivelant binary set.

There now my brain is fried :?

thanks
Acestu

EDIT: Ha Ha 15 Decimal to Binary =1111, Am I correct in thinking that the word "COUNT" is a set command and not just a variable name of your choice ?
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.

Post Reply