atxmega128a1 DAC is nonlinear and inaccurate when reference is above 2.4V or Vcc – 0.6V

March 12th, 2009

I started experimenting with the new ATMEL atxmega128a1 chip, when I noticed a strange noise in the signal generated by the DAC example (atmel application note AVR1301: Using the XMEGA DAC). I captured the signal with a Rigol VS5042 Digital Storage Oscilloscope:

XMEGA DAC problem

You can clearly see the noise at the bottom of the sawtooth signal.

The setup:

  • STK600 (Target Voltage 3.6V)
  • TQFP100 Package
  • ATMEGA128A1
  • AVR Studio 4.15
  • WINAVR 20080610
  • Rigol VS5042 Digital Storage Oscilloscope
  • AVR1301 example in C

I thought there was a mistake in the example program, and was about to review it, when I found the following note in the Errata section of the atmega128a1 preliminary datasheet:

“DAC is nonlinear and inaccurate when reference is above 2.4V or Vcc – 0.6V”

So I went back to AVR Studio and set the target voltage of the STK500 (and the target device) to 2.0V, and the problem does not appear:

DAC solved

I assume the VREF used by the example program is internal, so lowering the voltage of the target device is the setup that fixes the problem. I will change the example program to use external VREF and see if it is possible to power the target with 3.3V and lower VREF to 2.0V and see if the problem can be fixed as well. The ATMEL documentation says that there is no workaround to this problem, and they recommend using VREF below 2.4V or Vcc – 0.6V

The XMEGA is a very advanced and interesting device. The only disadvantage is that it is very difficult to get good documentation, user experiences, etc. So I will be preparing different settings and publishing the results.

Update: I checked the source code and VREF was set to AVCC, and AVCC = Target Voltage. That is why the only way to change VREF to 2.0V was to lower the complete target board (STK600) voltage to 2.0V. I modified the source code to use external VREF for DAC channel A, and the result is that I can set the target board voltage to 3.5V and VREF to 2.0V and now the example works ok, without noise in the SAWTOOTH signal.

DAC external AREF

DSO channel 1 (yellow) is the sawtooth signal output, with Vmax = 2.0V and channel 2 (blue) is VTarget, with Vmax = 3.5V.

Assembling the NKC Electronics JTAG ICE Clone Board (Rev. B)

March 12th, 2009

Assembling the NKC Electronics JTAG ICE CLONE Board (Rev. B)

by NKC Electronics

SCHEMATICS (right click –> view image)

jtag schematic

JTAG ICE Clone board is an implementation of the Aquaticus JTAG ICE clone. The Kit includes the PCB and all the parts requiered to build a fully functional clone of AVR JTAG ICE. It can even be upgraded using AVR-STUDIO when a new firmware is released by Atmel.

This guide covers the assembly process of the JTAG ICE clone Rev B kit (marked Rev B in the PCB)

First, unpack the kit and start with the PCB.

The JTAG ICE clone board has all the component values printed on the PCB, making the use of the schematic almost unnecessary.

jtag ice clone kit

We will install the passive components (resistors, capacitors, etc) first.

jtag ice passive

Start by soldering the resistors R1 to R7, C3 to C9 ceramic capacitors, C10 electrolytic capacitor and D2 diode

R1 10 K resistor
R2, R3, R4, R6 1 K resistor
R5, R7 4.7 K resistor
C3, C4, C5, C6, C7, C8, C9 0.1uF ceramic capacitor
D1 1N4148 diode
C10 10uF electrolytic capacitor

jtag ice clone kit

Next identify and separate the 2 22pF ceramic capacitors, 2 LEDs and the crystal

C1, C2 22pF ceramic capacitor
Q1 7.3728 crystal
PWR, JTAG 3mm LED

jtag ice clone kit

Now separate the 16-pin IC socket, 40-pin IC socket (wide), 10-pin male header, 5-pin male header, DB9 female PCB connector. Cut the 5-pin male header in one 3-pin header and one 2-pin header.

X1 DB9 female PCB connector
JTAG 2×5 male header
IC1 40-pin DIP socket
IC2 16-pin DIP socket
JP1 3-pin male header
JP2 2-pin male header

jtag ice clone kit

