High Voltage Coils

electrical and mechanical engineering

Home - 2015 - December

Month: December 2015

Rescue a DNT DigiMicro C11 Digital Microscope from scrap

Posted on 18. December 2015 in low voltage experiments

There is a very simple way to get an old DNT DigMicro C11 camera working in Windows 8.1. The company DNT has moved on with a newer products like the “DigiMicro Scale 2.0” link to product page , but stopped support for older products. Unfortunately the newer software does not recognize the old hardware, so i found a way to make this product working on a modern system (W8.1).

In the device manager, the camera hardware id was detected as:

USB\VID_0C45&PID_6270&REV_0101
USB\VID_0C45&PID_6270

The valid driver for this camera is “SN9C201” from Sonix Inc.
download the driver file (USB20PCCam_5.7.26000.0.exe) from the link below USB20PCCam_5.7.26000.0.exe

cam_manager

the device will be detected in the device manager

To display the image i used the VLC Mediaplayer, available from http://www.videolan.org. Open the player and use the function “CTRL + C” open device. Set the mode to “Direct Show”, device to “USB2.0 PC Camera (SN9C201)” and the audio to “None”, this step is mandatory or it will not work correctly!

cam_vlcsettings

The device works perfectly
cam_vlcrunrecord

Atmel xmega signal / sinusgenerator using DAC

Posted on 14. December 2015 in low voltage experiments

Hi all,

after several thoughts about how to create a sound with an xmega32a4 microcontroller from ATMEL, i detected two easy approaches to stick to, PWM (puls width modulation) or DAC (Digital Analog Converter). After thinking about the most flexible approach, i choose the DAC.

My code consists of 3 parts.

  1. static sinus lookup table, precalculated 12bit values, stored in a 16 bit word array
  2. A timer, which is acting as the sample rate clock, for example 48kHz
  3. The DAC, which will receive new values if the timer overflows

The hardware wiring is very simple, PORTB2 (DAC Channel 0 output) directly connected to an audio amplifier.

DAC working at 48kHz sample frequency

#include <avr/io.h>
#include "driver/avr_compiler.h"
#include "driver/driver_clksys.h"

const uint16_t sin1kHz[48] = {2048,2315,2578,2831,3071,3294,3495,3672,3821,3939,4025,4077,4095,4077,4025,3939,3821,3672,3495,3294,3072,2831,2578,2315,2048,1781,1518,1265,1025,802,601,424,275,157,71,19,1,19,71,157,275,424,601,802,1024,1265,1518,1781};

uint8_t idxsin = 0;
#define MAX_IDX 48

ISR (TCC0_CCA_vect)
{	// Timer overflow, put next sample into DAC
	DACB.CH0DATA = sin1kHz[idxsin];
	idxsin++;
	if (idxsin >= MAX_IDX) { idxsin = 0; }
}

int main(void)
{

	Config32MHzClock(); // set systemclock to 32MHz

	TCC0.CNT = 0; //Reset timer 0
	TCC0.PER = 167; // 21us @ 32MHz = ~48kHz
	TCC0.CTRLA = TC_CLKSEL_DIV4_gc; // Prescaler
	TCC0.INTCTRLB = TC_CCAINTLVL_LO_gc; // TCC0_CCA_vect, Compare Match

	PMIC.CTRL = PMIC_LOLVLEN_bm;
	sei();

	DACB.CTRLB = 0x00; // single channel operation PB2 only
	DACB.CTRLC = 0x08; // Vref = Analog Supply Voltage
	DACB.CTRLA = 0x04; // CH0EN = Enable Channel 0
	DACB.CTRLA |= 0x01; // ENABLE = Start the DAC

	while(1)
	{

	}
}

xmega_out2

1kHz @ 48kHz measured at uC output

The result is not bad, but feeding this to into my amplifier without additional filtering, results in  disturbing crackling noises. To reduce the “stair” effects, i choose to increase the sample frequency from 48kHz to 100kHz.

DAC working at 100kHz sample frequency

To make this work, i just need to reconfigure the timer parameters and sinus lookup table.

const uint16_t sin1kHz[100] = {2048,2177,2305,2432,2557,2681,2802,2920,3034,3145,3251,3353,3449,3540,3625,3704,3776,3842,3900,3951,3995,4031,4059,4079,4091,4095,4091,4079,4059,4031,3995,3951,3900,3842,3776,3704,3625,3540,3449,3353,3251,3145,3034,2920,2802,2681,2557,2432,2305,2177,2048,1919,1791,1664,1539,1415,1294,1176,1062,951,845,743,647,556,471,392,320,254,196,145,101,65,37,17,5,1,5,17,37,65,101,145,196,254,320,392,471,556,647,743,845,951,1062,1176,1294,1415,1539,1664,1791,1919};

uint8_t idxsin = 0;
#define MAX_IDX 100

ISR (TCC0_CCA_vect) 
{	
	DACB.CH0DATA = sin1kHz[idxsin];	
	idxsin++;
	if (idxsin >= MAX_IDX) { idxsin = 0; }
}	

int main(void)
{
	
	Config32MHzClock();	

	TCC0.CNT = 0;
	TCC0.PER = 157;	 // 10us @ 32MHz = ~100kHz	
	TCC0.CTRLA = TC_CLKSEL_DIV2_gc; // Prescaler
	TCC0.INTCTRLB = TC_CCAINTLVL_LO_gc; // TCC0_CCA_vect, bei Compare Match
	
	PMIC.CTRL = PMIC_LOLVLEN_bm;
	sei();	
	
	DACB.CTRLB = 0x00; // single channel operation PB2 only
	DACB.CTRLC = 0x08; // Vref = Analog Supply Voltage
	DACB.CTRLA = 0x04; // CH0EN = Enable Channel 0
	DACB.CTRLA |= 0x01; // ENABLE = Start the DAC
	
	while(1)
	{
		
	}	
}

xmega_out2

1kHz @ 100kHz measured at uC output

The result is not perfect, but the sinus at the amplifier output is completely clean, without any additional sidebands or crackling noises.

ls_out

signal after amplification measured at the loudspeaker

Performance measurements showed, the CPU load is at ~17% (time between samples = 10us @100kHz, time in ISR = 1,7us), which means that in theory, the sample rate may be pushed to 400kHz. For a better performance, i would recommend using the xmega DMA. A good implementation can be found at the AVR Xplain , Atmel AVR1508: XMEGA-A1 Xplained training – XMEGA DAC document, chapter “Task 4”.