Author Topic: Interuppter code help for sstc (LONEOCEANS SSTC2 )  (Read 268 times)

Offline prabhatkumar

  • High Voltage Experimenter
  • **
  • Posts: 55
  • Karma: +0/-0
    • View Profile
Interuppter code help for sstc (LONEOCEANS SSTC2 )
« on: April 05, 2020, 05:20:57 PM »
Hello there everyone !! I was on my way of building my first sstc originally from kaizer sstc 3 , but then i encountered many issues for which I already started 2 new topics an with the help of fellow members on this forum, I was able to fix them to a good level and proceed. Back then I was using my function generator as source for generating the interrupter signal. But now to pack up everything I need a standalone interrupter . For that i tried many 555 circuits but was satisfied with none, since i want to adjust frequency and duty cycle both( I came across a 555 circuit in which there are two cascaded 555 to change the duty and frequency but what happens actually is that it is never an independent control of it, when i change frequency duty also gets affected and vice versa.). So then i stumbled across the lone oceans sstc 2, he was using an attiny 85 interrupter. But now I am not able to undesrstand many parts if his code. If anyone can then please explain me the same. I will attach a link to the code file directly.
http://www.loneoceans.com/labs/sstc2/ATtiny85_SSTC_Interrupter_63.ino
I will list down the things which i am not able understand.
1)Right where he writes user definable variables, how does he decide what the maximum on time can be(32768/5) ??
2)In the create other variables part, what is critical frequency and how is it calculated??
3) In the part where he decides the frequency{Freq= 1+ vbps + 4)/4}, why did he add 4 to it ??
4) Also how the are the clock settings essential here, there is a link in the code on how to change the system clock settings( 1 MHz OR 8 MHz).
Else if you are super generous then a humble request , can you also explain the bottom part in brief

And if there are other suggestions for any other interrupter , then please do mention it. Thanks !!
« Last Edit: April 05, 2020, 06:53:33 PM by prabhatkumar »

Offline ritaismyconscience

  • High Voltage Technician
  • ***
  • Posts: 135
  • Karma: +3/-0
    • View Profile
Re: Interuppter code help for sstc (LONEOCEANS SSTC2 )
« Reply #1 on: April 05, 2020, 09:55:33 PM »
The critical frequency is the lowest frequency where the on time is still less than the maximum set in one of the variables. Basically you figure out from duty cycle and frequency how long the on time is, it's 10^6us/freq*duty. Then you solve for max on time and you get max = 10^6us/freq*duty --> freq = 10^6us/max*duty.