We are done with the soldering. You need to install the MCU and the RS232 (ICL3232, MAX3232, ST3232) driver in the sockets. The large chip is the ATMEGA16 Microcontroller. It is already programmed with the latest release of the JTAG ICE firmware, and the bootloader. Please, be very careful with the pins while inserting the ICs.

jtag ice clone kit

Insert the shunt shorting positions 2-3 of the 3-pin MODE header. The JTAG ICE clone board has two modes of operation:

  1. Programming / Upgrade mode
  2. Normal operation mode

Position 2-3 is the Normal operation mode (board is ready to connect to target board and start debugging)

jtag normal

Position 1-2 is the Programming mode. This mode is used to program or upgrade the JTAG ICE firmware. The firmware is distributed by Atmel with updates on the AVR Studio IDE. In the operation guide you will find the manual firmware upgrade process, explained in detail.

jtag program

This is how the JTAG ICE clone board looks ready to use with the 10-wire cable for the target board.
jtag ice clone kit

The target board must supply the power to the JTAG ICE clone board, using the standard JTAG connector. The board expects the power from the target board (2.7V to 5.0V) in the VTarget (VCC) pin. It is recommended to supply also the target voltage to the VTref pin (Use the provided JP2 and jumper to supply power to the board from the target device). The JTAG ICE board does not have voltage leveling circuit, so if you supply VTref, it must be the same as VTarget.

Testing the board:

  1. Start AVR Studio
  2. Verify mode jumper is in 2-3 Normal
  3. Connect JTAG port to target board. Supply VCC. At this point, you only need to supply VCC to the JTAG ICE clone board. No real circuit with target MCU is needed
  4. Both LEDs are on
  5. Select Connect to the Selected AVR Programmer avr studio connect
  6. You should see the following message: jtag avrstudio ocd error

This message means that AVR Studio detected the JTAG ICE clone board, but was not able to identify the target MCU (either it is not installed, or the installed MCU does not support JTAG).

The JTAG ICE clone board is now assembled and tested. Now you need a real target board to start debugging.

An important reminder: JTAG ICE requieres the JTAG fuse in the target MCU set: JTAG Interface Enabled [JTAGEN=0]. The setting looks like this in AVR Studio:

jtag avrstudio fuses

IMPORTANT NOTE to AVRStudio 4.13 sp2 users: There seems to be a bug in AVRStudio 4.13 sp2 that generates an error trying to read fuses using the JTAG interface. There is a fix posted in Atmel Norway website: http://www.atmel.no/beta_ware/as4/413sp2/stk500Dll.zip

Assembling the Freeduino Serial v2.0 Board (MAX232)

March 12th, 2009

Assembling the ArduinoTM Diecimila Compatible Freeduino Serial v2.0 Board

SCHEMATICS (click on images to enlarge)
freeduino serial schematic

The Arduino diecimila compatible Freeduino serial board is a special version of the Arduino serial board designed by NKC Electronics. The board is diecimila compatible (autoreset) and includes the 13 digital pin LED for easy diagnostics and basic LED sketch execution. The v2.0 board uses a MAX232 compatible chip for interfacing with RS232. The older v1.0 board used two transistors, but had some reliability issues with auto-reset and sketch uploading.
First, unpack the kit

freeduino serial KIT

and start with the PCB.

Let’s start with the power portion of the schematic using the following parts:

DC1 DC power jack
D1 1N4004 diode
C5 100nF ceramic capacitor
C6, C7 47uF (or 33uF or 22uF) electrolytic capacitor
IC2 7805 5V positive voltage regulator
Power LED 3mm LED
R2 330 ohm resistor

Freeduino serial KIT

Plug a wall plug voltage regulator (+7V to +12V). The LED lights up, indicating that the Power supply is working.
NOTE: This board is shields friendly as the 7805 voltage regulator is mounted horizontally.

Next continue with the soldering of the RS232 components:

Freeduino serial KIT

X1 DB9 female PCB adapter
IC3 16-pin IC socket
C4, C8, C9, C10, C11, C12 0.1uF (100nF) ceramic capacitors

Solder the rest of the components:

Freeduino serial KIT

R3 1.5Kohm resistor
R4, R6 1 Kohm resistor
R5 10 Kohm resistor
C2, C3 22pF ceramic capacitor
C1 0.1uF (100nF) ceramic capacitor
13 3mm LED (Arduino pin 13 status LED)
Q1 16 MHz crystal
RESET Reset switch
IC1 28-pin IC socket
ICSP 2×3 pin male header

