Wednesday, 18 October 2017

Digital DI Box 05 - Proof of concept

Digital DI Box 05 - Proof of concept

I finally made it to the actual proof of concept stage where I can actually see if the Digital DI box is possible at all

Test setup

Since I don't have (yet) another TQFP-44 socket to properly test the balancing/unbalancing of audio signal, I had to drive the inverted audio through the same MCU.


Audio IN (orig) ----> ADC0 -> Invert -> DAC0 -> Audio OUT (inverted)
                        |
                        +---------+
                                  |
                     Shift to adjust for time delay
                                  |
                                  v

Audio IN (inverted) -> ADC1 ---> Subtract -> DAC1 -> Audio OUT (final)

Time delay shift is tricky to measure precisely, there is no guarantee the inverted signal is exactly one measuring cycle away from the original.

Results

The resulting signal was difficult to obtain without some tweaking of the ADC data.

First of all there is a DC bias imposed by the ADC itself. It varies over time, depending on many factors such as original audio volume, temperature, etc. The DC bias makes it hard to subtract inverted signal from the original without overflowing , it had to be adjusted manually. NB: use low pass filter to capture the DC component on separate ADC channel to remove it.

Secondly the time delay between the inverted and original signals caused distortions in the output. Accurate measure of the delay would help, although I am not sure how to perform it reliably. May need to run a few tests with predefined waveform on DAC to understand the timing of conversion.

Overall if the above two problems get solved I can postulate that the Digital DI Box is possible to implement with minimal external components. I will wait for the socket, with two MCs I should be able to test balancing/unbalancing without (significant) time delay.

Monday, 16 October 2017

Digital DI Box 04 - direct ADC to DAC transfer

Digital DI Box 04 - direct ADC to DAC transfer

Direct transfer

After a lot of experimenting with DMA and Timers I decided to strive for the best possible data transfer from ADC to DAC. For this I put ADC into high priority interrupt mode and the rest to medium to low priority. To monitor the data I had to sacrifice continuous flow due to computer's USB serial port unable to cope with such loads. As a result the output quality is very good, I put some low pass RC filter in place to get rid of high frequency noise caused by ADC. Later I will fine tune it and install low pass filter as well.

Communication via interrupts

Serial comms now done through interrupts instead of polling. Sampling is done by getting the respective command on serial line, all data goes into uint16_t[512] array. Once the data is ready I get it in parts of 16 samples using a simple protocol. This causes some chirping sounds during playback, but this is only for data analysis, so should be fine

Sunday, 8 October 2017

Digital DI Box 03 - continuous data flow

Digital DI Box 03 - continuous data flow

Downsampling for better dataflow

Previously I concluded I will have to sample t 10KHz in order to keep up with the data flow. Right now I set the sampling rate at 7us - approximately 15KHz. The sound is not perfect (coming out of 10bit DAC) - mainly due to DAC noise and occasional ADC errors. And of course low sample rate makes higher frequencies sound poorly. Here is the graph of a youtube video passed through ATXmega controller and received in digital form at the same computer.

The red line is the actual signal, the blue line is the same signal averaged over 5 past values. The graph is autoscaled after reading roughly 250 samples from serial port every 100ms

Time problem

As usual the datasheet was near useless with timer setup. I had to guess the timer register TCC0 and I recon there will be more guessing on what is required to get the timer going. If I had a debugger I would probably able to figure it out. Oh well, I may need to google again.

Digital DI Box 02 - ADC

Digital DI Box 02 - ADC

ATXmega ADC

ATXmega32A4U has a 12bit ADC with the ability to perform up to 1M conversions per second. Since audio signal is signed, I will only get 11 bits, but with such fast rate I can oversample (I hope). Below is the initial buffered sample (approximately 1000 readings). Drawn in canvas, captured via serial port at 2Mbs Baud.

Due to the amount of data being transferred I could not send the bulk of data and at the same time perform the conversion. My calculations show that in order to send reasonable amount of data to put into more or less pleasant visible form will require at least 10us of CPU time. That means I will have to scan the ADC channel once in 10us. ATXmega datasheet is quiet about the ADC maximum clock (I assumed 2us, but at what CPU clock?). Anyway 2us supposed to give me almost 50KHz sampling rate. 10us for sending data over serial line will reduce the sampling rate down to 10KHz, unless I can oversample. This will have to wait, I need to get the continuous flow of data first - both for analysis purpose and to create a cool waveform on the computer screen :).

Thursday, 5 October 2017

Digital DI Box 01 - Intro

Digital DI Box 01 - Intro

What is DI Box

In Audio processing DI Box converts an unbalanced signal into balanced, to improve audio transfer on a longer distances. Normally this is done with a high quality transformer which inverts the incoming audio and sends it along side with t non-inverted original. This kind of devices are quite expensive.

Why Digital?

Since IC's these days are much cheaper than many analogue parts, I will attempt to create a Digital DI box. I will convert the unbalanced audio signal into bits, invert digitally and convert back to analogue. (Sending pure digital data will require complex protocols and proprietary hardware which defeats the purpose of the experiment). At the ogher end I will digitize both streams and combine back into unbalanced audio.

Plan

