Using the PSoC4 pioneer kit with the proximity project setup and trigger sound?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 So im looking to take and expand on the proximity detection project from element 14, ive got it running (the sample) and was trying to find a good tutorial on expanding that to trigger a sound or buzzer when you are within a certain range, 

   

 

   

Ive found some stuff on youtube, but most use arduino setup's and nothing is simple as i was hoping to do, i dont need all the bells and whistles, basically want to write the code for the pioneer to sound a buzzer or speaker that i attach to it when you are within certain distance from the device.. (setting up for my dogs) to keep them away from certain areas in the house.. 

0 Likes
33 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Just use a PWM with period beween 500Hz to 1kHz and connect a transistor that drives a small speaker. Care for freewheel diodes, because coils may induce some unwanted voltages. You may additionally change the frequency with the distance, if you like to.

   

 

   

Beep, ahhh... Bob  😉

0 Likes
Anonymous
Not applicable

 ok, so within the project there are already 3 PWM'sfor the RGB light on the board.. Are you saying to add another one to handle the other function im trying to do?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Yes, why not? There are enough resources left and using one more PWM (8 bit UDB) should work as far as I know.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Speaker -

   

 

   

Simple peizo drive.

   

 

   

enter image description here

   

Speaker -

   

 

   

   

 

   

R1 should be calced for Ic / 10, to insure saturation.

   

R2 is to keep Icbo from turning on Q1 when speaker is off or PSOC output tristated.

   

D1 to suppress L transients due to voice coil

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Well this work with any small speaker? I have small speakers i have removed from some shock sensor devices i had laying around. or will i actully need a peizo speaker?

   

 

   

They were in this device.

   

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

You have to know its technology, if either piezo or voicecoil yes, but drive

   

circuits different.

   

 

   

Make sure you clamp with diode(s) to insure no transient takes PSOC pin

   

Vdd + .5 > Vpin > Vss - .5

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 ill check when i get home and can look at it again.. 

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

If Piezo attached some apps info.

   

 

   

You can drive it differentially which will produce much more bending/volume.

   

Make sure to clamp each pin with a pair of diodes so the pin stays within

   

Vdd + .5 > Vpin > Vss -.5

   

 

   

Image result for cmos diode clamp image

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 So i got the proximity project built, then built a sample application in c# for serial communications via a sample found online.. 

   

I can see the output from the pioneer kit within the windows application.. so thats def good thing

   

Now, before moving on to wiring up the sound, id like to try and make the application a bit smarter before just triggering a sound, how can i determine a more accurate reading?

   

 

   

right now the only values that im getting back are 252,254 and 255.

   

255 being the value that indicates something within range.. now maybe i missed something but since i was seeing a  range of colors on the LED on the actual board, i figured that it was a range of values that were being read, if i view the data within the bridge control panel, the graph that is represented def shows a huge curve when i get close or touch the wire.

   

Is there a way to be little more granul so that i can trigger the sound when you are within feet instead of inches? I figure if i use a longer wire, that the range will be greater, so i def dont want to trigger the alarm when you are 10 ft away, i want it to sound when you are 1ft or less away.. 

   

what are my next steps, what sample or document should i review/read?

   

 

   

thank you

0 Likes
Anonymous
Not applicable

 Here is what i see within the bridge panel

   

   

