Audio Signal as Switch

hippy

Ex-Staff (retired)
Ive re-assembled the circuit on the project board, checked over it and fitted as new 08M2. However I still get the same situation as above.
That suggests there is some issue with the hardware or software. It's probably time to post circuits, program, full details and photos of exactly what you have to get to the bottom of the problem. There is only so much stabbing in the dark one can do.

It works absolutely fine for me when I test it so there is obviously something different in what you have which causes differing behaviour.

It may be tempting to ignore the problem if it seems to work, but if it's not working as expected it may be something wrong which could have adverse effects with time. You won't want to find there's a short or miswiring which could eventually blow the chip and dump a full 5V into the amplifier input or Pi output or randomly starts switching the amp on and off.
 

RustyH

Senior Member
Hi Hippy,

My schematic that is laid out on the project board is as below (will get some pictures shortly

The code Im using is identical to yours (copy and paste job)

One thing Ive just noticed (which I guess makes matters worse), is the circuit tests I was doing above was with my AXE029 bread board adaptor still attached (and connected to the PC USB). So I thought I would try with the 22k and 10k tie down resistors in place. But it actually latching on completely with that, does not react to the input. The if I remove the resistors, it latches off.

Something is very strange

Audio Detector - Schematic.jpg
 

hippy

Ex-Staff (retired)
My tests have been done with a download cable attached and that should not be the cause of the problem. Without the download cable it is more prone to activation but should keep the relay and LED off when connected via resistors to 0V.

You don't seem to have connected the jack socket 'ground' to 0V but that should not affect the operation disconnected, however ...

Do you have the 100K across jack signal to jack ground rather than to 0V ?

That would explain the behaviour you are seeing.

Is the 0V of the PICAXE connected to 0V ? Strange things will happen if not.
 

hippy

Ex-Staff (retired)
Errrmmmm, this is really dumb of me now, but how do I tell if Im on 0v and not ground?
There will be a common 0V rail in all PICAXE circuits and "ground" ( and "earth" ) will usually be somewhere else remote from that circuit and usually not attached to that 0V in any way.

Unfortunately there is a tradition of referring to 0V, common signal return paths, and similar as "ground" or "earth" which causes considerable confusion, and we are likely stuck with "earth" as a term to describe a vehicle's chassis.

I believe it is best to avoid such usage; use "ground" to mean land with a conductive spike driven into it and "earth" to mean the mains power earth connection. That leaves 0V as the local reference point in a circuit which all other voltages are measured relative to.
 

RustyH

Senior Member
Ok, I can see why its confusing, Im confused!!

Starting at the mains plug, Its a 2 wires mains connected using a figure 8 connector in to the transformer pack (so no earth). The transformer back is 16v DC @ 1.5A. It has two wires leading out of the transformer pack (positive and negative)

Ive connect the positive and negative to the project board. The 16v then goes through the regulator to 5v and on to the PIC. The pics negative (and ALL over negatives on in the circuit) are connected to the negative of the transformer pack).

I then how the positive cable of the amplifier connected to the 16v rail, and the negative connected to the FET (drain), the FET (source) is then connected to the same negative as above
 

hippy

Ex-Staff (retired)
Starting at the mains plug, Its a 2 wires mains connected using a figure 8 connector in to the transformer pack (so no earth). The transformer back is 16v DC @ 1.5A. It has two wires leading out of the transformer pack (positive and negative)
That's fine. The positive and negative are isolated from the mains so this is the equivalent of connecting a 16V battery pack.

Ive connect the positive and negative to the project board. The 16v then goes through the regulator to 5v and on to the PIC. The pics negative (and ALL over negatives on in the circuit) are connected to the negative of the transformer pack).
That is also fine; your negative becomes the 0V of the circuit, the positive measured against that is 16V and becomes your 16V rail.

I then how the positive cable of the amplifier connected to the 16v rail
You have lost me there.

One side of the relay coil should go to your 16V rail, the other side of the relay coil to your FET. The amplifier power should only pass through the relay contacts, not connect in any other way to the circuit.

I guess the idea has changed since earlier, you are now powering the amp with your PICAXE low-side switching its power through the FET.

The problem is that the 0V of the amplifier is then at the drain of the FET and most likely connected to the shield of the audio in jack, so, if you connect jack shield to 0V ( as you should for the PICAXE to work ), you are permanently powering the amp.

That suggest you haven't connected the jack shield to 0V which leaves the pin 4 input floating which is causing all the problems.

