Sunday, January 25, 2015

Arduino Binary Clock - Serial Output

An upcoming project of mine is a standalone Numerical Sexagesimal Binary Clock that will run on Arduino, and use a high accuracy RealTimeClock to keep time. In the mean time I've worked out a simple program that uses the UNO's onboard 16MHz system clock (oscillator) to keep time. The resultant one Hz events are tallied sexagesimally and then converted to binary. Both binary and decimal outputs are sent to the serial line for viewing on the arduino compiler's serial monitor.

Nearly all, if not all currently made "Binary Clocks" use Binary Coded Decimals (BCD) to display time. BCD is when you use binary for each digit of a sexagesimal time. This is popular because it is much simpler to implement, most people can read easy since all the "binary" numbers are low values, and it adapts easily to graphical and LED display.

Here's an example of Binary Coded Decimals: 1's represent Lit LEDs, 0's represent Unlit LEDs

00:00:01
00:01:00
01:11:00
00:11:01
-----------
02:37:09

You read each vertical column as if it were a true binary number and then assemble the sexagesimal time code. So, the above timestamp is assembled from the binary numbers:

0000 or 0
0010 or 2
0011 or 3
0111 or 7
0000 or 0
1001 or 0

This is not how my binary clocks will work.

My clocks will output true binary time; 02:37:09 will be displayed as 0010:100101:001001.

So, check back in the future for the project post for my standalone arduino binary LCD clock. Until then, enjoy messing around with this bit of code!


NOTE: You set the time at point of compiling and uploading, but the arduino doesn't actually begin keeping time until the serial monitor is opened. So, set the time about 30sec ahead, upload, and then open the serial monitor just before it is the set time. On my system it takes about two seconds for the monitor to initialize and the arduino to sync up to it. I use www.time.gov for reference. You could also just set the time for the next minute and watch as it rolls over, then start the serial monitor; this would be less accurate by a few seconds + your response time.

BIGGER NOTE: The arduino's intrinsic time keeping ability is heavily limited by the accuracy of the 16MHz clock. Mine is slow by about 5 seconds per hour, or 2 minutes per day. I've added a few lines that wait for until the arduino has been running for 12 hours and the current minute is near the end of the hour, then it advances the minutes one minute to compensate. Depending on what time it was when you uploaded and started the serial monitor it may have to wait an extra hour until correction. So, this doesn't really fix the inaccuracy problem, but it lessens it greatly, from 2 minutes per day down to no more than ten seconds per day. Your mileage may vary. There's a reason this was just an exercise in getting the decimal to binary conversion working well.

Monday, January 5, 2015

The USSTCC: Universal SSTC Logic Controller

Sig's Universal SSTC Logic Controller - The USSTCC!

  • A universal solution to the question of "What driver should I use for my Solid State Tesla Coil's Half or Full Bridge Inverter?".
  • Smaller footprint than competitors yet can drive even the largest TO-264 Power Switching Devices.
  • Operates on either Secondary Base CT (current transformer) or antenna based feedback, for maximum flexibility.
  • Very High Noise Immunity - will operate fine even in "floating ground" implementations.
  • Greatly reduced parts count. This means it is inexpensive to build and has less points of failure!
  • Tested Frequency range of 100KHz to 1MHz! *Additional heatsinking may be required for very high frequencies.
  • Automatically locks on to the resonant frequency and drives the inverter in sync even under dynamic loads!
  • Features a powered Expansion Port so you can branch out and add additional functionality like Modulation!
  • Operates from 12VAC to 24VAC or 14VDC to 33VDC at 2 Amps input current. Power supply not included.
  • High Quality Professionally Made Printed Circuit Board with Gold-Plated Through-Holes and Solder Pads.
  • All Through-Hole construction and Clearly Labeled Silk-Screened Solder Mask for EASY SOLDERING!
  • High Quality Screw Terminal Input and Output connectors for easy assembly to or disassembly from your Tesla Coil.
  • Pre-Drilled Mounting holes on Printed Circuit Board.




The data file includes invaluable information, schematics, diagrams, and instructions related to building your very own Solid State Tesla Coil, even without the use of the USSTCC board.

The user is required to possess and exercise a working knowledge of proper soldering technique and understanding of basic electronics principles. The user will need to know how to identify components and their orientation markings. NO BOARDS COME ASSEMBLED.

