Using PNP to On/Off Ultrasonic wawes, no effect on circuit

Hi friends,

2 separate ultrasonic head inputs.

I am doing a project about skin care. I used Arduino Mega Rev3 in this project. The PNP transistor does not work in the circuit. As you can see, digital pin 46, which is connected directly to B5 from the Arduino, is set to HIGH in the setup, but the signal still goes to the headers.

C0 is working and I can change the title, but I could not make both titles not work at the same time.

I wonder if R702-R703 10k resistors are too much?

I have an oscilloscope. Can you please help me with where I need to test or replace it?

Things I tried;

Assigning 46 as input.
Changing the header directions, even though I know it won't happen.
Bringing the adjustable resistor R704 from the beginning to the end (only increases the power)

The code does not compile because I only gave the relevant part to avoid wasting your time. I set it to HIGH during the setup phase, logically the Ultrasonic heads should not work.

The code and circuit attached, thanks friends.

int SonicPin = 46;
int pinC0 = 37;

bool Sonic = 0;
bool c0ayar=0;

void setup() {
  pinMode(SonicPin, OUTPUT);
  pinMode(pinC0, OUTPUT);

  digitalWrite(SonicPin, HIGH);
  digitalWrite(pinC0, LOW);
}

void loop() {
  if (Sonic == 1) {  // Sadece Sıcak Soğuk, kart B0 j201 6v
                     //Serial.println("0x31, Hammer high olucak :-------- ");
    digitalWrite(SonicPin, LOW);   //DİKKAT PWMLE ÇALIŞTIRILIP AYAR TYAPILACAK !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 50 hz yani 20ms periyot yüzde 20 de çalıştarım
    delay(4);
    digitalWrite(SonicPin, HIGH);
    delay(16);
    if(c0ayar ==1 ){
      digitalWrite(pinC0,HIGH);
    }
    if(c0ayar ==0 ){
      digitalWrite(pinC0,LOW);
    }

  } else if (Sonic == 0) {  // 
                            //Serial.println("0x31, Hammer low  olucak : ----------");
    digitalWrite(SonicPin, HIGH);

    
  }

  
}

Post the complete code.
What do you measure at the input of the transistor that is not working?

Titles...?

Nothing changes c0ayar in your sketch - you're aware of this, yes?

Same with 'Sonic' - it's set to 0 at the start and remains 0.

Could you perhaps start by explaining what the circuit is intended to do? Is it some kind of TENS device?
What do J701 and J702 connect to - what does the circuitry outside attached to those points look like?

In principle, it should. Here's a sim of the entry part of the circuit:


image

The blue trace is the + of V1, which is outputting a 50% duty cycle 50Hz signal between 0 and 5V.
The red trace is taken at the junction of L1 and R2.

You could emulate this in your physical lab setup and your scope. You'll have to inject a waveform into B5. As mentioned above, your sketch presently doesn't do this. You could use a Timer to output a block wave. I'd do just that and forget about all the rest for a moment. If your scope has a waveform generator, you could use that instead of the Arduino.

  • Start using proper syntax.
    bool use true/false

I don't understand at all what you are trying to achieve. Can you describe the purpose of your circuit and code, not the current solution? Try to find a better translator.

I fear that you'll kill C103 very soon, or have killed it already and misinterpret that as a failure of C102?

Sorry, my fault i mean header not titles. I have these 2 headers that connected on j701 and j702. I don't have the larger main piece. Instead, I tried to create a frequency myself. My resulted signals are just fine when I monitored j701 and j702 with an oscilloscope.

Image from

Yes I'm aware about C0, i making it HIGH in my main code afterwards and works fine( It switches headers, if c0 low j701 works and c0 HIGH j702 works.

I don't want this to work all the time. That's why I want to turn ON/OFF via Arduino mega. However, J701 works whether I set the 46th pin of the Arduino connected to pin B5 to HIGH or LOW. Therefore, giving the rest of the code will only waste time and create confusion because I set B5 to HIGH in Setup(), then even though the loop is empty c0 is LOW, the j701's header still work.

If I set C0 to HIGH in the circuit, J702 works .So no problem at c0, But I couldn't understand whether the signal was being interfered with or why I had no effect on B5.

I posted my purpose 1 up reply.
But i'm taking right signals from outputs(j701 and j702). if I killed c702 j701 shouldn't be working.

By the way thanks to you all : )

Why this if here?
If sonic is not true, it must be false. So no need to test...

To drive a relay, R701 might need a smaller value.
Also BC 847 can only handle 100mA.
Most relays will draw more.
Or is it a module with an optocoupler?
I looked up the datasheet. It takes only 30mA. So you should be fine as it is now...

But it is working properly.

Guys kindly please focus on when B5 is HIGH at setup and circuit still sends strong signals to outputs(j701-j702).

How can I make this controlled by mega?

Apperently you are sure that B5 is set high. We are not...

Take a multimeter. Check the voltage at B5.
Then move through your circuit...

Start by doing some measurements on the circuit. Firstly, disconnect the mega and instead just use a jumper wire to pull B5 to GND on your circuit. Then poke around with a multimeter around the PNP to see if everything looks as expected.

Measure the base of Q702 to see if you get 5V with B5 left floating, and whether you do get 0V to the base with B5 pulled down. Then measure at the junction of Q702 and R705. This should already tell you something. Follow the signal down the line, use Ohm's law to make sense of your readings. You're using a static signal (jumper wire) so all inductors can be assumed to be low value resistors and all capacitors become open circuits - easy.

What readings have you taken so far and what do they tell you? Can you post a schematic with the voltages you read in different places between Q702 and Q703 with B5 floating vs. B5 pulled down?

PS: I wouldn't have used a PNP but a P-channel MOSFET, but it doesn't matter; either should work.

PPS: if the only intent of Q702 is to disable the oscillator, what's all the rigmarole around the multiple resistors, an inductor (L702) thrown in etc? Why so complicated? Use an NMOS for Q703 and pull its gate low to disable the circuit.

PPPS: if this circuit around Q703 is indeed some kind of oscillator that you want to control (turn on/off) with an Arduino...why use an oscillator built around discrete components anyway? You've got a microcontroller that will generate any frequency and duty cycle at the drop of a hat. If it needs to be any particular waveform, hook up a simple DAC and output whatever you like. Amplify to the desired impedance. Again, why the Rube Goldberg approach?

Check all your soldering connections. For good connection and for shorts with neighbouring points. Post a picture of your setup...
Are you producing up to 400V waves?
And is that safe?

My dear friend thank you for your efforts and detailed answers, I really appreciate you especially. And thanks all.

Problem is solved when I use B5 only with 50Hz PWM with interrupts. There is a bug on arduinos when u use digitalWrite and anallogWrite together. When I use phase correct PWM on B5 its done.