Metronome First sub code reduces volume output

joliebrise

New Member
Very odd situation.

The following code works but the fist sub code "beat50" reduces the speaker volume

Question:
Why should the position of the first sub code “beat50” cause the sound output from the speaker to be significantly reduced.

INIT:

dirsb=%01000000
dirsc=%00000000

main:

if pinb.7 = 1 and pinb.6 = 0 and pinb.5 = 0 and pinb.4 = 0 and pinb.3 = 0 and pinb.2 = 0 then beat25
if pinb.7 = 0 and pinb.6 = 1 and pinb.5 = 0 and pinb.4 = 0 and pinb.3 = 0 and pinb.2 = 0 then beat30
if pinb.7 = 0 and pinb.6 = 0 and pinb.5 = 1 and pinb.4 = 0 and pinb.3 = 0 and pinb.2 = 0 then beat35
if pinb.7 = 0 and pinb.6 = 0 and pinb.5 = 0 and pinb.4 = 1 and pinb.3 = 0 and pinb.2 = 0 then beat40
if pinb.7 = 0 and pinb.6 = 0 and pinb.5 = 0 and pinb.4 = 0 and pinb.3 = 1 and pinb.2 = 0 then beat45
if pinb.7 = 0 and pinb.6 = 0 and pinb.5 = 0 and pinb.4 = 0 and pinb.3 = 0 and pinb.2 = 1 then beat50


beat50: : high c.5 : sound b.1, (50,50) : pause 4592 : low c.5 : goto main
beat45: : high c.4 : sound b.1, (50,50) : pause 4060 : low c.4 : goto main
beat40: : high c.3 : sound b.1, (50,50) : pause 3554 : low c.3 : goto main
beat35: : high c.2 : sound b.1, (50,50) : pause 3080 : low c.2 : goto main
beat30: : high c.1 : sound b.1, (50,50) : pause 2563 : low c.1 : goto main
beat25: : high c.0 : sound b.1, (50,50) : pause 2106 : low c.0 : goto main

The metronome was tested without Leds and worked correctly with even sound levels for all switch positions

The next stage was to add matching leds and this is where the problems started. The sound output at the first switch position was greatly diminished and other positions reduced the sound. I changed the chip and remade the breadboard.

Tested voltage across C pins and ground. C.0 – Beat 25 = 3.18v
Others were 3.95, 4.12, 4.06, 4.07, 4.09 At c.5

It struck me that the problem could be caused by the order of the sub codes. I tested various orders of the six codes with the number referring to the pulse delay;
beat25, 30, 35, 40, 45, 50 = 2.5sec, 3.0, 3.5, 4.0, 4.5 and 5.0sec
I even reversed the order of the switch input wires.

Full details
 

Attachments

lbenson

Senior Member
Not sure that it's related to your problem, but "dirsb=%01000000" sets b.6 as an output and all the rest as inputs. From your code, it looks like you want "dirsb=%00000010"--low order bits are rightmost, so the "1" for output refers to b.1.

However, since you're not using x=pinsB then I would expect that your using" if pinb.7" and "sound b.1" would set the pins to the appropriate state.

("dirsc=%00000000" sets all port C pins as inputs (or effectively tri-states them)).

Maybe a good photograph of the breadboard would be in order.
 
Last edited:

Buzby

Senior Member
I can't see any issue with your code which could affect the volume.

Are you sure there is not a wiring error ?.

Please post a photo of your setup. Another pair of eyes might spot a problem you've missed.

Cheers,

Buzby
 

AllyCat

Senior Member
Hi,
The metronome was tested without Leds and worked correctly with even sound levels for all switch positions

The next stage was to add matching leds and this is where the problems started. The sound output at the first switch position was greatly diminished and other positions reduced the sound. I changed the chip and remade the breadboard.

Tested voltage across C pins and ground. C.0 – Beat 25 = 3.18v
Others were 3.95, 4.12, 4.06, 4.07, 4.09 At c.5
The first question I ask is what type is the "6 volt" battery? But also you have two diodes in series with the PICaxe supply (to reduce the volts to a safer level). Switching on ANY of the LEDs will increase the current drain and cause a voltage drop across the diodes (and maybe load the battery).

But the main problem may be that the design / operation of that volume control is VERY dependent on the drive voltage (and also operating temperature), but the voltage from the PICaxe output will depend on many factors. Basically, the BD681 is a Darlington transistor which has a threshold input of about 1.2 volts (2 x Vbe) and an input resistance of about 7k ohms (according to its data sheet). With the pot at its centre (5k) you have a top divider resistance of about 17.2k, so the transistor will become "active" with about (17.2 + 7) / 7 * 1.2 = 4.1 volts.