No Tesla Resonators, heatsinks, mounting hardware, current transformers, basic tools, or wiring is included with any options. The User must provide all the necessary equipment and supplies for proper construction and installation.

Users must exercise caution and observe safe electrical guidelines and codes when wiring up the completed controller board and any inverter (half or full bridge). Buyer assumes all responsibility for the use, installation, and construction of the products featured here. Risk of injury and even death is always present when working with high voltages.

Return Policy:
Returns will only be given for unused, unsoldered, new, and undamaged boards and components.

These boards are still available for purchase at $15USD/board. Please send email to purchase. Payment by Paypal ONLY.

Click to Inquire about Purchasing a USSTCC Board

Video of USSTCC in operation:


Update - 2016-1-16
I wanted to copy the following text from my FAQ post and correspondence so there is zero ambiguity for anyone looking at this from the perspective of a new or potential user.
"Now let me understand some components, I have decided to use your logic board.
What exact piece of the puzzle does this include? What other components do I need to design and build myself. "

Okay, before listing off what it includes, let me state plainly what it and its associated files do NOT include, in other words things you need to source and build yourself:

1) Bridge Inverter. *
2) AC power cord for Bridge
3) AC power cord for USSTCC's step-down transformer
4) Secondary Resonator
5) Primary Coil
6) hookup wire
7) GDT; wire and core *
8) secondary topload (doesn't have to be fancy - salad bowl!)
*note I do have most of the suggested parts for these listed, things marked with asterisk have detailed instructions and parts lists.

What does the USSTCC Board include? It includes one bare USSTCC printed circuit board and all documentation required for proper construction of a working SSTC and lifetime Q&A help service.

Now, a better question; "What parts of the 'SSTC puzzle' does the completed USSTCC encompass?"

The USSTCC board takes care of the entire Low Voltage power supply supply, feedback processing circuitry, signal amplifier and splitter, add-on (interrupter & modulator) interfacing, and Gate Drive requirements of any SRSSTC operating in any mode. You add a bridge inverter, GDT, and completed resonator and have a fully working SSTC. All of the recommended parts for the bridge inverter and GDT are listed in the BOM files with their ordering numbers direct from reputable suppliers.

The only electrical components you need to pick and determine source of yourself are the AC power cords/plugs, GDT wire (22ga solid core, insulated (not enameled) to >300V, 2 or 3 colors), rosin core eutectic solder, and primary coil wire (10ga finely stranded copper, insulated to >300V - silicone if possible, cheap on eBay used for RC hobbies).

The physical components you'll need are coilforms, polyurethane, various mounting hardware (screws, nylon standoffs), etc.

Sigurthr's DRSSTC Calculator

This is a simple CLI (command line interface) calculator program to assist you in planning and designing your Doubly Resonant Solid State Tesla Coil. There is no installation process necessary; simply download the .rar, unpack it to a directory of your choosing, and run the .exe.  It is for Windows operating systems only.

Please note; only enter numerical characters when prompted for data. Entering letters or symbols will result in the calculator program crashing.

A README.txt file is provided in the .rar to explain the calculations behind the program and help the user get accustomed to its operation.

The program intakes simple parameters such as: DC Bus Voltage, Primary Inductance, Primary Capacitor Voltage Rating, Capacitor Derating Percentage, and Resonant Frequency. It then computes the Maximum Possible Peak Current and Voltage for the Primary Tank for the maximum usable Burst Length before the capacitor voltage is exceeded.

DRSSTC Calculator Download

Update: 24/2/2015 I'm pushing a new version of this up to the box.com download repository because it was brought to my attention that some users are still experiencing the missing .dll error. If you had any troubles previously, please try redownloading the file and give it a go again. My apologies for the inconvenience!

SigurthrEnterprises Website is CLOSING, all files and data being moved to THIS BLOG!

Hey everyone!

2014 has been a rough year, filled with serious medical and financial problems, and more than its fair share of stress. 2015 is here now and I'm beginning to pick up the pieces and restructure my life where needed. Part of the process is saying goodbye to my less-than-successful .com website. Though it got the majority of the traffic of my online presence, I just can't justify the expense as it generated very, very little income (less than one month's coffee for many folks).

Out of appreciation for those who did visit it and have enjoyed my data files and postings, I'm moving all of that data to this blog for permanent backup and access. Everything on the site will be available here. I still have USSTCC boards available, and still have many projects in the works.

Thank you all.

-Sig

Tuesday, December 2, 2014

Windows Batch File High Ping Datalogger

There comes a time in every internet user's life where they realize that their internet connection isn't all it is cracked up to be. For me, living out in rural mid-west USA, this is a constant struggle. I only have access to a singular phone and internet provider, and because I live more than three miles out from their one and only server center, I have to pay considerably more, and accept a far lower standard of internet service. It costs me roughly $90/mo for a 15mbit down / 1.5mbit up DSL line. bandwidth isn't usually the issue though, unless I need to upload a file, where if I exceed 125kbit bandwidth it swamps the line and terminates any downstream data streams. That can't be helped, it is a product of the hardware systems in place. The issue that plagues me most... is latency.

What do you do to check latency statistics? You run the ubiquitous Ping (ICMP Echo Request) diagnostic. Here, you select a target IP address, and your system will send a packet off to that address, tell you if it was delivered, and how much time it took to get there and back. You can go to just about any windows machine, open the command prompt, enter "ping" followed by a standard IP address, or even a domain name, and hit enter, to see the results of four packets being sent off. You can also run the Tracert or Trace Route ping utility, which sets the Time To Live (TTL - a limit of how many hops a single packet is allowed to make) to 1, which means you get a ping response from every single hop along the route consecutively.

Both tools are indispensable in network troubleshooting, but by the very nature of tracert it can only be used as a spot-check tool. You run it when you think there is a problem, or when you know there isn't one, and then compare the results. You can run a very light weight single ping anytime you want, and you can even make a batch file to run it continuously, once every set amount of time. This helps to keep connections that are prone to failure or timeout alive. It is simple to do, simply use the option "-n #" after the ip address, remember to remove the quotations, and replace the # with a number. Running continuous pings can be done with the "-t" option, but this can easily contribute to network congestion, both in your LAN and at the destination server. Some servers will even consider this a form of attack and block off communications with your IP address, not good, and thus not advised. You can get around this by adding a delay and automating the ping process in a batch file. A simple GOTO command and a TIMEOUT delay command are all that are needed.

Here's where the fun starts....

What if you want to record the results of the ping tests to catch intermittent latency issues. You probably want to run the ping commands relatively often, perhaps once every second or two. It's trivial to output the results from Ping.exe to a text file using the append operator ">>". Wait though, this is going to make a HUGE file that no IT professional is going to want to look over. Well, you could write up a text file parsing script to extract only the unusual ping results and place them in a new file. That would solve it. but now you're still eating system resources by continuously writing to a text file on your hard drive. Also, you now need to periodically run the parsing script to trim down the text file. Not very user friendly, and certainly not elegant.

The Programming Considerations.

You have a few choices.

1) You fire up your favorite language's IDE and start writing a from scratch program that will execute the functions that Ping uses and processes the resultant data and logs it accordingly. This will be tens of hours of coding, at the very least. If you take a look at Ping.c or Ping.cpp for example, they're rather huge works of programming.
2) You fire up your favorite language's IDE and write a from scratch program that will call on Ping.exe to do its thing and then grab the results. You'll have to deal with advanced systems like windows sockets, pipes, and all kinds of nasties.
3) You throw in the towel and find some end user program that probably isn't free that will datalog ping results, and hope it is good enough. Yeah, I'm not the kind to do that either.
4) You start learning a scripting language like Perl of Python to do what options 1 and 2 would but far easier. Yeah, still not going to do that.
5) Jump into the deep end of windows batch scripting and try to trudge through the muck of a poorly explained, foreign looking language with rather inaccessible documentation because you KNOW it can be done, and the results are likely to be the easiest to implement. Guess that's what we have to do.