Now solder the headers and sockets:

POWER & Analog In 6-pin female header
Digital 2 x 8-pin female header

Freeduino serial KIT

Pay special attention to the alignment of the female headers.

Freeduino serial KIT

And finally install the ATMEGA168/ATmega328P MCU and the MAX232 (or HIN232 / ICL232 / ICL3232) chips.

Freeduino serial KIT

Freeduino serial KIT

The board is ready to be used. Start the Arduino IDE and load the BLINK sketch from the examples directory. Verify that ATMEGA168 (or Duemilanove with ATmega328) is selected in Tools –> Microcontroller (MCU) and Arduino Diecimila in the Tools –> board option. Select the COM port number corresponding to the serial interface where the Freeduino serial board is connected to. Press the “Upload to I/O board” button in Arduino and the board should autoreset and complete the programming. If you selected correctly the BLINK sketch, the LED “13” must start blinking once every 2 second (0.5Hz).

The board has space for an optional 3.3V regulator (78L33 TO-92 footprint) with it’s associated decoupling 0.1uF capacitor (C13).

Freeduino serial KIT

http://www.nkcelectronics.com/arduino.html

Assembling the Freeduino (Arduino) Motor Shield

March 12th, 2009

Assembling the ArduinoTM Freeduino Motor Shield

SCHEMATICS (click on images to enlarge)
freeduino motor schematic

The Freeduino Arduino Motor Shield is the original Motor Shield V1.1 designed by David Cuartielles of the Arduino Team. This product is not certified nor endorsed by David or the Arduino Team.

The new version of the KIT features a white PCB.  The capacitor placements were slightly changed to avoid touching the USB connector.  The board has 2 parts, the motor driver and the encoder.  The KIT only includes the components to assemble the motor driver.  In the new PCB, the components for the motor driver are marked with a *.  You only need to solder the components market with * to have the fully functional motor shield.  The encoder components soldering is optional.

First, unpack the kit

freeduino motor KIT

freeduino motor KIT

and start with the PCB. The PCB has some extra space for an encoder. It is optional to assemble the encoder section. The kit only includes the components to assemble the motor control section of the PCB.
Let’s start with the IC sockets using the following parts:

IC Socket 1 14-pin IC socket
IC Socket 2 16-pin IC socket

Freeduino motor KIT

Freeduino motor KIT

Then, we can solder the resistors and the LED.

PWR 3mm LED
R7 1K resistor
R3, R4, R5, R6 100K or 68K resistors

The LED has two legs, one longer than the other. The longer leg is called ANODE (+) and the shorter is CATHODE (-). The LED goes in the PWR LED space. Insert the long leg into the left hole.

Then solder the 1K R7 resistor, and the four 100K (or 68K) R3 to R6 resistors.


Freeduino motor KIT

Freeduino motor KIT

We continue with the capacitors:

C4, C9 100uF electrolytic capacitor
C10, C11, C12, C13 100nF ceramic capacitor

Freeduino motorKIT

Freeduino motorKIT

This is the board with all the components installed, before we solder the sockets.

NOTE: The C9 capacitor was installed backwards in the picture. Follow the marking on the PCB, which is positive down, negative up.

Freeduino motor KIT

NOTE 2: In the new version of the PCB (white), the picture shows the capacitor C9 correctly soldered.

Freeduino motor KIT

Solder the rest of the components: male sockets to plug the shield to the Freeduino / Arduino board, and the 4-pin female socket to plug the motors.  The 4-pin female socket was replaced by male pin header.

Freeduino motor KIT

Freeduino motor KIT

The motor shield, completely assembled and ready to use.

Freeduino motor KIT

Freeduino motor KIT

You can connect two DC motors. One goes on the first 2 socket holes (MOTOR B), from the top.  The new version (white) includes male headers for the motors.
Freeduino motor KIT

The second motor (MOTOR A)goes on the 2 bottom socket holes.

Freeduino motor KIT

A simple Arduino code to test the shield:

// Motor Shield test
// by NKC Electronics
// Test Motor B

int dirbpin = 12; // Direction pin for motor B is Digital 12
int speedbpin = 9; // Speed pin for motor B is Digital 9 (PWM)
int speed = 200;
int dir = 0;

