Go Down

Topic: Using Arduino to control 74HC595 not CD40110BE in cascade using SPI. (Read 1 time) previous topic - next topic

marathonMAN1

#15
Sep 11, 2019, 01:26 am Last Edit: Sep 11, 2019, 02:15 am by marathonMAN1
I thought the CD40110B will work because it has an count up/down, cascade  features that allows it to count up which changes the tap position on the inductor which changes the inductance of both side of the inductor. then count down using the very same tapes to change the inductance the other way. all the taps are on the same inductor and since it is the positive side and two are on at a time there will be two north face magnetic fields at the two taps that are constantly moving. what this does is separate the one big inductor in two halves with one side increasing in current and the other side reducing in current in complete unison which is simple physics.

the pic below is the taps on the inductor which does not show all 46 taps for space reasons. the taps are positive side taps and at the bottom after the electromagnets is the negative side connection.

all this circuit does is vary the current through the two end feed connection of the inductor that mimic a brush rotating in a circle but change the inductor tap locations instead which causes Inductive reactance ie a current change of both feeds on either end of the inductor.
all i need to do is figure out how the timing of the two signal wires to the Arduino one being up and the other down plus ground, will be. for one revolution of a rotating brush will be 16.66 ms so that time has to be divided by 48  because one of the end channels are switched twice because of the up then down switching. this is good because that is what i need it to be.
each tap is on for .347 ms each which is divided by 48 channels of which will equal 16.666 ms of one revolution. does that mean a CD40110 b will not work and i am forced to use a cascade shift register. here i thought it will count up then down like it says in the Instructions.

i hope you can understand this with the help of the pic.


PaulRB

CD4017 does not do what you think it does, not what you want. You must have misinterpreted the "instructions" (data sheet?)

Shift registers (74hc595) will do what you want. 4 Arduino pins will be needed for clock, data, latch and output enable (to ensure break-before-make).

How much current will be flowing? If less than 150mA, maybe tpic6b595 could be used instead, removing the need for igbts.

marathonMAN1

#17
Sep 11, 2019, 06:18 pm Last Edit: Sep 11, 2019, 06:22 pm by marathonMAN1
johnwasser and PaulRB you are completely correct, i totally misunderstood the function of the CD40110. so i did some further research and both of you are correct in your assumptions that i need to use the 74HC595 in cascade fashion. fantastic chip and a perfect fit for this project, THANK YOU BOTH.

i can then cascade (6)  74HC595's to get my needed 46 channels timing them up then down.

PaulRB; that is make before break which is the leading channel on before the lagging one shuts off. also i will be using 1.4 amps peak of current @ 100 plus volts DC through the transistor.  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.

i am working on the timing circuit right now using the 74HC595 in a sop 16 package that i will have connected to a Tensy 3.6.  it is on a Tall Dog break out board but i can take that off and mount it to my timing board.

then comes the fun part of coding.

Arduino community is awesome, thanks guy for all the help.

PaulRB

#18
Sep 11, 2019, 08:43 pm Last Edit: Sep 11, 2019, 08:44 pm by PaulRB
Quote
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.

Quote
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.

PaulRB

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.

marathonMAN1

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.

PaulRB

#21
Sep 12, 2019, 07:30 am Last Edit: Sep 12, 2019, 07:42 am by PaulRB
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.

marathonMAN1

#22
Sep 12, 2019, 08:04 am Last Edit: Sep 12, 2019, 08:17 am by marathonMAN1
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.


PaulRB

#23
Sep 12, 2019, 07:14 pm Last Edit: Sep 12, 2019, 07:25 pm by PaulRB
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).

marathonMAN1

#24
Sep 13, 2019, 12:34 am Last Edit: Sep 13, 2019, 12:47 am by marathonMAN1
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.

 
Code: [Select]

/* 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.

PaulRB

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.

marathonMAN1

#26
Sep 13, 2019, 05:20 pm Last Edit: Sep 13, 2019, 05:32 pm by marathonMAN1
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.

PaulRB

#27
Sep 13, 2019, 05:38 pm Last Edit: Sep 13, 2019, 05:41 pm by PaulRB
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.

CrossRoads

Code: [Select]


/* 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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

marathonMAN1

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.

Go Up