The Windows Batch (.bat) File

Basically, batch files are a script of commands to be executed autonomously by the windows command line interface once the batch file is executed. Any command that can go into a CLI can go in a batch file, though you will usually need to modify the syntax and structure some.

Thankfully there is a website called SS64.com which is run by Simon Sheppard of the UK. This is a truly valuable resource when it comes to windows CLI and Batch files. If you have any experience with programming, especially in C/C++, this site will get you going writing useful and efficient batch files as long as you carefully read the information presented and apply some elbow grease.

The hardest part will be recognising the required syntax and wrapping your head around the fact that you don't have the structure to fall back on that most languages have. You don't declare/define variables at the top, and there are many hidden limitations when working with variables and data input/output. Getting things right in terms of structure and syntax was the most difficult part by far. Notepad makes a pretty piss poor programming IDE, haha. I know at least 90 minutes were swallowed up by forgetting to wrap a variable in % signs and having a line break after a DO command that it didn't like.

My Batch File

The heart of this 'program' is fourfold;
1) Call and save the date and time in an appropriate format to variables.
2) Ping the supplied IP address.
3) Find the relevant data in the Ping.exe output, save it to a variable,
4) Process the variables' text strings into usable chunks and then perform an IF THEN conditional check to discard all of the useless data points. Export the saved data to a log file.

Written within comments (lines preceeded by double colons) is the syntax and command structure basics, as well as links to their pages on SS64.com At the top of the file is my generic header that explains what the program is and what it does, as well as how to contact me. It goes on to explain what to change in what lines to repurpose this program for your own needs. I've gone ahead and generalized the output file names and filepaths, as well as the target IP address so that this program will just simply run on just about any modern windows machine. Feel free to use it as you like. To use, simply rename/SaveAs the file as a .bat instead of a .txt file in any text editor. If you have file extensions showing enabled you can just right click and rename as well. Note that with the default settings for the output file (C:\ directory) you might need to run the batch file as an administrator (right click, run as admin), depending on your operating system and account privileges. Simply change the directory to another place where you can easily write files to if this is an issue.

https://app.box.com/s/vmhhm3ojj2ergk604bf0

P.S. for what it is worth; my internet connection is far less stable than I thought it was. I am getting many spikes above 500ms roughly every hour, throughout all hours of the day and night. Less frequently there are spikes above 1 second. There are spikes between 200ms and 400ms roughly every couple of minutes. The "normal" ping time is 58ms for reference.

Thursday, July 17, 2014

Arduino Pulse Counter

Today I decided to create a computer interface for the geiger counter I repaired several years ago. It is a Black Cat Systems GM-45 that takes in 12V and outputs 12V pulses for each incident detection. It uses a russian mica window pancake tube, which is very sensitive. There were some issues with the HV inverter circuit when I bought it second hand, and they were easily fixed by simple component swaps. It was originally designed for RS232 communication, but this unit did not have a DB9 or DB25 connector on it, just flying leads. Likewise, it did not have the window exposed from the housing. I did the housing modifications when I first got it, but I'm debating remounting the board into a better enclosure and leaving the excessively fragile window enclosed and protected.

The hardware is simple, a 100nF dc blocking cap to block the ~2.4V DC bias on the output and a 10K:10K voltage divider to step down the ~9.6V to <5V suitable for TTL/USB communication. Corrected output is fed into the Arduino's pin3 and a ground/return wire is run between the arduino and GM detector for continuity.

The software was relatively straight forward for the counter. It simply increments a variable each time a pulse is detected and sends the total to the serial monitor at a set interval. Note that no delay command was used since it needs to count pulses while timing. I also programmed in an indicator LED to pin13 which had a built in led on the Uno. I had to code in hysteresis, which took me several hours, for this LED as the ~<10mS pulses are too short for our eyes to see well. This involved an entirely separate timer routine and some creative coding to toggle states efficiently.

Here's the links to download the .txt files with the arduino code.
General Purpose Pulse Counter

Note that the LED will appear continuous above about 30Hz. You can set the time period and make adjustments to better suit your needs, but remember that I'm only transmitting data from the arduino via the serial port, not to it, so you'll need to push new code for each change.

As well as this works I may look into picking up a cheap USB-RS232 converter and DC-DC converter to step up the 5V from USB to 12V so that I have a more compact all in one, always on radiation monitor. I don't want to tie up my only arduino, and as is this is taking my best breadboard and bench supply to power!

