Arduino compatible frequency counte project log
I was studying a self made project of an electronic module including a frequency generator, a frequency counter, 3 channels DC measurement displayed on PC, an ADC interface, some symetrical power sources and an interface to an Arduino Due, all included in a second hand enclosure. Since I saw a very cheap frequency counter module with good performance on ebay, I opted for buying this module.
After a few tests the fequency meter module burns. I read, too late, in the user manual, that signal voltage should not be over 5 volts! I was just trying to measure the frequency of a signal with a DC offset of about 10 volts! I also find that reading measurement on the 5 LED digits is really not easy. So I have to design my own frequency counter. It will better fit my needs and allows for easy interfacing with other Arduino boards included in my project. I consider building a much more versatile and robust Arduino compatible frequency counter. I search for some design concepts over the Internet and find that there exist a couple of DIY Arduino projects and also program libraries. Some of them share a common root and lead to the “freqcounter” and “freqmeasure” libraries coded by Paul Stoffregen ( pjrc.com )
I first try to use these libraries by breadboarding a circuit, and yes it is working. It is quite straithforward to test the concept. So I am decided to use an Arduino module. It will also be quite easy to display measurements on an LCD screen using a standard Arduino library. But I see the problem that I will have to fine solder an atmega chip. Until now I have been printing circuit boards using a simple laser printer and home made etching with an HCL/H2O2 solution.
The result is not so bad but I don’t solder very well. I don’t want to tin plate this board using a costly and poluting solution of liquid tin so I hot tin-plate them by hand and the result is not professionnal. So I search for ways to have a professionnal printed board. That is when I discover that some companies provide prototyping services and finally that some people are building kickstarter projects to finance the industrialization of such boards. Since I was more and more thinking about doing the best Arduino compatible frequency counter I can, the idea of buidling up a professionnal project is making its way.
It takes me a couple of hours to build a kicktarter campaign page. I first plan to launch this project in January since Christmas season is already here. I start to plan a project and rapidly discover that there is much more to do to achieve a successful campaign and that I need to have a much better validated concept before I can engage myself to provide at least one hundred of such boards. Now, in April 2017, I realize that it was a good decision not to launch the project on short notice!
I start to plan my project on ganttproject.biz
Yes, it took me already 5 months to study this project and still needs some time. I have been working in computing before and I know very well that most projects are very late. Usually if you plan a one-year project you can bet it will not be achieved before 1 and ½ year! I think it is even worth here and I heared some people say that launching a product from scratch, any kind of product, takes one year !
To evaluate the kickstarter contribution I need to get some quotation for the sourcing and assembly of components. I discover that many companies in China can provide a lot of services. I look also for french companies that will allow me to have better interaction with them while prototyping. It takes me a couple of weeks to have a better understanding of the costs and conditions for prototyping and building a board. One company gives me a lot of attention: Smart prototyping. They take a lot of time to source the components. That is when I discover that a minor activity in my plan is in fact a job in itself. Sourcing component is much harder than I imagined and I see the reason why some companies specialize in this activity. The problem is to cross: design * component specifications * component count and cost * including shipping cost * availability. And then you have to test the circuit, change the design and start again sourcing… At this moment I think I will source components myself and not use Smart Prototyping services but I thank them a lot for the pre-sale work they have done.
I see that I need some marketing support material to be able to present my project. Since it is a bilingual project and Kickstarter does not support it at this moment I have to build my own presentation site. This is best because I will be able to use it in the future for other projects and I can have it all under control. I find that building up a WordPress site will be very efficient. After conceiving a little marketing plan, I decide to use the brand name “Pandauino?” and build-up the site Pandauino?
I also need some material for visual promotion of this project. I use the software Diptrace to conceive the electronic circuit and discover that it inludes a 3D modeling function. It is very convenient and allows me to create a 3D model that I publish on sketchfab.com. From there on I make a little presentation video.
Since the Atmega328 chip that I plan to use is clocked at 16Mhz, the maximum frequency that the board could theoretically measure is about 16/2.5 = 6.4 Mhz and I would like to measure higher frequency signals with good precision. So It needs to use a prescaler. After some tests I discover that the 74HC4040 prescaler that I had selected has a maximum frequency of around 30Mhz in realistic conditions. I know the famous 74HC4093 will not over perform it. So I need to test some others and I sample some products from Fairchild (74HC161 etc). I also sample some op amps from Analog Devices and some voltage regulators from Microchip. It appears that all prescalers have a quite narrow bandwidth and that it will not be possible to prescale all high frequency signals. Signals will have to be treated differently over low frequencies, high frequencies under 100Khz-1Mhz and very high frequencies.
This board should reach frequencies above 50 Mhz and maybe 100 Mhz, so I need to go much further in the design of the electronic circuit and I use LT spice to design a very wideband amplification stage. The objective is to amplify signals between 5Hz and more than 50 Mhz with amplitude as low as 500 mV, or over 10 volts.
February and March
I search for some marketing information, go further in my marketing plan and search for sale leads. I migrate the pandauino? webiste to a new web host and spend quite a lot of time adding plugins and securing the website.
I have to search for some software libraries and write a first version of the program. I don’t design a sophisticated program, and don’t opt for an object oriented architecture. You will see the program is simply procedural. It already uses more than half of the memory resources. I now concentrate on building a program that provides:
- frequency counting
- LCD display measurement
- power voltage management
- energy economy
- menu management to tweak a couple of parameters.
I use DIA software to have a global vision of the program. I search informations on how to program a blank microcontroller and correclty set the fuse bytes (without blocking the microcontroller! ).
I design a first PCB and ask for a couple of prototype PCB’s in Schenzen city, China. It takes no more than 10 days to receive beautifull PCBs! I am very satisfied with the quality of these PCBS. I immedialty check the boards. After assembly everything is okay but some little mistakes that I discover when I try to program the board.
I experiment a strange phenomenom when testing the board. When I shut down power I see like a little “ghost” or spirit, hardly visible emanating from the board. Then it appears that my amplification stage has a gain of “1”! It seems the spirit of the transistor I am using has reached another world !
Unfortunately from design stages to design stages it seems I have selected a transistor with insufficient current capability. Reading again the datasheet gives the answer. This BFT92 transistor only has 25 mA max current. It does suport normal functioning but when I turn off power it certainly canno’t handle some over current due to capacitor discharging!
Also I discover that the voltage regulator self oscillates around 400 Hz! That’s nearly an A! I look for other regulators and I can see that stability is always a major concern discussed in regulators datasheets. Some need a high ESR cap on the power output to be stable and others support very low ESR caps. Since I need a power source that can handle VHF load variations on the output I need to use very low ESR caps. So I sample and order a couple of LDO regulators for further testing.
I need to build a little variable power source, buy some VHF oscillators as precision signal sources and find a way to collect some statistics on the precision of the frequency measurement. I want to have a precise estimate of the capabilities of the board before launching a marketing and financing campaign.
Since the board is equiped with an UART port I simply gather results on the Arduino IDE’s series monitor. Results are pleasant.
I can measure a frequency precision better than 0,1% nearly over the full range. But it is not possible at the moment to go further than 40 Mhz. I can see that
- The TVS diode that protects the signal input has much too high capacitance and it shuts down the signal above 40 Mhz
- The circuit will not amplify well above 40 Mhz.
- The transistor is burning.
Points 2) and 3) force me to refine the design of the amplifier. So I go back to LT spice modeling. I will have to use a two-stage transistor amplifier instead of only one. Since it will give better gain, I won’t need to bypass the emitter resistor with high capacity caps and will avoid high current discharges. Also I will use transistors with much higher current capabilities.
I am now confident that this board will reach a precision better then 1% over a very wide band and large amplitude range and so I will proceede with the marketing and financing campaigns. Meanwhile I will have to reach a better quality level of the software, the powering of the board and the amplifier stage.
It took a lot of time to design the new amplifier stage. After spice simulation and breadboarding of a couple of possible amplifier circuits I ordered a new PCB from China. Meanwhile I tried some marketing tools for presenting the project. I have been particularly working on email marketing. Its also time consuming and the financing campaign may be postponed.
The PCB arrived a couple of days ago and today, may the 30th, I did a batch of precision tests. After about 6 hours of carefull testing and a couple of tweaking of the board and software I am very surprised how precise the results are. The large majority of measures are reaching a precision of around 100 ppm! Only at the margins of the domain of utilisation the precision “falls” to about 0.2%. So I think this is the best that can be achieved using this technology.
Now that prototype 2 has been successfully tested, I think I could start a financing campaign. The problem is that after having a look at Kickstarter campaigns (and others) I see that most are either 1) not funded at all, or poorly funded, which results in the same 2) or very well funded and supported by massive and good quality communication tools, like professional videos. I look for some more information and usually it is said that a campaign must be prepared months before and started when a potential of about 30% of the funding is foreseen. Since we are approaching summer holidays, and particularly in France, most people will have a couple of weeks out. So I decide that I will spend the summer promoting my project.
I start by searching information about email marketing and find a couple of companies who provide email marketing support. Of course the first idea of any web developer would be to send emails through an SMTP server. In fact this is not advised at all. Mass emailing is very touchy since all servers, identified by their IP, are evaluated and blacklisted if any spam content is detected. So these specialized companies spend their time checking the quality of emails, the quality of contact lists and the legality of the emailing campaigns among other things… They do this to have their servers white-listed and achieve a high delivery rate. There is a tool that allows to check for the delivery rate of emailing companies: https://www.senderscore.org/ and I must tell you that I was very surprise to see the results for some leading companies.
These emailing companies do provide a quantity of services and counsels that anyone should follow to better the quality of their communication. Many counsels are in fact obvious but rarely applied by non-professionals. As an example it’s very useful to add appropriate references to a contact page, website, or youtube account when publishing content on a social media. Since I realized this, I often see interesting content on the web, but without any possibility to directly get more information… Emailing companies also provide automated contact forms and automated technical emails (to follow up a sale for example). Finally this lead me to have an email marketing course provided by https://www.getresponse.fr/
Marketing is a professional activity in itself and it could be a full time job. So I select only a couple of appropriate tools and methods and apply them. When searching a way to get into contact with potentially interested persons I decided to concentrate on Facebook and Twitter and indeed I am very surprised by the result. Not only I get many contacts but many persons are very enthusiast and supportive. I get in touch with genuinely interested people from all around the world.
I also spend my time finalizing the board. I decide to debug the Arduino code. I first debug the menu based on the library Menu Backend. It is working well. I just need to add some variable to keep the current menu values. At first I am a little confused since menu items are objects and finally I get a very simple solution: I keep pointer variables pointing to the current menu objects that are selected. Then I debug the energy economy mode. When the frequency counter doesn’t read any value for 5 minutes the microcontroller is put into sleep. I supposed I could use the menu button, connected at pin 17 (for layout optimisation considerations) but I see that I cannot attach an interrupt on this pin using the function attachInterrupt(). It seems to be limited to Pin 2 (int 0) or min 3 (int 1). So I have to swap connections 2 and 17. Since I had to revise the “energy economy” coding, I decided to publish a little post on the subjet. This and other little optimisation concerns need a redesign of the PCB layout.
Since I have to redesign the layout I also consider adding an EMI shield above the noisiest part of the board, which is the amplifier. This circuit may amplify signals nearing 100 Mhz at relatively low impedance and so I fear it does emit too much EM noise. Since I don’t have the means to measure electromagnetic noise emitted from the board I consider the possibility to add a shield “just in case”. If not implemented in the first batch of boards it could be ready for a possible EMC certification afterwards. In this view I have to design a simple 3D model of the shield. I never draw 3D models and I am very lost when I start to search for a 3D modelling tools. It seems there are many and some are very advanced, like Blender that allows to publish 3D movies. I don’t have the time and the will to learn 3D modelling. The learning curve seems quite sharp and long and this is not my main concern. Finally I decide to take a chance with a very simple tool TinkerCAD and indeed after a very short tutorial I see that there is an appropriate method to design the simple “box” model of the EMI shield. There is only one problem, TinkeCAD does not produce .step models but .stl files.
Fortunately I could convert these files using FreeCAD. This 3D model allows me to search for a manufacturer. But it is relatively complicated to design an EMI shield. There are a couple of different materials for the shield depending on the objective: isolation from the inside to the outside or from the outside to the inside, against electric fields or magnetic fields, and it depends of course of the frequency of the signals. I could use a shield with a lid or not. On top of this is the problem of heat. This shield is supposed to cover an amplifier, a prescaler, a multiplexer… I don’t have a precise idea of the heat generated and the necessity of making holes in the shield and the impact on isolation from such holes… Finally I don’t see how I could make the good choices without testing a couple of possible shields. So my idea at the moment is to consider the footprint of a possible EMI shield when designing the new PCB layout but I don’t think I will implement it. I am now in contact with suppliers and will think again about it.