Basically you need to use high-side switching for the amplifier if it is being powered through the FET. Using the FET to drive a relay and switching the amp's positive power through the relay coil as originally envisaged would be high-side switching.

I think you need to clarify how you are power switching the amp and if the jack shield connection is connected to 0V or not.
 
Last edited:

RustyH

Senior Member
Hi Hippy,

Sorry for causing the hassle on this

On the jack shield, this is not connected to 0v at the moment.

I have indeed changed the switching as originally I was going to switch the main voltage side of the power pack. However, Im not using a IRL520 to switch the 16v amp supply instead. The way its connected at the moment is exactly as the circuit diagram.

16v ------ (+ve) Amp (-ve) ------ FET (Drain) -- FET (Source) ------0V
| FET (Gate)
| |
Picaxe (via reg) |
|
Pin C.1 ------ 1K Res -----

Audio Detector - Schematic.jpg

In the schematic, the motor is the amp
 

hippy

Ex-Staff (retired)
On the jack shield, this is not connected to 0v at the moment.
And that's why it won't behave as expected ;-)

And what is the PICAXE 0V connected to ?

The PICAXE needs its 0V to be the supply 0V and the audio in shield / 'ground' has to also connect to that same 0V for the PICAXE to be able to measure the incoming signal relative to that 0V.

I have indeed changed the switching as originally I was going to switch the main voltage side of the power pack. However, Im not using a IRL520 to switch the 16v amp supply instead. The way its connected at the moment is exactly as the circuit diagram.
And unfortunately that will probably not work for the previously explained reasons.

Though I have to add that it might work if the amp jack shield is not connected but I am not sure what knock-on effects and problems that would cause.

It would be easier to high-side switch via a relay than low-side switch with a FET ...

