Tuesday, 31 October 2017

Power control 2-01 - Testing

Power control 2-01 - Testing

Sensors arrived

Finally! The sensors are here. I ordered ACS712T from Aliexpress almost a month ago and yesterday received 10 of them. I quickly soldered the sensors to the adapter board with separately soldered wires for stronger current (up to 5A).

Test Setup

According to ACS712T datasheet the device provides continuous output of instantaneous measurements of current. Also I found out since the resolution is roughly 30mA for a 10bit ADC I will not be able to measure small current. I am still waiting for a single supply opamps, this will help me to expand the current range.

Due to the instantaneous nature of current measurement it would be hard to sample high frequency AC. Since I don't need high precision I decide to use some analogue circuitry to maintain the voltage level. In the datasheet I found the following rectifier circuit.

Since I wanted the full range I omitted the resistors, leaving only the diode and capacitor.

First impressions

After running a small DC motor with the current sensor and rectifier circuit I was able to measure the current. Of course the data was not accurate - I will need to get a formula to adjust for capacitor and diode influence. But the general increase/decrease in current were consistent with the motor's behavior.

Next step will be running an AC load (up to 1A to start with) and plotting the data in real time. Also I will have a power calculation, but first I need to test it with a proper power meter.

Tuesday, 24 October 2017

Data Aquisition Real Time Visualisation

Data Acquisition Real Time Visualization

This is a new sub-project for the future version of Touchscreen Control (2.0). I wont reveal much details about this right now, suffice to say once I have all the components I will start on bringing everything together for testing phase

Setup

After playing with real time audio conversion/visualization in my Digital DI Box project I shifted the focus to slower sampling rate in order to be able to keep up with changing data. USB FTDI drivers are not suitable for 2Mbs continuous data flow and I am not ready yet to write my own USB driver. Instead I decided to use a simpler MC (PIC16F1827) with a reasonable amount of ADC channels to see if web interface is ready for moderate amount of data. I set sampling rate at 100ms, starting with one ADC channel and slowly moving to 5 channels (there will be more, I just ran out of sensors). Right now I get the following info:

  • Potentiometer
  • Potentiometer (inverse)
  • Magnetic sensor
  • Photo cell
  • Temeprature sensor

There was a vibration sensor, but it requires amplification and my opamps need dual power supply. The breadboard is already full and there is not much room for virtual ground and the whole bunch of additional wires.

Results

The web interface was able to produce some nice looking real life graphs. Unfortunately I killed the photo cell - it's sensitivity has dropped a lot after some miswiring. Otherwise the system is doing great. Next step will be to test the timing by gradually reducing the sampling period in order to capture finer detail (as you can see on the screenshot below the mangetometer - black line - is not very smooth when displaying slowly rotating magnetic flux).

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

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 ...