Generator ultrasounds for dogs

In this practice we are going to come, step by step, to create a system that, growingshepherd German

little by little, it is going to generate a sound of ultrasounds, frequently, time and algorithm of listening, configurable to the particular surroundings (circumstances of each house).

We must comment that one is not to punish any animal, but educate to him so that, when we have an untenable situation of barks, we educate to the dog so that it does not bark to certain hours. The ideal is to speak with the proprietor, but in this world of God we have a variety of creatures very varied€

1 Creamos the oscillator within arduino. First it is to create an audible sound, soon we will modify it so that it is of ultrasounds. We have used to buzzer 13 when coming out. The program that we must put for it is:

int ledPin = 13; //select for pin the LED

void setup ()
\ {
pinMode (ledPin, OUTPUT);

}

void loop ()

\ {
digitalWrite (ledPin, HIGH);
delayMicroseconds (125);
digitalWrite (ledPin, LOW);
delayMicroseconds (125);
}

The only thing that we created is a bow that puts ledPin high and low every 125 microseconds, which is equivalent to 4 KHz. This would be interminable and for this reason, immediate goal is to create a temporary interruption, so that it stops past 10 seconds.

2 Creation of the working time. We can do of two forms. With loop temporary so that an accountant or with some bookstore adds itself that handles times. In this case we are going to decide on nested accountants, so that whenever a cycle is executed, it is put raises the accountant. When it arrives at certain units, the cycle is deactivated. We add the following thing

int accountant = 0; //We created the accountant master

\ {
if (accountant < 30000)
\ {
digitalWrite (ledPin, HIGH);
delayMicroseconds (125);
digitalWrite (ledPin, LOW);
delayMicroseconds (125);
accountant = accountant + 1;
}
}

Elejimos 30000 as clock unit, that gives about 7 seconds (following the frequency of each clock) This is not very important at the moment. The routine says to us that if the counted one is smaller of that value, a cycle is executed. when he has finished, accountant + 1 is increased with accountant =;

3 System to detect the sound of the bark.

sensor-sound-ky-038

We are going to use a typical sensor of arduino that generates a variable analog signal to us (according to the power of the sound that receives). In a first step, when it detects a determined threshold, the system will issue order so that the sound is generated. We have varied a little the accountant, changing this one by a for sentence. He is the same but if created problems in the internal routine. It goes stays to us as:

void loop () \ {
sensorValue = analogRead (sensorPin);
if (sensorValue > 30)

\ {for (accountant = 0; accountant < 30000; accountant ++)
\ {
if (accountant < 30000) \ {
digitalWrite (ledPin, HIGH);
delayMicroseconds (125);
digitalWrite (ledPin, LOW);
delayMicroseconds (125);
}}}}

Sentence for says us, first puts accountant to 0, soon verifies if the condition is fulfilled (in this case tenth that the accountant is inferior to 30000) and to finish, before leaving for, it increases in a unit the accountant with accountant ++

Detectar a number of barks to activate the system. Now something with a little but complexity comes. We must cause that one activates when the sensor detects 3 or 4 barks. The barks are pulses of certain duration and certain intensity, separated in the time. For a German shepherd, usually they are slow (to but great but slowed down they are the barks). It is possible to be begun by two barks taking into account that it must appear a high tone, rest, tone high and rest. We are going to postpone this now to happen to create the ultrasound. To see point 6

5 Frequency of work. The dogs usually have a bandwidth that can arrive at 40 Khz. We are going to create it for 30,000 Hertz, thus, the duration of the width of the pulse is 1/30000 between two, which gives about 17 microseconds.

6 Control to activate one several channels. In the activity that or became in electronic on control with remote control, we have this control that is going to allow to give a step forward to us to verify if the system works or no. Why to roll to us with point 4 if he is but the complex one of all, and we verified the dog happens of our invention. Good, because we will use the program that attached and that I detail here but down

int ledPin = 13; //select for pin the LED
int control = 8; //Lee the D0 channel of the control

int accountant = 0; //We created the internal accountant
int contador2 = 0; //We created the accountant master
void setup ()
\ {
pinMode (ledPin, OUTPUT);
pinMode (control, INPUT);
for (int i = 7; i < 12; i++)
pinMode (i, INPUT);
Serial.begin (9600);
}

void loop () \ {

if (digitalRead (7)) //If there is signal of valid radio
\ {Serial.print (arrives a value to Us. \ t€); //is printed arrives a value to Us
if (digitalRead (8)) //we read port 8 to see if signal arrives

\ {for (contador2 = 0; contador2 < 2; contador2 ++)
if (contador2 < 2) \ {
for (accountant = 0; accountant < 30000; accountant ++)
\ {
if (accountant < 30000) \ {
digitalWrite (ledPin, HIGH);
delayMicroseconds (125); //for 4000 Hertz is 125 microseconds. For 30000, on 17
digitalWrite (ledPin, LOW);
delayMicroseconds (125);
}}}
Serial.print (the sound finishes Here€); //is printed, has been pressed
}

if (digitalRead (9)) //This is for another channel
Serial.print (Button B has activated€);
if (digitalRead (10)) //is repeated for the 10
\ {
Serial.print (Now Button C has been pressed.€);
digitalWrite (12! digitalRead (12)) ; //We removed by port 12 the value from 12
delay (500); //we waited for 0,5 seconds
}
if (digitalRead (11))
\ {
Serial.print (button D has been pressed€);
digitalWrite (13! digitalRead (13)) ; //activates exit 13
delay (500); //is expected 0.5 seconds
}
Serial.println (\ t€); //Prints a tabulator
}

}

7 but the easy thing but with little information. One is search a piezoelectric loudspeaker of high power with the characteristics. It is necessary to consider that these devices have a capacitive high impedance and they cannot be used as normal loudspeakers. On the other hand, the way to work is by tension (to apply variable tension in its tips). In our case, we are going to put 2N3055 with resistiva load and the loudspeaker put between collector and emitter. When the transistor works in way commutation, it will apply to a squared signal of value 24 volts to him. He is interesting to put tension to obtain the greater sonorous power, but this is about to verify.