Changing the MCU frequency from 1MHz to 8MHz will mess with the delay (since it'll take 8x less time or 8x more time)

The bottom code basically turns on the interrupter for a set period of time, then turns it off for a set period of time. It does this repeatedly.

Haven't looked at the other code enough to figure out why you divide by 5 or add 4 but in practice you're never going to use an ontime anywhere close to 6000us.
« Last Edit: April 05, 2020, 10:01:40 PM by ritaismyconscience »

Offline Max

  • High Voltage Enthusiast
  • *
  • Posts: 41
  • Karma: +3/-0
    • View Profile
Re: Interuppter code help for sstc (LONEOCEANS SSTC2 )
« Reply #2 on: April 05, 2020, 10:09:40 PM »
Hello prabhatkumar,

Considering the double NE555 solution I wouldn't be surprised if one controlled the ontime, and one controlled the period. And of course, maintaining the same ontime at variable frequencies results in different duty cycles (duty = ontime / period = ontime * frequency). So it might have worked perfectly fine.

I had a quick look at the code and honestly I don't really like it. At frequencies below 32Hz f.ex. it is possible to exceed the specified maximum duty cycle because he assumes your maximum ontime doesn't allow a high enough duty cycle at these frequencies, but doesn't check it. That means you can set a 6000us ontime at 30Hz (=18% duty cycle) and the code doesn't care if your specified maximum for the duty cycle is 5% or 50%. It is probably no problem in reality but still it doesn't seem right to me. Beside of that he mixes ints and floats and it is not always obvious that this causes no problems (but seems to be ok on first look). This chip doesn't have a FPU, so floating point calculations cost quite a bit of time - not really important for such a simple code, but I'd prefer everything in integer.

1) Not sure about that one. At first I thought it might me a limitation of delayMicroseconds, but doesn't appear to be. He uses it at the very end for the offtime which easily exceeds the 6553us. Second thought was that he somewhere multiplies it with another number and wants to prevent overflows (integers on this microcontroller can't go lower/higher than -32768/32767). But again, I couldn't find such a situation. So not sure what the reason is - or if this comment is not up to date.
2) Critical frequency is the frequency up to which you can keep the ontime at the given maximum without exceeding the duty cycle limit. Lets assume a max duty of 10% and a max ontime of 200us. Then you can maintain the 200us ontime up to a frequency of 1000000 / 200 * 0.1 = 500Hz (the 1000000 is needed because Hz = 1/s, not 1/us). If you want to go higher than 500Hz you (or rather the interrupter) have to lower your ontime. Example: At 1000Hz, 10% duty equals to 100us instead of the maximum of 200us.
3) Again not sure what his intention is but I assume he tries to ceil the division. Integer divisions are normally floored (anything up to x.99999 equals to x.0, 19/10=1). A trick to ceil the division (meaning 10/10 = 1, 11/10 = 2) is to add "some" to the value before dividing it. To ceil a division of x by n you simply add (n-1) to x. ceil(x/n) = (x+n-1)/n. Try it with some numbers, it works ;) Now I wrote "some" because his numbers aren't exactly right. To ceil a division by 4 you'd only add 4-1=3, but close enough I guess. The 1 + ... is probably to guarantee that Freq >= 1. So the right fomule would be f = 1 + vbps / 4 or f = 1 + (vbps + 3) / 4.
4) Clock is crutial for delay() and delayMicroseconds() to work properly. I programmed an ATTiny13 with Arduino and the delays were up to 50% off. I guess there was a quirk somewhere in the clock configuration. But even without, the internal oscillator of the Atmels have pretty rough specs (+/- 10%!). So you might consider this when setting your max frequency and max ontime.

About the bottom part (line numbers would have been helpful, but let me simply guess what you mean ;) ):
if (freq > critfreq){
    ontime = 1 + (vpw/1023.0)*period*duty;
Remember what I said about high frequencies and that you can't stay at maximum ontime? Well, period * duty gives your the maximum allowable ontime that doesn't exceed your duty cycle (remember: duty = ontime/period. So period * ontime/period = ontime :) ). This is then multiplied with your pulse-width setting. So effectively he lowers the upper limit of your pulse-width (ontime) range. The plus 1 is again to prevent 0us ontimes.

else{ontime = 1 + (vpw/1023.0)*maxontime;}
If the frequency is lower than that "critical frequency", we have the inverted situation: now the duty cycle would yield in too high ontimes. F.ex. 10% duty at 100Hz equals 1000us ontime. But your coil might only support 300us max. So in this case we don't take duty*period as upper limit, but maxontime. And again multiply it with your pulse-width setting and add 1 to prevent 0us ontime.

offtime = period - ontime;
This shouldn't be a problem?

Finally he outputs the signal. Turn on, wait, turn off, wait. He does this for two pins, one being the output to the tesla coil, the other one can be used to drive an LED which shows you if the output is active or not.


