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

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

Post by medelec35 »

acestu wrote:when I press the button the macro is called sending power to the whole of port A
No what is happening is (Assuming variable called COUNT = 0 so 0 is loaded into portA).
When you press the button, the interrupt macro is accessed.
COUNT is assigned with 15

Code: Select all

COUNT=15
the interrupt macro is exited. Think of the interrupt macro as a call macro. You call the macro, after all commands are completed the End part is reached and the program carries on straight after the call part.

Now variable called COUNT is assigned with 15.
Now when program returns to main since COUNT = 15 when the program gets to:
PortA output.png
(1.63 KiB) Downloaded 3530 times
Decimal 15 = binary 1111 is now sent to port A so all LED's light

If you changed
COUNT=15
to say COUNT = 1
Then only 1st LED will light when pressed switch. It will make no difference if you keep pressing switch, only 1 will be assigned to COUNT so the LEDS will never change from the single 1 LED lit.
acestu wrote:
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.
That is correct. 1 is added to what ever COUNT is currently set at.
So if COUNT =11
after

Code: Select all

COUNT = COUNT + 1
COUNT will be = 12



acestu wrote:Am I correct in thinking that the word "COUNT" is a set command and not just a variable name of your choice ?
No your not correct.
COUNT is just the name of the variable the creator of the Flowchart decided to use. I did not pick that variable name as it was already in the flowchart you posted.


To summarize:
Based on Flowchat I posted.
COUNT = 0
Main loop keeps looping sending value of COUNT= 0 to portA
Switch pressed, loop halts, Interrupt macro is accessed, COUNT is assigned with 15, interrupt macro exited.
Main loop now continues forever sending value of COUNT= 15 to portA

Hope this helps.

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
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

Do you have to put the variable name in brackets or something in the print variable function ?

I have just put an lcd on the tut program so that it will show me the value of count.

Thanks
Acestu
TUT_23.FCF
(14.54 KiB) Downloaded 232 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: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

Think you have posted wrong flowchart, as it the same as original flowchart you posted.
No LCD.

As for brackets:
Brackets are normally used for changing the order of calculations which is what is done in maths.

You do not require brackets to print value of variable.

If you post the flowchart with LCD I can take a look at it for you.
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
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Sorry Martin,


This is the 1:
TUT_23_2.FCF
(15.26 KiB) Downloaded 241 times
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: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

No worries.
I have altered Flowchart so B0INT and Timer0 interrupts are both working.

Timer0 is being used to count minutes and seconds.

As a mini prject see if you can add an additional LED that starts of Lit.
Then after 20 minutes it goes out.
Hint: Use an additional variable called AlarmOn, and decision branches are required.
Attachments
TUT_23_3.FCF
(19.14 KiB) Downloaded 222 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
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

I did what you said, but did it for 9 seconds instead of 20 mins so I could test it, not sure if how I switched of the led is correct though as I didn't use the variable, ie do I calculate variable AlarmOn to 0 and then send to port , or as I have done.

Thanks
Acestu
TUT_23_4.FCF
(21.42 KiB) Downloaded 264 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: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

Its fine, that works!

You getting the hang of interrupts?

I just noticed the message about erasing digits was in the wrong place.
Should have been:
Comment.png
(6.3 KiB) Downloaded 3504 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
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

I see what I was doing wrong before now, to show the value of count on the lcd it should be print number of the variable and not print string...

I am just going to have a look at the timer interrupt that you did now as I have not done anything with these before.. :D

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
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

I am not understanding the Timer Interrupt really,

I see that the Timer0 interrupt will call the macro "Interrupt_TMR0" but when, what triggers it ?

I could understand it if the timer was a count down timer which you set and when it got to zero the macro would be called

Is it something to do with prescaler rate ?

Thanks
Acestu

P.S. Let me know if I am asking too many questions :D
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: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

It's fine, ask as many question as you like. :)

Ive not got much time now, but here is a bit of information on timer0
http://www.matrixmultimedia.com/courses ... ure.Timer0

You can think of timer 0 as a register that is counting all the time. when timer0 interrupt is enabled, it calls the timer0 interrupt macro when timer0 counter rolls over ie after 255, if incremented by 1 the next number is 0.
254 + 1 = 255
255 +1 = 0
(with byte the highest number is 255. if you add 1, it rolls over to 0)

Here is another link:
http://www.matrixmultimedia.com/mmforum ... =29&t=7500