So far I will need the following:
  1. Practice with ADC on a relatively fast MC - e.g. ATXmega32A4U
  2. Establish high speed communication with the MC to ensure the data gets converted sufficiently
  3. Invert and convert to analogue digital audio
  4. Receive two audio streams simultaneously converting to digital
  5. Combine two signals into one and convert to analogue

Wednesday, 27 September 2017

The curse of education industry

The curse of education industry

This is not the first time I get hit by the (quite common) stereotypes about the Education industry. And I can't say I was not warned - quite the opposite, just before I got the job at the Uni I was told that it does not count towards commercial experience. But at that time I was quite sick of the corporate environment - a lot of rudeness, shallow jokes, tasteless parties, etc. I was hoping to find a better medium at the academic circles (and better pay, of course). At first it actually was so.

Now, having spent over 15 years at the Uni, I am sick of bureaucracy and fake smiles, budget cuts and wasteful spending. It's time to get the new job and I have prepared the CVs and cover letters, and am ready to dive in to the sea of unknown.

I tried this (not very thoroughly) earlier last year. I did not succeed despite receiving invitations for an interview on both occasions I applied. This year I was hoping for the similar result. Surprise: nothing, not even a click on my blog I started for this occasion. Looks like the myths about educational industry still prevail the minds of my potential employees.

Myth 1 - deadlines are not met and standards are low at Uni

Funny enough, there are thousands of students come through the University each year, and every time in the beginning of semester it's a mad house: last minute orders to install software on dozens of computers. Last minute rearrangement of lab layout. Unprovoked network port block by the central ITS. And so on. Guess who should fix all of the above before the first lab? So I do. And I succeed. It's true that many times the decisions are made quite late and there is physically not enough time to implement most of them. But it is also true that the students come next day to the fully functional computers and equipment. So the myth is not quite right about the people who actually do the work.

Myth 2 - Uni people are not skilled enough and their products are of low quality

Imagine an Uni tech, working on huge variety of subjects, from AV integration to CNC programming. The tasks change daily, there are always a new skill to learn - not to the perfection, but enough to make things running. In complex systems - and University is one of those - it is much more important to maintain the stable operational flow than to fine tune individual processes. At some stage after dealing enough with certain issue the skill level gets relatively high and the quality improves accordingly. So it is quite untrue that University means low quality experience. Rather it means broad skill set and ability to learn on the fly.

Myth 3 - Uni people tend to do everything perfect and thus it takes forever to do anything

The opposite to the previous point (and sometimes mindlessly quoted one after another) also does not bear the truth. While every one should thrive for perfection, in real world common sense rules that "good plan today is better then the perfect one tomorrow". Considering how many times I had to streamline some jobs due to late notice/urgent requests, the question of slowness is rather theoretical and based on stereotypes.

Thursday, 21 September 2017

Climbing up the corporate ladder

Climbing up the corporate ladder - does it worth the effort?

Abstract

I am going to highlight some features related to the career growth and promotion. Some things are obvious and need no explanation. Other are quite subtle and not many people either notice or speak openly about those. This post is short and is only intended to warn others of the possible pitfalls while they are at the beginning of their career.

Small to medium organization

Basically there are two types of small organizations: where it is possible to grow and where it is not. Some very small firms are so fixated on their survival so there is not much room left to expand and progress. But once the company starts to make some profit due to the nature of capitalism it will want to grow.

Starting at the very bottom it is possible to climb up a few rungs. Usually this is achieved by adhering to higher then normal workload and active involvement in company's projects. If your contribution has benefited the company and your efforts were noticed by the right people you have a very good chance for promotion. Your growth at this stage is related to the business growth.

Each stage will require different skills. As you improve your current talents and acquire new skills you have most of the opportunity to get a little bit higher. Eventually if you reached the desired position in the company but you want to move higher, you will start gazing at the larger pool of opportunities.

Large or government organization

In the large organization it is still possible to get a promotion, but it gets much harder towards equivalent of middle management. At some stage the organization is no longer operating in a predictable manner. What seemed logical at a very low level or at a small business described above does not work well (or not at all) at the big firm.

Hard work and personal initiative now are not the most important characteristics the management will look for in the potential candidate for promotion. Here comes something out of middle ages: loyalty and obedience. If you do everything your manager tells you, even if it seems stupid and absurd, you will get their appreciation. If you try to do something on your own, this is a signal that you are either too smart (and therefore too stupid), or too dangerous. In the best case scenario you will get ignored (even without formal thank you). In the worst case you will get ignored profusely to the point of pushing you out of the job.

To understand the psychology behind such behavior you need to understand how the higher ups got to their positions. When there are several candidates for the same role and there are no distinct professional criteria specified for that role, the one with better connections will win. Simple as that. At the top it does not matter anymore what you can do and what do you know. But who do you know and who knows you becomes very important.

But this is not a complete picture yet. The people at the top are also competing with each other. And if your boss is not successful at getting his own promotion, most likely you will not get yours. At that level the stakes are so high the people start to employ more and more ruthless methods of removing their rivals from the race. You can guess what kind of people most likely to get to the top.

Is it worth to struggle to get to the top? I guess everyone will decide on what kind of top is most suitable for them. My top (and full stop) starts where my dignity and self respect get ignored. This is the moment I start looking for another job.

Is low level programming still relevant these days?

The levels of abstraction have made the application programming much easier and faster. But everything comes at a price. This is a new ...