Complimentary Pins on Arduino?

Hello, I am in the middle of a university project, and at the point where we need to build a H-bridge. We want the output of one pin to be exactly the digital opposite of the other. Our supervisor recommended that I check if the arduino has something which he called 'complimentary pins' which output high when the other is low and vice versa.

I've searched a little and I cannot find anything, it could be that I am getting the correct term wrong.

Could anyone help me?
Thanks

No it doesn't look a port manipulation in the playground and/or the datasheet.

Why do you think you need this with a h-bridge?

Mark

Wouldn't a NOT gate do the trick?

Wouldn't a NOT gate do the trick?

Not if (and its a very big if) the OP really wants this,

We want the output of one pin to be exactly the digital opposite of the other.

Mark

Our supervisor recommended that I check if the arduino has something which he called 'complimentary pins' which output high when the other is low and vice versa.

The arduino does not have this feature, in fact there are only a few processors that have it.
Simultaneous switching can be done by outputting information on the direct port of the processor, but this will never be exactly the same because there will be a rise and fall time associated with each pin.

If you want to make a H-bridge then you do not need this feature if you design it correctly. In fact to avoid shoot through this is a feature you do not want. You want to be in control of what the signals are doing and do not expect anything to happen simultaneously.

holmes4:

Wouldn't a NOT gate do the trick?

Not if (and its a very big if) the OP really wants this,

We want the output of one pin to be exactly the digital opposite of the other.

Mark

Either I don't understand something about NOT gates, or we have a breakdown of communication.
I wasn't suggesting to implement a NOT gate somewhere on the arduino board, but to use one pin, fork it and use one side to to drive whatever is needed directly, and the other to hook up to the NOT gate and drive whatever else is needed.
Since there is no such thing as simultaneous anything, we all need to live with some kind of delays. A simple transistor changing its state is fairly fast.

Since there is no such thing as simultaneous anything

I think that was the point Mark was making, there will be a propergation delay between the input going to one logic state and the output following it to the other. This delay depends on what sort of NOT gate you use.

Isn't the point of direct port manipulation to make IOs update together?

PORTD = PORTD | 0b00001100; // set bits 2,3
PORTD = PORTD & 0b11110011; // clear bits 2,3

Won't those bits change on the same clock edge?

Yes they will be but they will not be changing at EXACTLY the same time but close enough I would think so for this application.

I think that was the point Mark was making, there will be a propergation delay between the input going to one logic state and the output following it to the other. This delay depends on what sort of NOT gate you use.

That's correct. Adding inverters in this way was used to delay signals.

Mark

Thanks for the replies, and the option I was considering was a NOT gate, but I know this will add a time delay on the order of nanoseconds, which isn't such a big deal.

I hope if I give more detail someone will be able to direct me the right way?

I'm making the h bridge from two Infineon BTN7960 half bridges, and the logic input changes whether the high side or low side transistor is on. I would have thought that having the input to one high and the other low would allow the current to pass through the motor one way then the other.

If I'm going about this he wrong way could someone point me in he right direction?

Thanks

andy_p_:
I'm making the h bridge from two Infineon BTN7960 half bridges

In that case, as far as I can see the only you need to ensure is that each half bridge is only driven high or low (and never both at the same time). And surely this is already ensured by the half bridge control logic? There is no need to have the two half-bridges switch simultaneously - it is harmless, and often beneficial, to have the two motor terminals either pulled to the same voltage (so the motor coasts) or deliberately connected (to form a brake) to reduce the massive transient when a rotating motor is abruptly powered in the reverse direction.

Grumpy_Mike:
The arduino does not have this feature, in fact there are only a few processors that have it.

I would say the exact opposite is true. Most microcontrollers support complementary pins and the AVR AtMega is no exception. This comes from the fact that IO pins are mapped in clusters (8-bits on the AtMega) and a full cluster (a port) can be set/reset within the same cycle and on the same clock edge.
You can use direct port io (as suggested by CrossRoads) - or you can program one of the timers to toggle two pins with complementary logic.

When using direct port io it is convenient to use the toggle instruction.

Example:
PIND = 0x03; // toggle digital pin 0 and 1

When using direct port io it is convenient to use the toggle instruction.

Example:
PIND = 0x03; // toggle digital pin 0 and 1

That is a cleaver method that many don't know about or remember. Just keep in mind that use of such methods is not portable across all the different AVR chips the arduino IDE now supports.

Lefty

Hi, update guys. The info on complimentary pins is great, and could come in useful, however issue solved after a conversation with the same supervisor, after he read the dataheet correctly!

It is true that I ont need this, I will be sending the pwm signal to the inhibit pin and using the IN pins to select any combination of transistors required, output from different points on the arduino, which will let me coast and fast brake.

Thank for the help everyone