I'm not sure of the best way to improve that volume control design, but I think I'd start by trying a resistor of perhaps 22k from the collector/loudspeaker connection back to the base (input) of the transistor. Also, I generally dislike using a "Pot" as a variable resistance (two terminals), I prefer to use it in a (3-terminal) "Pot." (Potential Divider) configuration.

Cheers, Alan.
 

joliebrise

New Member
Not sure that it's related to your problem, but "dirsb=%01000000" sets b.6 as an output and all the rest as inputs. From your code, it looks like you want "dirsb=%00000010"--low order bits are rightmost, so the "1" for output refers to b.1.

However, since you're not using x=pinsB then I would expect that your using" if pinb.7" and "sound b.1" would set the pins to the appropriate state.

("dirsc=%00000000" sets all port C pins as inputs (or effectively tri-states them)).

Maybe a good photograph of the breadboard would be in order.

Thanks for the info. Please see my reply to AllyCat. TK Tony
 

joliebrise

New Member
Hi,

The first question I ask is what type is the "6 volt" battery? But also you have two diodes in series with the PICaxe supply (to reduce the volts to a safer level). Switching on ANY of the LEDs will increase the current drain and cause a voltage drop across the diodes (and maybe load the battery).

But the main problem may be that the design / operation of that volume control is VERY dependent on the drive voltage (and also operating temperature), but the voltage from the PICaxe output will depend on many factors. Basically, the BD681 is a Darlington transistor which has a threshold input of about 1.2 volts (2 x Vbe) and an input resistance of about 7k ohms (according to its data sheet). With the pot at its centre (5k) you have a top divider resistance of about 17.2k, so the transistor will become "active" with about (17.2 + 7) / 7 * 1.2 = 4.1 volts.

I'm not sure of the best way to improve that volume control design, but I think I'd start by trying a resistor of perhaps 22k from the collector/loudspeaker connection back to the base (input) of the transistor. Also, I generally dislike using a "Pot" as a variable resistance (two terminals), I prefer to use it in a (3-terminal) "Pot." (Potential Divider) configuration.

Cheers, Alan.
Very interesting comments, I do have concerns about the current drain caused by the Darlington Transistor. I tried others in my box but they gave poor amplification. VR configuration needs to be looked at and to using Voltage regulators.


But this is not my problem.

The volume is substantally reduced by the position of the SubCodes "beat25" to "beat50". which ever is at the top of the list it reduces its volume.
I write websites using Xhtml, PHP & MySql so well versed in logic. I cannot see any logic faults

The circuit works with no problems without Leds. I cannot see how Led voltage drain can effect this problem

Regards Tony
 

Buzby

Senior Member
... The circuit works with no problems without Leds ...
If the problem goes away when you disconnect the LEDs then it would seem there is a problem with the LEDs or their wiring.

I would double check the resistors. e.g. Have you got a 33R where you should have a 330R ?.

... I cannot see how Led voltage drain can effect this problem ...
If an LED circuit is drawing too much current, it will drop the battery voltage down, especially if the battery is weak to start with.

(Your 330R resistors can probably be increased to 1K without significantly reducing their brightness. This will reduce battery drain.)

Please post a photo.

Cheers,

Buzby
 

AllyCat

Senior Member
Hi,
I do have concerns about the current drain caused by the Darlington Transistor.
I cannot see how Led voltage drain can effect this problem
You didn't actually answer my first question about the power supply (battery). :(

But, the LED CURRENT drain certainly could affect the volume because it may reduce the VOLTAGE swing from the PICaxe pin.

However, you are correct to be concerned about the Darlington load current. The "8 ohm" loudspeaker is direct coupled (from the supply) and loudspeaker "impedance" is often higher than the dc resistance. But even an 8 ohms resistor could drain up to 0.75 Amp (I = V/R) from the supply. In practice you have a base input current of less than 1 mA so the collector/loudspeaker current probably will be limited by the CURRENT GAIN of the Darlington. Unfortunately the data sheet doesn't specify a "Maximum" current gain (which could be many thousands) but it does give the Minimum as 750. So the drain on the battery could be many hundreds of mA.

Cheers, Alan.