So basically based on this graph, i would only want to sound the alarm when the reading was over 400 and steady for a few

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Best is always to post your complete project with all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
I recently made an example to show the use of printing data to the PC that uses a proximity switch as well, have a look here

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 well wait, my psoc project works as expected, everything looks correct within the bridge panel graph that i posted, im sure my issue is on the windows(c#) app side, would i need to post that as well?

   

 This is the example serial comm project i found and used.. 

   

http://www.dreamincode.net/forums/topic/35775-serial-port-communication-in-c%23/

   

im sure the converting to hex is where the problem is.. 

0 Likes
Anonymous
Not applicable

 So i have a question, probably very simple for most, but im learning, so i brought home my project for this from work so i can work on it over the weekend, so i loaded it, i have the same versions and updates as i have at work, everything builds and runs, setup on my home kit and everything reacts like it did at work, but when i open the bridge panel here at home and view the realtime data, the graph is really choppy, its not smooth like the above pic i posted.      

   

Ive gone thru the settings, cleared it and so on, but cant figure out how to get a smoother line.     

   

What am i over looking?     

   

 

   

Also, now that im working on this at home, id like to expand the range tht it can detect, so ive added a 2ft solid strand wire to the board. Could that have anything to do with the choppiness of the results being graphed?     

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

What was the wiring expanding, eg. whats it connected to ?

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 if you are referring to the 2ft wire, its connected to p1.0 on the board. its just a replacement for the shorter one that i had on there when i first started to work with the project.

   

 

   

If i put back the smaller wire, it still the same results.. ill try to post a pic of the graph that is generated within the bridge panel shortly.

0 Likes
Anonymous
Not applicable

 Well apparently it just needed a lunch break, i come back, plug it in, run the graph and it looks like the above graph.

   

Is there any reason that would happen? I mean the only thing that wasnt done when it wasnt working was i never unplugged it from the USB after programming, before lunch i unplugged to test powering it from battery, came back and plugged in and looks right.. 

   

 

   

But now i restarted the graph and its not right again.. 

   

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

In the first picture you took 300 samples and in the second chart were more than 100,000 samples displayed. That will make a difference.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 but what affects that, i just tested, if i unplug the usb, plug it back in and run the graph is looks nice and smooth, if i leave it plugged in for a while and then graph it, then it looks choppy.

   

does the length of the wire cause that? I mean being that the first wire was about 8in long and now i have almost 2ft wire connected, im assuming that more data is being collected right?

0 Likes
Anonymous
Not applicable

 to me it seems that the longer its powered on and running, the worse the graph gets, i understand that its merely collecting all the data points, but how will that work and affect me when im ready to set this up in my house to actually detect my pets?

   

Based on the smaller collection of data i can do a small test based on the range of collected values, im sure there is a calculation that i could use to deal with such a large amount of records, but for my baby steps, im just trying to understand and get working a small simple setup that once you or something is withing  X number of feet or inches that i can trigger a sound.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Maybe i wrote not quite clearly. The x-axis of the two pictures differs significantly: the second picture has more than 100,000 samples stored in the same screen area as the first with just 300 samples. So the first picture looks expanded in the x-direction (or the second picture looks kompressed) When you stay watching the chart you will see the effect life, the peaks are getting smaller and smaller with increasing time.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 ok, i figured it is due to running time of the device, if i just turn it on and run its only a few hundred, if i leave it plugged in for a bit it looks like that, and i understand that the bridge panel is meant more for debugging and actually seeing the data come out. I would think that the range of values will still be the same no matter if its 300 data points or 10,000 data points.. 

0 Likes
Anonymous
Not applicable

 So i went out and got a piezo siren today, and looking for a good source on how to add it to the pioneer kit and then the proper way to configure the PWM to trigger it.

   

Ive already added the PVM to my project, ive tied it into the Clock_PWM that is being used for the other 3 in the project, set the "line" to a Pin, digital output, HW connection, fast slew rate, VDDIO drive level, 4mA source, 8mA sink for current and transparent for the output mode. Mapping = Contigous, clocking all defaults, built ins all default.

   

That pin is then linked to VDD power and then on the pins window where you map the pins, i mapped the pin tp P2[2]

   

Does any of that sound correct?

   

If it is, then i know i need to write some code in the main.c to power the speaker when the threshold is met, can anyone offer suggestions or example links or documents on how to go about that.

   

 

   

thank you

0 Likes
Anonymous
Not applicable

 Can anyone point me in the right direction as to what documentation i need to read to properly wire the buzzer and power it from the board?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

To "wire the buzzer" is as difficult as to answer changing "fuse in the car". What buzzer have you got? Any documentations? Link to a datasheet?

   

Additionally consider posting your project here, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.



Bob
 

0 Likes
Anonymous
Not applicable

 Well maybe that was being to specific, i mean i am trying to wire the buzzer to my board, BUT im trying to learn and better understand PSoC, so i guess my question would be more like what to read and review on connecting and using external devices with the Pioneer Kit.

   

 

   

I woud like to learn and understand as i play with the kit more and more, how to run external devices(in this case the buzzer)

   

Ive gone thru a few of the other projects on 100days 100 projects, but maybe im over thinking it, but some of those seem like there is more involved than i would think to provide power to a pin? Like i said maybe im over thinking it.. 

   

This is the buzzer im working with, http://www.radioshack.com/102db-piezo-siren/2730079.html#q=siren&start=1
Operates on 6-14 VDC, with 150mA Current at 12V. Buzzer Tone rated at 2,000-4,500Hz. 

   

If the project still needs to be uploaded, ill try and publish it later today.

   

 

   

thank you

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

So what you selected is not quite easy: your PSoC is powered with 3.3V or 5V (selectable by a jumper) and you should act a device at 12V with 120mA. The very most an output pin should be prepared for is : Voltage at the pin not lower than GND and not higher than the selected 3.3 or 5V. The pin can source 4mA or sink 8mA wivh all is far away from your 12V, 120mA, so you will need something like an amplifier that is capable of

   

- isolating the pin from the 12V

   

- delivering the required 120mA

   

-does not need more than 4mA to turn on.

   

So I would suggest the schematic Dana supplied earlier in this thread with the speaker, use a darlington as transistor.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

And where can i find darlington as transistor? The Radio shack by me isnt very knowledgable, just school kids working there.. is it a specific one or type i need to look for or ask for or is that a online only type thing?

   

or can i look for a different buzzer/siren to make it easier of sorts that wouldnt require so much?

   

Since im just learning, id like to work my way up instead of jumping in full blown into this, id like to understand and see simple things work. Thats why i thought since i got the proximity project working and getting a better understanding of it, i could look at triggering a sound when within range. 

   

I did buy 2 other buzzers/sirens while at radio shack that day, these were them:

   

http://www.radioshack.com/85db-piezo-buzzer/2730060.html#start=4
This 85dB Piezo Buzzer operates on 4-28VDC, carrying 5mA current at 12V, with a loud buzzer tone rating of 3,600Hz.

   

http://www.radioshack.com/radioshack-3vdc-mini-buzzer/2730792.html#start=7
This 75dB Piezo electric buzzer operates on 2-4VDC, carrying a maximum 50mA current with a tame buzzer tone rating of 300-500Hz. 

   

 

   

Now since i did get a 3v one could i use that one instead and go a different route on wiring to the kit?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I would try the 75db buzzer, supplying the kit with 3.3V directly, might be a bit too faint.

   

Your darlington to drive the 12V buzzer just needs a max voltage of 30V and 200mA, 2W without cooling. Search in internet for availlable types at your local shop.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 yea i found this one, but its kinda close to what you suggested.

   

http://www.mouser.com/ProductDetail/Diodes-Incorporated/FZTA14TA/?qs=xZ%2fP%252ba9zWqZOsN%252b2CIdul...

   

And then these 4

   

http://www.digikey.com/product-search/en?pv814=4&pv588=2&FV=fff40015%2Cfff80078&k=darlington+transis...

   

If these wont work, ill have to see if i can make it to the local electronic parts outlet this weekend, they have tons of stuff and plenty of knowledgable people that can help locate what i need.

   

for the time being i can work with the other buzzer, what documentation can i read or look up to help move forward with powering that one?

   

i read a document over the weekend that was all about the "pins" controls, is that the only document i need? cause it wasnt enough for me to understand what was actually needed. 

   

 

   

is there another project i can review or play with that can help explain powering pins based on logic?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The 36 pages of the pin's datasheet is a bit too much to read, and the example project (Right-click on the digital pin component and select Find Example Project) is using an interrupt which is a little bit overdone. But look how the pin is defined, no hardware connection and a simple PinName_Write()

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 If i understood you correctly, i ended up opening a "Digital Pins v.1.0"  3 page PDF

   

which had these 4 items featured:

   

Features

   

 Digital Input pin with interrupt

   

 Resistive pull-up drive mode input pin for mechanical switch

   

 Digital output pin with hardware connection

   

 Software driven digital output pin

   

Based on your comment, i believe this is the correct document. 

   

Ill read it over and see if i can move a bit further in my project.

   

thank you

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

If you take a standard Piezo disc, not a buzzer with fdbk,

   

you can drive it differentially and get much higher loudness

   

out of it. Note use diode clamps each leg of piezo to Vss, Vdd,

   

to clamp transients.

   

 

   

   

 

   

If you do have a buzzer, and have relatively low drive current,

   

use a single bipolar (or MOSFET) vs darlington, gives you more

   

swing due to lower Vcesat in case of bipolar. The base drive

   

to transistor (bipolar) should be Ic / 10 to insure you sat it. So

   

if you have a 200 mA buzzer, you cannot develop 20 mA drive,

   

so use darlington. If its a 20 mA piezo then non darlington is

   

in order.

   

 

   

If use bipolar or MOSFET use a 10K or higher from base/gate

   

to ground to keep transistor off if pin tristated. This R absorbs

   

Icbo, or gate leakage which could turn on transistor.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 So if i use from this i can do everything with out all the extra stuff that the larger buzzer requires?

   

0 Likes