Author Topic: I need to convert a 0/1 signal to pulse when the output changes  (Read 892 times)

0 Members and 1 Guest are viewing this topic.

Offline ELS122Topic starter

  • Frequent Contributor
  • **
  • Posts: 937
  • Country: 00
I need to convert a 0/1 signal to pulse when the output changes
« on: February 15, 2020, 09:02:43 pm »
I have MOSFETs switching relays (low side) for a tube amp and I need to get a pulse that pulses each time any mosfet turns off/on.
is there a simple circuit that does this?
 

Online Circlotron

  • Super Contributor
  • ***
  • Posts: 3366
  • Country: au
Re: I need to convert a 0/1 signal to pulse when the output changes
« Reply #1 on: February 15, 2020, 09:20:59 pm »
Differentiate the rising and falling edges of the mosfet gate drive.
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4768
  • Country: nz
Re: I need to convert a 0/1 signal to pulse when the output changes
« Reply #2 on: February 15, 2020, 09:25:07 pm »
You want both 0->1 and 1->0 changes on any MOSFET to produce a 0->1->0 pulse on an output?

What do you want to do if more than one changes at the same time -- or at least before the previous pulse finishes?

I think what you'll need to do is:

1) XOR together all the MOSFET outputs
2) create a 0->1 triggered one-shot
3) create a 1->0 triggered one-shot (can be the same as the above, with an inverter before it)
4) OR together the previous two signals

Alternatively, you could do 2-3 for each MOSFET and then OR together all the outputs.

This seems definitely complex enough that it would be simplest to use a microcontroller with enough digital inputs and a very short program.
 

Offline ELS122Topic starter

  • Frequent Contributor
  • **
  • Posts: 937
  • Country: 00
Re: I need to convert a 0/1 signal to pulse when the output changes
« Reply #3 on: February 15, 2020, 09:32:33 pm »
well basically I need to get a pulse from every mosfet uppon switching off or on
then connect all of them together
then shorting the audio signal to ground somewhere, the FET shorting the signal to ground will be much faster than the relays so I wont need to delay the relays.
I checked how Mesa amps do this and they connect all of the backwards diodes from the relays together, put that into a 1:10 voltage divider to ground and using that to get the pulse.
but this seems it should only produce a pulse when it switches off.
 

Offline Dmeads

  • Regular Contributor
  • *
  • Posts: 171
  • Country: us
  • who needs deep learning when you have 555 timers
Re: I need to convert a 0/1 signal to pulse when the output changes
« Reply #4 on: February 16, 2020, 07:44:27 am »
Okay so look at the schematic I drew. I think this is what youre trying to do.

Link the signal going into your MOSFET to one input of an OR gate. Tie the other input of the OR gate to Ground. (this is called enabling the gate, because x OR 0 is always x), so you will just get whatever your input signal is (0 or 1) on the output of the OR gate.

You can then send this to a one shot (mentioned above). This can give you a longer pulse out than the input. Lets say your input signal is low (0), then it is high (1) for 20ms. Depending on the one shot circuit and the external components attatched to it, you could get an output pulse that is high for maybe 100ns or greater (all depends on the one shot circuit).

If you want the pulse to be the same length as your input signal, just use the output of the OR gate (although there will be a slight propagation delay in the order of nano seconds).

in other words: want pulse to stay high even after input signal has gone low? Use oneshot, otherwise, just use output of OR gate.

555 timers can be used for one shots and so can 74121 chips. If you use electrolytic caps with the 74121 make sure to use a switching diode too (see attatched datasheet) for proper operation.

Hope this helps!

-Dom

555 timer:  http://www.ti.com/lit/ds/symlink/lm555.pdf
74121: https://pdf1.alldatasheet.com/datasheet-pdf/view/177142/FAIRCHILD/DM74121.html

more info on oneshots: https://www.utm.edu/staff/leeb/3b3.htm
 

Offline Dmeads

  • Regular Contributor
  • *
  • Posts: 171
  • Country: us
  • who needs deep learning when you have 555 timers
Re: I need to convert a 0/1 signal to pulse when the output changes
« Reply #5 on: February 16, 2020, 07:47:54 am »
If you also need a pulse when the MOSFET turns off, do eveything the same except use a NOR gate instead of an OR gate. This will still give a high pulse out when the input signal is low
 

Offline Dmeads

  • Regular Contributor
  • *
  • Posts: 171
  • Country: us
  • who needs deep learning when you have 555 timers
Re: I need to convert a 0/1 signal to pulse when the output changes
« Reply #6 on: February 16, 2020, 07:55:35 am »
alternativley if you dont want to do all that you might be able to use an arduino and code it something like:
Code: [Select]

int signal;
int my_delay;   // delay in ms

signal = digitalRead(input pin);  // reads your input signal

if (signal == 1){
     digitalWrite(output pin, HIGH);     // this makes a pulse high for however long of a delay you want, 5000ms = 5second etc.
     delay(my_delay);
     digitalWrite(output pin, LOW);     // after, the pulse will go back low
}


 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4768
  • Country: nz
Re: I need to convert a 0/1 signal to pulse when the output changes
« Reply #7 on: February 16, 2020, 08:28:07 am »
Well, an AVR chip rather than a whole Arduino.

And the code might look like this:

Code: [Select]
long lastVals, lastTrigger;

void checkVals(){
  long now = millis();
  long newVals = (long)PORTA<<24 | (long)PORTB<<16 | (long)PORTC<<8 | (long)PORTD;
  newVals &= ACTIVE_INPUT_MASK;
  if (newVals != lastVals) {
    lastTrigger = now;
    lastVals = newVals;
    digitalWrite(OUTPIN, high);
  }
  if ((now - lastTrigger) > ONESHOTTIME) {
    digitalWrite(OUTPIN, low);
  }
}

Call checkVals() regularly. And of course you need some more code to set up the ports initially, and you need to specify your constants.

This will let you deal with up to 32 inputs, depending on how many digital IO pins your particular AVR has and how many you need :-)
 

Offline ELS122Topic starter

  • Frequent Contributor
  • **
  • Posts: 937
  • Country: 00
Re: I need to convert a 0/1 signal to pulse when the output changes
« Reply #8 on: February 19, 2020, 04:34:21 pm »
actually I think I will need an arduino cause all my relays and functions probably are easier done in programming than in circuit.
anyway I think I have enough options now to choose. thanks a lot!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf