Marathonman
Well-known member
Hello all;
I am new to Arduino and especially SPI protocol and would be very thankful for any such help on my project.
what i am attempting to do is switch taps on an active inductor controller electronically that exactly mimic a rotating brush assembly. the active inductor controller has 46 taps that need to be switched in a make before break scenario on a continuous basis. what i mean by make before break is the next channel needs to be on before the previous channel switches off. this way current is never interrupted which can cause a reverse inductive spike. the inductive controller uses self inductance or rather inductive reactance like a variac except with DC to control the current flow of two feeds in complete unison at 180 degrees from each other, one increasing in current and the other decreasing in current.
the below circuit is 6 shift register ic's that will have a Tensy 4.0 attached and below that is the previous work on the code that has been done so far. i have had other help from outside sources but this is as far as i have gotten. the code needs to first run at a slow speed so i can visualize with LED's to verify all is working then change the speed to a working model. the code then must switch at 180 microseconds on each tap.
I am new to Arduino and especially SPI protocol and would be very thankful for any such help on my project.
what i am attempting to do is switch taps on an active inductor controller electronically that exactly mimic a rotating brush assembly. the active inductor controller has 46 taps that need to be switched in a make before break scenario on a continuous basis. what i mean by make before break is the next channel needs to be on before the previous channel switches off. this way current is never interrupted which can cause a reverse inductive spike. the inductive controller uses self inductance or rather inductive reactance like a variac except with DC to control the current flow of two feeds in complete unison at 180 degrees from each other, one increasing in current and the other decreasing in current.
the below circuit is 6 shift register ic's that will have a Tensy 4.0 attached and below that is the previous work on the code that has been done so far. i have had other help from outside sources but this is as far as i have gotten. the code needs to first run at a slow speed so i can visualize with LED's to verify all is working then change the speed to a working model. the code then must switch at 180 microseconds on each tap.
Code:// This sketch controlls multiple 74HC595 shift regiters in cascade to electronically control Figuera's active inductor // controller by switching on taps located on part G connected to transistors in a "Make Before Break" scenario. by changing // tap locations continuously changes inductance which controls current flow of the primaries. // this sketch utilizes timing overlap to eliminate bsck Bemf or Cemf that would ocurr with single on off tap. it mimics // the brush rotation of a mechanical rotating brush thus creates a continuous increase/decrease current through the primaries. // Created by D Livesay aka Marathonman with the help of Paul RB 9/19/2019. // this sketch is distributed freely but if you use this program then post build on line give credit where credit is // due and not claim as your own design. // to adapt to your build change pin numbers, delay time and Array sequences. #include <SPI.h> unsigned long long int registerBuffer = 0b11; const unsigned long long int bit45 = 1ULL<<45; unsigned long int lastUpdate; const unsigned long updatePeriod = 10000UL; const byte latchPin = (10); // SS or CS output to STCK latch pin 12 on 74HC595 const int clockPin = (13); // SCk to Seial Clock SHCP Shift Clock pin 11 on 74HC595 const int dataPin = (11); // Mosi to DS in pin 14 on 74HC595 void setup() { Serial.begin(115200); SPI.begin(); SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0)); pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); } void loop() { if (millis() - lastUpdate > updatePeriod) { //Is it time to update the registers? lastUpdate = millis(); byte wrap = (registerBuffer & bit45) != 0; //Copy bit 45 from the buffer registerBuffer <<= 1; //Shift all bits in the buffer 1 place to the right if (wrap) registerBuffer |= 1; //Paste the copied value from bit 45 into bit 0 unsigned long long int temp = registerBuffer; //Take a copy of the buffer SPI.transfer(&temp, 6); //Send the buffer to the registers digitalWrite(latchPin, HIGH); //Latch the updated values into the register's output pins digitalWrite(latchPin, LOW); } }