7/20/14 UPDATE: I noticed that when used for a geiger counter scaler that the readings were a bit high. When I was writing the program I was concerned that the entire loop might be executed so fast as to have multiple triggers for the same pulse. This was confirmed with single pulse testing. I revised the code to include a delay line that prevents multiple triggering. There is now a user changeable variable that sets a dead time before the arduino will count an additional pulse. This is set to 100uS by default but easily changed to suit your needs. For non square pulses keep in mind that the arduino's digitalRead triggers on about 2.0V, so just have it for as long as the waveform is above 2V. I've also revised the serial output code for better visuals when used as a geiger counter and added in the function of dose rate conversion. Simply put in the counts per microRem into the GMsensitivity variable and it will do the math for you. To not clutter things there are now two .txt files, one for generic counter, and one for geiger counter. Enjoy!

Wednesday, July 16, 2014

DIY Arduino Stepper Motor XY Laser Scanner

I've recently worked on a project that I had the parts for for quite some time, but never got started on. I salvaged this XY stepper head from a cheap chinese "laser show" which had no programmable inputs and a nonfunctional "auto sound" mode that would only repeat the same three patterns over and over again. The laser that was built into it had its pump diode die a thermal death a long time ago so I shelved it and planned on modifying it eventually.

I decided to look into stepper motors and their control schemes and found that it would be rather simple to code the subroutines for single coil per step movements on an arduino. Once I realized this, it was time to start work.

Now, steppers aren't particularly fast or accurate, especially at the upper limits of their speed, as they start to miss steps. I can get these cheap ones to about 2.75mS/step and no further without losing steps, but that's good enough for me.

Instead of driving the motors with an intermediary IC (or even an entire dedicated board) designed for stepper control I decided to just go discrete electronics with NPN bipolar transistors and small signal fast diodes for flyback recovery. I'm only driving one coil at a time since I don't have the pinout for the motor coils and it is a 5pin unipolar motor with common ground. It doesn't appear that it is two center tapped coils with common CT., but rather it looks to be four individual coils with tied ends. I know there are ICs that can use the two center tapped coils in a bipolar drive method to allow microstepping and such but I don't think that is possible with these steppers. The reason for the NPN BJTs is that the arduino can only sink or source 40mA maximum per I/O line and these steppers draw about 90mA @ 9V (and they're 12V steppers, but run down to 5V min).

I experimented with increasing the motor voltage in hopes of gaining speed, but no increase in accuracy or speed was measured between 5.7V and 12V. I found that I got the best results with a 2.75mS ontime and 250uS offtime.

Unfortunately the mechanical issues of rotor inertia, jitter, and flicker could not be eliminated. Only the simplest of designs could be reproduced without a large degree of error. Attempting to reproduce a number 8 results in two vertically stacked squares with a space in between them, tethered in the center. (see video #3).

For the amount of work it takes to get this poor result it isn't worth continuing further. It was a good exercise and a fun experiment if you ignore the 12hours or so of coding. I wrote nearly 2500 lines of code for this, and while most were just edited copy/paste, it was still a nightmare of a job. There are 64 subroutines written for motor advancement: 1 to 16 steps forward, 1 to 16 steps backward, each for two axes.

The code is straight forward; manually pulse each coil for a set time in grouped ordered bunches to produce movement. The Achilles heel is that this is completely open loop. There is no way to detect or remember what the last coil used was so when you go back to the same axis you have to manually insert code to bridge the gaps to ensure it doesn't inadvertently reverse steps or miss steps entirely.

For example:

void loop(){
  xplus4();
  xminus4();
}

Thus pulses coils as such: 1 2 3 4 4 3 2 1. Notice the double pulse of coil 4? This means the rotor will sometimes make 4 positive movements and then three negative ones, and other times it will make three positive and three negative, depending on where the rotor was when the first pulse to coil 1 hit.

If we wanted to fix this we would have to do as so:

void loop(){
  xplus4();
  digitalWrite(1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(1, LOW);
  delayMicroseconds(tOFF);
  xminus4();
}

This pulses as such: 1 2 3 4 1 4 3 2 1. Now we'll always get four positive and four negative steps, but occasionally we'll get five positive initially, again depending on rotor position.

Consequently, the subroutine for xplus5 looks just like 1 2 3 4 1, so I would have just used it instead, but I wanted to illustrate the process more precisely. This example has a pre-written subroutine that fits in as a correction, but most transitions do not.

The hardware circuitry is simple, as this schematic and picture show:



Here's a link to the arduino code: 
https://app.box.com/s/mtae49elczo39468myul