|
Post by Marathonman on Sept 18, 2020 7:44:21 GMT -6
The good thing about using electronic switching is that you no longer have to gave a large flat surface for the brush to travel on. being taps off of the core it can basically be any shape you desire as long as it is closed core, proper Core size and the proper amount of winding's. please bear in mind that the winding's still have to be wound close together just like the mechanical version ie.. a variac. which is the same principle we are dealing with of inductive reactance. the only difference is the AC in the variac does the movement of current, in the part G using DC it is the circuit that is changing on a continuous basis. remember something always has to change (increase/decrease) in order for inductance to take place according to Faraday so therefore electronically switching taps on a continuous basis fulfills this basic requirement. each time an additional winding is switched in the inductance for that side of the circuit increases (Magnetic flux linking) and since it was created within the circuit, it will oppose the original current flow (Lenz's Law) so basically my point is all replicators that are using electronic switching of part G can use a standard off the shelf C core, Torroid or EI core or any other crazy design you can come up with as long as it is closed core.
Regards, Marathonman
|
|
|
Post by Marathonman on Sept 20, 2020 22:10:12 GMT -6
For any and all using electronic switching here is code using SPI to shift left then to right using Arduino and 6 595 shift registers. the code does not account for overlap which will then need timing overlap caps on the high side drivers. it can surely be used for other things also. i purchase a Tensy 4.0 which runs at over 600 Mhz and i will be testing it out shortly. sketch uses 14768 bytes so most Arduino's can handle the code including slower one's as SPI is much, much faster interface.
#include <SPI.h>
unsigned long long int registerBuffer = 0b11;
byte shiftPos = 0;
bool shiftingLeft = true;
unsigned long int lastUpdate;
const unsigned long updatePeriod = 177UL;
const byte latchPin = 10;
void setup() {
Serial.begin(115200);
SPI.begin();
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
pinMode(latchPin, OUTPUT);
}
void loop() {
if (millis() - lastUpdate > updatePeriod) { //Is it time to update the registers?
lastUpdate = millis();
//Shift the register left or right
if (shiftingLeft) {
registerBuffer <<= 1; //Shift 1 place to left
if (++shiftPos == 45) shiftingLeft = false; //Time to switch direction?
}
else {
registerBuffer >>= 1; //Shift 1 place to right
if (--shiftPos == 0) shiftingLeft = true; //Time to switch direction?
}
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);
}
}
Regards, Marathonman
|
|
|
Post by Marathonman on Sept 21, 2020 8:53:21 GMT -6
With the above code the only pin that needs to be declared is the latch pin. when using SPI.h it automatically takes care of that pin assignment for you as long as it is SPI 0. if you use SPI 1 or SPI 2 ect... then you will have to declare that in your sketch. with the above code it automatically uses SPI 0 so nothing else needs to be done.
Regards, Marathonman
|
|
|
Post by Marathonman on Sept 21, 2020 18:20:22 GMT -6
One more thing to rattle your chain. the line below is all that has to be changed to how ever many taps you have up to 64 bit. 64 of course being 8 shift registers so that will be 0-63.
if (++shiftPos == 45) shiftingLeft = false; //Time to switch direction?
changing 45 to what ever taps you have.
also the update time can be changed according to tap count by changing this line.
const unsigned long updatePeriod = 177UL; change 177 to what ever your time you need.
PS. if you are worried about space the Tinsy 4.0 is not only the fastest Arduino around but the above code uses less then 1 % which is 20316 bytes so the rest can be for voltage, current sensors and displays to read the results.
Regards, Marathonman
|
|
|
Post by Marathonman on Sept 23, 2020 9:59:02 GMT -6
My taps have not come in yet so i am at a hault on the mechanical so i am working on the electronic side today. what i am doing is making modular SMD boards to aide people and myself to pursue the electronic side switching of part G before the final production board.
the boards are all SMD parts and very small and modular meaning one board will contain a single shift register, a decoupling cap, power, ground, input and outputs. the same goes for the LED board which contain 8 LED's and resistors, inputs, power and ground. also a SMD 3.3 volt power supply with multiple outputs to accommodate the modular board needs.
both of these boards can be connected to Arduino boards and a power supply giving the ability to add as many modular boards you need in your quest and visualize the code you are pursuing. in my case i have 46 outputs so i will need 6 modular boards of each shift register and LED's. the reason i am doing this is i find using that many LED's and shift registers on a breadboard a pain in the ass and cumbersome to say the least. although i could make them to fit the breadboards also.
i am intending to run them all at 3.3 volts as most newer Arduino's are 3.3 volts IO. i am sure parts can be changed for 5 volts if necessary as the shift registers and LED's can handle the extra voltage. my Tensy 4.0 which runs at 600mhz plus has IO's at 3.3 and the shift registers can be run at 2 to 6 volts.
i will be posting pics sometime today as right now i am on spare computer as my windows 7 computer was bombed by Microsoft taking my activation code with it as well as the ability to add another activation code. windows 10 is nothing but a spying app that people are so unaware of it's pathetic so i need my windows 7 back as all my work is on it.
please post your comments on this situation of what is the best way you approach this.
PS. i like the read out loud feature on Firefox with the ability to change the voice, speed and pitch. if you do not understand something you can hear it and read it.
Regards, Marathonman
|
|
cheors
Junior Member
Posts: 33
|
Post by cheors on Sept 24, 2020 8:03:25 GMT -6
The schematic if i well understand
|
|
cheors
Junior Member
Posts: 33
|
Post by cheors on Sept 24, 2020 8:29:09 GMT -6
Something strange : millis() function can only count milliSeconds, not microSeconds. So even if you specify an updatePeriod of 177UL, i think the program loop will be 1000 times slower.
|
|
|
Post by Marathonman on Sept 24, 2020 9:57:04 GMT -6
Cheors, I forgot to state the millis() is set that way to see the LED's blink giving me the ability to visualize the proper function of the program. the millis() will be changed to micro() when in full operation. thanks for catching that. here are the breakout boards i have been working on. Regards, Marathonman
|
|
cheors
Junior Member
Posts: 33
|
Post by cheors on Sept 24, 2020 13:13:19 GMT -6
Problem : Micro() will overfow every 70 minutes and you will get a big timing discrepancy. I tried a simple solution with just a delay at the beginning of the loop :
#include <SPI.h>
unsigned long long int registerBuffer = 0b11; byte shiftPos = 0; bool shiftingLeft = true; const byte latchPin = 10;
void setup() { DDRD = 255; // PORT = output Serial.begin(115200); SPI.begin(); SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0)); pinMode(latchPin, OUTPUT); }
void loop() { delayMicroseconds(190); // 190 for 50Hz and 153 for 60Hz
if (shiftingLeft) { registerBuffer <<= 1; //Shift 1 place to left if (++shiftPos == 45) shiftingLeft = false; //Time to switch direction? } else { registerBuffer >>= 1; //Shift 1 place to right if (--shiftPos == 0) shiftingLeft = true; //Time to switch direction? } 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); }
|
|
|
Post by Marathonman on Sept 24, 2020 16:33:23 GMT -6
Quote; "Problem : Micro() will overflow every 70 minutes and you will get a big timing discrepancy."
why would it overflow it is just time. time will not overflow as it is not a function and that makes no sense. also why did you put in this "DDRD = 255; // PORT = output" there is no reason for this to be in the code as all pins are already taken care of. another thing is there can not be any delays like that in the loop as that will interrupt current flow causing BEMF in Part G. Regards, Marathonman
|
|
cheors
Junior Member
Posts: 33
|
Post by cheors on Sept 25, 2020 0:44:33 GMT -6
- See Arduino reference :
- Ok DDRD is useless but i use to add it each i write some code.
- millis() is another method to add a delay. Is'nt it? To shift the registers one step left or right, the program must send a clock pulse every 177 uS. So it has to wait and execute "if - else" instruction at the right time. No current interruption in part G. The 595 shift registers store and keep their output values during the delay or millis routines.
I also tried to use internal Arduino timer (TCNT0 counter) to manage a delay and it works fine.
Best regards
|
|
|
Post by Marathonman on Sept 25, 2020 18:33:25 GMT -6
This is the reason i can't understand. in this code a copy of the pattern is copied to the buffer and the buffer is updated every pass so i do no see how a buffer overrun can happen as it is over written every pass. mangling code for the fun of it is not right as i try to help people not confuse them so please do not do that in the future. millis() or in the final production Micro() is used for timing purposes there is no delay. SPI can be used completely separately from the chip clock so that leave one the ability to set their own clock pace and use the CPU for other things like sensors and such.
Regards, Marathonman
|
|
cheors
Junior Member
Posts: 33
|
Post by cheors on Sept 26, 2020 11:06:47 GMT -6
Yes i see that you don't understand what i mean : It is the micros() routine that will overflow. It uses an unsigned long int value.( 32 bits) The greatest possible number of microseconds is 4294967295, then the counter is reset and micros() return zero ! The value of micros() overflow and restart from 0 every 71 minutes. What happens here in your program when lastUpdate becomes greater than millis : " if (millis() - lastUpdate > updatePeriod) { //Is it time to update the registers? lastUpdate = millis(); "
I don't write mangling code for fun, i try to help you to eventually avoid some problems.
Best regards
|
|
|
Post by Marathonman on Sept 26, 2020 12:59:36 GMT -6
I was referring to the direct port code. I still do not understand as this was made by a very experience person and i find it very hard for this to happen. even if the program starts over what will happen then. unsigned long long int registerBuffer = 64 bit not 32 bit. i will contact the person who coded it for me and ask about what you say is correct or not.
Regards, Marathonman
|
|
cheors
Junior Member
Posts: 33
|
Post by cheors on Sept 26, 2020 15:44:31 GMT -6
Ok, i recheck the limit conditions and it seems there is no problem because calculations are made with unsigned long int variables. Sorry for the inconvenience.
This is my small test sktech :
unsigned long int lastUpdate,x;
const unsigned long updatePeriod = 177UL;
const byte latchPin = 10;
unsigned long int SimulMicros;
void setup() {
SimulMicros = 8; // just after overflow lastUpdate = 4294967294; // before }
void loop() {
if (SimulMicros - lastUpdate > updatePeriod) { //Is it time to update the registers?
lastUpdate = SimulMicros;
x++;} // variable to verify we execute the "if" instruction not later than 177uS SimulMicros++;
}
|
|