Considering other interrupters... I don't know any interrupter that would be as cheap as a single Atmel chip. You might want to have a look at Oneteslas ATmega 328 based (MIDI) interrupter. Buying a complete one is rather expensive but you should be able to find the source code to build your own. The next step would be my more powerful MIDI interrupter. It is designed to be controlled with a rather cheap touch display or by a PC. It supports smooth transitions between different ontime settings, as well as different sounds for MIDI mode (yes you can have quite a bit more than only "beep" "beep" ;) ). You'll find everything you need to know over here: https://highvoltageforum.net/index.php?topic=1020.msg7116#msg7116And then there's Netzpfuschers UD3 which is a whole other beast, but I don't think that's what you're looking for.


Hope this helps!
Max

Offline Max

  • High Voltage Enthusiast
  • *
  • Posts: 41
  • Karma: +3/-0
    • View Profile
Re: Interuppter code help for sstc (LONEOCEANS SSTC2 )
« Reply #3 on: April 06, 2020, 10:21:47 AM »
Sorry for the double post but I get a 403 forbidden error if I try to edit my last post.


At the beginning I said I don’t like this code, giving examples why but also explaining that it probably works just fine. I wanted to clarify this a bit.
All in all it does work but is rather quick ‘n dirty. If you want to use it ‘as is’ it will be fine. If you want to make changes/improvements however I’d really start from scratch, write a proper version. You can still use loneoceans code as inspiration.
Why? Well these quick ‘ n dirty codes tend to work as expected up to a certain point. And then you get headaches while trying to figure out why it doesn’t work anymore. F.ex. you add some more calculations and your frequency setting doesn’t work anymore. How long would you try around until you find that it is because the float calculations cost too much time and slow down the whole code? And here’s the next problem with quick ‘n dirty code: once you have a problem it usually means rewriting most of it (in the example you’d have to rewrite all maths).

No matter what you do (use it whitout changes, write your own, use a different code) you should verify the output of the interrupter with an oscilloscope to make sure it never exceeds your max ontime or max duty.


Kind regards,
Max

Offline prabhatkumar

  • High Voltage Experimenter
  • **
  • Posts: 55
  • Karma: +0/-0
    • View Profile
Re: Interuppter code help for sstc (LONEOCEANS SSTC2 )
« Reply #4 on: April 09, 2020, 04:11:09 PM »
Thanks Everyone for the replies !! I am sorry for the very late response reply ( actually there was no notification in my mail this time so I missed it up here ) . I have understood the whole code successfully except for that 6563/5 but that's ok anyways I am not going to to use that much high on time ( I am using 2000 uS as it is a SSTC so hope that's ok ). I am using a duty cycle of 20% and I have verified it on an oscillsocpe , it never exceeds it . But I have modified it a bit , I have set the maximum frequency to a 800Hz. So now I can vary from 0- around 600 ( it doesn't cross 600 I don't know why even though I set the max to 800 ) but still it's fine . So I think it's fine now . I will open a new topic for a bit different kind of issue i am experiencing . The issue is that now whenever I try to go to max, in between for a some freqencies there appears to be some kind of weird vibrations or I should say bad noise and not the usual sound . But whenever I take my hand close to the coil , the strange noise disappears. So I will continue with the new topic with a video highlighting the problem .
Edit : the weird noise issue thing is now gone. Well it was pretty wild guess, but then I thought I have excessively long antennae for the fact that I had Corona formation at it's ends many times . So when I used to put my hand in between the coil and the antennae the Corona formation stops and the strange noise vanishes. So it was for then sure that something wrong with the antennae only. So all did was to replace with a small single wire stand , and then everything was working fine. Thanks everyone to all replied !!
« Last Edit: April 09, 2020, 08:02:00 PM by prabhatkumar »

High Voltage Forum

Re: Interuppter code help for sstc (LONEOCEANS SSTC2 )
« Reply #4 on: April 09, 2020, 04:11:09 PM »

 


* Recent Topics and Posts