void setup()
{
pinMode(dirbpin, OUTPUT);
}

void loop()
{
digitalWrite(dirbpin, dir); // set direction
analogWrite(speedbpin, speed); // set speed (PWM)
dir = ((dir == 0) ? 1 : 0); // change direction
delay(10000); // 10 seconds
}

Motors can be any DC motor that can work up to the Vin voltage. Vin is the power supply voltage – 0.6V. If you are using a 12V transformer, then Vin is 11.4V. You can use a 12V motor. If you are using a 9V transformer, then Vin is 8.4V and you can use a DC motor rated at 9V.

The motor driver can support 3.6V to 36V motors (1A). But the shield is designed to take Vin from the Arduino / Freeduino power supply, before the 5V voltage regulator. You cannot supply Arduino / Freeduino with 36V without burning the voltage regulator.

If you need to use a motor rated < 7V or > 14V, you will need to modify the shield. Do not install the Vin pin header to the Arduino / Freeduino board (or install the Vin and GND pins upwards, to plug a connector from where you can supply this shield with a different voltage range than the Arduino / Freeduino board)… and install a socket and supply Vin in the Shield from a different regulated DC power source, using the same GND connection.http://www.nkcelectronics.com/arduino.html

Assembling the Freeduino Serial v1.0 Board

March 12th, 2009

Assembling the ArduinoTM Diecimila Compatible Freeduino Serial v1.0 Board

SCHEMATICS (click on images to enlarge)
freeduino serial schematic

The Arduino diecimila compatible Freeduino serial board is a special version of the Arduino serial board designed by NKC Electronics. The board is diecimila compatible (autoreset) and includes the 13 digital pin LED for easy diagnostics and basic LED sketch execution.
First, unpack the kit

freeduino serial KIT

and start with the PCB.

Let’s start with the power portion of the schematic using the following parts:

DC1 DC power jack
D1 1N4004 diode
C5 100nF ceramic capacitor
C6, C7 47uF electrolytic capacitor
IC2 7805 5V positive voltage regulator
Power LED 3mm LED
R2 330 ohm resistor

Freeduino serial KIT

Plug a wall plug voltage regulator (+7V to +12V). The LED lights up, indicating that the Power supply is working.
Freeduino serial KIT

NOTE: This board is not shield friendly, as the 7805 is too tall and there is no room to install it horizontally.

If you need to use shields with this board, mount the 7805 on the bottom side of the board following the next pictures:

Freeduino serial KIT

Freeduino serial KIT

The result is shown with the XBee shield, Motor controller shield and NKC Electronics protoshield.

Freeduino serial KIT

Freeduino serial KIT

Freeduino serial KIT

Next continue with the soldering of the RS232 components:

Freeduino serial KIT

X1 DB9 female PCB adapter
T1 BC547
T2 BC557
D2, D3 1N4148
C8 10uF electrolytic capacitor
R1 4.7K resistor
R3 1.5K resistor
R4 1K resistor

Solder the rest of the capacitors and resistors:

R5-R9 10 Kohm resistor
C2, C3 22pF ceramic capacitor
C1, C4 100nF ceramic capacitor

Freeduino serial KIT

Now solder the crystal, switch and the 13-pin LED:

Freeduino serial KIT

S1 reset switch
13 3mm LED
Q1 16MHz crystal

Freeduino serial KIT

Now solder the headers and sockets:

ICSP 2×3 pin male header
POWER 4-pin female header
Analog In 6-pin female header
Digital 2 x 8-pin female header
IC1 28-pin DIP socket

Freeduino serial KIT

Pay special attention to the alignment of the female headers.

Freeduino serial KIT

And finally install the ATMEGA168 MCU.

Freeduino serial KIT

The board is ready to be used. Start Arduino0009 or Arduino0010 and load the BLINK sketch from the examples directory. Verify that ATMEGA168 is selected in Tools –> Microcontroller (MCU) and Arduino Diecimila in the Tools –> board option. Select the COM port number corresponding to the serial interface where the Freeduino serial board is connected to. Press the “Upload to I/O board” button in Arduino and the board should autoreset and complete the programming. If you selected correctly the BLINK sketch, the LED “13” must start blinking once every 2 second (0.5Hz).

http://www.nkcelectronics.com/arduino.html