If you still stuck then I will explain more later.
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
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

The keyboard has blown on my laptop so I haven't had much time to look at interrupts, I am getting one from ebay.

I think I understand Timer Interrupts a bit better now, basically they are running all the time and when they reach the point at which they roll or overflow the associated macro is called if that is right without involving all the complicated mathematics of pre-scalers.

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: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

Yes that sounds right to me.

Sorry to hear about your keyboard peoblem Hope you get your laptop working soon.

A few more important things regarding interrupts.

1) When interrupt is called (serviced), as soon as in the interrupt macro all interrupts are automatically disabled until interrupt macro is finished (leaving at the END point)
So for that reason keep the interrupt as short as possible. Best to make sure the time within interrupt is much sorter than the time it takes to fire next interrupt, otherwise next interrupt will be missed.

2) I have mentioned above that "all interrupts are automatically disabled until interrupt macro is finished (leaving at the END point)"
For that reason never use a call macro within an interrupt macro. Allow interrupt to comply finish and exit.

3) Corruption will occur if the using same component within an interrupt that you have in a non interrupt part of your flowchart.
E.g Anything containing delays: LCD, Delays themselves, RS232 etc. Even the Mod function.

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
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin,

I have got it half working for now, a very strange fault though in that anything that I clicked on the desktop windows would delete it, also when typing it would automatically put spaces in everywhere, oh well will get a new keyboard soon.

Was it you who bought the microwave and pir sensors when I did or was it Enamul, I just wondered if you had done anything with them yet.

Thanks
Acestu

EDIT: When you want to write a program do you draw a flowchart first ?
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: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by medelec35 »

Yes I have bought microwave and pir sensors, but not done anything with them yet.

As for drawing flowcharts first:
I just think about what I want the project to do and create the flowchart directly with Flowcode.
I'm not saying that's the best way, but i'm not that good at drawing flowcharts, and I can be a bit lazy with drawings first.

Since Flowcode has a simulator, I not felt the need to draw first.

I would say it's a good idea to write out all the i/p's o/p's required and any forms of conversions/calculations 1st
Look for most suitable microcontroller.
Then created Flowchart prior to ordering microcontroller.
Just in case code turns out to be too big!
Martin

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by Brendan »

Just a brief note on ultrasonic detectors in cars - should you ultimately decide to go that route.

I'd advise keeping the transducers away from the dashboard as any drafts from the dash/screen vents (such as on windy days) can set them off. It's possible to mitigate this in code to a degree, but better placed elsewhere in the vehicle cockpit - such as the door pillar or on the middle of the back shelf facing forwards if there's no rear vents nearby.

OEMs often mount them near or above the mirror for this reason, and reduced near-field reflections for improved disturbance detection, but possibly difficult for retrofit application without your nice car looking like an electricians workshop :)


All the best,
Brendan

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

Re: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Martin/Brendan,
Thanks for the info Martin about the flowcharts, and Brendan, I believe that the microwave sensor doesn't have to be in eye view of the intrusion ie it can be inside a glove compartment etc, not sure if that is right but I saw it on another website somewhere, but if this is not the case it won't matter because this is why I am trying to build a Dualtechnology alarm that must be triggered by both Microwave and PIR, thanks for the input though....
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.

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: Ultrasonic Transducer Module Car Alarm

Post by Brendan »

Hello Acestu.

The strategy is sound and should certainly improve matters, though I would personally combine microwave and ultrasound to secure a vehicle cockpit. My comments regarding ultrasonic sensing were based on a brother who used to fit them for friends and colleagues in the days when vehicle security devices were optional extras, and discovered this flaw the hard way !

Ultrasound will not sense beyond the vehicle cockpit (as can microwaves), though microwaves will be insensitive to drafts. A logical AND before triggering an alarm should prove reliably robust and avoid those nuisance triggers which engender complacent disregard.

Best wishes with your project :)

All the best,
Brendan

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

Re: Ultrasonic Transducer Module Car Alarm

Post by acestu »

Hi Brendan,
Microwave and Ultrasonic sounds interesting, the only reason I was going for microwave and pir is because that is what commercial property alarms use, your suggestion sounds rather good, I am not too keen on Pir because of its dislike of white light, You have me thinking now because I already have some ultrasonic transducers because that is what I was going to use originally hence the thread name, lets see what other input I get now.......
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.

Post Reply