EDIT: I've just noticed that the wiper of the rotary switch is connected directly to the 6 volts battery, which it then feeds on to (one of) the PICaxe input pins; 6 volts is the Absolute Maximum rating for the PIC(axe). In practice, the associated "electrostatic protection" diode inside the PICaxe will feed the 6 volts through to the supply rail. This is confirmed by the "5.3 volts" label on the circuit diagram, which is one diode forward drop less than 6 volts. If the two 1N4001 diodes (in series) were conducting, then the supply rail would be in the range 4.6 - 4.8 volts. Perhaps another reason why the LED version is not as "loud" ? It is not "catastrophic" to allow this "Phantom Powering" to happen, but the internal diodes have a maximum current rating of 20 mA (much less than a 1N4001) so will probably give a more variable voltage drop if the load current changes.
 
Last edited:

joliebrise

New Member
Hi,

You didn't actually answer my first question about the power supply (battery). :(

But, the LED CURRENT drain certainly could affect the volume because it may reduce the VOLTAGE swing from the PICaxe pin.

However, you are correct to be concerned about the Darlington load current. The "8 ohm" loudspeaker is direct coupled (from the supply) and loudspeaker "impedance" is often higher than the dc resistance. But even an 8 ohms resistor could drain up to 0.75 Amp (I = V/R) from the supply. In practice you have a base input current of less than 1 mA so the collector/loudspeaker current probably will be limited by the CURRENT GAIN of the Darlington. Unfortunately the data sheet doesn't specify a "Maximum" current gain (which could be many thousands) but it does give the Minimum as 750. So the drain on the battery could be many hundreds of mA.

Cheers, Alan.

EDIT: I've just noticed that the wiper of the rotary switch is connected directly to the 6 volts battery, which it then feeds on to (one of) the PICaxe input pins; 6 volts is the Absolute Maximum rating for the PIC(axe). In practice, the associated "electrostatic protection" diode inside the PICaxe will feed the 6 volts through to the supply rail. This is confirmed by the "5.3 volts" label on the circuit diagram, which is one diode forward drop less than 6 volts. If the two 1N4001 diodes (in series) were conducting, then the supply rail would be in the range 4.6 - 4.8 volts. Perhaps another reason why the LED version is not as "loud" ? It is not "catastrophic" to allow this "Phantom Powering" to happen, but the internal diodes have a maximum current rating of 20 mA (much less than a 1N4001) so will probably give a more variable voltage drop if the load current changes.
4 x aa bateries,, I think I understand your comments about current and voltage losses. The actual problem is not related to this.

The order of the sub codes beat25 to beat50 in the program effects the volume output. Which ever code is at the top of the list its volume is significantly reduced. How is this possible?. I used the same led, changed the order of the input leads and output leds, new chip and remade protoboard. every purmutation, all with the same result. The first code caused the volume reduction. How?
 
Last edited:

AllyCat

Senior Member
Hi,
The actual problem is not related to this.
You can't make that statement until you know what IS causing the problem ! As described, I've no idea what that might be.

But first, I would reduce the number of AAs to 3 and remove (short circuit) the two 1N4001s. Then measure the voltages on ALL related pins, including the supply rail and Darlington legs.

Cheers, Alan.
 

erco

Senior Member
Wiring error for sure. That funky "amp" isn't helping. You can buy a decent amplified speaker at the Dollar Store.

Why use 6 pins on your rotary switch when one would do? Use an ADC to read a pot or a rotary switch with multiple resistors as a voltage divider.

Simpler is better, reduces wiring errors.
 

joliebrise

New Member
Wiring error for sure. That funky "amp" isn't helping. You can buy a decent amplified speaker at the Dollar Store.

Why use 6 pins on your rotary switch when one would do? Use an ADC to read a pot or a rotary switch with multiple resistors as a voltage divider.

Simpler is better, reduces wiring errors.

Using ADC/pot is not accurate enough.
There are no wiring errors.
The problem is odd as it is the order of the sub codes (beat50). The volume of the first code is always reduced.

Tony
 

hippy

Technical Support
Staff member
The problem is odd as it is the order of the sub codes (beat50). The volume of the first code is always reduced.
It is odd because the sound pin will simply be putting out a high and low pulsed signal which will swing between +V to 0V. There's nothing I could see with the code which would cause the result which you are experiencing.

I would suspect that, including because it was okay before adding any LED's, that the issue is with external hardware but I am not sure what.
 

premelec

Senior Member
Sometimes a capacitor has to charge up - is there one one the input to audio part of system? I just looked back and found a schematic - various capacitors... if you have an oscilloscope check if capacitor voltage changes with first pulse of sound...
 
Top