post Re: Isn't there a better way to make a custom toroid?
[General Chat]
Rowdy
May 24, 2020, 11:47:26 PM
post Re: GDT cable specs
[Transformer (Ferrite Core)]
costas_p
May 24, 2020, 11:09:44 PM
post Re: Welcome new members, come say hello and tell a little about yourself :)
[General Chat]
Rowdy
May 24, 2020, 10:39:45 PM
post Re: GDT cable specs
[Transformer (Ferrite Core)]
station240
May 24, 2020, 09:55:49 PM
post Re: Working Principle Of Neon Transformer Circuit
[Transformer (Ferrite Core)]
davekni
May 24, 2020, 09:55:48 PM
post Re: Welcome new members, come say hello and tell a little about yourself :)
[General Chat]
Mads Barnkob
May 24, 2020, 08:16:40 PM
post Re: GDT cable specs
[Transformer (Ferrite Core)]
thecyberman
May 24, 2020, 05:38:27 PM
post Re: Welcome new members, come say hello and tell a little about yourself :)
[General Chat]
Rowdy
May 24, 2020, 02:33:55 PM
post Re: Freewheeling diodes are burning (Now other problems)
[Solid State Tesla Coils (SSTC)]
hip424
May 24, 2020, 02:31:39 PM
post Re: Working Principle Of Neon Transformer Circuit
[Transformer (Ferrite Core)]
iraquois
May 24, 2020, 02:08:53 PM
post Re: Easy to build Polyphonic MIDI Interrupter
[Computers, Microcontrollers, Programmable Logic, Interfaces and Displays]
Max
May 24, 2020, 12:12:36 PM
post Re: Working Principle Of Neon Transformer Circuit
[Transformer (Ferrite Core)]
ritaismyconscience
May 24, 2020, 07:56:21 AM
post Re: Freewheeling diodes are burning (Now other problems)
[Solid State Tesla Coils (SSTC)]
ritaismyconscience
May 24, 2020, 03:09:57 AM
post Re: Working Principle Of Neon Transformer Circuit
[Transformer (Ferrite Core)]
davekni
May 23, 2020, 10:24:55 PM
post Re: GDT cable specs
[Transformer (Ferrite Core)]
johnf
May 23, 2020, 09:30:29 PM
post GDT cable specs
[Transformer (Ferrite Core)]
costas_p
May 23, 2020, 09:06:39 PM
post Re: Working Principle Of Neon Transformer Circuit
[Transformer (Ferrite Core)]
Mads Barnkob
May 23, 2020, 08:22:59 PM
post Re: Freewheeling diodes are burning (Now other problems)
[Solid State Tesla Coils (SSTC)]
davekni
May 23, 2020, 07:47:49 PM
post Re: Building a bigger DRSSTC
[Dual Resonant Solid State Tesla coils (DRSSTC)]
davekni
May 23, 2020, 07:41:41 PM
post Working Principle Of Neon Transformer Circuit
[Transformer (Ferrite Core)]
iraquois
May 23, 2020, 02:09:26 PM
post 600 Watt GEL Battery Charger Teardown - Signet Systems HB600-24B
[Electronic Circuits]
Mads Barnkob
May 23, 2020, 12:46:23 PM
post Re: Building a bigger DRSSTC
[Dual Resonant Solid State Tesla coils (DRSSTC)]
ritaismyconscience
May 23, 2020, 04:14:52 AM
post Re: New projet OmegaDR
[Dual Resonant Solid State Tesla coils (DRSSTC)]
ritaismyconscience
May 22, 2020, 01:15:36 AM
post Re: New projet OmegaDR
[Dual Resonant Solid State Tesla coils (DRSSTC)]
Mugi30
May 21, 2020, 11:55:37 PM
post Re: Easy to build Polyphonic MIDI Interrupter
[Computers, Microcontrollers, Programmable Logic, Interfaces and Displays]
Max
May 21, 2020, 07:46:28 PM
post Re: New projet OmegaDR
[Dual Resonant Solid State Tesla coils (DRSSTC)]
Mugi30
May 21, 2020, 09:15:57 AM
post Re: How to get rid of stuff?
[Sell / Buy / Trade]
johnf
May 21, 2020, 06:35:31 AM
post Re: How to get rid of stuff?
[Sell / Buy / Trade]
MRMILSTAR
May 21, 2020, 05:23:40 AM
post Re: Easy to build Polyphonic MIDI Interrupter
[Computers, Microcontrollers, Programmable Logic, Interfaces and Displays]
futurist
May 21, 2020, 12:16:04 AM
post Re: How to get rid of stuff?
[Sell / Buy / Trade]
klugesmith
May 20, 2020, 11:22:34 PM
post Re: Powerful easy to build MIDI Interrupter
[Computers, Microcontrollers, Programmable Logic, Interfaces and Displays]
Max
May 20, 2020, 12:15:43 PM
post Re: Portable Q(uarantine)CW Tesla Coil
[Dual Resonant Solid State Tesla coils (DRSSTC)]
SteveN87
May 19, 2020, 02:08:20 PM
post Re: New projet OmegaDR
[Dual Resonant Solid State Tesla coils (DRSSTC)]
Mugi30
May 19, 2020, 12:05:51 PM
post Re: Powerful easy to build MIDI Interrupter
[Computers, Microcontrollers, Programmable Logic, Interfaces and Displays]
Max
May 19, 2020, 11:49:02 AM
post Re: Powerful easy to build MIDI Interrupter
[Computers, Microcontrollers, Programmable Logic, Interfaces and Displays]
Mads Barnkob
May 19, 2020, 09:26:06 AM
post Re: Portable Q(uarantine)CW Tesla Coil
[Dual Resonant Solid State Tesla coils (DRSSTC)]
Weston
May 19, 2020, 07:55:54 AM
post Re: What's the best way to trigger these things?
[Capacitor Banks]
klugesmith
May 19, 2020, 01:55:11 AM
post Re: New projet OmegaDR
[Dual Resonant Solid State Tesla coils (DRSSTC)]
ritaismyconscience
May 18, 2020, 11:54:27 PM
post Re: New projet OmegaDR
[Dual Resonant Solid State Tesla coils (DRSSTC)]
Mugi30
May 18, 2020, 10:10:09 PM
post Re: New projet OmegaDR
[Dual Resonant Solid State Tesla coils (DRSSTC)]
Mugi30
May 18, 2020, 10:05:14 PM
post Re: What's the best way to trigger these things?
[Capacitor Banks]
johnf
May 18, 2020, 09:03:11 PM
post Re: What's the best way to trigger these things?
[Capacitor Banks]
John123
May 18, 2020, 07:50:08 PM
post Re: Powerful easy to build MIDI Interrupter
[Computers, Microcontrollers, Programmable Logic, Interfaces and Displays]
Max
May 18, 2020, 04:15:16 PM
post Re: Freewheeling diodes are burning (Now other problems)
[Solid State Tesla Coils (SSTC)]
hip424
May 18, 2020, 03:13:14 PM
post Re: How to get rid of stuff?
[Sell / Buy / Trade]
klugesmith
May 18, 2020, 06:31:25 AM
post Re: Building a bigger DRSSTC
[Dual Resonant Solid State Tesla coils (DRSSTC)]
ritaismyconscience
May 18, 2020, 03:18:40 AM
post Re: What's the best way to trigger these things?
[Capacitor Banks]
davekni
May 18, 2020, 02:26:27 AM
post Re: What's the best way to trigger these things?
[Capacitor Banks]
rikkitikkitavi
May 17, 2020, 11:17:06 PM
post Re: Secondary parameters
[Solid State Tesla Coils (SSTC)]
Alberto
May 17, 2020, 10:18:22 PM
post Re: SSTC Micro
[Solid State Tesla Coils (SSTC)]
davekni
May 17, 2020, 09:42:29 PM

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
SimplePortal 2.3.6 © 2008-2014, SimplePortal