Using Arduino to control 74HC595 not CD40110BE in cascade using SPI.

that is make before break which is the leading channel on before the lagging one shuts off.

Ah, sorry. In that case, don't bother with an Arduino pin for Output Enable, just tie it to ground. You will need to send data to the shift registers at twice the anticipated rate, so be sure to use hardware SPI pins for speed.

i might want to switch to a logic level NPN to switch a high power PNP to make it easy on me instead of having to use high side drivers.

Sounds like you are confused about types of transistors. NPN & PNP are BJT transistors, switched by current not voltage, so there is no such thing as a "logic-level NPN", they are all logic level. I suspect you meant to say logic level n-channel mosfet. But if you are switching high-side, is a p-channel MOSFET you want. You could control the p-channel MOSFET's gate with an npn bjt. If you do that, consider the tpic chip again. That would save you 46 npn-transistors, because the tpic chips could drive the p-channel MOSFET gates directly.

Checking your diagram again, I don't think you do want high-side switching or p-channel MOSFETs or PNP BJTs. You want logic-level n-channel MOSFETs, which you can directly control with 74hc595 outputs.

That is what i was talking about was Enhanced MOSFET i just forgot to add that as i was out the door.
the switching has to be done on the high side only. so i can use cheap logic level capable NPN MOSFET triggering PNP MOSFET.
this way as you say can be directly controlled by the logic level N channel Mosfet.
I can not use the N channel MOSFET on the high side without a driver and that is a lot more parts i do not want to spend on.
the BJt is current controlled and the shift register does not put out that kind of current so it has to be a logic level N channel MOSFET.

in your opinion what would be the cheapest way out using a high side switching scenario.
Thanks again.

Can you draw a schematic showing a few of the coils and high-side switches please? Based on your previous diagram, which I still find confusing, I'm not getting what you are saying about the need for high side switching.

I think I may have misunderstood your diagram. I interpreted the grey rectangles on the right and left, with the orange stripes on each side, as batteries, with their positive terminals connected to the ends of the coil and the two negative terminals connected together. But now I think they are something else. This is why a proper schematic would be helpful. They are, if done correctly, much less ambiguous.

The closed core in the middle is an active Inductor with 46 positive taps. the ends of the inductor are connected to electromagnets on either side which then are connected to the negative of the power supply.
when i sweep the taps back and forth i am changing the magnetic flux to current ration which in turn creates Cemf that opposes the current flow of both feeds through the electromagnets

with this active inductor i can vary the current flow of two feed on either side of the inductor 180 degrees out from each other but in complete unison.

what i need to do know is or figure out how to switch on PNP MOSFETS with such low voltage coming from the 74HC595's or at least come up with a solution.

with PNP's will i still need a driver to turn them on.

The 74hc595 outputs would need to drive npn bjt transistors or small n-channel FETs with logic level gates. Each bjt/fet, when switched on, would pull the gate of a large p-channel MOSFET down to ground to switch the MOSFET on. When the bjt/fet is off, the p-channel MOSFET's gate would be pulled up to high voltage, with a resistor, to switch it off.

Earlier, I suggested that this could be simplified by using tpic6b595 instead of the 74hc595. The idea was that the tpic chip's outputs could drive the p-channel MOSFET gates directly. The pull-up resistors would still be needed, but the bjt/n-channel fet would not be needed. In logic terms, the tpic chips are identical to 74hc595, but their outputs won't be damaged by high(er) voltages. The 74hc595 can't be connected to high voltages, which is why the bjt/n-channel FETs are needed with that chip. HOWEVER, the tpic chips are only rated up to 50V, and you are talking about 100V+, so the tpic chips won't be suitable. You will need to find npn bjt or n-channel FETs rated for over 100V to drive the gates of your p-channel MOSFETs (which must also be rated over 100V).

Awesome ! Thank you PaulRB very much for everything.
i was wondering if i shouldn't throw in a opto isolator in the mix to protect the IC's. i even found 300 volt opto's.

here is the code for the sketch i found that i can add to to switch multiple 74HC595B's shift registers. right now it is at 16 LED's.

/* Test circuit of the 74HC595B shift register serial to parallel Converter
   16 Leds in sequence up then back by Derek Mallow.
*/

const int clockPin = 9;  // Clock Sequence
const int hdataPin = 8;  // MS byte Serial data line
const int ldataPin = 11; // LS byte Serial data line
const int latchPin = 10; // Latch Pin

