Speedy78
0
- Joined
- Dec 17, 2012
- Messages
- 2,081
- Points
- 63
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
/*
Sigurthr's Digispark SSTC Interrupter!
By Matt Giordano
Based heavily on ATTiny45/85 code for a simple Solid State Tesla Coil Interrupter
By Gao Guangyan, <www.loneoceans.com/labs/>
Thank you Gao!
offThresh allows the user to turn off the interrupter
by turning the potentiometer for BPS to below a certain threshold.
E.g. with Threshold set at 5/1023 --> 24mV, the signals will be off.
Set Threshold to 0 for always-on operation.
Digispark Physical Pinout:
Pin 5 as Digital Input: CW/Interrupted Mode switch.
Pin 4 as Analog Input: Frequency.
Pin 3 as Analog Input: Pulse-Width.
Pin 1 as Digital Output: LED.
Pin 0 as Digital Output: Fiber Optic Tx.
For the above analog inputs use a 10k Ohm pot with center wiper to associated
pin, one side to 5V and the other side to GND. For Pin 5 use a SPDT On/On
switch with center pin to Pin 5 and one side pin to ground, the other side pin to 5V.
*/
// User Modifiable Variables Here
float maxontime = 5000; // us - no greater than (32768/5) or 6553us!!
int offThresh = 0; // Define (offTresh/1023 * 5)Volts as off-threshold
float duty = 0.5; // Max Duty Cycle desired (here it's 10%)
// User Modifiable Variables End
int vpw;
int vbps;
int vcw;
int critfreq = (1000000*duty)/maxontime; // Hertz
float ontime = 0; // always us
float offtime = 0; // ms or us
float freq; // BPS Hertz
float period; // us
int outPin = 0;
int ledPin = 1;
int bpsPin = 2;
int pwPin = 3;
int cwPin = 5;
void setup() {
pinMode(outPin, OUTPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
vpw = analogRead(pwPin)-offThresh; // read pw voltage
vbps = analogRead(bpsPin); // read bps voltage
vcw = digitalRead(cwPin); // read cw switch state
if (vcw == HIGH) {
digitalWrite(outPin, HIGH);
digitalWrite(ledPin, HIGH);
}
else {
if (vpw < 0){
// Force logic low output when pw voltage is pulled low
digitalWrite(outPin, LOW); // Off
digitalWrite(ledPin, LOW); // Off
delayMicroseconds(100); // Short delay
}
else {
freq = 1 + ((vbps+2)/2);
// sets max BPS to 512.
// change to ((vbps+4)/4) for 254Hz max.
// change to ((vbps+1)/1) for 1024Hz max.
/*
If the period becomes > 2^15 us (T = 32.768ms or f less than 30.51Hz), then
the period variable runs over! Hence, we make sure this doesn't happen by
counting the numbers in milliseconds instead of microseconds.
Else, we can be free to count in microseconds
*/
if (freq < 31){
period = (1.0/freq)*1000; // ms
// Since 31 is a very low frequency, it will not exceed our
// pulse width at 10% duty cycle, so we just calc ontime in us.
ontime = 1 + (vpw/1023.0) * maxontime; // us
if (ontime > maxontime){ontime = maxontime;}
offtime = period - ontime/1000; // period in ms
// Now send the output signals
digitalWrite(outPin, HIGH); // On
digitalWrite(ledPin, HIGH); // On
delayMicroseconds(ontime); // delay in us
digitalWrite(outPin, LOW); // Off
digitalWrite(ledPin, LOW); // Off
delay(offtime); // delay in ms
}
else {
period = (1.0/freq)*1000000; // us
if (freq > critfreq){
ontime = 1 + (vpw/1023.0)*period*duty; // period in us
}
else{ontime = 1 + (vpw/1023.0)*maxontime;} // period in us
// Calculate off-times, capping the on-time to some max
if (ontime > maxontime){ontime = maxontime;}
offtime = period - ontime; // period in us
// Now send the output signals in microseconds
digitalWrite(outPin, HIGH); // On
digitalWrite(ledPin, HIGH); // On
delayMicroseconds(ontime); // delay in us
digitalWrite(outPin, LOW); // Off
digitalWrite(ledPin, LOW); // Off
delayMicroseconds(offtime); // delay in us
}
}
}
}
Sigurthr - earlier said:They take a thin copper plate about 1.5" x 0.5" and hammer it until it sits flush on your pvc former, then solder the LV connection to it and epoxy it to the former. Some people then use a pipe clamp (the slotted strap kind) to make connection to the plate, others solder a bolt to the plate, etc. The main idea is to keep all wiring on the outside of the secondary, because having wire on the inside can lead to internal arcing, which can easily destroy a secondary.