Code:
16V >----------------------------------.---.----.
                                      _|_   )   o
                                      /_\   )    / RELAY
                                  FET  |    )   o
          PICAXE-08M2       ___    |---^---'    |
          .----_----.   .--|___|-->|            |
         -|+V     0V|-  |          |---.        |
         -|SI  SO/O0|-  |   ___        |        |
      .---|X4     X1|---^--|___|--|>|--{        |
      |  -|I3     X2|-            LED  |        |
      |   `---------'                 _|_       |
      |       ___                               |    AMPLIFIER
      `------|___|-----.                        |   .---------.
              47K      |                        `---| +Ve     |  _ /|
           _           |       _           _        |         |=|_| |
   Audio  | | v----.---^----v | | ....... | | v-----|         |    \|
     In   | |  v---|------v   | | ....... | |   v---|         |
          `-'-.   .|.       .-`-' ....... `-'-------|--.      |  _ /|
              |   | |       |                       |  |      |=|_| |
0V >---.      |   |_| 100K  |                   .---|--'      |    `|
      _|______|____|________|___________________|_  `---------'
;
 

RustyH

Senior Member
I really really dont see what Im doing wrong then.

I have the circuit working with serial pull down resistors now. But I still have the case of the system latching on when an audio cable is not plugged in

Below are some images
The first is with the audio cable inserted, but no music playing, therefore the LED should be (and is) off
The second picture is with the audio cable removed, and the LED is on (but shouldnt be)

20131017_230252.jpg


20131017_230235.jpg
 

hippy

Ex-Staff (retired)
The second picture is with the audio cable removed, and the LED is on (but shouldnt be)
I cannot see any reason it isn't working either.

Keep the Serial In 22K and 10K resistors in place. Remove the jack socket and the two resistors connected to that. Remove the power supply and power from 3xAA batteries. Remove all unnecessary jumper wires and short leg 3 / pin 4 to 0V. Does it keep the LED off then ?
 

RustyH

Senior Member
Hi Hippy,

Ok, Ive done the above in stages

Firstly, I connected the circuit with out the input parts, but still with the reg, so a lab power supply. Result was light on

20131018_190822.jpg

Next, I tried the lab supply directly (no regulator circuit) @ 5v. Light still on

20131018_191004.jpg
 

hippy

Ex-Staff (retired)
finally, I shorted pin 4......LIGHT OFF
Well at least it's working as expected in that case. Now to build up again in reverse.

Remove the short, add the resistor which goes into pin 4 (47k?). Does the light come on if you touch the open end ( it likely will, but perhaps not ), and when the open end of the resistor is shorted to 0V does the LED remain off ? If so good so far.

Remove the short. Add the 'from that to 0V' resistor (100K?) and repeat the same. The LED should remain off when the open end is shorted to 0V.

If the LED does remain off as expected, keep that as it is with the resistors shorted and add in the power supply.
 

RustyH

Senior Member
Remove the short, add the resistor which goes into pin 4 (47k?). Does the light come on if you touch the open end

The light comes on the second I remove the short, so even with the 47k in, its still latched on
 
Last edited:

Technical

Technical Support
Staff member
Have you used a multimeter to check the resistor values yet?

Another thing Ive noticed, is if I short pin1 (leg 6), the light also goes off
That's where the LED is connected!?
 

RustyH

Senior Member
Just removed that comment cause how stupid it was of me!! Lol

ive checked all resistor values a number of times. I even replaced all the resistor with new ones just in case

The resistors in the bare bones circuit above are 22k and 10k on the serial in

And 330R on the led
 

RustyH

Senior Member
I think success is near

Ive just started again, and its looking better. Im running off battery, with the socket in position and all resistors, and its finally behaving. I will update you more shortly
 

RustyH

Senior Member
Update: Ive rebuilt the circuit, and its behaving a lot more like it should

HOWEVER!! :) I think the initial issue was down to a sensitivity problem. I tried the circuit on a different part of my desk (sound stupid I know). When I plugs the power pack it, it works, the LED didnt come on. But as soon as I put my hand close to the circuit it came on. I could literally turn the LED on and off by moving my hand towards and away from the circuit.

I then move the circuit back to where I originally had it on my desk, and the led came on and stayed on!!

Does that behavior make sense, or is there still and issue somewhere?
 

hippy

Ex-Staff (retired)
Remove the short, add the resistor which goes into pin 4 (47k?). Does the light come on if you touch the open end
The light comes on the second I remove the short, so even with the 47k in, its still latched on
That is expected behaviour as previously stated. But what of the rest of the question ... ?

Remove the short, add the resistor which goes into pin 4 (47k?). Does the light come on if you touch the open end ( it likely will, but perhaps not ), and when the open end of the resistor is shorted to 0V does the LED remain off ? If so good so far.
We need to know what happens when the 'open end' of that resistor is shorted to 0V.

When shorted the LED should remain off. If so then that test configuration is working. If it is not off then that is a problem which needs further investigation.
 

hippy

Ex-Staff (retired)
Does that behavior make sense, or is there still and issue somewhere?
The behaviour makes sense. It is symptomatic of something left floating when it should not be. You have not necessarily solved the problem just found a situation where the problem does not exhibit itself.

Also see post #61 above.
 

RustyH

Senior Member
Oh ok, sorry, back to the original plan than

Remove the short, add the resistor which goes into pin 4 (47k?). Does the light come on if you touch the open end ( it likely will, but perhaps not ), and when the open end of the resistor is shorted to 0V does the LED remain off ? If so good so far.
Remove the short - LED comes on!
Add 47 Resistor - LED still on!
Short open end on 47k resistor - LED goes off
 

hippy

Ex-Staff (retired)
Remove the short - LED comes on!
Add 47 Resistor - LED still on!
Short open end on 47k resistor - LED goes off
Okay, that is correct.

Now test what you have in the area of the desk where you were previously seeing the LED come on when it should have been off. It should remain off with the short fitted. If it comes on then that needs to be investigated.

If the LED stays off with the short fitted, keep everything in that place, and continue to add the other resistor and then power supply, testing after each step that that the LED stays off when the short is fitted. The LED may come on with the short removed; that is okay and useful if it does, but it does not matter if it does not.

It is behaviour with the short in place which we are most concerned about.

( I have to do other things so won't be back for a while )
 

RustyH

Senior Member
Thanks Hippy

I have now re-assembled the cicruit, including the regulator, 16v power, and mosfet, and 3.5mm audio jack (not included the relay yet)

The LED has remained off with the short on the audio jack side of the 47k resistor

If I then put my finger on the pic side of that 47k resistor, the LED comes on (I assume cause the comparator has detected body voltage).

There seems to be no interference at this point with my hands etc close to the circuit :)
 

RustyH

Senior Member
Ive also just tried to swap out the short with a 100k resistor, and the LED comes on
 
Last edited:

hippy

Ex-Staff (retired)
Ive also just tried to swap out the short with a 100k resistor, and the LED comes on
Adding the 100K and shorting its open end to 0V ( and not ) was what was meant to have been next tested following my post #64. Perhaps I wasn't clear on that, but that's what needs to be done.

It's an interesting exercise in 'preciseness' and just how difficult and time consuming it is to describe step-by-step building and testing a three resistor, one LED, PICAXE circuit.
 

RustyH

Senior Member
OK, ive added in the 100k resistor and shorted it to 0v
Do I need to remove the direct short as well??
 

hippy

Ex-Staff (retired)
OK, ive added in the 100k resistor and shorted it to 0v
Do I need to remove the direct short as well??
Yes. Remove the short previously on the 47K, only short the 100K. Short it only at the end not attached to the 47K.
 

RustyH

Senior Member
Just want to make sure im reading this step correctly. The original schematic shows a 100k resistor from the video line to 0v ( in my case from the left audio line to 0v)

You want me to fit it the same, so 100k resistor connected to the audio socket side of the 47k resistor, then down to 0v
 
Last edited:

walker1

New Member
I am not sure this has popped up in this thread before (very long!), but when I added a PC speaker system to my TV in order to get a somewhat better sound quality, I used an 'opto-triac' controlled by USB voltage out of the TV.
This one in fact. It has zero crossing turn-on so you avoid large current rush-in. http://www.wvshare.com/datasheet/FAIRCHILD_PDF/MOC3081M.PDF

It can handle up to 1 amp peak, so I added a normal triac after the opto to take the load. (See Figure 11 in the PDF)
 

hippy

Ex-Staff (retired)
You want me to fit it the same, so 100k resistor connected to the audio socket side of the 47k resistor, then down to 0v
Yes; I want you to add a 100K to the end of the 47K.

Step 1

Build the circuit as below with the 47K to pin 4. Test when point "A" is shorted to 0V and when it is left open circuit.

When point "A" is shorted to 0V the LED should remain off. When point "A" is left floating the LED may come on but it does not matter if it stays off.

Providing the LED remains off when point "A" is shorted to 0V; continue to Step 2 otherwise leave the circuit as it is as we will need to investigate further.

This test was previously completed so on to Step 2.

Code:
                            PICAXE-08M2
                            .----_----.
+V >------------------------|+V     0V|---.
           [b]___[/b]    .---------|SI  SO/O0|-  |    ___
    [b]A O---|___|---[/b]|---------|X4     X1|---|---|___|--|>|--.
           [b]47K[/b]   .|.       -|I3     X2|-  |          LED  |
                 | | 22K    `---------'   |               |
                 |_|                      |               |
                 .|.                      |               |
                 | | 10K                  |               |
                 |_|                      |               |
                  |                       |               |
0V >--------------^-----------------------^---------------^-
Step 2

Add a 100K to the end of the 47K as below.

Test when point "B" is shorted to 0V and when it is left open circuit.

When point "B" is shorted to 0V the LED should remain off. When point "B" is left floating the LED may come on but it does not matter if it stays off.

Providing the LED remains off when point "B" is shorted to 0V; continue to Step 3 otherwise leave the circuit as it is as we will need to investigate further.

Code:
                            .----_----.
+V >------------------------|+V     0V|---.
           ___    .---------|SI  SO/O0|-  |    ___
       .--|___|---|---------|X4     X1|---|---|___|--|>|--.
      [b].|.[/b]  47K   .|.       -|I3     X2|-  |          LED  |
 [b]100K | |[/b]        | | 22K    `---------'   |               |
      [b]|_|[/b]        |_|                      |               |
       [b]|[/b]         .|.                      |               |
    [b]B  O[/b]         | | 10K                  |               |
                 |_|                      |               |
                  |                       |               |
0V >--------------^-----------------------^---------------^-
Step 3

Add the power supply regulator and all the other components in your poswer supply.

Test when point "B" is shorted to 0V and when it is left open circuit.

When point "B" is shorted to 0V the LED should remain off. When point "B" is left floating the LED may come on but it does not matter if it stays off.

Providing the LED remains off when point "B" is shorted to 0V; we will continue to Step 4 ( to come later ) otherwise leave the circuit as it is as we will need to investigate further.


Code:
         [b].---.[/b]                            .----_----.
[b]+V >-.---|REG|-------[/b]---------------------|+V     0V|---.
    [b]_|_  `-.-'[/b]           ___    .---------|SI  SO/O0|-  |    ___
    [b]-.-    |[/b]         .--|___|---|---------|X4     X1|---|---|___|--|>|--.
     [b]|     |[/b]        .|.  47K   .|.       -|I3     X2|-  |          LED  |
     [b]`-----{[/b]   100K | |        | | 22K    `---------'   |               |
           [b]|[/b]        |_|        |_|                      |               |
           [b]|[/b]         |         .|.                      |               |
           [b]|[/b]      B  O         | | 10K                  |               |
           [b]|[/b]                   |_|                      |               |
           [b]|[/b]                    |                       |               |
0V >-------^--------------------^-----------------------^---------------^-
 

RustyH

Senior Member
sorry, I was testing step 2 with the regulator etc in place.

So Changing to running off the battery pack this is what I get

Step 1
Point A shorted - LED OFF
Point A floating - LED ON

Step 2
Point B shorted - LED OFF
Point B floating - LED ON


If I then do step 3 with the regulator and power pack, I get these results
Point B shorted - LED ON (the LED seems to blink a little)
Point B floating - LED ON

NOTE: If I change the 100k resistor to a 22k resistor then I get these results
Point B shorted - LED OFF
Point B floating - LED ON
 

rossko57

Senior Member
Hippy's sketches have missed the 0.1 cap at the Picaxe, and an output cap for the regulator.
Time to add that in your "step 3" test?
Are you able to measure the output of your regulator with meter on both DC and AC volts?
 

hippy

Ex-Staff (retired)
Step 1
Point A shorted - LED OFF
Point A floating - LED ON
That's a pass, good so far.

Step 2
Point B shorted - LED OFF
Point B floating - LED ON
That's a pass, so still good.

If I then do step 3 with the regulator and power pack, I get these results
Point B shorted - LED ON (the LED seems to blink a little)
Point B floating - LED ON
That is a fail and we are now identifying what the problem may be.

The power supply or circuitry appears to bring some sort of issue which causes the PICAXE on-chip comparator to activate when it should not. This is why we are doing it a step at a time to see where things stop behaving as expected.

The question now is; why is the power supply causing problems ?

Rossko77 is correct that the circuit should have a 100nF (0.1uF) cap across the PICAXE supply and there may be other capacitors required around the regulator.

It is probably time to detail all the parts of your power supply, all components including the wallwart / plug-in module; what is that rated at, voltage, current, AC or DC ?

NOTE: If I change the 100k resistor to a 22k resistor then I get these results
Point B shorted - LED OFF
Point B floating - LED ON
There are three possibilities as I see it; noise or ripple being introduced at Pin 4 which is taking the on-chip comparator above its activation point, or noise and ripple being introduced on +V or inside the PICAXE which is causing the on-chip comparator to activate, or a combination of both.

I would at this point normally recommend using a scope to see exactly what the signals are doing; on PICAXE +V, at the 100K to 47K junction, and at pin 4 of the PICAXE.

I am betting you don't however have a scope, so, before simply throwing capacitors at the problem, tweaking resistors, or making guesses as to how we can best fix things we need that full circuit diagram of the power supply.

While reducing the 100K seems to solve the problem that feels to me to be simply masking whatever fundamental issue there is. My test setup works as expected with a 470K pull down so it is intriguing why your setup does not work with 100K. While we can probably bash it into shape and make it work it would, to me, make sense to understand why it does not work.

With 100K plus 47K I can activate the LED by touching the sheaved wire between the 47K and pin 4 or the join between the 47K and 100K so perhaps the resistors are simply too high value, that they are prone to induced pick-up and it is simply that I don't have such induced pick-up.

A 100nF capacitor across pin 4 and 0V seems to overcome activation when the sheaved wire from 47K to Pin 4 is touched ( though not when the bare 47K/100K join is touched ) so perhaps that is a fix worth trying.
 

RustyH

Senior Member
I actually have a Tektronix 2225 Oscilloscope, but Im not ofay with setting it up yet!!

The power supply Im feeding off is the power pack of the speaker system (Harman Kardon)
It has the following wrote on the label

I.T.E Power Supply
Model No.: NU40-2160150-I3
Input: 100-240v 50/60 Hz 1.2A
Output: 16v 1.5A
 

RustyH

Senior Member
Im sorry if these are rubbish :confused:

This is the input to the PIC
I connected the ground clip of the probe to 0v, and the probe tip to the 5V pic input

20131020_182136.jpg

20131020_182158.jpg
 

hippy

Ex-Staff (retired)
Unfortunately it's not easy to tell with photos. It looks like there's some pulsing on the trace but not easy to tell what magnitude or frequency.
 

RustyH

Senior Member
Im not sure if these are of any use, but this is the power pack supply. I managed to get it open last night.

20131021_082142.jpg

20131021_082230.jpg
 
Top