void setup() { // happens once on startup
  pinMode(clockPin, OUTPUT);
  pinMode(hdataPin, OUTPUT);
  pinMode(ldataPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
}

  void loop() {
    for (int i=0; i<16; i++)
    {
      if(i<8)shiftOut(ldataPin, clockPin, MSBFIRST, B00000001 << i);
      else shiftOut(hdataPin, clockPin, MSBFIRST, B00000001 << i-8);
      digitalWrite(latchPin, HIGH);
      delay(62);
      digitalWrite(latchPin, LOW);
    }
      for (int i=0; i<16; i++)
  {
      if(i<8)shiftOut(hdataPin, clockPin, MSBFIRST, B10000000 >> i);
      else {
      shiftOut(hdataPin, clockPin, MSBFIRST, B00000000);
      shiftOut(ldataPin, clockPin, MSBFIRST, B10000000 >>i-8);
      }
      digitalWrite(latchPin, HIGH);
      delay(62);
      digitalWrite(latchPin, LOW);
      }
  }

i copied it off of a video on youtube and compiled it and it worked so all i have to do is follow the format he used and add more shift register data lines. i have the circuit already done in DipTrace with 46 channels shifted right then left, now all i need to do is the recoding.

Thet sketch may be ok for initial testing, but as I said earlier, given the timings you mentioned in your first post, you need to be using the Arduino's hardware SPI, because shiftOut() is very slow by comparison.

Yes the whole sequence has to happen at 60 times a second and i am unaware of the speed of the shiftOut. do you happen to know the limitation of shiftOut.???? can shiftOut do micoseconds.??? can Tensy's shiftOut faster.???
the chip i will be using can hit 100 Mhz so then the limitation then falls on the Arduino.
EDIT;
each shift left then right has to happen in 16.66 ms so i thought shiftOut was fast enough.

i know nothing about hardware SPi so is there any information you can provide to help me in my quest. darn this really bites the bullet, i thought i had a winner.

Thanks so much.

shiftOut() is implemented in software and you have no control over its speed. It will probably be somewhat faster on teensy 3.x compared to AVR based arduino, but I guess still not fast enough. I would expect the clock speed to be a few tens or low hundreds of KHz.

SPI hardware can perform the same function as shiftOut() but it is much faster. Its clock speed can go up to 8MHz even on a 16MHz Arduino. On teensy 3.x it will be faster again, especially if Direct Memory Access is used in conjunction with the SPI hardware. DMA is a feature of more advanced MCUs which can send out data through the SPI hardware while the CPU performs some other task, such as preparing the next batch of data.

/* Test circuit of the 74HC595B shift register serial to parallel Converter
   16 Leds in sequence up then back by Derek Mallow.
*/
// Edits by CrossRoads to use SPI
#include <SPI.h>


//const int clockPin = 9;  // Clock Sequence
//const int hdataPin = 8;  // MS byte Serial data line
//const int ldataPin = 11; // LS byte Serial data line
//const byte latchPin = 10; // Latch Pin
const byte latchPin = 8; // SS from Arduino


void setup() { // happens once on startup
  SPI.begin(); // default 4 MHz clock
  //13,SCK, to clock
  //11, MOSI
  //  pinMode(clockPin, OUTPUT);
  //  pinMode(hdataPin, OUTPUT);
  //  pinMode(ldataPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
}


void loop() {
  for (int i = 0; i < 16; i++)
  {
    if (i < 8) {
      digitalWrite (latchPin, LOW);
      SPI.transfer(B00000001 << i);
      digitalWrite (latchPin, HIGH);
    }
    else {
      digitalWrite (latchPin, LOW);
      SPI.transfer(B00000001 << i - 8);
      digitalWrite (latchPin, HIGH);


    }
    //      digitalWrite(latchPin, HIGH);
    delay(62);
    //      digitalWrite(latchPin, LOW);
  }
  for (int i = 0; i < 16; i++)
  {
    if (i < 8) {
      digitalWrite (latchPin, LOW);
      SPI.transfer(B10000000 >> i);
      digitalWrite (latchPin, HIGH);
    }
    else {
      digitalWrite (latchPin, LOW);
      SPI.transfer(B0000000);
      digitalWrite (latchPin, HIGH);
      digitalWrite (latchPin, LOW);
      SPI.transfer(B10000000 >> i - 8);
      digitalWrite (latchPin, HIGH);
    }
    //      digitalWrite(latchPin, HIGH);
    delay(62);
    //      digitalWrite(latchPin, LOW);
  }
}

I don't know if the delay(62) is needed for display purposes.

The Nexperia 74HC595 has a shift out frequency of 100 mhz so that is comforting to know.
also a feature in the data sheet states the shift clock and the store clock can be tied together which then lags the store function (Latch) by one clock cycle so i am wondering if this can speed things up.

if not i might have to go to direct port manipulation which even a regular 16 Mhz Arduino can fit the bill.

CrossRoads;

this program i copied off of a video which it works well but i have not changed anything just yet, i wanted to get some advice on the program before doing anything else. i was just curious if the shiftOut and digitalWrite commands were fast enough to round trip 46 channels in 16.66 ms. well actually divided by 50 as the ends are on for three times longer. this works out to be 0.333 ms each channel with the ends 0.333 x 3 x 2 + 46 channels = 16.66 ms.

again Thank you very much.

I had a sketch that used SCK at 8 MHz (used SPI clock divisor of 2, vs default of 4), and uploaded data to 45 shift registers at a 20 KHz rate (an update every 50uS).

16.66mS = 16,660uS. Easily achievable I would think.
I used direct port manipulation for the SSpin low & highs; digitalWrite is way slower.

CrossRoads;

That sounds great, one thing i am forgetting though is i miss calculated badly. i was suppose to have a round trip if the channels and i only accounted for a one way trip. i know, i know how ignorant of me making that bad of a mistake.

the channels are 46 in total total so up and back will be 92 plus two added for the ends on longer so i have to divide 16.666 ms per revolution by 94 up and back total.

so now i have 16.666 ms per rotation of the channels up and back to mimic a rotating brush at 3600 rpm. so that leaves me with each channel on for .177 mS or 177 uS each.

i would love to see the sketch CrossRoads or at least part if their is any way possible. i need to study port manipulation badly, been reading all day long on the subject. i didn't realize that replacing a rotating brush would involve so much work but the end result will be fantastic.

Thank you so very much.

I ask out of ignorance - what is the pattern of output bits going to look like? It's repeating I assume, but it'll go through some sequence?

Channels are overlapped with two always on at a time in Make Before Break.

Are you Doug Pine by the way.

pic is just for reference concerning the overlap only not the channels available.

In that case, in each 177us period, you would need to update 6x 74hc595 only once, to achieve make-before-break. So that's 48 bits in 177us. That's around 1 bit every 3us, a clock rate of ~333KHz.

With 8MHz clock you can send out data to the 6x '595 in as little as 6us. Of course, there will be overheads: preparing the data, latching the outputs.

Code-wise, I would suggest to use an unsigned long long, for simplicity and performance. These are 64 bits, so enough to hold your 46 bit pattern, which you can initialise to 0b11. You can easily shift the bits in either direction with << and >>. You also have to handle the "wrap-around" between bit 0 and bit 45. When sending out the data with SPI.trsnsfer(), you can cast the unsigned long long into a byte reference, to avoid the need for more shifting and masking to extract individual bytes. You can use micros() to perform the timing.

Hi,
Are the taps part of the two inductors, or a separate tapped inductor?

I'm not sure what will happen with DC, but I was involved long ago with a project involving switching auto-transformer (AC) tap with similar make-before-break.
The problem was circulating currents between the two connected taps, current being induced into them by the current in the rest of the winding.
The transformer was 10A, but the circulating currents we up to 10 times that amount.

With DC you will have switching transients, so I'm not sure what sort of circulating current you will get.
This current will flow through your tap switching components.

Channels are overlapped with two always on at a time in Make Before Break

No, you should have two ON at switch over, not ALL the time.

Like this.

Tap 1 ON.
then
Tap 2 ON
then
Tap 1 OFF
then
Tap 3 ON
then
Tap 2 OFF
then
Tap 4 ON
then
Tap 3 OFF.

I hope that makes sense.

Tom.... :slight_smile:
PS. It will be interesting to see how the inductors interact with changing current and the CORE coupling them together to give a MUTUAL INDUCTANCE.
You are effectively making a transformer with pri winding magnetically and electrically connected to sec winding. :o
How are your inductors connected, START to START or START to FINISH terminals?

marathonMAN1:
Are you Doug Pine by the way.

Nope.

PaulRB;

Simply outstanding advice :slight_smile: and exactly what i need and i really do appreciate the explanation. the coding will be much more involved then shiftOut which is to bad as that is simple and i am not that experienced in coding. i also PaulRB was wondering will a Tensy 3.6 fit the bill for the timing as i have one on a Tall Dog break out board.????

TomGeorge;

no the Inductor is not two separate Inductors, it is one closed core inductor with the ends on either side connected to electromagnets. the moving taps are the action of a rotating positive brush converted to electronic switching. with the taps being positive it will cause two north face opposing fields at the brush or taps overlap that essentially separate the single Inductor to two separate inductors with current increase of one side and decrease current on the other in complete unison. it is essentially using inductive reactance to control current flow in two different feeds to the electromagnets 180 degrees out from each other which shift the opposing fields to one side then the other while maintaining field line pressure.

there is NO mutual inductance between them because of the opposing fields at the on taps that separate one inductor in to two halves. their is also no secondary as i am controlling the current flow to two sets of electromagnets in repulsion.
the pic below is the single layer Inductor that will control current flow of two feeds. it has less winding's then the real version as this is just for visuals to get the point across. the timing graph i posted is how the timing is going to be irregardless of word meaning and interpretations. two channels overlapping throughout the entire sweep except on the ends where they are on for three times longer then the ones in the middle. i posted a pic of the set up but i guess you pass that by.

again Thank you PaulRB, CrossRoads for your help many times over.