Adding Piezo PT-1540PQ to my Alarm

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

Moderator: Benj

Post Reply
User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Adding Piezo PT-1540PQ to my Alarm

Post by JLeith »

Hello All
I have been trying to follow the post on adding a Piezo for my Alarm State.

The Piezo is small enough and I would like to add code to make it work in my Baseball Counter.

All the Piezo project are back in V2 2013 can't find on for V6 flowcode

I have added my program The alarm sequece truggers at 25 pitches. And Port 5 Pulses. I would like to control a Piezo on B7

I have 2 terminals to connect the Piezo ( PT -1540 PQ ) Terminal 1 from PIC Terminal 2 Ground
The B7 current state flashes a LED

All the help would be helpful

John
Attachments
Pitcher count Master_016_July 22_JL.fcfx
(116.47 KiB) Downloaded 265 times

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: Adding Piezo PT-1540PQ to my Alarm

Post by medelec35 »

Hi John,
I would say the easiest way is to add PWM component.
Choose a spare channel which has nothing connected to the pin.
If you select the PWM on panel then if can't see properties, just right click and select properties.
Keep selecting a different channel until a pin is shown that is free.
Change Frequency to match resonant frequency of piezo = 4KHz
Set Prescaler to 16 and Period Overflow to 124.
Add

Code: Select all

 PWM1 Enable
component to Main just below

Code: Select all

TMR0 enable
will be fine.
To control the Sound use

Code: Select all

SetDutyCycle
0 for piezo off
My guess is set

Code: Select all

SetDutyCycle
to 62 for maximum volume.
The lower the value, the quieter the sound will be.
If on Maximum volume sound is not loud enough, then you will required an additional transistor to connect piezo to a higher voltage.
If higher voltage is not available then other way is to connect the piezo to two pins.
You won't be use PWM component as that does not allow push pull two pins.
You would have to use a timer interrupt to toggle pins at the desired frequency.
This has the effect of doubling the peak voltage.
If going down that road the flowchart will be a bit more complex, so I can assist you with that.

Martin
Martin

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Adding Piezo PT-1540PQ to my Alarm

Post by JLeith »

Thank you Martin

Nice to work with you once agian

Off to program. Will let you know how it goes

John

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Adding Piezo PT-1540PQ to my Alarm

Post by JLeith »

Hello Martin

My Black hole is back

I think I followed your program steps but no sound
I used my Team Display I can get to the Printed circuit to make connections.

I have PORT E0 on the Master and Team Displays.

I tested and Port E0 will activate with a buzzer but no Sound with Piezo.

On the setting in Flowcode 6 I can not set the frequency
Only Port, Timer, Prescale.

Set a picture and the Team Program

John
Attachments
Alarm Settings.jpg
Alarm Settings.jpg (131.71 KiB) Viewed 6097 times
Team Pitch count 23 John_July 24.fcfx
(116.54 KiB) Downloaded 273 times

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: Adding Piezo PT-1540PQ to my Alarm

Post by medelec35 »

Hi John, first of all you need PWM at 4KHz.
You can't directly set frequency you can only set period and prescaler.
You still have period at 255.
In my previous message:
medelec35 wrote:Set Prescaler to 16 and Period Overflow to 124.
You can check the PWM output by connecting a scoope or even LED + limiting resistor.
LED should be more dimly lit then if connected to +5V and GND

There is a PWM bug with FC6, have you seen this post?

Martin
Martin

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Adding Piezo PT-1540PQ to my Alarm

Post by JLeith »

Thank you

Opps I miised the 'Period" to 124

Changes made I checked the Patch listing My file is 2015 is 14.8 KB and the new one on that listings is 14.7 KB.

Didn't change my 2015 version should I change it ?

John

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Adding Piezo PT-1540PQ to my Alarm

Post by JLeith »

Hello Martin

100% working I renamed the File and loaded the new version

Now I just need to do a liitle tweak to get a double tone.

All the best
Attachments
Happy thumbs up.jpg
Happy thumbs up.jpg (11.06 KiB) Viewed 6092 times

Post Reply