Documente Academic
Documente Profesional
Documente Cultură
www.elektormagazine.com
DDS
Function Generator
Sines, squares and triangles
MEASSY
For audiophile up to 10 MHz
speaker builders
Analog Robot n:
i s E ditio s
Tibo, from concept to In Th s Project ts
construction 7 Lab r s Projec CBs
de P
3 Rea odules &
M s
6 New 4 Course s Add a Bill of Materials An
e v ie w
2 R ore ! Analog Robot Android I/O Board
n d l ots m
a (2) ARM CSIS Developer Competition
ARMed T-Board ARM Micros and the SPI Bus
BL-600 e-BoB (5) Bullheaded Buck Converter Coax Connectors Compact
60-watt Amplifier Compact USB to Serial Converter DDS Function Generator
Digital Zoetrope Dot Labs is Dee-I-Wye e-ethics Enhanced FM Stereo
ARM'ed T-Board
on Red Pitaya Hexadoku LED Driver with High PF and Ultra Wide Output
Here's Cortex M0+
32-bit power Range MEASSY Not enough pins again? PIC replacement for a 555 timer
Rise of the Drones Rohde & Schwarz HMC8043 PSU The Tefifon Grooved-
Tape Recorder Two Arms for the ARM Windows on the Raspberry Pi
this edition
Volume 41 Edition 6/2015
No. 467 & 468 November & December 2015
10 From 8 to 32 Bits:
ARM Microcontrollers for Beginners (6)
The SPI Bus
26 An Analog Robot
56 ARMed T-Board
30 Windows on the Raspberry Pi (1)
Installation and first programs
64 Compact 60-watt Amplifier
112 Review
Rohde & Schwarz HMC8043 PSU
how does it stack up?
82
122 Retronics
The Tefifon Grooved-Tape Recorder
DDS
Function Generator
68 next edition
Active Crossover
This active 3-way crossover filter is designed with versati-
lity in mind. One possible application is an active speaker
system.
64
To an Elektor reader, replacing the fridge thermostat is a
piece of cake. Finding the right thermostat though is a lot
more difficult. Using an Android I/O board we make a frid-
ge thermostat adjusting device that allows a cheap, gene-
ral-purpose thermostat to be used.
Not enough pins again? to the third state. Note: to avoid excessive
By Dr. Martin Oppermann current consumption, an open pin should be
quickly switched back to an output and set to
Jumpers are often used to configure microcontroller
a defined level.
circuits. Thats easy if there are only two possible states
to be configured the desired state can be determined by All this is made possible by the parasitic capacitances present in
fitting or not fitting a jumper on a port pin. However, if you every circuit, the high input impedance of microcontroller inputs,
have to distinguish between three possible states, you normally and the small number of commands necessary for the polling pro-
need an extra pin. Many years ago a Microchip application engineer cedure. The code finishes execution before the parasitic capaci-
gave me a tip that in any case works with PIC microcontrollers: tances can be discharged.
the three settings are defined by the High, Low and Open states You can even use this method with an analog input. I took advan-
of a single pin (see the figure). tage of this in a temperature control circuit (see figure). If a poten-
tiometer is connected to the analog port, the target temperature is
+5V set by the potentiometer, but if pin GP1 is open (P1 is not fitted),
then the target temperature is set to a fixed value.
R1
10k
+5V
IC1 1 3
VDD JP
2 7 2
GP5/CLKIN GP0
3 6
GP4/CLKOUT GP1
4 5
GP3 GP2 1
R2
VSS IC1 1
VDD
10k
8
PIC12F609SN 2 7
GP5/T1CKI GP0/CIN+/AN0 R1
3 6
GP4/T1G/AN3 GP1/CIN/AN1 4k7
4 5 P1
GP3/MCLR GP2/COUT/AN2
VSS 5k
Use the following procedure to poll the port pin: 8 PIC12HV615SN
Configure the pin as an output.
Write a 1 to the pin.
Configure the pin as an input.
Read the pin and save the value.
Pin GP1 is polled the same way as in the previous example. If a
Configure the pin as an output. potentiometer is connected, a DC voltage between 0 and 5V will
Write a 0 to the pin. be present on pin GP1 (depending on the potentiometer setting),
which is declared as a digital I/O for the polling procedure. The
Configure the pin as an input.
Schmitt trigger characteristic of the digital inputs ensures that the
Read the pin and add the value to the previously saved value.
read value is always either High or Low. The result of adding the
two values read from the pin will only be 1 if the input is open
If the result of the addition is 0 (0+0), the pin is Low. If the result (150479)
of the addition is 2 (1+1), the pin is High. If the result of the
addition is 1 (1+0), the pin is open (floating), which corresponds
Got a neat solution for a tricky problem? Using components or tools in ways they were never intended to be used? Think
your idea to solve a problem is better than the usual method? Have you discovered a work-around that you want to share with
us and fellow makers? Dont hang around; write to us now, for every tip we publish youll earn 40 pounds!
As we have seen previously in this series, the SERCOM module in the SAMD20 can be configured as
a U(S)ART or as an I2C interface. To complete our tour of the module, one interface remains to be
described: SPI. In this installment we look at a large-scale project that uses the SPI bus as well as other
already-familiar peripheral modules.
In the previous installment of this series we explored using the to receive or transmit the individual data bits, and there are
ADC with an LM335 temperature sensor. We now want to use accompanying data registers: TxDATA, to which the CPU can
that sensor in a larger-scale project which also uses the SPI bus: write bytes to be transmitted, and RxDATA, from which the
a temperature logger. We will use an EEPROM from the 25LC or CPU can read data bytes that have been received. The RxDATA
25AA families with an SPI connection: these devices are avail- register is also equipped with an additional buffer register to
able in a wide range of storage capacities and are easy to drive. help ensure smooth data transfer.
EEPROMs are often handy devices to have around in any case, as The SPI master also has responsibility for generating the bus
very large projects can benefit from a large amount of external clock: in the case of the SAMD20 this job is done by the baud
storage. We also need an accurate time reference, preferably rate generator. The clock frequency is set using the BAUD reg-
one that records hours and minutes. And as luck would have ister. When configured as an SPI slave the module compares
it, we have already seen how to use the RTC in calendar mode. the received address (if present) with the values in ADDR and
ADDRMASK to determine whether the microcontroller is the
SERCOM module as SPI peripheral intended recipient of a data packet.
Configuring the SECOM module of the SAMD20 in SPI mode There are of course many details to the configuration, such as
gives us an overall structure that is rather similar to that when whether data are sent LSB first or MSB first. As a slave the SERCOM
it is used in I2C mode. The block diagram in Figure1 shows module can also operate in sleep mode (even slaves are allowed
the SERCOM module on the left configured as an SPI master to sleep!). As usual with the SERCOM module, there is a choice of
and on the right as an SPI slave, with the four SPI signals pins that can be used and there is also a choice of clock sources.
shown in the middle. Both configurations use a shift register More details can be found in the datasheet on page369[1].
Figure1. Outline block diagram of the SERCOM module configured as an SPI peripheral in slave and master modes (block diagrams and screenshots courtesy Atmel).
and the various peripheral modules and other components that EXT1
will be used in it. Since the microcontrollers data sheet gives
1k
1 15 PB00
1%
a list of all the peripheral modules and the pins to which they
EXTENSION 1 HEADER
can be connected, it is easy to work out where the external
components should be attached. There are of course many
ways this can be done, as in many cases the device includes GND LM335
10k
10k
their standard configuration. 15 PA05
1 CS VCC 8
16 PA06
Now it is an easy matter to draw the circuit. For this project 17 PA04
2 SO HOLD 7
we will connect the LM335 using the same circuit as in the pre- 18 PA07
24LC040
PA07
vious installment in this series, and we will attach a 25LC040 3 WP SCK 6
19 20 VCC
EEPROM using a minimal circuit: see Figure2. The circuit can 19 GND 4 VSS SI 5 PA06
slave_dev_config.ss_pin = PIN_PA05;
is used to tell the microcontroller to use pin PA05 for the SPI
slave select (SS) signal. The settings in slave_dev_config are Figure3. The authors prototype built on a breadboard.
void configure_spi_master(void)
{
struct spi_config config_spi_master;
struct spi_slave_inst_config slave_dev_config;
spi_slave_inst_get_config_defaults(&slave_dev_config);
slave_dev_config.ss_pin = PIN_PA05;
spi_attach_slave(&slave, &slave_dev_config);
spi_get_config_defaults(&config_spi_master);
config_spi_master.mux_setting = EXT1_SPI_SERCOM_MUX_SETTING;
config_spi_master.pinmux_pad0 = EXT1_SPI_SERCOM_PINMUX_PAD0;
config_spi_master.pinmux_pad1 = PINMUX_UNUSED;
config_spi_master.pinmux_pad2 = EXT1_SPI_SERCOM_PINMUX_PAD2;
config_spi_master.pinmux_pad3 = EXT1_SPI_SERCOM_PINMUX_PAD3;
config_spi_master.transfer_mode = SPI_TRANSFER_MODE_0;
config_spi_master.data_order = SPI_DATA_ORDER_MSB;
config_spi_master.mode_specific.master.baudrate = 250000;
spi_init(&spi_master_instance, EXT1_SPI_MODULE, &config_spi_master);
spi_enable(&spi_master_instance);
}
Listing2. The rather lengthy callback function for the RTC in calendar mode.
void rtc_match0_callback(void)
{
adc_start_conversion(&adc_instance);
while(adc_read(&adc_instance, &data) == STATUS_BUSY){}
volt = data * 0.000805;
measure_result = 25 + (volt - 2.945) / 0.01;
rtc_calendar_get_time(&rtc_instance, &time);
spi_select_slave(&spi_master_instance, &slave, true);
spi_write_buffer_wait(&spi_master_instance, &write_enable, 1);
spi_select_slave(&spi_master_instance, &slave, false);
delay_ms(10);
spi_select_slave(&spi_master_instance, &slave, true);
spi_write_buffer_wait(&spi_master_instance, &write_command, 1);
spi_write_buffer_wait(&spi_master_instance, &adress[i], 1);
spi_write_buffer_wait(&spi_master_instance, &time.hour, 1);
spi_write_buffer_wait(&spi_master_instance, &time.minute, 1);
spi_write_buffer_wait(&spi_master_instance, &time.second, 1);
spi_write_buffer_wait(&spi_master_instance, &measure_result, 1);
spi_select_slave(&spi_master_instance, &slave, false);
i++;
alarm.mask = RTC_CALENDAR_ALARM_MASK_SEC;
alarm.time.second += 10;
alarm.time.second = alarm.time.second % 60;
spi_attach_slave(&slave, &slave_dev_config);
config_spi_master.mode_specific.master.baudrate = Clear
Status Register
250000;
Then we transfer the settings in the structure to the SERCOM0 Load time
module (which here goes under the name of EXT1_SPI_MOD- 12.10.15 13:45:34
ULE) and enable the peripheral.
The code also declares various variables and arrays. For exam-
ple, the command bytes for the SPI EEPROM (see the Text RTC-ISR
box) are kept in an array, as are the ten addresses in the array Temperature (every 10s
measurement from 13:45:35)
adress. More on this shortly.
10x
In the next installment we will describe several smaller pro- [4] http://forum.elektor.com/viewtopic.
jects which demonstrate some of the libraries we have so far php?f=2698569&t=2715200
neglected to cover for reasons of space. There will also be a [5] https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
few tips and tricks for using the SAMD20 and Atmel Studio.
[6] http://ww1.microchip.com/downloads/en/
Watch this space!
DeviceDoc/22064D.pdf
(150286)
The 25LC040
This small and low-power device Figure 6. Internal structure of the
from the eight-pin 25LC family of 25LC040. (Source: Microchip)
EEPROMs offers a storage capacity of
4Kbits (512bytes) and is very easy
to drive over SPI at clock rates of up master (the microcontroller) brings
to 2MHz. EEPROM is a non-volatile the SS pin (here /CS) back to a high
storage technology and has a number level. Before each write operation the
of advantages, in particular a high WREN command must be sent to enable
write speed. In the case of this device, writing; also, the protection bits in the
the maximum write time is 5ms. status register must be appropriately set
Figure6 shows the internal structure to allow access to the memory area in
of the EEPROM. There are two active- question.
low inputs: /HOLD and /WP. The first
of these can be used to pause an SPI The 25LC040 is compatible with the
transfer that is already underway, while the second prevents larger-capacity devices in the same family of EEPROMs,
the device from being written to over SPI. If these functions the only difference being that they require more address
are not used, the pins must be bytes[6].
pulled high using pull-up resistors.
The remaining pins are for power
and for the SPI bus connections.
DesignSpark Mechanical
CAD Tips & Tricks (3)
The top table is the Top Level BOM. It shows all of the design
components and their names in the Part Number column. The
bottom table is a Full Detail BOM and is usually the more use-
ful of the two. It shows all of the design components along Figure 2. Edit Ordering Information window.
in collaboration with
Export to CSV
Once youve finished with setting up the BOM its easy to export Figure 3. Updated enclosure information.
it to a Comma Separated Value (CSV) format so that you can
open it a spreadsheet application like Microsoft Excel. First
you click on a BOM table to select it and then DesignSpark
Mechanical will draw a box around it with dashed lines. Now
you can choose the CSV export option in the Bill of Materials
menu and DesignSpark will export a BOM as a .csv file in the
project directory with same name as the .rsdoc design file. It
will also automatically open the default external program asso-
ciated with CSV files where you can edit the file as needed.
The website, Allied Electronics in my case since Im in Can- Figure 4. BOM examples.
ada (www.alliedelec.com; Allied is the US/Canadian/Mexican
branch of RS Components, Ed.), will then try to match all of
the part numbers in your design to the available parts. In this
case it found the Hammond enclosure where I had entered
the proper RS and Allied stock numbers. But you dont always
have to have the stock numbers in advance. For example, I
only entered the manufacturer (Molex) and the part number
prefix (54819) for the USB connector. DesignSpark will warn
you when you dont enter a RS Components or Allied stock
number but its okay to ignore it. The Allied site then gave me
a list of possible matches for the Molex part number so that I
could choose the complete part number.
Conclusion
DesignSpark Mechanical has some really easy to use BOM tools
to help speed up your design process. I used a pretty simple
example here but the real value of the BOM tools is when you
have larger, more complex designs.
Give it a try!
(150294) Figure 5. Online quotation tool.
PIC Assembler
Crash Course
(3) PIC replacement for 555 timer
By Miroslav Cina (Germany) miroslav.cina@t-online.de
The first part of this series introduced the basics of programming in Assembler and the hardware
fundamentals of the PIC controller used. Part two dealt with electronic dice. In this final part we discover
how we can get a modern microcontroller to simulate a standard IC such as the well-known 555 timer.
Theres no need to waste words describing the NE555 timer. low right up to around 166kHz. At lowish frequencies a micro-
This IC has been produced since 1972 and up to now has held controller is simply outstanding, as it can generate stabile peri-
the record for the quantity of units made, even though its not ods or pulses with durations of one day, one month or even
even digital. Its remarkable versatility means that it is by no longer. The maximum frequency depends on the clock speed
means confined to its intended applications as a squarewave of the controller. As Figure 1 illustrates, the circuitry could
generator or monostable. hardly be simpler.
The necessary program concerns itself only with controlling
The standard bipolar version generates signals up to 500kHz, the output. For a squarewave signal with a mark-space ratio
whilst modern successor chips, like the LMC555 from TI, can of 50% we achieve the highest frequency with the following
produce frequencies right up to 3MHz. But squarewave signals Assembler code:
and suchlike can also be produced using microcontrollers as
modern-day do everything ICs. We shall now explain how to output_1 bsf GPIO,D'001' ;1us @ 4 MHz
use a PIC12F675 as a 555 replacement. This time round the nop ;1us @ 4 MHz
focus is on its function as a squarewave oscillator. Other func- nop ;1us @ 4 MHz
tions such as monostables and so on can of course be achieved bcf GPIO,D'001' ;1us @ 4 MHz
in software too if you feel like being creative. goto output_1 ;2us @ 4 MHz
1. Minimalist oscillator The first command sets output GP1 to logical 1. In the com-
For our first program we need just a microcontroller plus a mentary to this the run-time of the command is declared as
couple of lines of code and thats it. The code lets us set the 1s at a clock rate of 4MHz. After this we wait 2s during
frequency of the squarewave signal generated, from extremely two nop commands until the output is set back to logical 0.
IC1 1
VDD
7
GP0/AN0
6
J1 VREF/GP1/AN1 J2
1 5
+5V GP2/AN2
4 1
GND GP3/MCLR
3
POWER GP4/AN3 OUT
2
GP5/T1CKI/OSC1
GND
8
PIC12F675P
Figure 1. In the simplest version of a 555 replacement the PIC manages Figure 2. Oscillogram of the signal in example #1: clean and tidy 166kHz
without any external connections. with a duty cycle of 50%.
The delay is necessary for reasons of symmetry, as reverting The extra 4s reduce the frequency to around 100kHz. Since
to the start of the loop using goto takes 2s. With the inter- the 1-phase now requires 7s and the 0-phase only 3s, how-
nal oscillator clocked at 4MHz, this endless loop produces an ever, the duty cycle of 70% seen in Figure 3 arises.
output frequency of around 166kHz.
The oscillogram in Figure 2 demonstrates the high quality of Some more about timing: normally all commands require four
the squarewave signal produced in this way. clock pulses. The execution time is therefore very easy to cal-
culate as t = 4/clock frequency.
For lower frequencies we simply build in longer delays. To do
this we have two possibilities: for the kHz region we add the Exceptions arise, for example, with the goto, call or return
appropriate number of additional NOPs. For slower signals commands that manipulate the program counter, as these
its better to create an explicit delay loop that is initiated from require eight clock pulses and consequently double the exe-
the main loop. For a duty cycle of 0.5 the delays must be sym- cution time.
metrical. The following example demonstrates how we invoke Its worth noting that you can adjust the accuracy of the inter-
the routine wait_1 twice: nal clock generator, factory-calibrated to 1%. This calibration
value laid down in the chip can be altered when necessary. We
output_1 bsf GPIO,D'001' ;1us @ 4 MHz initiate this with the following code:
nop ;1us @ 4 MHz
nop ;1us @ 4 MHz bsf STATUS,RP0
call wait_1 ;predefined delay call H'3FF'
bcf GPIO,D'001' ;1us @ 4 MHz movwf
OSCCAL
call wait_1 ;predefined delay bcf STATUS,RP0
goto output_1 ;2us @ 4 MHz
It goes without saying that we can also write our own value
Invoking this using a call command takes 4s altogether into the Register OSCCAL and thereby alter the actual clock.
(call itself takes 2s and the reversion that follows in the Now that the principle is clear, check out Listing1 for the com-
routine takes a further 2s). In the routine wait_1 we deter- plete code to transform a PIC12F675 into a 166kHz square-
mine the delay period required. wave generator with a duty cycle of 0.5.
If an asymmetric duty cycle is called for, we build in asymmetric First the controller in use is established and then configured
delays. The following code achieves this with nop commands: from _U002. In the process, the internal oscillator is activated
using the three LSBs with the value 100. It is established
output_1 bsf GPIO,D'001' ;1us @ 4 MHz that MCLR is acting as an input and not, say, as a reset pin.
nop ;1us @ 4 MHz The next four commands (from bsf to clrf) deactivate the
nop ;1us @ 4 MHz unnecessary analog functions and set Pin GP1 as output. The
;additional delay additional 4 s --------- following three commands call to bcf calibrate the internal
nop oscillator as already described. The closing main loop from bsf
nop to goto consists of only five commands.
nop
nop
2. Setting the frequency
;--------------------------------------------
The schematic in Figure 4 includes an additional pot or trim-
bcf GPIO,D'001' ;1us @ 4 MHz
pot (potentiometer) P1, with which we can set the output fre-
goto output_1 ;2us @ 4 MHz
quency from approx. 885kHz to 1.45MHz. However, the way
IC1 1
VDD
7 P1
GP0/AN0
6
J1 VREF/GP1/AN1 10k
1 5
+5V GP2/AN2
4
GND GP3/MCLR J2
3
POWER GP4/AN3
2 1
GP5/T1CKI/OSC1
GND OUT
8
PIC12F675P
Figure 3. With four additional nop commands the frequency drops to Figure 4. Adding a trimpot makes the frequency adjustable.
100kHz and the 70% duty cycle is no longer symmetrical.
we produce the signal is totally different from that in the first ANSEL: Analog Select Register; this determines the sam-
example. Here we demonstrate the use of the CLKOUT feature ple rate and which Pin becomes an analog input.
together with how we handle the integrated A/D converter.
The significance of the Bits in the ADCON0 Register can be
Previously squarewave signals were produced by alternately checked out in Table1. Bit7 is the so-called A/D Result Formed
setting and resetting the output pin. Now were going to let Select Bit (ADFM). The integral ADC has a resolution of 10Bits
the hardware do this for us. The PIC12F675 offers the facility but the result has a width of two 8-bit Registers = 16bits, of
to direct the clock frequency (divided by a factor of 4) direct which only 10Bits are significant. The remaining 6Bits have
to an output. If we now set the three LSBs of the Configura- the value 0.
tion Register to 101 instead of 100, Pin GP4 can be used for The value of ADFM decides the position of the overflow Bits.
CLKOUT. With a clock rate of 4MHz we get a signal of 1MHz When ADFM = 0 the result is aligned left, i.e. the six LSBs of
and a duty cycle of 50%. the ADRESL Register are set to 0. Consequently the eight
MSBs of the result are deposited in the ADRESH Register. On
To alter the frequency, the internal oscillator is recalibrated the other hand, the two remaining LSBs go in the two MSBs of
(using other values for the OSCCAL Register), as mentioned ADRESL. If ADFM = 1 its the other way round and the result
previously. The value of the 8-bit Register ranges between 00h in now aligned right.
and FFh. The internal oscillator can typically be pulled from fre-
quencies between 3.0 and 5.8MHz. A quarter of this produces VCFG selects the reference voltage of the ADC. If VCFG = 1,
the output frequency range already mentioned. then the Vref Pin (GP1) is used. When VCFG = 0 its simpler
Some additional code is required to enable the microcontrol- and the supply voltage VDD is used as reference.
ler to recognize the position of the pot. Three Registers are The two Bits CHS1 and CHS0 select the Pin that acts as input for
relevant to this: the ADC. If both are 0, channel AN0 and Pin GP0 are selected.
Go/Done initiates an A/D conversion when we set it to 1. We
ADCON0: Configuration of the ADC. can check afterwards whether the conversion is already com-
ADRESH, ADRESL: MSB/LSB of the 16-bit ADC results. plete. Then this bit has the value 0.
Listing1.
;************************************************** movwf TRISIO
;* NE555 Replacement - Example 1 * clrf ANSEL ;GPIO are digital I/O's
;* v 1.00 - 19.06.2015 * ;--------------------------------------------------
;************************************************** ;oscillator calibration
;* Microcontroller: PIC12F675 * call H'3FF'
;* Oscillator: internal * movwf OSCCAL
;************************************************** bcf STATUS,RP0 ;switch back to Bank 0
;Pin connections:
;GP0 --> N/C ;--------------------------------------------------
;GP1 --> Output ;Main Loop
;GP2 --> N/C ;--------------------------------------------------
;GP3 --> N/C output_1 bsf GPIO,D'001' ;1us @ 4 MHz
;GP4 --> N/C nop ;1us @ 4 MHz
;GP5 --> N/C nop ;1us @ 4 MHz
;-------------------------------------------------- ;additional delay - additional 4 us ---------------
;Chip configuration: nop
INCLUDE "P12F675.INC" nop
_U002 EQU B'00000110000100' nop
;MCLR = input/internal osc. nop
__CONFIG U002 ;--------------------------------------------------
;-------------------------------------------------- bcf GPIO,D'001' ;1us @ 4 MHz
;analog functions off, GP1 = output goto output_1 ;2us @ 4 MHz
bsf STATUS,RP0 ;switch to regist. bank 1 ;--------------------------------------------------
movlw B'11111101' END
;GP1 = output; GP0; GP2 - GP5 = input
Listing2.
;************************************************** ; ADON = 1 --> switch the module ON
;* NE555 Replacement - Example 2 with P1 * movwf ADCON0
;* v 1.00 - 19.06.2015 * ;Samplerate, GP0 = analog input
;************************************************** ; movlw B00010001
;* Microcontroller: PIC12F675 * ; ADCS<2:0> = 001 --> ADC clock = FOSC/8
;* Oscillator: internal * ; ANS3 = 0
;************************************************** ; ANS2 = 0
; ANS1 = 0
;Pin connections: ; ANS0 = 1 --> analog input on AN0 (GP0)
;GP0 --> Poti
;GP1 --> N/C bsf STATUS,RP0
;GP2 --> N/C movwf ANSEL
;GP3 --> N/C bcf STATUS,RP0
;GP4 --> CLKOUT ;--------------------------------------------------
;GP5 --> N/C ;Main Loop
;-------------------------------------------------- ;--------------------------------------------------
;Chip configuration: ;start A/D conversion ------
INCLUDE P12F675.INC main_loop bsf ADCON0,D001
w_adc btfsc ADCON0,D001
_U005 EQU B00000110000101 goto w_adc
;MCLR = input / internal osc. + CLKOUT
__CONFIG _U005 ;modify clock ------
;-------------------------------------------------- movf ADRESH,0
;setup ADC ------ bsf STATUS,RP0
;Result left adjusted, VDD = reference, GP0 = input, movwf OSCCAL
activate ADC bcf STATUS,RP0
movlw B00000001 nop
; ADFM = 0 --> result is left justified nop
; VCFG = 0 --> Vdd = voltage reference goto main_loop
; CHS1:CHS0 = 00 --> Channnel 00 (GP0) ;--------------------------------------------------
; GO = 0 --> no start now END
Finally we use ADON = 0 to shut down the complete A/D sec- approach. There is no getting around the use of Interrupts and
tion (to save current) and ADON = 1 to reactivate it. setting a Timer. Additional components in the schematic shown
The ADRESH and ADRESL Registers contain the ADC result, in Figure 5 are the crystal itself plus its two loading capacitors.
as already mentioned. The software has two tasks to fulfill. On one hand, as previ-
ously, it needs to read in the setting of the trimpot and on the
The significance of ANSEL is given in Listing2. other, generate a precise squarewave signal that will not be
The first variation from Listing1 lies in the value of 101 for the
three LSBs of the configuration Register. Consequently at Pin
GP4 we have a quarter of the clock frequency at our disposal.
P1
In the following section we configure the ADC. First the result is IC1 1
aligned to the left. If we use only ADRESH and ignore ADRESL, VDD
10k
7
GP0/AN0
well get a ready formatted 8-bit result. In addition VDD is used 6
J1 VREF/GP1/AN1
as reference and GP0 as measurement input. +5V
1
GP2/AN2
5
J2
4
GND GP3/MCLR
3 1
The next step will see the ADC clock frequency reset to one- POWER GP4/AN3
2
GP5/T1CKI/OSC1 OUT
eighth of the main clock and GP0 set as analog input. With
GND
that the Initialization process is over. 8
X1 PIC12F675P
In the main loop we initiate an A/D conversion and then read
in the result. Following this, we make the frequency of the C1 20MHz C2
internal oscillator dependent on the ADC result and set the
22p 22p
position of the trimpot wiper with a resolution of 256 steps.
affected by frequency changes and suchlike. For this reason the a Timer. From then onwards TMR0 is incremented with every
code consists of two parts. We already know how to evaluate Instruction cycle (clock rate divided by 4).
a pot. Producing the output signal employs two new functions
of the microcontroller: Timer0 and Interrupts. A couple of words more about Interrupts: all significant char-
acteristics are controlled by the INTCON Register. The signifi-
Timer0 can be used either as a timer or as a counter. In timer cance of its Bits can be inspected in Table2. For our purposes
mode the associated Register is incremented periodically, being only three of the Bits are important:
driven by clock pulses. As a counter it counts external events.
For substituting the 555 chip we need to use the timer mode. GIE: Global Interrupt Enable. GIE = 1 activates and GIE =
The timer then generates the actual output signal. Heres how: 0 deactivates the Interrupts.
At the outset a value is written into the TIMER Register TMR0. T0IE: Timer0 Interrupt Enable. Only when T0IE = 1 does
From then on this value is incremented continually until the an overflow of TMR0 produce an Interrupt.
value FFh is reached. Because we are dealing with an 8-bit T0IF: Timer0 Overflow Indicator. An overflow of TMR0
Register, an overflow occurs with the next increment and the makes the value of T0IF become 1. We can interrogate
Register then contains the value 00h. The overflow is an event (poll) the Bit and it must then be reset to 0 in the code.
that triggers an Interrupt. In the interrupt routine we can gen-
erate the actual signal. Its also vital that the Interrupt Routine begins always at
The interaction with Timer0 and its TMR0 Register is totally memory location 004h. Two new Commands are relevant for
uncomplicated. If we set the Bit T0CS to 0, Timer0 is used as Interrupts:
Listing3.
;************************************************** ;--------------------------------------------------
;* NE555 Replacement - Example 3 with Xtal * ;ISR
;* v 3.07 - 05.07.2015 * ;Save status register ------
;************************************************** int_main movwf w_save0 ;save content of W-reg.
;* Microcontroller: PIC12F675 * ;could be Bank0 or Bank1
;* Oscillator: internal * swapf STATUS,0 ;move content of Status to W
;************************************************** bcf STATUS,RP0 ;switch to Bank0
;GP0 --> Poti movwf stat_save
;GP1 --> Output ;save original content of Status
;GP2 --> N/C ;GPIO toggle ------
;GP3 --> N/C movf v_value,0
;GP4 --> Xtal movwf GPIO
;GP5 --> Xtal incf v_value,1
;-------------------------------------------------- ;Store ADC value in TMR0 ------
;Chip configuration: movf v_delay,0
INCLUDE P12F675.INC movwf TMR0
_U003 EQU B00000110000010 bcf INTCON,T0IF
;MCLR = external xtal up to 20 MHz ;Restore status register ------
__CONFIG U003 swapf stat_save,0 ;restore old Status to W
;================================================== movwf STATUS
;Variable definitions ;push content to Status register
w_save0 EQU H20 ;select old Bank
w_save1 EQU HA0 swapf w_save0,1 ;rebuild content of W-reg.
stat_save EQU H21 swapf w_save0,0 ;restore W register
v_delay EQU H22 retfie
v_value EQU H23 ;--------------------------------------------------
v_tmp EQU H24 ;ISR
;================================================== rst_main
;Set adress of subroutines ...
ORG H000 ;missing code
goto rst_main ...
ORG H004 ;--------------------------------------------------
goto int_main END
SWAPF
Table 3. Output frequencies using crystal frequency as
This command swaps (exchanges) the two Nibbles of a Regis- the parameter
ter. For a value of E4h, this changes after the swap to 4Eh. For
Xtal frequency fout min. fout max.
Interrupts it is also important that the STATUS Register remains
2 MHz 237 Hz 4.63 kHz
untouched by the execution of this command. The syntax is:
4 MHz 474 Hz 9.26 kHz
swapf
f,d 20 MHz 2,370 Hz 46.30 kHz
Listing4.
;************************************************** ;GP3 --> N/C
;* NE555 Replacement - Example 4 w/o code * ;GP4 --> Output
;* v 1.00 - 19.06.2015 * ;GP5 --> Poti
;************************************************** ;--------------------------------------------------
;* Microcontroller: PIC12F675 * ;Chip configuration:
;* Oscillator: internal, RC mode with external R * INCLUDE P12F675.INC
;**************************************************
_U004 EQU B00000110000111
;Pin connections: ;MCLR = input, RC mode, GP4 = CLKOUT
;GP0 --> N/C __CONFIG _U004
;GP1 --> N/C ;--------------------------------------------------
;GP2 --> N/C END
The frequency ranges covered with this circuit and code are Final thoughts
dependent on the crystal frequency and can be seen in Table3. With that example using no code our Assembler Crash course
A discussion of the missing part of the listing would be too has reached both its climax and its conclusion. I do hope you
lengthy for this article. But it goes without saying that the enjoyed it! Perhaps you will now get into PICKit3 or PICKit2
entire sample code, complete with the other listings, can be and try improving or extending one or two of the examples
downloaded free from the web page for this article [4] and there. If you have any questions about this my e-mail address
then inspected at your leisure. is at your disposal: miroslav.cina@t-online.de.
(150393)
4. PIC without software
A microcontroller without software is this capable of doing
anything at all? In fact, although the only additionalcompo-
nent in Figure 6 is a potentiometer, youcanstill manage to
setafrequencyofabout170kHzto3.5MHz without using
anybitsandbytes.
Web Links
[1] PIC12F675: www.microchip.com/wwwproducts/Devices.aspx?product=PIC12F675
[2] First part of this course: www.elektormagazine.com/130483
[3] Second part of this course: www.elektormagazine.com/150274
[4] Third part of this course: www.elektormagazine.com/150393
An Analog Robot
From concept to construction
By Tino Werner (Germany)
The commercial robot kit Tibo packs lots of fun for young
and old alike. A standard opamp lies at the heart of the
design; you wont find a single line of code or a microcontroller
anywhere. Pluggable resistors and capacitors allow you to define
the rules which govern the robots behavior and the results can be
amazingly complex. It was a long and winding road from the initial
spark of an idea to the finished product, a journey the author shares
with us here.
DIP socket housed the dual opamp, and provided free sockets V+
Figure 4. Tibos control PCB (left) and power PCB (right). Figure 5. An example from the experimenters instruction manual.
I was short of 300 of these ICs so started out on a quest to the requirements of the applicable EC directives. It is import-
track down any remaining stocks on the retailers shelves but ant to check out any legislation concerning the product life
ended up sourcing some from the Far East. These unfortunately cycle, eventual recycling and even packaging made from bio-
turned out to be counterfeit and could only deliver around degradable products. When in doubt, it is advisable to seek
12mA instead of the expected 80mA. I made 30 requests out the help of professionals even if you think initially that
to tender, supplying information such as the complete part you will be able to deal with all of the matters yourself. Just
number together with photos of the exact chip and ended up to get some experience I started to put together the first 100
placing over ten trial orders to test the components but all kits but quickly realized its better to leave such tasks to the
were unsuccessful. All of the samples had exactly the same professionals. After this initial phase all subsequent kits have
fault. After much fruitless searching I discovered the German been expertly tested and packed by a local workshop.
company TronicPool who specialize in sourcing discontinued
components. They were successful in tracking down the last For many inventors it may be a better solution to license your
piece of the jigsaw; at last my quest was at an end. invention so that all production worries are taken over by an
established manufacturer. This way you receive an agreed per-
Sourcing the metal-geared motors (PGM-12F) was also just as centage of the sales and you dont incur the risks associated
protracted. These particular motors measuring 25x12x10mm3 with forming your own company. There can also be pitfalls
are quite compact and available in a range of operating voltage, if you choose this path but instead of all the stress and time
gear ratio and power. The standard operating voltage seems involved in marketing your own product you can concentrate
to be 6V but 3V versions (as used in Tibo) are also available. on designing the next one.
On the grounds of costs, it was not possible to source these (140510)
from one European supplier. You can expect to pay around
15 per unit for a low volume order. There are many suppliers [1] Braitenberg, Valentino: Vehicles: Experiments in Synthetic
on eBay such as Aliexpress and Alibaba offering these types Psychology (MIT Press 1986)
of motors for a very good price. You need to exercise caution
here though, sometimes you can receive a perfectly accept-
able sample but thats no guarantee that future supplies will
be of the same quality. While you can expect low delivery
costs you need to take into account delivery times which are
typically a few weeks longer than from local suppliers. During
tests I tried out a total of seven different types of motor for
the robot. The properties I was looking for were low power
consumption, low start up voltage and smooth running. Many
of the examples failed because of wobbly spindles and failure
to even begin rotating. For personal use and for small volume
orders I would recommend using motors sourced from local Tibo from Elektor Store
suppliers, in the long run you have better quality control and
The Elektor Store provides a fantastic opportunity to pres-
will spend less time fielding customer complaints.
ent fascinating developments such as the Tibo robot kit to
customers worldwide. The kit of parts contains all the me-
And more problems... chanical and electronic components necessary to build Tibo.
Anyone toying with the idea of developing and bringing a prod-
uct to market should be aware that as well as the technical
At www.elektor.com/tibo-robot-kit you will also find more
challenges there are also many other aspects of the process
information about the kit and ordering information. In ad-
that will take up your time and money.
dition there is a 40-page builders and experimenters guide
I had already decided to patent both the controller and the
and a video showing construction of the robot in detail.
kinematics concepts of the robotic spider. All the necessary
research proved very interesting and I could compare alter-
native ideas and identify the essence of my own design that
could be protected. Owning the rights to your Intellectual Prop-
erty (IP) is of course no guarantee that your product will be
marketable or successful but I recommend the use of a Patent
library or patent attorney to ensure your idea does not infringe
other designs already protected. The same goes for the regis-
tering of a trade mark. In Germany we have the government
funded SIGNO institution which supports small and medium
sized businesses as well as individuals, offering advice on legal
protection and commercial exploitation of innovative ideas.
Check the government web sites active in your own country
for similar schemes.
The kit costs 89.95
Finally for products manufactured in the EU there is CE confor-
Elektor members grab a 10% discount!
mity. This mark is your declaration that the product meets all
The RaspberryPi
is a low-cost
computer ideal for
measurement, monitoring
and control applications. Recently a
special version of Windows10 has been
released that runs on the Raspberry Pi2, and it is
available free-of-charge. In this mini-series we take a
look at what it can do for the electronics hobbyist.
Whether you are a fan or not, there is no denying that British First steps
entrepreneur Eben Uptons company has made a powerful sin- If you want to run Windows10 on your Raspberry Pi2, you
gle-board computer that is affordable by almost anyone. And will need a desktop computer to develop programs for it. That
now, thanks to a partnership with Microsoft, it is possible to computer must run Windows10: if your desktop is currently
run a version of Windows10 on the Raspberry Pi2. running Windows7 or Windows8 you will therefore need to
The version in question, Windows10 IoT Core, is by no means carry out the (free) upgrade to Windows10. The operating
a desktop operating system, and it will not turn your Rasp- system for the RaspberryPi is provided in a container format
berry Pi2 into a desktop replacement. It is rather a trimmed- newly-introduced with Windows10, which cannot directly be
down version of Windows10 designed for use in kiosk mode. transferred to an SD card (minimum 8GB capacity required)
This means that the operating system will only ever run one with older versions of Windows.
specified application while the system is on: for example, this
might be a measurement, monitoring or control application, Navigate your way to the website at[1] and click on the down-
in which case we might think of the machine as a dedicated load link in the section headed Windows10 IoT Core for Rasp-
process control computer. berry Pi2 to download the image file. In the Edge browser you
can now open the ISO file by clicking on Open in Explorer, Visual Studio programs are called solutions, and can contain
which will cause the installation program contained in the image several independent projects. When debugging is initiated the
to start running. project shown in bold face will be the one that is run. To change
Microsoft has simplified the deployment of the operating sys- this, use a right mouse click and Set Startup Project. In the
tem with a tool called WindowsIoTImageHelper. In the first case of our skeleton project, however, we have only a single
step the application asks you to select the card reader device Universal Windows application.
to be used, and in the second step you must select the image Applications user interfaces are described using a modern
file at C:\Program Files (x86)\Microsoft IoT\FFU\RaspberryPi2\ technology called XAML, a derivative of XML. Each XAML file
flash.ffu. Clicking on the Flash button begins the process of consists of the mark-up itself (which gives the layout of control
transferring the operating system to the SD card, which can elements such as buttons and text entry fields), and is accom-
take several minutes. panied by a code-behind file, which contains the required
program code. The code is conventionally written in the C#.
Now plug the SD card into the Raspberry Pi2, which should NET language, but development in Visual Basic is also possible
also have an Ethernet connection, as well as keyboard, mouse for the Raspberry Pi.
and monitor attached. The first boot-up typically seems to take
about ten minutes. After the obligatory reboot the Raspberry Developers with experience of writing for microcontrollers may
Pis desktop should appear on the screen: this is a dedicated not be used to the event-driven paradigm that is used when
application which just displays the IP address of the machine. writing Windows10 applications. This means that there is
If the Raspberry Pi is used without a screen (headless), the no main loop to be seen in the program code, and no polling
IP address can usually be discovered via the web interface of of buttons or inputs. Instead the vast majority of the code
the router it is connected to. In our case the Raspberry Pi can comprises functions which are called in response to specified
be found at IP address 192.168.0.100. events, called event handlers. Among these event handlers
The development environment that we need is Visual Stu- might be a function that responds to a button in the user inter-
dio 2015. The free community version can be downloaded face being clicked; another type of event is generated when
from[2] and installed: it is worth doing this installation in a character is received.
parallel with downloading the ISO image. Make sure that you
choose the Custom option in the installation wizard; in the Running our first program
next step you will need to select the option Universal Windows At the moment out application does nothing more than pres-
App Development Tools. ent a black screen. This is not a problem, as the program is
still under the control of the debugger process.
Before we can develop an application for the Raspberry Pi2 we Figure 1 shows the part of the Visual Studio toolbar that relates
have to extend Visual Studio to include the necessary project to configuring the debugger. The first combo box allows the
templates. This can be done using the extension manager built
into the IDE, accessed under Tools- Extensions and Updates.
Click on the Online column and then in the Visual Studio Gal-
lery column look for Windows IoT Core Project Templates. A
click on Download will cause these to be loaded automatically
onto your machine.
Windows10 workstations have to be put in developer mode
before they can be used for programming. Under Settings
Figure1. Debugger configuration.
click on Update& Security- For developers- Developer mode.
Figure2. Visual Studio projects are comparatively complex. Figure3. At the bottom right is the text message output by our program.
nection. The IP address of the Raspberry Pi should be entered Let us now try this out by clicking on Play. The Visual Studio
in the Address field in the pop-up window that appears, and screen reconfigures itself when a program is run: for reasons
for Authentication mode select None. Now click on Select the author cannot fathom the output window only appears in
to save these settings. You can change these settings later by the edit view. The problem can be fixed by changing the setting
right-clicking on the project (that is, the universal Windows at View- Output, to cause the text message to appear among
application) in the Solution Explorer as shown in Figure2 the runtime messages: see Figure3 at the bottom right.
and then selecting Properties- Debugging.
Tracking down problems is made easier with the help of
The deployment process itself is carried out without further advanced debugging functions. Double-clicking on the gray
prompting by clicking on the play symbol. When first trans- area just to the left of the source code allows a breakpoint to
ferring a program Visual Studio starts by sending a few librar- be set: the debugger will now halt program execution when-
ies to the target machine, a process which can take up to a ever the line of code in question is reached. In this state of
minute. Then the status line at the bottom of the screen will suspended animation you can inspect the values of local and
change to a dark orange, which means that the program is global variables, and then resume program execution either
being executed. one step at a time or continuously.
}
Figure4. An LED is connected to GPIO pin4 via a series current-limiting }
resistor.
a look at the declaration of this class, an excerpt from which Windows IoT Extensions for the UWP. The GpioController
appears in Listing2. At a glance you can see what methods class will now appear in the context menu.
are available in the class: the names of the methods should Beginners may find dealing with the two classes GpioCon-
be self-explanatory. troller and GpioPin somewhat confusing at first. As usual,
a good way to gain experience with such things is to start with
Some readers may have heard of garbage collection, a process an example program written by someone else, and then try
where Windows from time to time deletes any unused objects modifying it one step at a time.
in order to reclaim the storage space they occupy. This applies
also to Windows on the Raspberry Pi and its GpioPin objects: Lighting an LED
in this case, when the object is deleted the corresponding Now we come to our demonstration. As usual, the code is
hardware pin is automatically returned to the high impedance available for free download at[3]. First we create an object of
state. This can be a problem in electronic projects, which we class GpioController and then open the pin. Next we config-
shall investigate more closely in the third part of this series. ure the pin as an output using the method SetDriveMode().
To obtain access to a GPIO pin we must first open it. This is Finally we set the output high:
done using the OpenPin method of an object of class Gpio-
Controller. This object is created using the line GpioController myGPIO = GpioController.GetDefault();
GpioPin myLEDPin = myGPIO.OpenPin(4);
GpioController myGPIO = GpioController.GetDefault(); myLEDPin.SetDriveMode(GpioPinDriveMode.Output);
myLEDPin.Write(GpioPinValue.High);
and then pin X is opened using
GpioPin myPin = myGPIO.OpenPin(X); As described above, we can include this code in the Main-
Page constructor so that it will be executed when the program
which also returns an object of class GpioPin. In this case we starts up.
have called the object myPin. Try it out, and you should be greeted by an illuminated LED!
Readers who have already done some programming using the Now to make it blink
.NET framework will know that before using a class the corre- With a minimum of extra effort we can extend the program so
sponding namespace should be declared at the start of the that the LED blinks continuously. The necessary code is shown
code file, with a using declaration. Missing declarations are in Listing3. As you can see, the code is again inserted into
indicated by Visual Studio underlining the affected elements. the MainPage constructor so that is is executed when the pro-
A context menu (accessed using a right mouse click) helps to gram starts. The first part of the code we have seen already;
identify the correct namespace. The class GpioController, the section that follows initializes a timer with a period of one
however, cannot be located in this way because it is in the second, and starts it running. An interesting point is the line
form of an extension.
myTimer.Tick += MyTimer_Tick;
To solve this problem click on the References folder in the
solution with the right mouse button, and from the context which supplies a function to the variable Tick which belongs
menu that appears select Add reference. Then switch to Uni- to our object myTimer. The function will be called when the
versal Windows- Extensions and add a tick before the package timer interval expires, that is, once per second. The function
Speed
Figure5. Not a pretty sight: oscilloscope trace when attempting to switch
As electronics engineers we are of course interested in seeing
the output every millisecond.
how quickly we can make the LED blink. The class TimeSpan
puts one limit on what is possible: the smallest possible time
span that can be represented is one millisecond.
This is because the Write commands only update the value GpioController myGPIO = GpioController.GetDefault();
stored for the pin within the GPIO driver. The level on the pin myLEDPin = myGPIO.OpenPin(4);
itself is only updated after the timer handler completes. myLEDPin.SetDriveMode(GpioPinDriveMode.Output);
Direct Conversion
offers a high performance mode with improved IP3 performance.
CML Microcircuits new CMX994A and CMX994E are RF receiver ICs The CMX994, CMX994A and CMX994E DCRx ICs offer excellent RF per-
featuring I/Q demodulators with low power consumption and high formance, exceptional IP2 from I/Q mixers and are suitable for modu-
performance features. These devices are targeting the next genera- lation schemes including: QAM, 4FSK, GMSK and pi/4-DQPSK. Key fea-
tion of narrowband and wideband Software Defined Radios (SDR) for tures of the device include on-chip VCO for VHF applications, on-chip
wireless data and two-way radio applications. Their design provides LNA, precision baseband filtering with selectable bandwidths and the
the optimum route for high integration, allowing a small RF receiver smallest PCB area, typically less than 50% of a dual superhet.
to be realized with a minimum of external components in zero-IF, near www.cmlmicro.com
zero-IF and low-IF systems. (150486-2)
The CMX994A and CMX994E ICs build on the success of the popular
CMX994 and are the first devices to use CMLs PowerTradeTM technol-
ogy. PowerTradeTM enables the devices to dynamically balance power
consumption and performance characteristics to suit varying operat-
ing requirements. Very low power consumption can also be achieved
in standby mode whilst looking for an RF signal, using intelligent
control of power cycling, phase control and I/Q channel selection. The
CMX994A delivers a very low power DCRx device while the CMX994E
also includes the low power mode of the CMX994A but in addition,
Publication:
Black ArsenicPhosphorus: Layered Anisotropic Infrared Semiconductors with Highly Tunable Compositions and Properties
Adv. Mater., 2015, Early View DOI: 10.1002/adma.201501758
http://onlinelibrary.wiley.com/wol1/doi/10.1002/adma.201501758/abstract
LED Driver
4
with High PF and
Ultra Wide
Output Voltage
ZXYTT
7733A By Inki Park
An LED voltage may vary considerably eliminating secondary feedback circuitry. the diode is conducting, output voltage
depending on the number of LEDs in This makes it feasible to fit the driver (VOUT) and the diode forward-voltage drop
series, and temperature. LED current circuit inside small-form factor retrofit (VF), is applied across the transformers
however should remain constant no mat- lamps and meet international regulations secondary-side inductance and diode cur-
ter which type of design because the total without excessive cost increases for SSL rent (ID) decreases linearly from the peak
lumen is proportional to the current. At application. Fairchilds FL7733 Pulse Width value (IDS.PK NP/NS) to zero. At the end
the same time, high Power Factor (PF) Modulation (PWM) PSR controller, helps of inductor current discharge time (tDIS),
and low Total Harmonic Distortion (THD) simplify meeting SSL requirements while all energy stored in the transformer has
have become key design requirements for eliminating external components. The been delivered to the output.
LED drivers. Therefore, a driver suitable FL7733 provides highly precise output
for wide output voltages will be helpful to current regulation versus change in the Mode III
increase flexibility and compatibility with transformers magnetizing inductance, When the diode current reaches zero,
various LED characteristics. In this arti- input and output voltage information, the transformer auxiliary winding volt-
cle, a PWM controller integrated with an as well as powerful protection functions age begins to oscillate by the resonance
advanced Primary-Side Regulation (PSR) for system reliability. between the primary-side inductance (Lm)
technique will be introduced, and design and the effective capacitor loaded across
guidance of the single-stage flyback con- Mode I MOSFET (Q).
verter suitable for wide output voltage During the MOSFET turn-on time (tON), The output current can be estimated
ranges will be provided. input voltage (VIN) is applied across the using the peak drain current and induc-
transformers primary-side inductance tor current discharge time because output
Primary Side regulation (Lm). Then, drain current (IDS) of the MOS- current is the same as the average of the
controller and its operation FET increases linearly from zero to the diode current in steady state. The peak
Primary-Side Regulation (PSR) for LED peak value (IDS.PK), as shown in Figure value of the drain current is determined
drivers can be a solution for achieving 1. During this time, the energy is drawn by the CS peak voltage detector and the
international regulations (such as Energy from the input and stored in the inductor. inductor current discharge time is sensed
Star ) for Solid-State Lighting (SSL) by the tDIS detector. With peak drain cur-
products. PSR controls the output cur- Mode II rent, inductor current discharging time,
rent precisely with the information in the When the MOSFET (Q) is turned off, the and operating switching period informa-
primary side of the power supply only, energy stored in the transformer forces tion; the innovative TRUECURRENT cal-
removing output current sensing loss and the rectifier diode (D) to turn on. While culation block estimates output current
1 tdis N 1
Io = VCS P (1)
2 ts NS RS
tdis
VCS = 0.25 (2)
ts
VCS.PK = ISW.PK RS (4) Figure 3. VS (voltage sense) circuit for wide output voltage range.
Figure 4. CC (constant current) performance over Figure 5. PF (power factor) performance versus Figure 6. THD (transient harmonic distortion)
whole input and output voltage. input voltage according to load conditions. performance versus input voltage according to
load conditions.
According to Equation (3) the prima- Because the FL7733s VDD operation range To show the validity of the design proce-
ry-to-secondary turn ratio is determined is 8.75~23 V, MOSFET switching will be dure presented in this application note,
by the sensing resistor and output cur- shut down by triggering UVLO if output the converter described by the design
rent as: voltage is lower than VOUT-UVLO (8.75NS example was built and tested. Figure4
/NA). Therefore, VDD should be supplied shows the CC (constant-current) toler-
I0 RS
nPS = (5) properly without triggering UVLO across ance measured over the entire line and
0.125
the wide output voltage range of 12~50 output voltage ranges. CC over universal
V. VDD can be supplied by adding external line at the rated output voltage is less
VDD.OVP 23
nAS = = (6) winding NE and VDD circuits composed of than 0.26%, and total CC regulation
VO.OVP VO.OVP
a voltage regulator, as shown in Figure3. for whole line and output voltage range
The NE should be designed so VDD can be (12~51 V) is 1.23%.
nAS
nAP = (7) supplied without triggering UVLO at mini-
nPS mum output voltage (Vmin.OUT). The exter- Figures 5 and 6 show the PF and THD
nal winding, NE, can be determined as: performance measured respectively at
Since the saturation flux density various load conditions.
decreases as temperature rises, the
NE >
( 8.75 + V
CE .Q1 + VF .D 3 )N NA (8)
S
high-temperature characteristics must (VF .D1 + Vmin.OUT ) Conclusion
be considered if the transformer is used The design considerations for a LED driver
inside an enclosed case. where VCE.Q1 is Q1s collector-emitter sat- with wide output voltage as described
uration voltage, and VF.D3 is D3s forward here aim at increasing flexibility and com-
The first consideration for R1 and R2 voltage, and VF.D1 is D1s forward voltage patibility for various LED lamp specifica-
selection is to set VS (voltage-sense) at the minimum output voltage. tions and LED characteristics. Fairchilds
to 2.7 V to ensure high-frequency oper- PSR controller type FL7733 can provide
VIN .bnk
ation at the rated output power. The R1 = nAP (9)
good performance for high PF and low
second consideration is VS blanking. IVS.bnk THD as well as constant current regula-
The output voltage is detected by aux- tion over very wide output voltage range.
iliary winding and a resistive divider where VIN.bnk is the line voltage level for In addition, the proposed LED driver can
connected to the VS pin, as shown in VS blanking and IVS.bnk is the current level be used for a variety of LED lamps with
Figure3. However, in a single-stage fly- for VS blanking. simple design and low cost.
back converter without a DC link capac- (150370)
R 2 2.7
itor, auxiliary winding voltage cannot be R1 = (10)
clamped to reflected output voltage at (VOUT + VF .D1 ) nas 2.7
low line voltage due to the small Lm cur-
rent, which induces VS error. Frequency
Inki Park Application Engineer
decreases rapidly at the zero-crossing
Inki Park joined Fairchild Semiconductor in 2010 as
point of line voltage, which can cause
an Application Engineer. He develops primary-side
LED light flicker. To maintain constant
regulation controllers for LED drivers in addition to
frequency over the whole sinusoidal line
designing high-performance power converters with
voltage, VS blanking disables sampling
power factor correction.
at less than a particular line voltage VIN.
Prior to Fairchild, Park spent six years developing a
by sensing the auxiliary winding. The
bnk variety of power systems and LED drivers.
third consideration is VS level, which
Park received a Master of Science and a Bachelor of
should be operated between 0.6 V and
Science in Electrical Engineering from Kangwon National
3 V to avoid triggering SLP and VS OVP
University in Kangwon, South Korea.
in wide output application.
Compact
USB to Serial Converter
Using the FT232H
By Ton Giesberts (Elektor Labs) and Thijs
Beckers (Netherlands Editorial)
+3V3 +3V3
multi-protocol serial converter based on VCCD
the FT232H from FTDI (Elektor May/June
2015, page 90 [1]). The project described C4 C5 C6 C7 C8 C9 C10 C11
here is an extension of that design and 100n 100n 100n 100n 100n 100n 100n 47
38
40
39
12
24
46
+5V
3
8
VCCA
VREGIN
VCCD
VPLL
VCCIO
VCCIO
VCCIO
VCCCORE
VPHY
47 ADBUS5
USB B 17
ADBUS4
project, but it prevents the converter from 1
2
34
6
RESET ADBUS3
16
15
CTS
RTS
K2 +5V
DM ADBUS2
being used as a breakout board. Here 3 7
DP ADBUS1
14 RXD JP1
4 C1 D1 5 13 TXD
REF ADBUS0
the main aim was to keep things small, IC1
4
5 +5V
10n 3 R2 21 +3V3
which we managed reasonably well with C3 ACBUS0
7
6
2 45 25
12k0
EECS ACBUS1
dimensions of 2233mm. L1
10n 44
43
EECLK FT232H ACBUS2
26
27 UART
EEDATA ACBUS3 +3V3'
1
28
PRTR5V0U2X ACBUS4
29
ACBUS5
42 30
TEST ACBUS6
4 31
Features +3V3
9
AGND
AGND
ACBUS7
ACBUS8
32 +5V +3V3'
41 33
AGND ACBUS9
XC6206P332MR
USB 2.0 High Speed L3 L4
IC2 2
GND
GND
GND
GND
GND
GND
GND
GND
3
Pin compatible with the FTDI-USB- XCSI XCSO
VPHY VPLL R3
1
2
10
11
22
23
35
36
47
48
X1
TTL (UART) cable
1
1k5
C18 C19
Right-angle USB connector for
C12 C13 C14 C15 C16 12MHz C17 D2 1u 1u
space-saving mounting
47 100n 47 100n 27p 27p Power
Selectable 3.3V or 5V supply
150387- 11
voltage on the output connector
Automatically recognized as a
COM port (after installation of VCP
Figure 1. The schematic is a slimmed-down version of the USB to multi-protocol serial converter
drivers [3])
published in Elektor May 2015.
Capacitors Miscellaneous
Default: SMD 0603 K1 = Micro-USB 2.0 type-B through-hole PCB
C1,C3 = 10nF, 50V, 10%, X7R connector, vertical
C2,C11,C12,C14 = 4.7F, 10V, 10%, X7R, K2 = 6-pin SIL socket, 0.1 pitch
SMD 0805 JP1 = 3-pin pinheader, 0.1 pitch Its nice to have that
C4-C10,C13,C15 = 100nF, 50V, 10%, X7R JP1 = jumper, 0.1 pitch
C16,C17 = 27pF, 50V, 5%, C0G/NP0 X1 = 12MHz quartz crystal, CL = 18pF, SMD High Speed feeling
C18,C19 = 1F, 6.3V, 20%, X5R 5 x 3.2mm
PCB # 150387-1
Inductors
L1-L4 = 600 @ 100MHz, 25 %, 0.15 ,
1.3A, SMD 0603 Find the differences
If you look at the schematic diagram in
Figure1, youre bound to see a lot of
similarities to the original design. The
FT232H is supported by a 3.3V volt-
age regulator (IC2) and the usual filter
and decoupling capacitors. A special pro-
tection diode guards the inputs of the
FT232H against static discharges up to
8kV. The 3.3V supply voltage is con-
nected to the RESET pin through R1/C3
as specified by the data sheet. Another
thing specified by the data sheet is resis-
tor R2 (12k, 1%), which ties the cur-
Figure 2. Virtually every square millimeter is used on the miniaturized PCB.
rent reference input REF to ground. The
12MHz crystal (tolerance 30ppm) is
also a mandatory component, along with
the tuning capacitors C16 and C17. L1, L2
and C1 provide a bit of protection against
high-frequency noise on the supply line
and the shield. The power indicator LED
(D2) survived the slimming-down exer-
cise and is handy for seeing whether the
module is powered up.
K1 is a Micro USB connector, which is
FT232H.
The EEPROM that enables configuration of
the USB to multi-protocol serial converter
has been eliminated to cut cost and save
space. It is thus not possible to config-
ure the FT232H in different modes with
FTProg, so it only works in the default
UART mode.
Practical aspects
The small PCB (see Figure2) has four
mounting holes for securing it with M2
screws. The USB connector is mounted
on the rear of the board, and we choose
a right-angle type for this model so it can
be accessed through a relatively thick
front or rear panel.
When it is connected to a PC, the FT232H
Figure 3. After the VCP drivers are installed on the PC, the FT232H is recognized immediately as a
is immediately recognized as a UART if COM port.
the Virtual Com Port (VCB) drivers [3] are
already installed. Figure3 shows how
Web Links
the FT232H is recognized in Windows7.
If it doesnt work for you, there are lots [1] USB to Multi-Protocol Serial Converter, Elektor May/June 2015: www.elektorma-
of descriptions on the Internet that can gazine.com/130542
help you, such as on the Adafruit web- [2] FTDI cable: # 080213-71 (5V version) and # 080213-72 (3.3V version) at
site [4]. www.elektor.com
(150387) [3] FTDI driver downloads: www.ftdichip.com
[4] Adafruit installation help: https://learn.adafruit.com/adafruit-ft232h-breakout
Access-Point. The latter mode is not yet CPS and input states. This default behav- The author used the program TeraTerm
fully implemented. Furthermore, the data ior can be configured from the app. Pro[2] and the Elektor FT232R USB/serial
is not forwarded transparently, but it has The best chance of success is achieved BoB. For TeraTerm Pro the serial connec-
to be requested via AT commands. This when you first connect the Break-out tion appears as a COM port. In setup/
means that the firmware of the Android Board (with the FT31xD) to the Android serialport you can set the baud rate. In
I/O board has to be modified. It is the device, before starting the app. Once setup/terminal you should set newline to
intension that this module will be covered Android has recognized the connection, auto and CR.
in a future article once a stable version you can start the app.
of the firmware is available. Standard classes
Elektor FT232R USB/Serial Bridge To make it easier to program your own
Elektor Android Break-out Board (# BoB (# 110553-91) app for the Android I/O board, the author
130516-91) It is also possible to directly mount an has written a number of standard classes
This Break-out Board, which uses an Elektor FT232R USB/serial breakout board to set up the Bluetooth, WiFi and USB
FT311D, was described in the June 2014 on the Android I/O board. Other modules connections. The classes are called
edition of Elektor Magazine. This board based on the FT232x can also be con- BTFunctions, WiFiFunctions, USB-
fits in the 10-way connector (MOD3) on nected, if necessary via discrete wires. Functions and USBHostFunctions
the Android I/O board. There are also In any case, these modules work with PCs (from here on called xFunctions). The
other modules available that use the using the drivers from FTDI. On Android classes have the following five methods:
FT311D. Since then, FTDI has released devices youll need a USB-host port or a
the FT312D. Whereas the FT311D can USB OTG port. Most tablets will have one void initiate(int channel, handler
operate using several protocols (including of these (even the cheaper ones), but for messageHandler <,String address>
the serial connection), the FT312D has smartphones this is less likely. In addi- <, int port>, context)
just the serial connection. This is there- tion, the Android device has to be set to void connect()
fore suitable for use with the Android I/O USB debugging mode (under settings/ void disconnect()
board. developer options/USB debugging). boolean connected()
You need Android version 3.2 or later in The Elektor FT232R USB/serial BoB can void send_command(String
order to use the USB Accessory-mode be configured to supply3.3V or 5V. command)
(and therefore to use these modules). In contrast to the FT311D board, only
In practice, it turned out that the mod- one voltage is output in this case. The In initiate you have to pass a handler and
ule didnt work with a number of Android PIC16F1938 microcontroller and the I2C the address of the Android I/O board. The
devices, despite having the correct flash memory can operate at either volt- handler is the communications channel
Android version. age. You can then choose to make the between xFunctions and the app. There
The Elektor Android Break-out Board sup- Android I/O board to operate with a 5V are two sub-channels; One channel is
plies both 5V as well as 3.3V. For small supply, if this is advantageous for the used to communicate the state of the
currents you can use the 3.3V supply I/O. With a 5V supply you should adjust connection, the other channel passes on
directly. All you need to do is to con- the values of the current limiting resis- all the data that is sent back from the
nect the top two pins of JP2 together and tors (R1 to R4) for the LEDs. When the Android board. A message handler in the
remove IC3 (the 3.3V voltage regulator PIC16LF1938 is used, the supply can only app has to receive and process this data.
on the Android I/O Board). be 3.3V. In either case, IC3 should not The address for Bluetooth is the set of
If you expect to need a larger current, you be mounted and the top two pins of JP2 6 hexadecimal numbers (separated by
should use the 5V supply. In that case, should be connected together. colons); for WiFi it is the IP-address and
IC3 should be used and the top two pins port number, and for USBHostFunctions
of JP2 should not be connected together. Board connector JP2 the port number is the board number,
The serial connection of the FT31xD chips Board connector JP2 takes care of the where 0 is the first board, 1 the sec-
requires a longer stop bit than usual. Even connections for the serial data and the ond, etc.
when it is configured for 1 stop bit, the supply for the modules. During normal
FT31xD expects a longer stop bit. If this operation, the top three pairs of pins have The (main)channel is used to distinguish
is not taken into account, youll find that to be connected together. JP2 can also be between the boards when you connect
you will receive strange characters in the used to test the microcontroller and the more than one Android I/O board. Each
Android app. The author has therefore communications module independently. connection will now have a unique num-
modified the firmware, increasing this You can connect a USB/serial converter ber, which is sent along to the message
period. This firmware is identified by the to JP2 to communicate directly with the handler. This way you can differentiate
FT31xD in its file name. module or microcontroller, using a ter- between the various data streams. When
It should also be noted that the FT31xD minal program on a PC. The left side of the app supports a single board, the value
must not receive characters from the the connector goes to the microcontroller, of this number doesnt matter. The con-
Android I/O board before the FT31xD the right side to the module. Note that text can be obtained using this.
has been enumerated. In practice, this you cant use the same cable for both With connect you create the actual con-
means that the Android board should not sides, since the TX and RX connections nection, and disconnect breaks the con-
automatically send the results, such as have been swapped over on each side nection. It is recommended that you
the time, ADC values, or changes in the (for the jumpers). break the connection whenever the app
Figure2. The screen layout of Eclipse, with the project manager (left), source editor (top, center), outline view (right),
and the consoles (bottom). Android Studio has a similar layout.
Eclipse it will ask for a workspace; its example, one option with layout files is A project can be compiled via the menu:
best to use a new, empty directory for to edit them graphically. Error messages run/run configurations, or by clicking on
this. Once youve started Eclipse you are (in text mode) shown in the left and the icon in the taskbar.
can use File/Import.../Android/Existing right of the margin. When you click on An overview of the files needed for our
Code Into Workspace to import the code. the symbol in the left margin you will be example app is shown in Table2.
Make sure that you tick Copy projects presented with possible solutions, which The overall structure of the app is shown
into workspace. can be included in the code with a dou- in Figure3. The main code is in the file
ble-click. On the left is the structure of src/com.example.EtchControl/MainActiv-
By default, Eclipse shows an overview the file. For a java file we will see the ity.java. When the app starts, Android
of the files in the project on the left (see functions and variables, along with their calls onCreate(). This is where everything
Figure2). In the middle is the source interdependencies. At the bottom are var- has to be initialized.
file being edited. For some files you will ious consoles, such as an overview of all Sending data to the Bluetooth port (for
see different tabs at the bottom, which errors and warnings, the compilation sta- example) and reading from it are done
let you edit the file in different ways. For tus of the project and debug information. in two individual streams that are com-
Android OS
GUI
Message handler
onCreate
Loop thread
IOBoardFunctions
onResume
onPause
Figure3. The structure of the example app. Figure4. Various settings in the etching app. Figure5. The control surface of the app in
portrait mode.
pletely independent. It is therefore not The communications from the main siveness when data from the Android I/O
possible (nor is it advisable) to have the thread to the thread (when a button has board has been received. When youre
code write to the stream and then wait been pressed on the GUI, for example) writing your own app, this period may
for a reply from the Android I/O board in can also take place via a message han- be longer or shorter, depending on your
some way. Instead, the reply of the con- dler. However, in this app weve used a requirements.
troller is analyzed in something known as variable as a flag. Since the thread is in A command is sent once per second from
a message handler. This message handler an endless loop, it can read the variable inside the loop that requests the tem-
is (indirectly) called by Android at the and perform specific actions, depending peratures (from the NTCs), using r b3
instant when data has been received. This on its value. and r b4. The replies, R B4 x and R B5
is represented in Figure3 by the arrows. x respectively (where x is the decimal
The data is then analyzed by inspect- The thread must not be running con- value), are sent to the message handler
ing the first few characters (for example, tinuously, since it would then take up with the tag RECEIVE_MESSAGE_CON-
GB0 is followed by the value read from all the CPU time and the Android device DATA. In the message handler the first
B0). From inside the message handler would become unusable. For this reason four characters are compared with RB4
you can change graphical elements or you have to put a Sleep in the loop of and RB5. If they match, the rest of the
call functions that do this. the thread, which causes the thread to string is converted into a temperature
sleep, giving the CPU time to deal with and stored in a variable (refer to the inset
The app also has to periodically read the all the other tasks. In this app a sleep to see how the temperature is derived
values from the Android I/O board. This time of 25ms has been used, as a com- from the measured value of the NTC).
cant be done from the main thread. With promise between CPU load and respon- Another variable is then set to indicate
Android programs its the case that while
the code in the main thread is running,
the graphical user interface (GUI) cant
be updated. More importantly, when
the main thread has run for more than
a few seconds, Android assumes that it
has crashed and will ask the user if its
ok to close it. For these reasons, you
have to create a separate thread that
runs outside of the main thread, which
periodically deals with the readings in an
endless loop. Its not possible to update
the graphical elements of the GUI from
within the thread (to update some text,
for example). This also has to be done
via a message handler. Figure6. The same menu, but now in landscape mode.
Component List
Resistors
R1,R2,R3,R6 = 100
R4,R5 = 10k BZ1
K2
1
Semiconductors
RE1,RE2,RE3 = S202S01 solid-state relay
2
NTC2
Miscellaneous
K3
1
K5
1
8
R3 RE3
(C)Elektor
2
150309-1
Figure8. The board layout for the circuit in Figure7. Take great care, V1.0
since part of the board is connected directly to the live AC line!
terface, depending on the orientation of will need to fit a heatsink to the relay. can be downloaded from[4]. If youre
the screen (portrait or landscape mode). The relays are connected to pins A6, A7 going to switch more than several hun-
The standard layout (Figure5) is in and B0. The author only had a heated dred watts, you must reinforce the tracks
layout/layout.xml. When you create an etching tank and a light box, so only two by tinning them or adding wires in par-
alternative layout in layout-land/layout. of the relays had to be mounted. This can allel. The circuit could also be built on
xml, Android will automatically use this be specified in the app. The author did an experimenters board, but then you
when the screen is in landscape mode measure the temperature of the develop- have to make absolutely sure that it is
(Figure6). ing tank with the other NTC, since it can electrically safe. In any case, the circuit
be too warm immediately after mixing, should be mounted in a fully isolated plas-
The circuit or too cold if its been out in the shed. tic enclosure.
In Figure7 you can see the circuit dia- The buzzer is connected to pin B1. This
gram of the hardware that measures the is a piezo-electric type with built in In the third installment well take a look
temperatures and controls the light box electronics. at the data logging function of the Android
and the heating elements. You can con- I/O board and explain how the firmware
nect two NTCs, one for the temperature The author has designed a single-sided can be modified and how to upload it
measurement of the developing tank, the board for this small circuit, which is shown using the bootloader.
other for that of the etching tank. Each in Figure8. The layout and the Eagle files (150309)
NTC (NTC1/NTC2) is part of a resistor
network, using resistors R4/R5. The junc-
tions of these networks are connected to Web Links
pins B3 and B4, respectively. [1] http://ww1.microchip.com/downloads/en/DeviceDoc/50002230A.pdf
[2] http://ttssh2.sourceforge.jp/index.html.en
The 230V heating elements are controlled
by solid-state relays, since mechanical [3] www.ftdichip.com/Drivers/D2XX.htm
relays that operate from 3.3V are very [4] www.elektormagazine.com/150309
hard to come by. The S202S01 used here [5] http://developer.android.com/tools/help/adt.html
can switch up to 8A. When you switch
[6] http://developer.android.com/sdk/index.html
a current of more than a few amps you
Advertisement
USB Add USB to your next project. The Easiest Way to Design Custom
It's easier than you might think! Front Panels & Enclosures
DLP-USB1232H: USB 2.0 UART/FIFO
HIGH-SPEED
480Mb/s
On
Multipurpose: 7 interfaces ly $
28.
95!
Royalty-free, robust USB drivers
No in-depth knowledge of USB required You design it We machine it
to your specifications using and ship to you a
our FREE CAD software, professionally finished product,
Standard 18-pin DIP interface; 0.6x1.26-inch footprint no minimum quantity required
Front Panel Designer
ARMed T-Board
Heres Cortex-M0+ 32-bit power
While 8-bit microcontrollers remain the need a range of supporting components, 8/16/32-bit Timer/Counter
bread and butter of the enthusiast and making them not that user-friendly 3 24-bit Timer/Counters
maker communities, there is a growing straight off the shelf they need to be 32-bit RTC with clock/calendar
interest in 16- and 32-bit microcontrol- mounted on some kind of development functions
lers. Without doubt, the most popular board to be at all useful to the enthusi- USB 2.0 interface (host and device
emerging architecture is the ARM Cor- ast, or for prototyping purposes. Sadly functionality)
tex-M a core that nearly all the major the existing development boards are not 4 Serial interfaces (USART, I2C, SPI,
manufacturers include in their microcon- designed for use on breadboards, mak- LIN)
troller line-ups. Unquestionably, the pop- ing them sometimes clumsy and hard to 12-bit DAC with 20 channels (differ-
ularity is in part driven by declining prices use in a prototyping environment. Enter ential and single-ended input; over-
(you can now buy a small Cortex-M0+ for the T-Board: specifically designed to be sampling support in hardware)
less than $1), combined with a require- plugged directly into the breadboard with 10-bit DAC
ment for more processing power, features all the pins brought out and unobscured. Inter-IC Sound (I2S) Interface
and I/O pins as interest in IoT continues If youve ever used another T-Board youll 2 Analog Comparators
to grow. Also, with Elektor Magazine run- know just how quick and easy it is to get 16 External Interrupts
ning its From 8 to 32 Bits ARM pro- up and running with a prototype! 26 GPIO pins
gramming course, the educational aspect Peripheral Touch Controller: 10 x 6
is covered too. ARMing the T-Board lines
While there are a range of ARM Cortex The ARM-equipped T-Board houses the Maximum frequency: 48MHz
development boards around, we believe Atmel ATSAMD21E18A microcontroller, an 1.62V to 3.63V supply
that the T-Board is a perfect platform for ARM Cortex-M0+. If you arent familiar
an ARM Cortex-M0 microcontroller. ARM with the ATSAMD21E18A, take a quick Thats quite a handful of features com-
chips come in small-pitch packages, and look over these specifications: pared to ye olde 8-bit micro. We felt that
this microcontroller would be the perfect (D1) protects the board against reverse that further on.
one to add to the T-Board platform: in polarity, while a PTC resettable fuse Continuing along the journey through the
addition to the specifications weve listed (F1) protects against overcurrent with a schematic, youll note the micro-USB con-
above, the pin count is manageable for 0.5amp trip-rating more than enough nector at K5. The 5-V supply from the USB
a breadboard-based board; it has a very to power the board and a few peripherals connection is of course fed into the volt-
decent 256KB of flash memory and 32KB (given that each VDD pin can draw a max- age regulator to be filtered and dropped
of SRAM; has USB support; and comes imum of 92mA). Capacitors C1, C2 and to 3.3V. Electrostatic discharge (ESD) is
in at a reasonable price point. C3 smooth and filter the supply current a threat when connecting peripherals, so
Now that weve established the What as it passes through a 3.3V low-drop- an ESD protection diode array (D2) has
and Why of the ARMed T-Board, lets out voltage regulator (IC2). Unlike the been added to protect the USB D and
delve into the details of the design. Atmel AVR microcontrollers, the ARM D+ signal lines. Weve chosen the NXP
Cortex MCUs can tolerate a maximum PRTR5V0U2X for this purpose; it comes in
The T-Board design supply of 3.8V. Hence we settled on the a tiny SMD package and is designed spe-
Figure 1 shows the schematic for the common 3.3V for the supply. Parts R2 cifically to protect high-speed data lines.
ARM-style T-Board. In common with its and LED1 combine to indicate that the Buckle up: its official name according to
AVR-based siblings, primary power is sup- board is powered. The jumpers JP1 and NXP is: Ultra low capacitance double rail-
plied through a standard 2.1-mm cen- JP2 have been placed to help with reduc- to-rail ESD protection diode.
ter-positive jack (K1). A 1N4007 diode ing the power consumption more on The fifth pin on the USB connector, USB_
IC2
LD111733CTR VCC
K1
D1 F1 JP1 JP2
1 1
R2
1N4007 500mA C1 3V3 C2 C3 LED
330R
100u 10u 100n
25V 25V
LED1
VCC VCC
PWR
R1
C5
10k
L1
100n
BLM18PG471SN1D
JP3
C7 C6 C8
RESET
Component List
Resistors Miscellaneous
SMD 1206, 1%, 0.125W S1 = switch, tactile, 24V, 50mA, 6x6 mm
R1 = 10k JP1,JP2,JP3 = jumper, 1x2, vertical, 0.1 pitch
R2 = 330 F1 = 500mA PTC resettable fuse
K1 = DC barrel jack 2.1mm pin
Capacitors K2,K3 = 14-way pinheader, SIL, 0.1 pitch
C1 = 100F 25V 20%, radial K4 = 10-way (2x5) pinheader, 0.05 pitch
C2,C8 = 10F 25V 20%, radial K5 = micro USB receptacle, 2.0 type B, SMD
C3,C4,C5,C6,C7 = 100nF 50V, X7R, 1206 jumper socket 0.1 pitch
PCB, Elektor Store # 150059-1
Inductor Alternatively: ready-assembled board, Elektor
L1 = BLM18PG471SN1D ferrite bead, 0.2/1A, Store # 150059-91
470 @100MHz
Semiconductors
D1 = 1N4007 (1000V, 1A)
LED1 = LED, red, SMD 1206
IC1 = ATSAMD21E18A-AU Figure 2. Component layout of the ARMed
IC2 = LD1117S33CTR (3.3V LDO voltage
T-Board. Dont worry, the board is available
regulator)
IC3 = PRTR5V0U2X (ESD protection diode) ready manufactured from the Elektor Store.
the power consumption of the T-Board-28 spent reading up on their systems and
(housing an ATmega328 microcontroller). architecture. Our purpose here is to intro-
The ability to achieve this kind of flexibil- duce you to the T-Board, not to dive into
ity and control was one of the key moti- the intricacies of ARM microcontrollers
vations behind the design of the T-Board we dont have nearly enough space in this
and this has not been lost in the design article, and the From 8 to 32 bits series
of the T-Board ARM. covers it comprehensively. Moreover, Via-
Jumper JP1 enables you to connect cur- cheslav Gromov who kicked off this proj-
rent-sensing circuitry to measure the ect will be covering software specifically
consumption of the board, and there- on this ARM T-Board in a future edition.
fore to assess the impact of any code With these caveats, lets get cracking.
changes and optimizations introduced to
Figure 3. This ARMed-T-Board-on-a-breadboard
reduce the current draw. The original AVR Step 1: Layout the Breadboard
is all ready to go.
T-Boards allowed you to do this; however The first step is to place the T-Board onto
we have improved on this in the T-Board a breadboard. Position it so that the sec-
ARM by including JP2. That jumper allows tion containing all the power components the same breadboard row as the cath-
you to disconnect the power LED, so that projects over the edge of the breadboard ode, and the other leg inserted into the
the draw from the LED doesnt skew your and the header pins are located on either negative power rail.
measurements. side of the breadboards central chan-
nel. Then: Figure 3 shows the board plugged onto
The physical board design 1. Connect a jumper between the GND a breadboard and all connected up Im
If youve already used a T-Board youll pin and the negative power rail of the sure youll agree that its impressive to
see the same heritage running through board. see only one jumper on the entire board!
this boards blood-lines. You will recall 2. Connect the anode of an LED to pin
that the horizontal cross-bar of the T is A07, placing the cathode in an empty Step 2: Create the Project
designed to keep the bulk of the compo- row on the breadboard. Next up is the creation of the project.
nents out of the way of your breadboard- 3. Place a resistor so that one leg is in Well work in Atmel Studio 6.2 for this
ing, while the vertical stem breaks the
microcontrollers pins out in a way that
makes it straightforward to plug into the Alternative IDEs
breadboard and access them.
When you start working with ARM microcontrollers, youre playing in the big
league when it comes to Integrated Development Environments. There are a
The T-board is of course open source in
range of developers who provide what seem to be fairly solid tools but its out of
the spirit of sharing, and the design files
the scope of this article unfortunately to draw full comparisons between what are
are downloadable for you if you have the
complex pieces of software. To give you a taste of whats out there, here are three
equipment and wherewithal to make your
of the more popular ones.
own board [3] using the parts list and the
board layout in Figure2. If you arent
Atmel Studio 6.2
feeling quite brave enough to tackle the
This in my mind is the first choice for those not professionally developing on ARM
0.8-mm pitch of the ARM microcontrol-
microcontrollers. It is free, is not code-limited, and is written and supported by
ler TQFP package, or the invisible pins
Atmel themselves, hence is guaranteed to support not only the microcontrollers
of the USB connector, then the board is
but also the Atmel programmers and debuggers. www.atmel.com/atmelstudio
available through the Elektor store, fully
assembled and tested, and ready to be
IAR Embedded Workbench for ARM
plugged into your breadboard.
IAR have a wide range of professional-level IDEs and of course at professional
prices! They support Atmels AVR and ARM microcontrollers, as well as a range
ARMed-n-ready
of ARM and non-ARM MCUs from other manufacturers. If you work with a range
Im sure youve heard enough about
of microcontrollers from different manufacturers, then this may be a good bet if
the design and want to see the board in
you can afford it. There are code-limited versions, but so limited that they are
action! Lets keep this project straight-
more useful for assessing the tool than for any practical projects. www.iar.com/
forward to illustrate the use of the board.
iar-embedded-workbench/arm
To explore more complex projects, turn
back to the series From 8 to 32 bits: ARM
Keil
Microcontrollers for Beginners that made
Keil MDK-ARM is an IDE that is owned by ARM itself, and is a respected tool for
its debut in the January & February 2015
development of ARM projects primarily aimed at professionals. However, Keil do
edition of Elektor Magazine.
offer a lite edition of their MDK-ARM tool that is code-limited to 32KB probably
Working with ARM microcontrollers is
enough for most enthusiasts and hobbyists. If you have the time to spend, and
definitely more complex than with AVR
want to explore ARM micros from other manufacturers, then its well worth looking
microcontrollers. If youre new to them
at. www.keil.com
they require perseverance and some time
Web Links
[1] Atmel USB 2 GO:
www.atmel.com/Images/Atmel_11201_USB-OTG-Like-Connector-Implementation_SAM9G-SAM9X-SAMA5D3_Application-Note.pdf
[2] T-Boards low power article: www.elektormagazine.com/140413
[3] Project resources page: www.elektormagazine.com/150059
[4] Atmel Studio: www.atmel.com/tools/atmelstudio.aspx
[5] www.der-hammer.info/terminal/
5. Finally upload the program: choose challenge you to take one of the previ- ingA and the inset: My/Your/The/A First
Start without Debugging from the ous projects in the From 8 to 32 bits Project on the next two pages.
Debug menu. series and use the T-board in place of the We hope that you enjoy using the ARMed
6. You should now see a blinking LED! Xplained Pro board. Youll cut down the T-Board both as a learning tool and a way
number of jumpers, making the projects to get your next project prototyped and
The next steps easier to design and troubleshoot. running more quickly!
Now that youve seen the T-Board in Meanwhile, co-designer Viacheslav here (150059)
action, youre probably chomping at the presents another kick-off program spe-
bit to start additional projects. If youre cially written on the occasion of this
new to ARM Cortex microcontrollers, Id hardware dominated article: see List- Mind U! ...continued overleaf
//Function Prototypes
void configure_port_pins(void);
while (1)
{
//Nothing needed here as we are using interrupts to toggle the LED
}
}
1. The Hardware
FigureA shows how the external parts
connections to the ARMed T-Board, Fig-
ureC, the practical realization. With all
E F
parts connected up, you can use a USB-A
connector to USB Micro-B connector cable
to connect the T-Board to your PC. This
type of cable is often used for charging
smartphones or tablets, so you should
have one ready to hand. You also need to
connect a debugger like Atmel ICE to the
T-Board on the SWD (Debug) connector
and of course also to your PC (FigureB).
2. The Software G H
First, download the Atmel Studio project
Next, open it in Atmel Studio6, which can send later to the board with the ter-
named First_T-Board_project from [3].
you can download under [4] after a minor minal program. For each of the three let-
registration or as a guest, if you havent ters there is a case. The number of the
installed it yet. If you are not familiar case isnt the letter, its the ASCII-num-
PA08
with the Atmel SAMD family and/or At- ber for the letters: 76 stands for L, 66
mel Studio look in our ARM Microcontrol- for B and 84 for T. Please note that
PA03 lers for Beginners course. these are all capital letters.
In the first case, 76, there is an else-
1k
PA01
1%
PA00
The program starts with the declarations if statement which turns the LED on,
220R
of the variables and arrays, function pro- when variable number is 1, and off, when
VCC totypes and configuration-functions for number equals0. The variable number
GND LM335
the peripherals. After that, in the main gets the (second) character from the USB
function, the system, the interrupts and with number = udi_cdc_getc(); be-
the delay-functions get initialized and all fore this. Also, LED is on and LED is
the configuration-functions get called. off will be sent with udi_cdc_write_
ListingA shows the endless loop with buf(&buffer, x) over the USB. For
A the main part of code. The whole code is arguments it needs only a pointer to a
in a switch statement which receives string with the data (buffer) it has to
one ASCII-character with udi_cdc_ send, and the number of characters due
getc()on the USB and chooses the cor- sending (x). But here, we dont use a
rect branching to follow. In TableA you pointer to a buffer to keep things sim-
can see all characters (combinations) you ple, we embed a text like LED is on
B
Table A. Mini Command Set
1 Sending L1 (for: LED) causes the LED to be switched on and you receive a
L message LED is on. Sending L0 switches the LED off and you get LED is
0 off. Sending L with a number other than 0 or 1 returns: Error.
Sending B (for: Button) causes the T-Board to respond with Button is
B
pressed or Button is not pressed.
Sending T (for: Temperature), causes the T-Board to emit a string with the
T
C currently measured temperature x, like: Temperature: x C.
direct into the command like this: udi_ as described in the first part of the ARM D21E18A) by Device like in FigureH.
cdc_write_buf(LED is on\n , course. You also need to select a GCC C After you pressed OK once more the
10);. The \n stands for new line. If this ASF Board Project under File/New/Proj- cproject is generated. Now you can im-
variable is found to contain another value ect (FigureG), but in the next step, port the ASF libraries you need in the ASF
than one or zero, Error will be sent to after you pressed OK, its different Wizard and write your code!
the computer. you now need to select our MCU (ATSAM-
In the next case, 66, an if statement
processes the state of the button pin, Listing A. The endless loop of our get-u-going program looks like this.
PA01, with: port_pin_get_input_
while(1){
level(PIN_PA01) and sends either
switch (udi_cdc_getc())
a Button is pressed or Button is not {
pressed message over the USB. case 76: //if received "L"
The last case, 84, measures the voltage number = udi_cdc_getc(); //get the second character (a number)
on ADC channel 16 (PA08) supplied by if (number == 49) //if received a one
the LM335, and calculates the tempera- {
ture from this voltage. A string like Tem- port_pin_set_output_level(PIN_PA00, 1); //put the LED on
perature: x C gets sent over USB in a //send "LED is on" with a "new line" on USB
more circumstantial way due to the spe- udi_cdc_write_buf("LED is on\n", 10);
}
cific requirements of the float-tempera-
else if(number == 48) //if received a zero
ture-value described in the ARM Course.
{
port_pin_set_output_level(PIN_PA00, 0); //put the LED off
3. The First Test //send "LED is off" with a "new line" on USB
Lets try it out! Please select your debug- udi_cdc_write_buf("LED is off\n", 11);
ger above on the right and start com- }
piling and transfer the program with a else //if received a wrong number (not 1 or 0)
click on the green Start Without Debug- {
ging-button (FigureD). After the MCU udi_cdc_write_buf("Error\n", 6); //send "Error" and a "new line" on USB
is programmed, the T-Board will register }
on your computer as a Communication break;
case 66: //if received "B"
Device Class ASF example yep, a vir-
if(!port_pin_get_input_level(PIN_PA01)) //get the level on PA01 (button)
tual serial interface. Maybe your comput-
{
er needs some time to install the right
//if pressed, send "Button is pressed" and a "new line" on USB
drivers. After its done, you can open udi_cdc_write_buf("Button is pressed\n", 18);
the device manager on the PC to see }
which COM port numbers been assigned else
to your T-Board under Ports (COM & {
LPT). Now open a terminal program like //if not pressed, send "Button is not pressed" and a "new line" on USB
HTerm [5], and set up the comms like in udi_cdc_write_buf("Button is not pressed\n", 22);
FigureE: }
break;
case 84: //if received "T"
COM port number (see Device
adc_start_conversion(&adc_instance); //start ADC-conversion
Manager)
//read and save the conversion result
9600 baud
while(adc_read(&adc_instance, &data) == STATUS_BUSY){}
8 data bits //calculate the temperature
1 stop bit temperature = (25 + (data * 0.000805 - 2.945) / 0.01) * 100;
no parity //reformat the result in a buffer
new line on LF sprintf(temperature_string, "%i", temperature);
//send "Temperature:" with USB
With all settings adjusted and DTR On, udi_cdc_write_buf("Temperature: ", 13);
connect with the board and test it with //send the temperature on USB
our command-capital letters like in Fig- for(i = 0; i < 4; i++){
if((temperature >= 1000) && (i == 2)) udi_cdc_putc(44); //make a comma
ureF. Congratulations, your first project
if((temperature < 1000) && (i == 1)) udi_cdc_putc(44); //make a comma
with the ARMed T-Board is running now!
udi_cdc_putc(temperature_string[i]); //send a digit on USB
That was all copycat though now on
//send "C" and"new line" on USB at the end of transmission
with building a new project. if(i == 3) udi_cdc_write_buf(" C\n", 3);
}
4. Create a new project with the break;
ARMed T-Board & Atmel Studio }
The project generation is nearly the same }
Building your own amplifier is not as pop- ence the market too; do-it-yourself ampli- inally designed 15years ago to be a small
ular as it used to be, possibly because fier designs were popular in the disco and cheap discrete-transistor module that
sophisticated designs with exotic audio era, when there were cost savings to be could pack a healthy punch for its size.
transistors can work out as expensive made. Perhaps then, low cost is the key The circuit was designed around the best
as ready-made stacking separates from to making home construction attractive. cost/power ratio transistors available at
China. Of course, changes in fashion influ- Enter the 60-watt compact amplifier, orig- the time, the BDW93C/94C Darlingtons,
Specifications
Input sensitivity: 0.2 Vrms (alternatively 1Vrms; see text) Signal to noise ratio: >90dBA
Input impedance: 7k (or 14k with lower gain option; THD + noise: 0.045% at 1kHz (10W/4)
see text) Damping factor: >250 (1kHz)
Sinewave power: 4 60W, THD+N = 1% (>1300 at lower gain see text)
8 36W, THD+N = 1% Quiescent current: 33mA (complete amplifier)
Bandwidth: 20Hz 80kHz (-3dB)
R7 +24V
1k
LD1 C6 C7
R5 R9 R14 R16
100R
10k
2k2
5k6
100n 470u
TR12 35V
TR1 BC560C
P
C3
BC560C TR7
R3 D1
39p BDW93C
2k2 R11
1N4148
8k2
TR10 R21 ... R28 = 0W6
TR3 TR4
TR9 R17
390R
2x R21 R22 R23 R24
BC550C BC R18
L1
*
270R
550C
1R
1R
1R
1R
C1 R1 R2 R13 R29
BC550C
2k2 4k7 470k 3R9
R25 R26 R27 R28
1u (4k7) (10k) (180k) C5 0W6
(0u47) R19
270R
RV1 BC LS1
1R
1R
1R
1R
R4
2k2 560C 100n
TR5 TR6
C2 C10 R20 R30
IN
470k
R12 390R
3R9
(560p) 1n 100n 2x
3k3
(180k) TR11 4-8
BC560C 0W6
D2
S P
SIG GND
C4
1N4148 BDW94C
TR2 TR8 PGND
39p
P
BC550C BC550C
TR13
LD2 C8 C9
R6 R10 R15 R31
100R
10k
2k2
5k6
100n 470u
R8 35V
1k
24V
and 15years on, they are still readily ple design. In addition, the input capac- ronment, where the prototype showed
available and as cheap as ever at the itor now serves double duty, providing no signs of instability.
time of writing, a set of output devices will both AC coupling and reducing DC gain In the past, most amplifiers were
cost you only 1! Those seeking ultra-low to unity. designed with relatively low input sensi-
distortion figures should look elsewhere In fact, all frequency dependence is kept tivity (1Vrms) for connection to line level
but if good quality, low cost, small size outside the feedback loop here, the signal sources. You can build the amplifier that
and easy construction are important to being completely pre-conditioned by the way if you wish (use the component val-
you, read on... existing passive input network to save a ues shown in parentheses for a gain of
few more components. 12 or 22dB), but lets face it, nowa-
Into to the circuit The basic amplifier, therefore, operates days line-level sources are less common
The circuit is shown in Figure1. Its con- with high gain to frequencies beyond the than low-level headphone outputs from
ventional in layout, a fully symmetrical audio band and it will be noticed that smartphones and tablets.
design with single pole frequency com- aside from the 39-pF frequency compen- How many of you have connected one
pensation, but a few unusual steps have sation capacitors and some basic decou- of these devices to your Hi-Fi, only to
been taken to reduce component count. pling, the design is not festooned with find its barely audible, even at full out-
First, the amplifier is wired in the invert- mysterious RC networks for stability. put? The circuit as presented has a gain
ing configuration, rather than following Despite this, the amplifier has a theoreti- of 36dB (67) which allows full power
more conventional non-inverting path. cal phase margin of 40 and the compact from a typical modern headphone out-
Consequently, speaker polarity must be PCB layout keeps parasitics to a minimum put (0.2Vrms) the damping factor is
reversed, but inverting amplifiers dont think of it as a discrete power op-amp. adversely affected at higher frequencies
have to work as hard at correcting open- All measurements for this article were but its really most important in the lower
loop phase shifts as their non-inverting made with partially unshielded test leads registers anyway.
brethren a definite bonus in a sim- in an electrically noisy workshop envi- Another point of interest is the LED bias-
a b
Figure 2. THD vs. frequency response (2a) and THD vs. output power response Figure 3. The protection locus is effectively
determined by the amplifier loading and the
power transistors SOAR specs.
ing for the current sources LEDs gener- tion figures for several practical bene- arate from a well-known (high quality)
ate lower noise than zener diodes, elim- fits, including lower wasted energy (not manufacturer, demonstrating tight bass,
inating two bypass capacitors, and they just politically correct but also saves on accurate detail and a transparent vocal
have lower thermal drift to boot! the heatsinking) and the ability to drive midrange.
Further cost and space saving is found the output stage with uncooled TO-92s.
in the power devices emitter resistors, Protection and supply
where standard 1- types are paralleled, Performance 60watts (65watts at 10% THD) from
giving a secondary benefit in the form of Despite the less ambitious transistors TO-220 output transistors is driving these
lower inductance than the conventional used, audio quality is good, Figures2a devices hard and so good heatsinking is
wire-wound choice. The output devices and 2b showing the usual graphs. In important (see below). In circuit terms,
themselves are operated at low quiescent subjective listening tests the prototype this means overload protection is not con-
current, sacrificing insanely low distor- rivalled an expensive Hi-Fi stacking sep- sidered a luxury here. Conventional single
Components List
Resistors
R1 = 2.2k (4.7k)
R3,R5,R6 = 2.2k
R2 = 4.7k (10k)
R4,R13 = 470k (180k)
R7,R8 = 1k
R9,R10 = 5.6k
R11 = 8.2k
R12 = 3.3k
R14,R15 = 100
R16,R31 = 10k
R17,R20 = 390
R18,R19 = 270
R21R28 = 1 0.6W
R29,R30 = 3.9 0.6W
RV1 = 2k preset, vertical
Optional: 2 pcs 150 4W resistor for use
during setup
() = value for lower gain
Figure 4. Printed circuit board layout shown at a scale of 150%.
Capacitors
C1 = 1F (0.47F)
C2 = 1nF (560pF)
C3,C4 = 39pF
C5,C6,C8,C10 = 0.1F Miscellaneous:
Semiconductors:
C7,C9 = 470F 35V radial Heatsink (see text)
D1,D2 = 1N4148
() = value for lower gain Mounting kits for TR12 and TR13
LD1, LD2 = 2mm x 5mm 2.1Vf red LEDs
9 wire links on PCB
TR1,TR5,TR6,TR7,TR11 = BC560C
Inductors PCB
TR2, R3,TR4,TR8,TR9,TR10 = BC550C
Suitable power supply, including 2A quick-
L1 = 10 turns 1-mm diameter enameled cop- TR12 = BDW93C
blow fuses in 24V lines (see text for
per wire, inside diameter 5mm TR13 = BDW94C
recommendations)
slope circuits are used. The protection circuits (over 6A with a speaker load)
locus is shown in Figure3, where it can giving a total module dissipation of 72W.
be seen there is good leeway for induc- Assuming a maximum ambient tempera-
tive and lower than advertised resistive ture of 40C and good quality thermal
speaker loads (down to about 3.1). The insulating washers yielding 0.5K/W per
amplifier should also be protected with transistor, the heatsink will be 18C
2-A quick blow fuses in the supply leads. cooler than the device cases, giving it
A conventional unregulated power supply a maximum temperature of 69C, an
is sufficient, a 100-VA 18-0-18V trans- increase of 29C over ambient. Thats a
former, bridge rectifier and two 10,000- 0.4K/W heatsink.
F capacitors will supply a stereo pair. Thats a big heatsink. Another approach
It is advisable to tin the high current PCB is to use something smaller, more suited
Figure 5. Do not skimp on the heatsink!
tracks those related to the output tran- to music signals.
sistors collectors and emitters and the 1.2K/W should be sufficient. A 70-C
speaker load and power ground but bimetallic switch fixed to the heatsink
beyond that, construction is straightfor- and wired to disconnect the speaker
ward; aside from fitting the nine wire when things get too hot would give peace
links, taking care to avoid solder bridges of mind and possibly allow you to use
on the compact PCB (Figure4, shown something slightly smaller still. This is a
scaled at 150%) and ensuring that the compact amplifier after all. A fan would
flat side of the amplified diode (TR9) is help too.
in firm contact with the main heatsink What about one of those CPU heatsink/
(thermal epoxy is recommended), there fan assemblies? The maximum tempera-
is little to say. tures and power dissipations of current
Intel/AMD chips are similar to what were
Mind the heatsink looking at here. The prototype was fitted
How large should the heatsink be? Its to a plain aluminum heatsink of unknown
Figure 6. Low in aesthetics but definitely okay for
a subject thats often skimmed over rating (it felt right) which proved ade-
keeping the power transistors cool.
or ignored completely, but inadequate quate for one module without a fan and
heat-sinking is probably the number one suitable for a stereo pair with (gentle)
cause of unreliability in home built ampli- forced cooling, see Figure5.
fier designs! Theres a reason why its
poorly discussed. Its because its one One last point on cooling. The transistors In-line fuse holders (20-mm glass fuses
of those things theres no correct answer tabs are connected to their collectors and were used for the prototype if you are
to. Do you heatsink for sine waves or for need to be electrically isolated from the using more than one module, each will
some sort of standardized music signal? heatsink. We assumed in the last para- have to be fused separately) are a good
What degree of reactive load element graph the use of thermal washers giving idea for the 24V connections.
do you consider? Under what ambient a performance of 0.5K/W. Youll have to
temperature do you plan to operate and be careful to achieve that. Mica washers Before its first power-up, the prototype
what kind of thermal insulation wash- with a thin, even coat of thermal grease was checked very carefully for shorts on
ers will you use? Ultimately you have to on both sides are recommended; if you the PCB, the fuses temporarily replaced
make a subjective decision and either use the grey/pink glass/silicon variety with 150- 4-W resistors and RV1 set
take the belt and braces approach or be be wary some of them are rated for fully clockwise (no speaker connected!).
practical and risk failure under unlikely high voltage isolation rather than good Once switched on, the output should be
conditions. During testing the output Dar- thermal performance (they can be ten close to zero volts (just a few mV off-
lingtons were allowed to overheat and times worse than mica). Be sure to use set on the prototype) and RV1 should
fail, the only damage being to themselves bushes of the correct depth and screw be adjusted until the temporary 150-
and the power supply fuses no fused the transistors down good and tight (till resistors are dropping 5V each, for a total
PCB tracks or cascade failures resulted a bead of thermal grease has oozed out quiescent current of 33mA (RV1 was then
and the damage was limited to about 1. all around) see Figure6. at mid-travel on the prototype). Assuming
The limiting factor is the maximum all that went well the temporary resistors
permissible temperature of the output Construction hints can be replaced with fuses, the module
devices (itself another subjective decision, Once construction is complete the mod- tested with music signals then cased up
unless you want to use DC dissipation ule(s) must be wired to the power sup- and put into service.
values and thats like belt, braces and ply. To avoid hum, the center tap of the (150183)
duct tape...). The BDW93/94 should not supplys capacitors should be used as the
rise above a case temperature of 87C in common system ground point, the PCBs
this design (40W DC, higher for pulses). power and signal ground connections
Under short-circuit conditions the current being taken back to this point by separate
is limited to about 3A by the protection wires (a stout wire for the power ground).
A few years ago I needed a function gen- sand pages to elucidate their devices, a maximum output frequency of 37.5MHz
erator for my home laboratory. In my Analog Devices manages to fit a com- (half the clock frequency). The downside
job I had worked with some expensive plete description of a complex microcon- of such a fast clock signal is a frequency
commercial models and initially I had troller into a document of slightly more resolution of just 0.28Hz owing to the
planned to buy one of these. However, than a hundred pages. Analog Devices chips 28-bit integer frequency divider.
none of them really was what I wanted also specializes in DDS chips, operational That doesnt sound like a big deal, but
too complex for simple use and so I amplifiers and other analog support chips it does equate to almost 0.6% at 20Hz.
decided to design and build my own. It and so made for a great one-stop shop To improve this, the clock frequency can
turned out to be DDS (direct digital syn- for this project. Their friendly sampling be lowered, albeit at the expense of the
thesis) based but that was not the only service quickly got me started without maximum achievable output frequency.
component selection issue I ran into. Here forking out a lot of money. At 1MHz for instance the resolution
are a few more. The MCU I selected was the ADuC7024B- becomes 0.004Hz, which corresponds
STZ62, a member of the Precision Ana- to an error of 0.005% at 20Hz, but the
My components, your log Microcontroller family in a 64-pin maximum frequency is then down to a
components? package, containing an ARM7TDMI core measly 500kHz. In this project the DDS
After researching various techniques I running at 44-MHz clock speed. These clock frequency is 75MHz to ensure a
settled on a Direct Digital Synthesis (DDS) MCUs are called analog because they relatively clean signal up to 10MHz; res-
based architecture for my project. DDS feature analog inputs and outputs (yup, olution was traded against range.
employs a digital oscillator with quartz ADC and DAC) and an analog compara-
crystal precision to accurately generate tor. Besides, they sport PWM, timers and The user interface is an important part
sinewaves up to very high frequencies. standard serial ports (SPI, UART, IC). of any instrument and so I spend a lot of
For the microcontroller I chose one from Our micro has 8KB of RAM and 62KB of attention on this. I added a graphic dis-
Analog Devices. Although well known flash memory that can be programmed play and a bunch of pushbuttons to allow
for their Digital Signal Processor (DSP) in-circuit over a serial port. Note that easy navigation through clear menus and
families, this may not be the first MCU some types use IC for flash memory options. Two multiturn potentiometers are
manufacturer that comes to mind. They programming, so make sure you get the used for quickly adjusting the output sig-
do have a nice family though of 32-bit specified type and not one with a slightly nals amplitude and DC offset. For the
ARM controllers supported by something different part number. display I used a cheap cellphone replace-
I like a lot: comprehensive documenta- The DDS chip for the project is the popu- ment display, the Nokia 6100, thats
tion. Unlike other MCU manufacturers that lar AD9834. The maximum frequency of well-documented by the open-source
sometimes need more than one thou- the external oscillator is 75MHz, allowing community on the internet. Unfortunately
this display exists in two variants (Epson this problem I wrote two versions of the aluminum enclosure from Hammond.
and Philips) that are not fully compati- software to support both types. The result is a very stylish instrument
ble. Even more inconveniently, in most Because looks are important too, when that has won a preeminent place on my
cases you cannot specify the type you the electronics were completed I built the electronics workbench.
want when you buy it. To work around generator into a nicely milled standard
The circuit The passive parts around DDS chip IC3 of a higher order one was simplicity. Also,
Figure1 shows the schematic of the DDS are as recommended by the manufac- as we will see later on, a high-order filter
function generator. The signal generating turer. Its output is filtered by RC network was not really necessary.
part is at the top, the lower part shows R16/C18 before being amplified by IC5.A. The output signal from IC5.A follows two
the microcontroller and the user interface. The reason for such a simple filter instead paths. The upper path is used for sinusoi-
DVDD
P1.2
C31
DVDD DVDD +3V3 DVDD AVDD 2
VDD R26
Triangle, Sinus 6
S2 A 100n 2k
K5
1 IC7 5
C13 C14 IN D IC8 R32
R18 3 3
1.8V p-p 4 ADG779 100R
2k R21 S1 P2 2 6
D 100n A 100n C15 GND AD811 R33
499k 1k 2
5 4 D A 3 100R
2 Square (0:0) 1
DVDD AVDD 10n A A A
CLK 14 3 1 6 R27
SCLK COMP R16 IC5.A
MOSI 13 19 0.6V p-p 3 7
IC5.B
220R
SDATA IOUT 910R R22
CSL 15 5 R19
FSYNC IC3 1k 1.8V p-p R29
11 17 R17
910R
DVDD RESET VIN C18 10R
C22
1k2
AD9834 C21
8 1.41V p-p
IC4 4 MCLK 10p IC9 C24
6 16 R20 R25 2 220u 25V
VDD CAP/2.5V SINGBIT 100p R28
1 3 9 1 A 6 C23
910R
OP1177
1k2
EN OUT FSELECT FSADJ 10k 100n
10 20 3
GND PSELECT IOUTB
12 2 A 220u 25V
OSC 2 SLEEP REFOUT 6
R14 R13 R15 R30 +15V A
75MHz DGND AGND 2 7 +1V25
C11 C12 C16 C17 R23 IC6.B 10k
200R
200R
6k8
7 18 1 5
IC6.A 1k +15V
3 1
1u 100n 100n 100n
V+
R24 IC10
D A AVDD 499k 3
NC C26 C28
DAC0 0V-2Vmax
V ADR1581 7 7
+3V3 1 P1 100n 100n
2 IC8 IC9
K4 2 C27 A C29
1 8 C30 8 C19 8 C20 4 4
A
IC2 = AD8032ARZ +15V IC2 IC5 IC6 1
+1V25
2 100n 100n
3 10k
IC5,IC6 = AD8042ARZ 4 100n 4 100n 4 100n V+
3 IC11
4 3
NC
A 3
POWER 15V
15V 5 1 V ADR1581
IC2.A 2
ADC0 7 2
IC2.B R31
6 1V25
10k
R37
15V
AVDD DVDD 1k R36
10k
DVDD
K1
C2 C1 C3 C4 C5
R1 +15V
1 10
VCC VLED+ 220R
10u 100n 100n 100n 10u 2 9
RST VLED 0W75
A D 3 8
DATA GND
4 Nokia 7 D
CLK NC
R3 5
6100 LCD 6
60 59 20 42 CS VCC
IOVDD
IOVDD
AVDD
DACVDD
1k
37 38 DVDD
P3.6 P3.7
ADC0 61 27
ADC0 P0.3/TRST
62 29
ADC1 P3.4
63 30 R5 R6 R7 R8 R9 R10 R11 R12
ADC2 P3.5
64 31
10k
10k
10k
10k
10k
10k
10k
10k
ADC3 P0.4/IRQ0
1 32
ADC4 P0.5/IRQ1
2 43
ADC5 P4.0
3 44
ADC6 P4.1
4
ADC7 IC1 P4.2
51
5 52
ADC8 P4.3
6 53
ADC9 P4.4
DAC0 9 54
DAC0/ADC12 P4.5
10 13
DAC1/ADC13 P4.6
56 14
DACREF P4.7
P1.2 48 16 S1 S3 S5 S7
P1.2 P0.6 VCC
47 18 TDO
P1.3 TDO
CLK 46 ADUC7024 11 TMS S2 S4 S6 S8
P1.4/IRQ2 TMS VCC
45 36
P1.5/IRQ3 XCLKI 6 4 2
MOSI 40 35
P1.6 XCLKO K3
CSL 39 34 D
P1.7 P0.7 JTAG
23 33
P3.0 P2.0 5 3 1 DVDD
24 12 TDI R2
P3.1 TDI GND
25 17 TCK
P3.2 TCK
1k
26 8
K2 P3.3 ADCNEG VCC DVDD
JTAGVCC
1 50 15
RXD P1.0 P0.0/BM
2 49 28
TXD P1.1 RST
55 21
DACGND
GNDREF
DGND
2 JP2 2 JP1
C7 C6
58 7 57 19 41 22
RESET DOWNLOAD
470n 470n
1 1
A D
150210 - 11
Figure 1. The signal generators main circuit board contains everything except the power supply.
dal and triangular waveforms (IC3 can do adds this DC voltage to the output signal.
both). This path is connected to input S2 The output signal is fed to one of the
of IC7, a CMOS single-pole, double-throw microcontrollers analog inputs (ADC0)
(SPDT) switch that provides very good after scaling and removal of the DC offset
isolation between its two inputs and the (IC2). The purpose is to monitor the level
output. The lower path is used when the of the output signal as indicated on the
output waveform of the generator must display. Refer to [2] for measurements.
be square and it is connected to input The circuitry around microcontroller IC1
S1 of IC7. is quite self-explanatory: eight pushbut-
The squarewave is created by gener- tons, a graphic LCD, a number of decou-
ating a triangular signal and passing it pling capacitors and some headers, thats
through IC5.B and IC6.B that are wired all there is to it. The MCU runs from its
up as relatively fast comparators with internal oscillator so no external quartz
Figure 2. One period of a 1.00-MHz square wave
proper amounts of hysteresis. The refer- crystal is required.
(50% duty cycle) at almost maximum output
ence voltage needed by the comparators Note the JTAG connector I used for pro- with potentiometer P2 a 10-turn, 1-k type.
comes from one of the analogue outputs gramming and debugging the software.
(DAC0) of the microcontroller, buffered The serial port is also accessible for folks
by IC6.A. This allows for precise control forced to use the MCUs bootloader to
of the square waves duty cycle. program it. JP1 lets you make the MCU thats almost completely populated with
The output of IC7 drives potentiometer start in bootloader mode. surface-mount devices (SMDs), the power
P2 and then gets amplified by high-speed The power supply (Figure3) is a clas- supply was built from through-hole com-
video op-amp IC8. This amplifier is fast sic design built around LM317s and an ponents from the Elektor.Labs Preferred
(2500V/ms slew rate) and is capable of LM337. Together they produce a sta- Parts (ELPP) list.
driving low-impedance loads. Note that a ble 15V needed for the analog output A single transformer is used with two
through-hole type was used here so that stage, and a clean +3.3V for the rest secondary windings of 15V/5VA each.
it can be replaced easily in case it gets of the circuit. Contrary to the main PCB 10VA or so is enough to power the DDS
hurt by a tragic lab mishap.
The peak-to-peak level or amplitude of
the output signal is adjusted by P2. Due C15
240R
1
C16
nal. The pots cut-off frequency is related 10n
C17 C18 C20 C21
10u
used for clean high-frequency sinewaves 50V
2k0
R4
at the output of IC3 and including the C10 +15V
(115)
F1
10u
15V
C6 C8 50V C12 C14
width and contribute to some degree to
C3 R3
1000u 10u
the low-pass filtering of the output signal. 100mA T
(115VAC; 200mA T) 10n 50V
100n
50V
100n
180R
FL10/15 D3 1
This is why only the first-order RC-filter 2x 15V / 10VA F3 ADJ
2 3
R16/C18 was explicitly added. Also, if D4
R7
315mA T LM337
a high-order filter were used instead, a
IC2
10k
C4 15V
third path would have been necessary to
10n
LED1
convey the triangular waveform, making
POWER
the design more complex. 150210 - 11
generator. To minimize power loss in the age of the Schottky diodes is less than The software
3.3V regulator a separate rectifier (D5/ 0.45V whereas a classic 1N4007 would The source code was written in C using
D6) with a relatively small filter capac- drop almost twice as much. the well-known Vision integrated devel-
itor is used (C17/C18). The high ripple Printed circuit boards were designed for opment environment from Keil. A real-
voltage that remains reduces power loss both the main circuit and the power sup- time operating system (RTOS) was not
in regulator IC3 somewhat. ply. The main board was given special used to keep things simple.
Schottky diodes are used in positions D1 attention in order to keep the output sig- The code consists of only a few files.
and D2. At maximum load the voltage nal away from any interference produced Some of them are header files contain-
drop across normal diodes together with by high-speed digital control signals. Most ing definitions and function prototypes,
the ripple on C5 cause the input voltage parts by far are SMD but assembling the the others contain the functions itself.
of IC1 to come perilously close to its min- board should not pose problems as long Two of them are to support the two dif-
imum value. At 0.5A the forward volt- as you wear strong glasses. ferent graphic LCDs, the file main.c con-
Figure 4a. Component overlays of the generator PCB (double-sided SMD populated).
tains all the signal generator code. The that appears at power up. No tricks were too difficult as long as you have good
file init.s is written in assembly language needed to fit all this in the MCU because eyes and/or a magnifying glass. Note that
and contains the functions to initialize its flash memory is large enough for the the pushbuttons and the LCD must be
the microcontroller. This file was written purpose. mounted on the bottom side of the PCB.
from scratch and is not part of the devel- The software archive for the project can The LCD requires some special attention
opment environment. be downloaded FOC from [1]. as its flexible flat cable must be detached
The LCD driver is partly based on open from its plastic support (Figure5) so that
source code found on the Internet and Building it it can be folded over the PCB and reach
partly written by myself. Since the dis- Two PCBs have been designed to hold all K1 (Figure6).
play is not connected to a hardware SPI the parts; they are printed in Figure4 The two potentiometers should stick
port, the communication protocol is emu- along with the component lists. As men- through the PCB with the shaft protrud-
lated and bit-banged on GPIO pins. The tioned, assembling the main PCB is not ing from the bottom side. At Elektor.Labs
functions WriteLcdCommand and WriteLcd-
Data take care of this. Most of the display
driver coding effort went in creating two
fonts, a large and a small one.
The keyboard is handled by polling in the
main endless loop.
To keep code size small and IDE-inde-
pendent, an attempt was made to avoid
using floating-point arithmetic and math
libraries.
All source files have been compiled into
so-called ARM thumb code (16-bit code).
Not so much reducing the size of the hex
file, but because the flash memory of
the microcontroller is 16-bit wide, making
16-bit code faster to execute. The total
size of the executable is about 8KB plus Figure 5. On the left, the display as used in some mobile phones of a well-known Scandinavian brand
another 20KB to hold the splash screen (aint Ikea), on the right the same display adapted for our generator.
Semiconductors
D1,D2 = STPS2L60, DO-41 case
D3,D4,D5,D6 = 1N4007, DO-41
case
IC1,IC3 = LM317, TO-220 case
IC2 = LM337, TO-220 case
LED1 = LED, green, 3mm
Miscellaneous
K1 = 2-way PCB screw terminal
block, 0.3 pitch, 500V Figure 4b. Component overlay of the power supply PCB (single-sided TH populated).
Programming
Before the signal generator will work
it must be programmed with the right
firmware. Because of the two possible
LCD configurations, two pieces of firm-
ware are available from our website [1].
Since you cant tell the exact type of the
display by looking at it, it is a matter of
trial and error to find the right software.
Nota dicky bird from the function gener-
ator after programming the MCU? Try the
other firmware. No wave either? Uh-oh
There are two ways of programming the
Figure 8. The prototype built at Elektor.Labs by Jan Visser. All cutouts were done with a 100 K CNC MCU: JTAG or bootloader.
machine simple tools, care & patience. The first option requires a JTAG adapter
User Manual
PB Function PB Function Set again to stop the sweep (sweep stop is displayed
S1 Set S5 Down in the first line) and new values can be set. Press Sweep
to return to the main menu.
S2 Right S6 Mode
Contrast Press Calibration to open the calibration
S3 Left S7 Sweep
menu where the LCD contrast can be set. Use Set to
S4 +Up S8 Calibration navigate to the contrast option, then use +Up and
Down to change the contrast level. Press Calibration to
Waveform Press Mode to toggle between sine, square return to the main menu.
and triangle. Calibrate voltage levels Connect an oscilloscope
Duty Cycle The duty cycle can only be set in square to the generators output and set the output level to
wave mode. Press Mode to activate the square wave 5Vpp. Press Calibration to open the calibration menu.
output. The duty cycle is indicated on the bottom line of Select Measurements to start the calibration procedure.
the display. Adjust the duty cycle by pressing +Up and (If entered by mistake, the only way to get out is by
Down (the digits must not blink). switching off the power.) Adjust P1 to set the minimum
Frequency Press Set. A digit starts blinking. Use +Up value of the output signal to 0.00V, press Set when
and -Down to change the value of the blinking digit; done. Adjust P1 to change the maximum value of
use Left and Right to navigate through the digits. When the output signal to 12.00V. Press Set when done. A
done press Set. message appears to indicate that calibration has been
Amplitude Adjust P2. Note that adjusting the completed. Press Calibration to return to the main
amplitude affects the offset voltage. See [2] for detailed menu.
measurements. Calibrate frequency Connect a high-precision
DC offset Adjust P1. frequency counter to the function generators output.
Frequency sweep Press Sweep to open the sweep Press Calibration to open the calibration menu. Select
menu. The least significant digit of the start frequency is Frequency to start the calibration procedure. (If entered
blinking. Use +Up and Down to change the value of the by mistake, the only way to get out is by switching off
blinking digit; use Left and Right to navigate through the power.) Adjust the output frequency to 100,000Hz
the digits. When done press Set to advance to the next by pressing +Up and Down. Press Set when done. A
parameter. Set the stop frequency, the sweep time message appears to indicate that calibration has been
(called msec) and the sweep mode (logarithmic or completed. Press Calibration to return to the main
linear). Press Set to start the sweep. This is indicated by menu.
sweep run in the first line of the sweep menu. Press
Following on from the BL600s IC port we looked at last time, were going to take a look here at its serial
interface. To do this, were going to be using a digital/analog converter, itself fitted with an SPI port. This
will be an opportunity to produce your own Bluetooth application.
Out of the BL600s impressive arsenal, were going to take a Slave Input and pin12, CLK) (Figure2). The DAC also has a
look here at its serial interface, referred to as SPI. To do this, serial output that weve connected to the input of the e-BoBs
were going to be using a 16-bit digital/analog converter (DAC), SPI port (pin11, MISO = Master Input, Slave Output), which
itself fitted with an SPI port. The joint information will be an will let us check our circuit is working. Using a voltmeter con-
opportunity to produce your own Bluetooth application. Obvi- nected to the DAC output (pin7), well measure its output volt-
ously, its not our aim to give a course in development under age and adjust the drive so as to obtain a voltage of e.g. 1V.
Android, but the article gives all the elements you need for your
phone and the BL600 to be able to get along well together. If Our BL600 module and the DAC are now connected. Now lets
there is enough demand, perhaps one day well present here take a look at the BL600s SmartBASIC program. Heres what
an Android application devoted entirely to our SPI device. happens in the LTC1655L.sb program (Listing1), download-
Note: the tools and commands used in this article have already able from the Elektor Magazine website[4]:
been presented in the previous articles in this series. [1].
a) Open SPI
SPI port and DAC The first step is to open the SPI port and handle its return code
The LTC1655L DAC from Linear Technology [2] can be pow- using a simple if condition.
ered at 3.3V, and if we use the internal voltage reference, it
operates with no other components (Figure1). In this case, Rc = SpiOpen(0,1000000,0,handle)
its output voltage is limited to 02.5V. The value we want this
output voltage to take will be sent to the DACs serial port by nMode = 0: CPOL (Clock Polarity) to 0 and CPHA (Clock
our BL600 e-Bobs SPI port (pin10, MOSI = Master Output, Phase) to0
1 CLK 16-BIT RX 12
CLK
16 USB
MOD2 MISO LTC1655L
P SHIFT TX 11
16-BIT +
MOSI 1 8
CBUS4 +5V CTS 10 CLK VCC
3 CS/LD REG DAC VOUT 7 CBUS3 VCCIO RTS 9
2
DIN VOUT
7
BOB-BL600
AND CBUS2 +3V3 VCC 8
3
CS/LD REF
6
DAC MOD1 4 5
LATCH CBUS1
CBUS0
GND
CTS
GND
RES
3
2
CS
DOUT GND
TO
RX
RESET
TX
OTHER GND
DACS
5 150272 - 11
Figure 1. Internal circuit of the LTC1655L analog/digital converter (ADC) Figure 2. Circuit of the BL600 using the LTC1655L. The use of the FT232
used to illustrate communication via the SPI interface. e-BoB was described in the previous articles.
com
lairtech
bt
ble
classic
filehandler
misc
Figure 4. If the voltmeter displays a voltage of 1V, the LTC1655L.sb The tree structure in the library.
program has run successfully.
BPM (blood pressure) Documentation is available with the library download. There
HRM(heart rate) are three classes:
Proximity BluetoothAdapterWrapper Class
HTM (medical thermometer) used with the temperature Initialization of the Bluetooth
sensor in the previous article. Verifies if Bluetooth is present
Serial(UART) Detects Bluetooth peripherals
OTA(Over The Air) BluetoothAdapterWrapperCallback Interface
Batch Detects, stops Bluetooth devices
We are offering you for download [4] the extremely sim- Handles Call-Backs
plified source code for an application using just the UART BleDeviceBase Abstract Class
service. We have used Android Studio, available under Access to the Bluetooth methods for initializing the
Windows, MAC OS and Linux [5] connection to the peripheral. For example: connect,
isConnected etc.
The manufacturer has created a librarylaird_library_
ver.0.18.1.1.jar in order to speed up development of Android In our program, youll find the tree structure in the library.
applications in normal Bluetooth and Bluetooth Low Energy.
Listing2
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/textView"
android:layout_alignParentStart="true"
android:layout_above="@+id/btnSend">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollViewVspOut"
android:background="#ffffffff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/valueVspOutTv" />
</ScrollView> Figure 5. As simple as possible: the Figure 6. Display of the
screen for our Serial application. mDialogFoundDevices Dialog class
</LinearLayout>
with two peripherals.
The program tions two buttons: btnScan and btnSend. Heres what happens
The complete program can be downloaded from the Elek- for btnSend: the text to be sent is read in the text box; if it is
torsite [4]. The first step is to create your project. As Pack- other than null, it is copied into the receive text area then sent
age name weve chosen: com.ja.serial (where ja are the using the startDataTransfer function (Listing5).
authors initials)
(Tip) Launching the connection automatically: To establish
Screen layout: To start off, lets keep it simple: two buttons an automatic connection, lets remember how we do it man-
btnScan and btnSend, an area for displaying the received data ually: we start the scan using the btnScan button, then we
using scrolling scrollViewVspOut and valueVspOutTv, and the select our peripheral in the Dialog box. So for our automatic
text entry box valueVspInputEt. And thats all (Figure5). connection, we leave the main program to execute the code
Example of activity_main.xml for the received data display for the setOnClickListener function, then, instead of displaying
area with scrolling (Listing2). the list of peripherals in Dialog, we start the connection to the
module entered in the code name.
Permissions: The AndroidManifest.xml file allows our program
to access the Bluetooth. If you forget this, it will cause an error (Tip) Receiving and sending data: To enter the data to be
in the application that is difficult to identify. sent and display the data received, we have two text boxes:
<uses-permission android:name=android.permission. valueVspInputEt and valueVspOutTv. Theres nothing to stop
BLUETOOTH /> your program sending the data via some other action. For
<uses-permission android:name=android.permission. example, you can send 0 or 1 depending on the position of a
BLUETOOTH_ADMIN /> button Switch. You can handle the characters received in your
program as we have done in the Thermometer application
Declaration in the program: Were going to import different described in the January/February 2015 issue[6]. There, we
classes with no changes to the original sources into the fol- performed a complex calculation that couldnt be done by the
lowing directories: BL600 before displaying the result in large characters.
/*
Given that the two classes SerialManagerUiCallback and Blue-
toothAdapterWrapperCallback are implemented, youll find all * *************************************
their classes specified in our program. These can be recog- * SerialManagerUiCallback
nized by the presence of comments at the start (Listing4). * *************************************
*/
The Dialog class appears when scanning for peripherals. /*
Then, from the list, the application connects to our BL600 *************************************
e-BoB. Watch out: the application only works with peripherals
* Bluetooth adapter callbacks
that have the UART service.
* ***********************************
*/
The buttons: We find the setOnClickListener for our applica-
Listing5
mBtnSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
switch(v.getId())
{
case R.id.btnSend:
{
String data = mValueVspInputEt.getText().toString();
if(data != null){
mBtnSend.setEnabled(false);
mValueVspInputEt.setEnabled(false);
if(mValueVspOutTv.getText().length() <= 0){
mValueVspOutTv.append(">");
} else{
mValueVspOutTv.append("\n\n>");
}
mSerialManager.startDataTransfer(data + "\r");
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
if(isPrefClearTextAfterSending == true){
mValueVspInputEt.setText("");
} else{
// do not clear the text from the editText
}
}
break;
}
}
}
});
(renamed to MyHandlerLoop) in order to recover the data In red: youve already seen this code. We store the characters
received in Bluetooth (Listing6). received via Bluetooth in the variable text$. If the character
Here is the list of the various actions to be carried out by the string contains the return code 0x0D (end of string), we enter
handler in order to process the character string received via the IF condition.
Bluetooth:
In green: First of all, we recover the value of the voltage
receive via Bluetooth the text corresponding to the desired wanted at the DAC output. To do this, we convert the charac-
voltage; ter string into a numeric variable using the StrValDec function,
convert the received text into a value to be sent to the then we calculate the value for the DAC. Watch out: if the value
DAC; received yields a result higher than 65,535 (2161), we force
send the value to the SPI port; the value to 65,535, a 16-bit value. In order to adhere to the
receive a value via the SPI port; format of the SpiReadWrite function, the value is converted
convert the value received into a character string; into two characters using the StrSetChr function, thereby cre-
send the string via Bluetooth. ating a character string stWrite$.
Listing6
OnEvent EVVSPRX call MyHandlerLoop //EVVSPRX is thrown when VSP is open and data has arrived
OnEvent EVUARTRX call MyHandlerLoop //EVUARTRX = data has arrived at the UART interface
OnEvent EVVSPTXEMPTY call MyHandlerLoop
OnEvent EVUARTTXEMPTY call MyHandlerLoop
For many years the author has been using A phantom 48-V power supply for and linearity of the MEASSY. The signal
the ARTA software package [1], which was condenser microphones or integrated to noise ratio (SNR) is largely determined
developed by Ivo Mateljan at the University preamps by the input noise level of the MPA. If
of Split. To measure the frequency response A 30W power amplifier with clipping you want to have a true 16-bit dynamic
and impedance of loudspeakers, the author indicator range (96dB) with the line input (sig-
uses a sound card as a signal generator A switchable shunt resistor corre- nal level 10dBV) of a sound card at a
with software-controlled signals and a sponding to the ARTA Measuring Box gain of 26dB, the maximum allowable
microphone for signal input. Although the A USB sound card (optional) noise level at the MPA input is 250nV.
matching ARTA Measuring Box [2] consid- The above list is essentially the require- When you consider that the thermal noise
erably reduces the cable clutter for making ments spec for the project. Now lets see level of a 100-W resistor is 182nV, this
measurements, its only a partial solution. what it looks like in practice. looks like a difficult requirement. Fortu-
A better approach is to fit all the cir- nately, measuring microphones do not
cuitry and other components needed for Quality requirements have anywhere near this sort of SNR.
a proper measurement setup, including a Before you start drawing circuit diagrams, Even with high-quality devices, the SNR
power amplifier, into an enclosure. That its a good idea to consider what you actu- is only about 74dB referenced to a sound
makes a major dent in the number of ally want and need and to define some pressure 1Pa, which corresponds to an
cables required and frees up space on the quality requirements. You need separate acoustic sound pressure level of 94dB.
bench. MEASSY is an acronym of Mea- quality requirements for the MPA and the This yields a calculated equivalent qui-
surement Assistant and consists of the power amplifier. escent noise level of 20dB. With mea-
following components: surements at a sound level of 106dB, the
A balanced, adjustable-gain micro- Microphone preamp requirements microphone therefore achieves an actual
phone preamplifier (MPA) with a peak Aside from the microphone, the MPA is SNR of 86dB. In other words, you can
indicator the key component for the dynamic range knock 10dB off the 96dB requirement.
Nevertheless, the corresponding input for measuring the transfer characteris- MEASSY electronics
noise level of 0.8V (or less) is still a tics of home audio systems. The situa- The individual circuits were developed
challenge. tion is different with sound systems for with the above requirements in mind.
Linearity is not much easier. Although rock concerts, but that is not what the The power supply is doubtless the least
there are ICs available with -100dB THD MEASSY is intended for. demanding of the lot, so we can start
at unity gain, things look different at a with a description of its special features.
gain of 40dB. With regard to the nec- With regard to the SNR, the consider-
essary gain, the sensitivity of suitable ations are similar to those for the MPA, Power supply
condenser microphones lies in the range but low power levels also have to be taken The power supply has to provide several
of 2 to 20mV/Pa. Here we use the worst into account, so you should assume a voltages: balanced 15V for the MPA, a
case to calculate the gain: loudspeaker requirement of 100dB. This results in 48V phantom feed for the microphone,
sensitivity of 80dB/Wm (fairly low), an output noise level of 110V at the and balanced 24V for the power ampli-
amplifier output power 3W, measuring nominal power level (11VRMS with a 4W fier. The supply voltages for the MPA and
distance 3m, and microphone sensitivity load). The equivalent input noise level can the microphone should be well regulated,
2mV/Pa. In this case the sound level at be found by subtracting the gain for but an unregulated supply voltage with
the measuring microphone is 75.2dB. example, 3.44V with a gain of 30dB higher load capacity is sufficient for the
The gain necessary for a signal level of (amplification factor 32). This noise level power amplifier.
10dBV (316mV) is therefore 62.8dB. is not a significant problem. As can be seen from Figure1, all you
This means that a gain of 60dB is suffi- need is a conventional circuit consisting
cient for unfavorable conditions. In prac- Distortion is also not an issue, since of rectifiers and filter capacitors along
tice, assuming loudspeakers with high even simple circuits can achieve a THD with several voltage regulators. Due to
efficiency, relatively high power and a of 0.01% (80dB below the signal level). the required voltages, you need a power
smaller measuring distance, the gain can Robustness is a more difficult issue. The transformer with two 18V secondary
even be as low as 0dB. power amplifier should be short-circuit windings. With regard to the power rat-
proof, and due to the small dimensions ing, the key factor is the efficiency of a
Power amplifier requirements of the MEASSY, you also have think about class AB amplifier. For 30W into a 4
An output power of 30W is fully sufficient cooling and overtemperature shutdown. or 8 load, a toroidal transformer rated
R15 C17
100R
100u
CAS
BR2
TS1 R17
1.5KE100
C19 C20
18k
R16 C18
T1
100R
B80C500 100u 100u
100u
R18 ZD1
BC
2k2
D6 546B +48V
IC5
1N4148 ZMM8V2 TP1
LM317LZ (ZMM10V)
3 2
+24V
IC3 ADJ
TP5
TP2 LM317T +15V 1 R19 R22
3 2 D8
AC1
360R
2R2
R24
ADJ
LL
360R
1 R21 4148
100R
C16A C16C
R23 R20A R20B
AC1 C21 C23 C25 C27 C29 C30
22n 22n
18VAC
3k9
27k
27k
TP3
COM1 4700u 220n 10u 47u 1u0 1u0
BR1
KBM08 R25
COM2 C22 C24 C26 C28
18VAC
3k9
C16B C16D
AC2 4700u 220n 10u 47u
1 T1: 200mW
ADJ R20: 160mW
2 3
AC2
LM337T 15V
TP4 TP6
24V IC4
130453 - 13
D7
1N4148
Figure 1. The power supply circuit, which provides unregulated 24V and regulated 15V and +48V.
5k
U1
both priced at about 180.
Rf1
3k0
The specified requirements can be fulfilled
OUT nicely by the type INA163 instrumenta-
Ri2
A3
tion amplifier from Burr Brown (now part
Rs2 5k of TI). As a special feature, it has addi-
120R R2 R4
Vo2 tional driver stage outputs that can be
A2 1.0001k 1k
used to boost the common mode rejec-
U2 tion ratio (CMRR). Due to the need for a
Rg Rf2 CMRR = 80dB
3k 3k0
R5 R6
phantom power supply, the input is not
only low-impedance but also connected to
10k1
10k
ground, which is unfortunate. The CMRR
Rz Cz is therefore determined by the imbalance
600R A4 in the apparent output impedance of the
100u
signal source, regardless of the balance of
130453 - 15
the signal input. Unlike the situation with
an ungrounded transformer output, with
direct galvanic coupling an imbalance of
Figure 2. Basic circuit of a balanced microphone preamplifier with enhanced CMRR.
more than 20 can occur due to toler-
ances and long cables, which results in a
relatively poor CMRR of about 40dB with
at 50VA should be more than adequate. sioned to ensure the required minimum typical impedances.
The 24 V supply voltages for the power current of 2.5mA under no-load condi- A simple countermeasure is to use boot-
amplifier are taken directly from filter tions. However, this value is only specified strapping to raise the input impedance.
capacitors C21 and C22. The 15V sup- by National Semiconductor (now Texas Figure 2 shows the basic circuit of this
ply voltages are provided by the tried Instruments). If the current through the sort of balanced amplifier. Opamp A4
and true complementary voltage reg- regulator is too low, the output voltage feeds the sum signal from outputs Vo1
ulators LM317 (IC3) and LM337 (IC4. will rise. Here it should be noted that and Vo2 back to the input. Capacitor Cz
Capacitors C25 and C26 suppress AC hum the current through Zener diode ZD1 prevents input saturation with this form
and reduce the noise level. The custom- bypasses the regulator (IC5). The value of positive feedback. Summing with resis-
ary protection diodes are not necessary of R17 can be relatively high thanks to tors R5 and R6 is intended to strongly
because the two ICs in this circuit do the low required current and the gain of suppress the difference signal in order
not allow reverse current flow. However, T1. As a result, the power dissipation of to avoid bootstrapping the difference sig-
diodes D6 and D7 are provided to protect R20 remains within reasonable bounds. nal. As a result of the positive feedback,
them against any voltage spikes that find A pair of 0805-SMD resistors wired in the signal currents through Ri1 and Ri2
their way onto the supply rails. parallel can easily handle the 160mW are very small and the common-mode
For the phantom power supply, we use dissipation. input impedance is much greater than the
some clever circuitry instead of a sep- When loaded with a connected micro- physical resistor values, but the differen-
arate transformer. Bridge rectifier BR2 phone, the current through the regula- tial input impedance (Ri1 + Ri2) remains
and capacitors C17C20 form a voltage tor is always sufficient. At higher cur- the same.
multiplier (charge pump) that generates rent levels the voltage multiplier would It should be noted that due to the elec-
70V on the positive terminals of C19/ be hard pressed to do its job and the trometer configuration of A1 and A2, the
C20, nearly three times the peak voltage output ripple voltage would rise to more common-mode gain of the first stage is
of the transformer secondary. The no-load than 10mV. For this reason the maxi- fixed at 1, regardless of the value of resis-
voltage can be as high as 80V. Resistors mum current is limited to 8mA, which is tance Rg. Now the 80dB CMRR of the
R15 and R16 limit the peak current. To more than enough for normal measuring second stage can be maintained over a
reduce the required working voltage of microphones. At 8mA, transistor T1 dis- wide frequency range. The lower cutoff
C19 and C20 (and thereby their dimen- sipates 250mW from its TO-92 package. frequency is determined by the high-pass
sions), their negative terminals are ref- As an alternative, you could use a BD139 network Cz/Rz, while the upper cutoff fre-
erenced to C21. The downstream voltage (TO-126 package) for T1. quency is determined by the bandwidth of
regulator is based on a standard applica- A4. With this arrangement, the quality of
tion circuit for the LM317 for operation Microphone preamplifier the cable is practically insignificant. The
with relatively high voltages [3], since The most logical place to test loudspeak- precise mode of operation of this circuit
it is not designed to handle 80V. IC5 is ers is in their normal listening position. topology is described in detail in an AES
configured as a floating regulator, with The necessary cable length and associ- article [4].
an accuracy largely dependent on the ated noise problems make unbalanced The basic circuit of Figure2 is incorpo-
current through the regulator (input to microphone connections unsuitable. rated in the actual MPA circuit shown
output). Resistors R17R20 are dimen- Besides, most measuring microphones in Figure3. There the bootstrapping
is extended to include two other paths For a linear amplifier gain control in dB Peak indicator
for HF filtering and the phantom supply. units you need a potentiometer with a The peak signal level indicator is imple-
Resistors R3 and R4 inject the 48V sup- reverse logarithmic characteristic, which mented with an LM3915 and a full-wave
ply voltage; they should be selected for is very hard to find. With an adjustment rectifier (see Figure4). This part of the
matched values. The combination of C8, range of more than 40dB, its not pos- circuit is conveniently fitted on a small,
R12 and the narrow bandwidth of IC2A sible to achieve this by tweaking a lin- separate PCB along with the rotary switch
forms an HF filter. Additional filtering of ear potentiometer. However, continuous for the gain setting, which is mounted
the phantom supply voltage is provided adjustment is by no means necessary vertically behind the front panel. IC2
by C11. A Spice simulation of the circuit because modern USB sound cards have operates in dot mode to minimize noise
with an imbalance of 20 and a gain of integrated programmable gain amplifiers on the supply rail and reduce power con-
20dB yielded a consistent CMRR of more (PGAs), which can boost the signal by at sumption. Because IC2 is connected to
than 60dB from 70Hz to 80kHz. least 10dB without noticeably increas- the MPA supply rail and the individual
IC2B is wired as a DC servo to eliminate ing the noise level. A gain control with LEDs have a forward voltage of approx-
any DC offset at the output. The cutoff discrete settings in steps of 6 to 10dB is imately 2.2V, the maximum number of
frequency of the integrator is 2Hz. IC2 therefore sufficient. A two-gang selector LEDs that can be used here is six. To
should have FET inputs. A detailed expla- switch with six positions, with the two increase the display range to 6dB for
nation of how the protection diodes work gangs wired in parallel for reliability, small signals, two IC outputs are com-
would take too much space here. How- allows the gain to be set over the range bined for each of the first four LEDs (LED1
ever, you can read more about it at [5]. of 6 to 48dB in six 8dB steps. to LED4). The current through resistors
27k
4 1
IN VO1 27k
470p 3
CON1 0%1 RG 8 MICO
3 RG0 SNS
MIC. C9 15V R11
2 IC1 9
6k12
27k
R7
220k
R2 470p C4
0%1
100R
1u0
D2A BAS216
R9
BAV199
+15V
typ. +70mV offset 220k
C12
C8 15V R12
D3B
620R 330n
3 6
150p C13
C10 1 7
+48V IC2A IC2B
22u D3A 2 5
R14 330n
C11
620R BAV199
on 100u
S1 R13
PHANT. IC2 = OPA2132
POWER
3k3
15V
off
76R8
200R
590R
2k0
+15V 46dB
C6 C14 38dB
6 12
130453 - 11
1k
5 2 5 the output offset voltage may rise slightly
1
IC1A due to the current through R31. The R28/
3 C1
IC1 = LF442
C32 network at the input forms a low-
2u2
15V pass filter that attenuates signals above
80kHz.
+15V The CD outputon pin5 is an open-drain
24dB 18dB 12dB 6dB 3dB +0dB
type. It provides a precise indication of
amplifier saturation or clipping. This out-
LD1 LD2 LD3 LD4 LD5 LD6
put drives a non-retriggerable monostable
built around IC8b and is active at dis-
tortion levels as low as 0.5%. Even
1 18 17 16 15 14 13 12 11 10
+15V extremely short clipping events there-
L10
L1
L2
L3
L4
L5
L6
L7
L8
L9
IC2
fore cause the red part of the bicolor
2 3
V V+
LM3915 LED to blink for 0.5s, driven by T6. In
C3
combination with the green Operating
MDE
RLO
ADJ
RHI
SIG
VR
100n
8 4 6 7 9 8 5
SIG
indication, LED1 is thus lit yellow in the
IC1 R7
4 820R
event of clipping. The CLIP signal is also
C4
R8
C2 connected to IC8a at the junction of R51/
100n
C46. This circuit detects the duty cycle.
1k
2u2
At 40% (zero reference level) or more,
130453 - 14
15V
flip-flop IC8a is constantly set and the
mute pin of IC6 is pulled to ground by
T4. The red part of the bicolor LED is then
Figure 4. The peak indicator consists of an LED bar driver and a full-wave rectifier.
lit by T5, but the base current for T7 is
cut off and the green part is dark. The
resulting red indication signals a probable
R7 and R8 (16mA) determines the bright- choice for output power levels below short-circuit condition.
ness of the LEDs as well as the total signal 50W. Modern IC power amplifiers have The response time is determined by R51/
level range. The maximum level for SIG excellent specifications, and they are C46 and R49/C44 and depends on the
is set to 2.72V. Together with the gain compact and inexpensive. Two options mark/space ratio: 36ms at 40%, 24ms
of the rectifier (IC1), the output signal here are the LM3886 from TI and the at 50%, and 13.5ms at 75%. Conven-
level of the MPA required for maximum TDA7293 from STM. The former is tional solutions with relays take approxi-
signal amplitude is 447mVp (10dBV), short-circuit proof, but the STM IC has mately 15ms. A duty cycle less than 36%
which is the normal line level for con- better specs and its Clip and Short Detect is interpreted as saturation (full clipping)
sumer electronics. This gives the MPA a (CSC) output, which can be used to drive and corresponds to a THD of approxi-
healthy headroom of 20dB. a clipping indicator, is a major advan- mately 9%. If a short-circuit condition is
Because the output of the MPA has no tage because it makes distortion mea- detected, the amplifier must be switched
DC offset, the conventional rectifier cir- surements more reliable. The author also off and then switched on again. The exter-
cuit built around the two opamps in IC1 knows from experience that the TDA7293 nal reset signal for IC8a comes from the
can be DC coupled. The amplification can survive output shorts if the supply collector of T2, so short-circuit detection
factor of the two stages is 6.06. Due voltage and signal level are low. Opera- is enabled shortly before the amplifier
to the different impedance values of tional reliability is enhanced by a supple- output is unmuted. This prevents false
the two stages, the diode leakage cur- mentary short-circuit detector. detection during power-up.
rents cause a small gain error (less than Figure5 shows a standard application The +6V auxiliary voltage is generated
0.5dB) between the two half-waves, circuit for the TDA7293. The gain is set by voltage regulator IC7. The circuitry
which is negligible in practice. The rise to 30dB by resistors R29 and R30. No around T2 and T3 provides a switch-on
time 2.2ms, which is determined by the capacitor should be connected in parallel delay of approximately 2.5s and imme-
time constant of R6/C1. The fall time is to R29. A Boucherot network (R33/C40) diate shutdown of the amplifier. The dif-
0.44s (determined by (R5+R6)xC1). at the output improves stability. Capac- ferent resistance values (R45+R46 ver-
Fall times shorter than 0.4s are gener- itor C40 is a multilayer type instead of a sus R47+R48) result in a time delay
ally regarded as undesirable. film type, due to the better specs of the between the signals on the STBY and
former. Resistor R33 should be a low-in- MUTE inputs of IC6. Noise suppression
Power amplifier ductance type. The combination of capac- utilizes the Standby function. The series
Integrated power amplifiers are a good itors C33a and C33b (with bias voltage resistor for IC7 (R40) has a relatively
R29
18k
+24V
C35 C36
C31A
470u 220n R34A
J1 JP2 120R
1 1u0
C31B R34B 2W
2 7 13
120R
3 R28 +VS +PS
1u0 3 R34C 2W
10k IN+ 14
2 OUT 120R OUT+
IN C39
R27 R34D 2W
C32
IC6
120R
220k
P1 47u
R32 2W
10k B 150p
4
220R
IN+MUTE
TDA7294S
10 6
MUTE MUTE BTRP
9 5
STBY STBY CD CLIP
R30
SBG VS PS RE1C
R33 9 8
620R
1 8 15
+Uaux C33A 24V RE1B
3R3
R31
4 5
1M
C34 C37 C38 C40
47u
C33B
330n 220n 470u 220n
OUT
47u
RE1D S3A
RE1 1 D9
10 11
MICO
J2 RE1A R35 S3B 12 LL4148
3 2
5k6
R39
R37
220R
5k6
CALIBRATE
ZD3 ZD5
R36 R38 MEASURE S2
ZF2V7 ZF2V7 FREQ. RESP
620R
620R
IMP. MEAS
ZD4 ZD6
ZF2V7 ZF2V7
CLIP
+Uaux
24V
R50 R54
C47
220k
47k
+24V 100n 2x
T5 BC549 T6 T7
+Uaux BC559
1k0
1k0
22k
4 10
IC7 R55 R56 R53
6 R 8 R
78L06 TR TR
390R
390R
100k
3 1 IC8A IC8B
1 5 13 9
C42 DIS OUT DIS OUT
LD1
2 12
2 T2 THR THR
47u CV CV
C46 C48
3 11
D13 2u2
BC516 330n
220k
10k
1k
C43 D12
AC1 D10
T3 T4 14
R41 220n LL4148 IC8 IC8 = TS556
D11 470k
7
BC549 BC549
AC2 2x LL4148
130453 - 12
Figure 5. Integrated power amplifier with clipping detector and auxiliary voltage generator.
+0 0.5
loudspeaker measurements are rarely
-0.2
0.2
made at full output, but instead about
-0.4
-0.6
0.1 3dB lower, corresponding to an output
power of approximately 20W. The effi-
d 0.05
B -0.8
r %
-1
A
-1.2
0.02
ciency of a class AB amplifier is about 43%
0.01
-1.4
0.005
at moderate load levels, so the dissipation
is around 12W. With a maximum ambi-
-1.6
-1.8 0.002
-2
20 50 100 200 500 1k 2k 5k 10k 20k
0.001
20 50 100 200 500 1k 2k 5k 10k 20k
ent temperature of 45C and a thermal
Hz Hz
shutdown threshold of 125C, the allow-
Figure 6. The frequency response of the power Figure 7. THD + N at 1W (blue) and 20W (red) able temperature range is approximately
amplifier at 1W output into an 8 load. into 8. 80C. The permissible thermal resistance
is therefore approximately 6.5K/W.
A properly mounted TCA7293 IC has a
Audio Precision Audio Precision thermal resistance (die to heat sink) of
+0
-0.3 -50
d
B -0.4
d
B
-60
not require continuous operation, but a
r r -70
A
-0.5
A -80 fan might be a good idea if you expect
-0.6 -90
-1
-130
-140
Fischer SK574, with a length of 75mm.
20 50 100 200 500 1k 2k 5k 10k 20k 20 50 100 200 500 1k 2k 5k 10k 20k
Hz Hz
Practical aspects
Figure 8. The frequency response of the Figure 9. The frequency spectrum of the MPA
preamplifier with the same scale as in Figure6. with a 1kHz test signal (suppressed). The MEASSY is designed for an input sig-
nal level of 316mVRMS (10dBV). That is
suitable for many internal sound cards,
but not for the Transit USB model from
large value to limit the power dissipation by the effective 30 resistance. Unlike M-Audio used by the author. The USB
of the transistor to less than 250mW. The the original Measuring Box, S2 is com- audio codecs in the Transit USB work
LED1 currents are also limited to 10mA plemented by a high-quality relay, which with a 3.3V supply voltage. The inputs
per diode for the same reason. is not readily available. Voltage dividers and outputs are unbalanced, and the
The circuitry around S2, S3 and Re1 R35/R36 and R37/R38 are suitable for an signal levels are in the range of 0.72
incorporates the measuring functions of amplifier output power of 30W (20dB to 1.35V RMS,, which is around 0dBV.
the ARTA Measuring Box, with R34 as at 12VRMS). With this sort of sound card the MEASSY
the measuring resistor. It consists of four A few words about cooling: The 50VA throws away about 7dB of dynamic
metal-oxide resistors, each rated at 2W. toroidal transformer limits the maximum range, even though the MPA output can
That is sufficient for the power dissipated output power to less than 35W, regard- deliver much higher levels. If you want
to utilize the maximum dynamic range
in this situation, you can change R8 to
1.8k on the separate PCB. Then the
The Author 3dB LED will light up at 700mVp to
Sergej Koschuch has an engineering degree and more than 20years experience indicate full amplitude at 700mVRMS. The
as an analog designer for integrated circuitry at STMicroelectronics, Micronas and same applies to R35/R36 and R37/R38.
Infineon. He has also maintained an active interest in discrete circuit design, which At maximum power the signal level at the
is still common and useful in loudspeaker construction. amplifier output is 12VRMS. For impedance
measurements, this can be achieved with
the output signal from a sound card with
Web links an input signal level of 0dBV, attenuated
[1] ARTA software: www.artalabs.hr by 20dB.
The MEASSY was measured in the Elektor
[2] ARTA Measuring Box www.artalabs.hr/AppNotes/AP1_MessBox-Rev3Eng.pdf
Labs, independently of the author. Fig-
[3] LM317 application note: www.ti.com/lit/an/snva583/snva583.pdf ure6 shows the frequency response of
[4] Circuit theory: the power amplifier at 1W output into
www.thatcorp.com/datashts/AES6261_New_Balanced_Input_IC.pdf an 8 load, which fits very well with the
[5] Protection measures: intended use. A frequency response from
www.thatcorp.com/datashts/AES7909_48V_Phantom_Menace_Returns.pdf 1Hz to 100kHz is not necessary because
measurements are not made in that range.
[6] PCB files: www.elektormagazine.com/130453
Note the very high vertical resolution of
Summary
The author built a very attractive MEASSY
prototype, as can be seen in Figures 10
to 12. Figure10 shows the MEASSY in
an AUS12 case from Teko, with a very
tidy layout for the aluminum front panel.
For new construction, the author would
Figure 11. MEASSY rear panel with connectors for AC power, loudspeaker and microphone.
use Cinch (RCA) sockets instead of the
two 3.5mm jack sockets, for quality rea-
sons. The most striking feature on the
rear panel (Figure11) is the gold-plated
loudspeaker terminals. A standard three-
pin XLR socket handles the microphone
connection.
The PCB layout files for this project are
available on the web page for this article
[6]. The author recommends that only
audiophiles with sufficient experience,
who also understand the content of arti-
cles [1] and [2], attempt to construct
the MEASSY.
Enhanced FM Stereo
on Red Pitaya
Advanced instrumentation platform on the air
To call Red Pitaya nothing more than a USB oscilloscope would The signal from the ADC in Red Pitaya is sampled at 125MS/s
be a shallow understatement. In the introductory article in and fed to the FPGA. Its in the FPGA that the first stage of
Elektor [2] we explained how this programmable open-source our FM receiver is achieved, mixing down to baseband (zero
instrumentation platform could also be deployed as a signal IF) and the filtering. This produces a signal with a sample rate
generator, spectrum analyzer, oscilloscope, PID controller and of around 244kHz at the input to the CPU, where the actual
much more besides. Numerous programs for doing this are demodulation takes place. The stereo decoder is transformed
available free. Enhancing the high-performance system-on- as C code, leaving just enough processing power in hand for
chip, with a Xilinx ZC7Z010 (dual-core ARM9 CPU), fast FPGA an RDS demodulator/decoder.
and a plentitude of RAM running under Linux (on an SD card
like the Raspberry Pi) we also have high-speed A/D and D/A Inside the FPGA
converters to provide an interface to the analog world. Red The mixing process in the FPGA is carried out using a DDS
Pitaya also provides, as appropriate for a system of this kind, oscillator, which follows the signal generator provided with
numerous other interfaces from universal I/Os, through Red Pitaya. Instead of passing the output to a D/A converter,
RS-232 and USB, all the way up to Ethernet. this signal is used for mixing within the FPGA. Sine and cosine
signals are obtainedbyread-outfromthetable,usinganoff-
The concept setthat corresponds to90 degrees. This produces a so-called
Red Pitaya can digitize signals up to around 50MHz. For this I/Q mixer [3].
reason a simple front-end (as seen in Figure 1) is required to
convert the broadcast band between 88 and 108MHz down to The two components calculated in this way I (In-phase sig-
the region between 22 and 42MHz. An NE612 is deployed as nal) and Q (Quadrature phase signal) enable us to deter-
mixer, using the 66MHz crystal local oscillator LO1. mine the amplitude and phase of the signal being received.
I = A cos(p)
Q = A sin(p)
In Figure 5 we can see the instantaneous phase (above, in trum of a received MPX signal, evaluated on the hoof by Red
yellow) and the current frequency (below, in blue) for an FSK Pitaya using FFT and output by both D/A converters into an
(frequency-shift keyed) signal with square-wave frequency x-y representation on an oscilloscope. The 19 kHz pilot tone
keying. After each of these, according to whether the fre- is clearly recognizable as a narrow, tall spike and to the left of
quency is positive or negative, a rising or falling saw-tooth is this, the spectrum of the L+R audio signal. To the right of this,
produced as the phase response. Figure 6 shows the spec- symmetrically at 38kHz, we find the L-R signal. The two small
humps at far right indicate the RDS signal. With live spectral
displays of this kind, the high processing power of Red Pitaya
is of course especially noticeable.
Stereo decoder
Lets return to Figure 4 After low-pass filtering the signal
reaches a stereo decoder, which is once again programmed in C.
Figure 5. Instantaneous phase (yellow) and frequency (blue) in FSK. The details of the stereo decoder are shown in Figure 7. A
PLL reconstructs the 19 kHz auxiliary carrier. Using the 19 kHz
oscillator implemented in this way, at the same time we can
take care of the 38 kHz auxiliary oscillator, with which the L-R
signal is mixed down to baseband. Low-pass filtering produces
the L+R signal from the MPX signal. The L-R signal is filtered
using the same low-pass. The signals of the two stereo channels
arise out of L+R and L-R by means of addition and subtraction.
The great thing with Red Pitaya is that you can portray test sig-
nals with the D/A converters. Figure 8 shows (above) the L-R
signal in yellow plus (below) the VCO control voltage CTRL in blue,
and indeed on the left-hand side with the control circuit disabled
(with switch S not closed). The control voltage has a sine-wave
form, in which its frequency is the difference frequency between
the transmitted and local 19 kHz pilot tone. Simultaneously the
L-R signal is amplitude modulated at double the frequency. The
amplitude varies according to how well the phase of the local 38
kHz auxiliary carrier agrees with the transmitted carrier.
More or less in the center of the picture the control circuit is
switched in. After a brief transient oscillation the PLL locks in
and the L-R signal is recaptured with constant amplitude. With
Figure 6. Spectrum of the received MPX signal. the stereo decoder we have now produced a fully functioning
Figure 7. Block diagram of the stereo decoder. Figure 8. Inner workings of the stereo decoder.
RDS decoding
Figure 9 shows the block diagram for extracting RDS infor-
mation. Since the 57kHz RDS signal contains no spectral
components itself, conventional PLL chips cannot be used for
recovering the 57 kHz auxiliary carrier. Instead we need to
employ a Costas Loop circuit, which in effect extracts the
carrier from the sidebands.
As we start implementing RDS decoding, the ARM CPU begins
to reach its limits. However, by applying DDS table techniques
instead of complex trigonometric functions (sine, cosine) for
implementing the various mixer oscillators and switching in
speed optimization of the compiler, we can claw back sufficient
headroom to enable simultaneous stereo and RDS demod-
ulation with the CPU of Red Pitaya at 244 kS/s. Linked to the
demodulation we have sample-rate recovery as well as frame
detection and synchronization with error correction. Following
Figure 9. Block diagram of the RDS decoder.
this we can finally display the data.
In a way events have now come full circle for the author, whose
software RDS decoder [6] saw its first publication in Elektor Web Links and Documentation
25 years ago.
[1] https://en.wikipedia.org/wiki/FM_broadcasting
Note: Radio Broadcast Data System (RBDS) is the official
Final thoughts
name used for theU.S.version ofRDS.
A project of this kind is obviously not completed in a sin-
gle weekend. Its important to progress in stages, checking [2] www.elektormagazine.com/140277
the functionality of each individual block (mixers, filters, rate [3] Ellis, Michael, Using Mixers in Radio Communications,
reduction and control circuits) one at a time. When you do http://michaelgellis.tripod.com/mixerscom.html
this, it is worth outputting test signals from the FPGA or the [4] Donadio, P., CIC Filter Introduction,
C software using the D/A converter and evaluating these with http://home.mit.bme.hu/~kollar/papers/cic.pdf
the scope. In this respect the process for a software-based
[5] Ossmann, Martin: AVR Software defined Radio, E-book, Elek-
project resembles classic hardware development. In the same
tor International Media,
way you can feed in test signals as and when required (from
www.elektor-magazine.com/fileadmin/E-book_AVR_Soft-
signal generators) into the software via the A/D converters,
ware_Defined_Radio.pdf
for instance to frequency-sweep filters. Or let the software
generate test signals itself. [6] Ossmann, Martin:
(150326) RDS Software Decoder, Elektor December 1989
The ARM board used in our course From 8 Atmel Studio6 [5], you can get cracking also as analog inputs for measuring volt-
to 32 bits: ARM Microcontrollers for Begin- straightaway with program construction, ages. Many of these pins have interface
ners [1] is an undisputed bestseller in the as no additional hardware or software functionality in addition. Figure1 shows
Elektor Shop. No wonder, because for tools are required. For checking out the the three expansion connectors with their
around 40, 30 or US$45 the SAM D20 various controller features like UART, I2C, pin numbering and respective Port pins.
Xplained Pro offers a powerful platform for ADC and similar three expansion connec- The logical functions given are a selection
developing your own embedded projects tors are provided in the form of 2x10-pin we have made (and among these, those
[2]. Included is a SAMD20J18 controller header strips. In addition to 3.3V and that can be preset). The lower half of each
with a generous 256KB of Flash and 32KB Ground in each case, 16Controller pins are connector contains interface pins for I2C,
RAM [3], whilst to simplify development provided, whose functions can be preset UART and SPI, above which youll see the
a handy Debugger by the name of EDBG in the normal way using Controller Reg- digital inputs and outputs (GPIO), analog
is also on board [4]. After downloading isters. All of these pins can behave as inputs (AIN) along with pins provided for
the cost-free development environment digital inputs and outputs, in many cases timer and counter functions (TC).
DEBUG
EXTERNAL TARGET
EXT1
1 ID 1 2 GND GND
AIN[8] PB00 3 4 PB01 AIN[9]
EXTENSION 1 HEADER
GPIO PB06 5 6 PB07 GPIO
TC6/WO[0] PB02 7 8 PB03 TC6/WO[1]
EXTINT[4] PB04 9 10 PB05 GPIO
(S2) I2C SDA PA08 11 12 PA09 (S2) I2C SCL
(S4) UART RX PB09 13 14 PB08 (S4) UART TX
(S0) SPI SS PA05 15 16 PA06 (S0) SPI MOSI
(S0) SPI MISO PA04 17 18 PA07 (S0) SPI SCK
19 GND GND 19 20 VCC VCC_3V3
32kHz
CRYSTAL
EXT2
1 ID 1 2 GND GND
SAMD20J18 AIN[18] PA10 3 4 PA11 AIN[19]
EXTENSION 2 HEADER
EXTENSION 3 HEADER
(S5) SPI MISO
(S4) UART RX
(S2) I2C SDA
(S5) SPI SS
TC2/WO[0]
EXTINT[8]
AIN[0]
GPIO
GND
ID
PB16
PB17
PB30
PB11
PA08
PA28
PA12
PA02
GND
19
17
15
13
11
9
7
5
3
1
20
18
16
14
12
10
8
6
4
2
PB23
PB22
PB10
PA09
PA27
PA13
PA15
PA03
GND
VCC
TC2/WO[1]
VCC_3V3
AIN[1]
GPIO
GPIO
GND
Figure 1. The tables beside the three expansion connectors indicate the connector pin numbering and
the respective Port pins. We have included a selection of their logical functions.
+3V3 +5V
Beef up your projects
R3 R4
10k
10k
T2
RX K3
1 2
BSS138
+3V3 +5V 3 4
R1 R2
PWR
10k
10k
T1
1 2 +5V
AIN0 AIN1 GPIOA
CONTROLLER BOARD
3 4
AIN2 AOUT/PWM
5 6
I2C_SCL I2C_SDA BSS138
7 8
+3V3 +5V
SPI_MOSI SPI_MISO
9 10 R7 R8 K4
SPI_SS/SYS_CLK SPI_SCK
11 12 1 2
GPIO1 GPIO2
10k
10k
T4
13 14 3 4
VOUT 3,3V GND
GPIOB 5 6
7 8
ECC/GNUBLIN
+3V3 BSS138 +5V
9 10
R5 R6 ECC
10k
10k
T3
Figure 2. Specification of the 14-pole Gnublin/
EEC connector. When used on a controller board, TX
K1
1 2
CONTROLLER BOARD
10 9
3 4 AIN0 K2
GPIOA VOUT 5V
8 7 5 6 1 2
GND
6 5 7 8 AIN2 3 4
RX TX
4 3 9 10 GPIO2 5 6
GND I2C_SCL
2 1 11 12 7 8
VIN 5V GPIOB 13 14 9 10
15 16 SPI_MOSI 11 12
ECC 17 18 13 14
19 20
EEC/GNUBLIN
SAM_020 +3V3
Pinout
These tables indicate the pin numbers of the expansion connectors, the controller
pins used (in the example EXT1) and their functions for EEC and ECC.
1 2 GND GND
AOUT PB0 3 4 PB1 AIN0
GPIOA PB6 5 6 PB7 GPIOB
AIN1 PB2 7 8 PB3 AIN2
GPIO1 PB4 9 10 PB5 GPIO2
I2C_SDA PA8 11 12 PA9 I2C_SCL
Figure 4. Here we have a SAM D20 board and an
Arduino Uno (with extension shield) connected RX PB9 13 14 PB8 TX
for working together. Because the two polarizing SPI_SS PA5 15 16 PA6 SPI_MOSI
keys of the ECC connectors point outwards on SPI_MISO PA4 17 18 PA7 SPI_SCK
each of the boards, we need to use a crossover
GND GND 19 20 3,3V EEC_3,3
ribbon cable.
Expansion boards
Together this should provide just about I2C_SDA
GPIO1
all a developers heart could desire. Along AIN1
with some fly-leads and the addition AOUT/PWM
Communication
The larger adapter board (140572-1) is
wired identically but is provided addition-
ally with an ECC (Embedded Communi-
cation Connector) for relaying UART sig-
nals (Figure3). At Elektor Labs we have
developed all manner of compatible com- Figure 7. The large adapter board can be connected only to EXT1, whereas there is room to fit all the
munication modules. Examples of these expansion pins of the small board.
Schematics
We dont need to say a lot more about
the circuits in Figure5/Figure6. You
EEC #5
will note the purely passive 3.3 V connec-
DISPLAY tions along with the four level convert-
ers mentioned already. K3 is the small
PWR (power) connector at upper right
on the ARM board. K1 represents one
140572 - 15 of the three expansion connectors EXT1,
EXT2 or EXT3. The large adapter board,
as Figure7 clearly shows, can only be
Figure 8. Connector numbering scheme for the demo project. These numbers are assigned when the
connected to EXT1.
boards are initialized, starting with the controller board.
BlockProtocol_Engine();
Web Links
R 0 5 +<CR>
[1] www.elektormagazine.com/140037
relay 5 (for example) on the board is [2] www.elektor.com/samd20 board
activated [12].
[3] www.atmel.com/Images/Atmel-42129-SAM-D20_Datasheet.pdf
[4] www.atmel.com/images/atmel-42102-samd20-xplained-pro_user-guide.pdf
In the demo project, which you can down-
load from the Elektor web page for this [5] www.atmel.com/tools/atmelstudio.aspx
article [6], a welcome message appears [6] www.elektormagazine.com/140572
on the display. If you press push button
[7] www.elektormagazine.com/140009
SW0 on the SAM D20 board, the user
[8] www.elektormagazine.com/140512
LED is then toggled.
If you dont have any RS-485 modules or [9] www.elektormagazine.com/120668
the RS-485/USB adapter, you can alter- [10] www.elektormagazine.com/140328
natively connect the PC direct to the ARM [11] www.der-hammer.info/terminal
board via USB. In this case you must alter
[12] www.elektormagazine.com/130154
the UART block number, by which block
Digital Zoetrope
Old & new united
By Willem van Dreumel (Netherlands)
This article contains a shade of nostalgia. Young people are The circuit itself con-
perhaps no longer familiar with this, but the older generation tains only six components. This is of course partly due to the
will likely have come across one of these in the ancient past: microcontroller, an ATtiny85, which takes care of all the con-
the zoetrope [1]. The zoetrope is a kind of predecessor of the trol. The code in the text box Arduino sketch for the digi-
Nipkow disk [2]. In a relatively primitive way a picture is put tal zoetrope ensures that the microcontroller does what we
into motion. This makes use of the same principle as film: expect from it. We use this to turn the LED on for 1ms every
multiple images are quickly shown one after the other and so 20 steps.
create the illusion of a moving image. Because the images are
generally on the inside of a revolving cylinder, the scenes are You will find comprehensive instructions about the program-
extremely short and are often chosen such that a repetitive ming of (among others) the ATtiny85 at [3]. Since the software
motion is shown. has been written in the form of an Arduino sketch, you can, of
course, also use an Arduino board for the control. In this case
Digital age you will have to pay attention to the five port numbers which
The circuit presented here (see Figure1) shows a more con- are used for the stepper motor and the LED. You will have to
temporary version, where a small stepper motor takes the change those to suit the Arduino board that you used.
required number of steps to place the next image in the correct
position. By illuminating a bright LED at just the right moment Stepper motor and LED
we create an exceptionally stable moving image. When using a bipolar stepper motor the control can remain
39R
7805 taking into account the 5% duty cycle (see text box Resistor
calculation). We will then have some margin. The slightly
8
VCC 1W higher resistance limits the current a bit more and as a con-
1 7
PB5 PB2 sequence the calculated dissipation in the resistor(s) is also a
2 6
3
PB3
ATtiny85
PB1
5
little less than that calculated.
PB4 PB0
GND BS170
4 Small circuit board
The small circuit board of Figure2 offers space for four com-
ponents. The LED, the series resistor and the stepper motor
to motor supply
have been omitted from the circuit board for practical reasons.
8 16
The LED because it will then be easier to mount it in its place
VCC2 VCC1
1
EN1,2 EN3,4
9 above the disk, the series resistor because there a various dif-
ferent ways in which it can be made and the stepper motor
2 15
7
IN1 IN4
10
because it is not necessary and possibly impractical anyway.
IN2 IN3
The LED and resistor are connected as shown in Figure2. The
L293D
3
OUT1 OUT4
14 power supply for the motor is connected to the connector on
6 11
OUT2 OUT3 the right. The L293D does not tolerate more than 36V, but
GND
GND
GND
GND
before that time the 78L05 will have already gone up in smoke
4 5 12 13
with its maximum input voltage of 35V. At such high power
supply voltages both ICs will become very warm and we there-
Stepper Motor
fore recommend against using a power supply voltage that is
this high. For most stepper motors a fraction of this voltage is
already more than sufficient.
150251 - 11
In practice
Another thing we have to take into account is the step size
Figure 1. The schematic with only six components (and a stepper motor).
of the stepper motor you are using. A typical step size is
1.8degrees. Because we switch the LED on every 20 steps,
this therefore corresponds to a rotation of 36degrees and
quite simple: An IC of the type L293D has everything on board so we need 10 successive images on the disk. The disk can
that is required for this. Four digital outputs from the ATtiny then rotate through 360degrees, after which the illustration
drive the L293D. After every twenty steps the FET is turned sequence repeats again. A multiple of 10 will work as well, of
on and the LED flashes. It is best to use a substantial size LED course, but the pictures will then become rather small. The
for this, for example a 1Watt type, to minimize the interfer- digital zoetrope is exceptionally stable. If the direction of rota-
ence from ambient light on the moving imge effect. The volt- tion is not correct then simply turn the stepper motor plug the
age applied to the stepper motor can be variable. The series other way around.
Resistor calculation
For calculating the value of the current-limiting resistor we At the selected minimum current of 200mA the following
assume the following characteristics for a 1-watt LED: applies:
Web Links
[1] Zoetrope, Wikipedia entry: https://en.wikipedia.org/wiki/
Zoetrope
[2] Nipkow disk, Wikipedia entry: https://en.wikipedia.org/wiki/
Nipkow_disk
[3] Tutorial ATtiny programming: http://highlowtech.
org/?p=1695
[4] Zoetrope images collection: www.bekkahwalker.net/MediaAr-
cheology/disks.html
[5] Sketch: www.elektormagazine.com/150251
Figure 2. The printed circuit board layout for the digital zoetrope.
ARM CMSIS
Developer Competition
The Winners!
Back in March ARM, along with microcontroller manufacturers ST, NXP, Freescale
and Infineon, launched a developer competition in conjunction with Elektor. There
were dozens of top-quality entries, and judging them was far from easy. And here
are the winners!
ARM Cortex-M series microcontrollers have a very wide range being useful and ideally innovative, the software, exploiting
of features, and low-level drivers are needed to simplify access the features of the CMSIS driver library, had to be maintain-
to interfaces such as U(S)ARTs, I2C and USB. The CMSIS driver able and portable. Competitors were also encouraged to make
standard is a neat idea by ARM that unifies these drivers in the fullest possible use of the features of their selected board.
a manufacturer-independent way, and our competition grew
out of that idea. Competitors were allowed to choose from a Choosing the winners
range of four well-equipped development boards produced by By July dozens of projects had been sent in and it was up to
ST, NXP, Freescale and Infineon, and were given a free six- the jury, formed of experts from the manufacturers involved,
month license for the powerful ARM/Keil MDK development to make their decision. It was not an easy task! The jury was
environment. A total of US$10,000 in prizes was up for grabs. impressed not only by the high quality of the code and docu-
mentation in the entries, but also by the breadth of the range
Run on the boards of application areas: from medical electronics to amateur radio
The demand for boards was tremendous: in total the folks at and from audio to home automation. And so, without more
ARM received around 800 requests, coming from all corners ado, we announce the winners!
of the world. On the basis of the proposed projects 400 com- (150297)
petitors were selected to receive a free board. Developers
then had around five months to turn their idea into a reality. More information on the projects can be found at
The bar was set high: as well as the concept behind the project www.keil.com/contest.
Waldemir Cambiucci, So Paulo, Brazil the signals from flow sensors and tank
This project addresses a pressing prob- level indicators and controls pumps, all
lem: water shortages in large Brazilian under the direction of a web-based inter-
cities and the consequent rationing of face. The project is based on a Freescale
supplies. The solution is very economi- Kinetis K64F microcontroller, which uses
cal, and allows the user to monitor water the ARM Cortex-M4 core. Interfacing and
use in real time and track down possible control functions, as well as access to the
leaks or wastage. The system processes Ethernet port, are provided by the CM-
SIS drivers.
Honorable mention
Nitin Bhaskar: a smart point-of-sale Stuart Bockman: a device to measure Javier Fernandez: a flexible bus
system using NFC. the jitter of a laser pointer and to analyzer.
Andreas Siebert: the Relax Player, detect hand movements using an Alexander Dmitriev: an intelligent
a web-controlled audio player with a accelerometer. watering system for plants, with a
handsome wooden enclosure. web interface.
Review and
Teardown
A new 3-channel 100-
watt power supply
how does it stack up?
By Martin Cooke
First Impressions and V but technically PD is more accurate and underlines the
Bench power supplies arent really pieces of kit that get your fact that the outputs of the HMC8043 are fully floating and can
pulse racing, they just sit there doing their job, in some cases withstand a common mode voltage of up to 250V.
giving gentle background heating to keep the lab warm in
the winter and providing enough ballast to stop your bench Testing
wobbling about too much. The traditional bench top power Turning outputs on/off shows a well behaved output voltage
supply always came with a sturdy handle on the top to give waveform with no tendency to overshoot or undershoot with
you a clue that inside is some serious ironwork and that this various loads. The internal processor is monitoring key presses
beast is going to be heavy. But that was all yesterday; buy a and controls the output appropriately. The output voltage can
power supply today and it doesnt look much different from be adjusted in mV and the current limit in mA or 100 micro-
any other piece of test gear; covered in buttons with a TFT amps steps for levels less than 1A. A track option allows all the
display and the chances are you can wrap your hand around it channels to track together in terms of their voltage and current
and pick it up one-handed. Thats true of the HMC8043 three settings. Each channel of the HMC8043 can be programmed
channel 100-watt bench power supply from Rohde & Schwarz to operate in constant voltage or constant current mode and
I received for reviewing. has an impressive range of protection mechanisms including
The front panel layout is restrained and efficient, consistent over-voltage, over-current and over-power protection. Elec-
with their current compact range of test equipment; users tronic fuse values can also be defined for each channel along
of the HMC8012 multimeter will be familiar with the almost with a fuse delay from 10ms to 10s to avoid channel dropout
identical layout. at start up inrush. Fusing can be interlinked between channels.
The output terminals along the front panel do not include an In addition to displaying voltage and current readings the instan-
Earth post. Setting up the functions via the front panel buttons taneous and accumulated power delivered to the load in W/s in
and bright TFT display is fairly intuitive and did not require too can also be logged. This gives a useful indication of the power
much recourse to the operators manual. Voltage designations requirements and expected battery life particularly if the cir-
on German equipment often use capital U instead of V. This cuit switches between sleep and active modes.
indicates difference and is best taken to mean Potential Differ- The three isolated outputs allow the freedom to assign the
ence (PD) which is a voltage difference not referenced to ground available 100W as you wish: connect all three in parallel to
potential. Most power supplies dont differentiate between PD give 0-30V at around 3A or in series to give 0-99V at around
Dynamic-Load Testing
A 0.7-ohm resistor switched in parallel with a 7-ohm resis-
tor was used to test the performance of the supply driving a
dynamic load. The resulting DC output level is shown as the
Figure 2. Output voltage 1.800V hard turn off (power fail) 20ms/div, 0.5V/
upper trace in Figure 3 with the switching waveform shown div. load = 7 ohm with + 1.5 microfarads cap (increasing capacitive load to
as the lower trace. The voltage output is set to 0.700V and 220 microfarads showed slight improvement (reduced peak)). Captured on
the output current turned up to maximum to ensure that any a 10 MHz scope.
control mechanism didnt limit the output current. The output
characteristics show excellent recovery to the dynamic load
with well controlled voltage damping and good phase margin.
tection in the design until a co-worker produced a woodworking Useful for development environments using multiple supplies,
rasp and asked him to rake it across the outputs. Apparently the sequence option allows turn-on of a channel to be delayed
the intermittent short circuit can defeat the most carefully from 10ms to 10s after the master On/Off is activated. The
considered protection and test the regulator control loop to analogue control input can also serve as an external trigger
the limit. Sure enough Bob returned to his workplace nursing input which initiates pre-programmed processes in the power
a smouldering prototype. Lesson learned; could the HMC8043 supply. A manual trigger pushbutton is also included on the
pass the test? (Figure 4) Well there were sparks but in short, front panel.
yes it did. The same test with three channels in series should
not be attempted because the maximum reverse could be The EasyArb feature on the HMC8043 is Rohde & Schwarzs
exceeded on one channel. very close approximation of an arbitrary waveform generator
(AWG) function. Whereas AWG is usually time-based, in the
Device Connection Options MHC8043 it can also be event-based, which is exceptional in
The version of the unit supplied is not fitted with an IEEE-488 its price class.
connector (this is optional) but has a LAN connector for test
environments using the newer LXI (LAN Extensions for Instru- EasyArb allows the output voltage level on any channel to be
mentation) network based on Ethernet. The rear mounted USB defined with a resolution of 10ms, 1mV and 1mA. The wave-
port allows the unit to be connected to a computer where it can form can be defined using a maximum of 512 points and can
communicate using a virtual COM port or via USB TMC (Test be repeated a programmed number of times or indefinitely.
and Measurement Class). Using a virtual COM port allows you Entering the data by hand using the front panel buttons can
to communicate via a standard terminal emulation program be tedious; HMExplorer is the more convenient option here.
Figure 4. The Pease Test there were sparks but it survived. Figure 5. Battery recharging using remote sensing.
using the SCPI commands after the corresponding Windows Remote Voltage Sensing
drivers have been installed. Alternatively you can use the free The three channel version I tested has a rear socket which
Windows application HMExplorer which has a built-in terminal amongst other signals, offers remote voltage sensing for all
emulator function and also allows you to save screenshots, three outputs. This is useful to remove the voltage drop pro-
define an arbitrary waveform and store measurements. duced in the cables supplying power to the load. This feature
can also be handy when the supply is used to recharge a
The rear panel connector also allows the connection of an multi-cell rechargeable battery pack. Its always a good idea
analogue control input voltage. This allows an external ana- to include an external diode in series with the battery pack
logue voltage in the range from 0 to 10V (or current from 4 when charging from a power supply. Without the diode, a
to 20mA) to control any or all of the three output channels. power outage will often cause the energy stored in the multi-
Assume, for example that channel 1 and 2 have been selected cell battery pack to bite back and destroy the power supply
to be controlled by the analogue input. Using the menu the output stage. The remote sense allows the battery pack volt-
output voltage of channel 1 is set to 30V and channel 2 to age to be monitored directly, ignoring the non-linear voltage
20V. Now as the analogue control voltage is increased from drop induced by the diode (Figure 5); the remote sense can
zero to 10V the outputs from channel 1 and 2 will increase compensate for a drop of up to 1V max.
proportionally from zero to their maximum setup values. On this model the sense voltage connection is available on
the rear panel mounted 16-way connector. The special, mat- SMD components which populate both sides of the board.
ing connector is pictured in Figure6. The unit automatically Behind the front panel is a PCB which interfaces to the display
detects the sense input is active and displays shows this on and pushbuttons. The chassis extends up at the rear to form
the display. Ensure the remote sense is securely connected the instrument back panel.
before the channel output is enabled; a flaky sense connection There are no nuts to work loose and cause problems. With
can cause the output voltage to fluctuate. the unit open we can see on the upper level, a panel holding
a fan and a third-party, industry standard, open-frame 200-
A logging function is also available to allow instantaneous watt AC/DC, switched-mode supply unit. This unit supplies
measurements to be stored to the internal memory or a USB 48V DC to the lower PCB where it divides into three micro-
memory stick. The measurement interval can be defined in the controller (Microchip dsPIC DSCs) controlled DC/DC switching
setup menu. The stored values can be in either .TXT format or regulators for outputs to the front and rear panels. The PCB
.CSV format so that can be input to a spreadsheet like Excel. quality, component mounting and layout are second to none.
The really exciting aspect here is that the HMC8043 and the With the front panel power switched off the main AC/DC power
USB stick is all you need to automatically record readings for supply remains continually powered in standby mode until the
many hours, even weeks depending only on the size of the PSU is turned off at the rear switch. In standby the unit uses
USB stick. No remote control by a PC is necessary at any point just over 8W.
during the measurements, and the .CSV file loaded from the
stick can produce charts almost instantly using Excel. This How does it stack up?
makes charging, monitoring and condition checking of all sorts Considering the high build quality and technical sophistication
of batteries and battery packs a pleasure to do. of the HMC8043 its remarkable that little effort been put into
Figure 6. The special 16-way connector required for wiring up remote Figure 7. Inside the case. On top is the Cincon 200-W open frame AC/
sensing and other applications. DC switch mode regulator supplying 48V to the three microcontroller-
controlled DC/DC convertors on the lower board.
By Harry Baggen
Quadcopters and their relatives are ragingly popular these days, not only with young people, but many
adults as well. Among electronics enthusiasts too, there is much interest in these multi-legged, flying,
electronic marvels. They are available in a multitude of types and sizes, ranging from simple toys to
large professional versions. In this column we will take a look at a few of the more unusual types.
In bygone times it was the dream of many a boy (and also company Droidworx has developed a quadrocopter which looks
his father) to fly a model aircraft. Nowadays it appears that like a small square black box when folded up [1]. The motor
everyone wants to play with a quadcopter or something sim- supports in their folded-up state fit exactly in recesses in the
ilar. By now were infested with these things. Toy stores have housing, and this includes the propellers which can also be
dirt-cheap models available for children, but also in the higher folded up. On the front of the enclosure there is a panel with
price categories there is an enormous supply for those who a few membrane pushbuttons and an HD-camera. The blu
would like to take photos or videos from the air. And then can be operated using a remote control, a computer or an
were not even considering the aircraft for professional users Andoid or iOS device. For making recordings of yourself there
and military purposes. is a selfie setting where the quadcopter will continue to fly
behind you at a distance which you can set. The blu looks
So drones exist in all price categories, types and sizes. There rather fragile, at first glance, with its designer looks, but the
are a number of remarkable examples regarding their con- thing is made from carbon reinforced and nylon parts and as
struction or function, and it is a few of these that we will take a consequence is very robust. The required computing power
a look at this time. is provided by an STM32F7 32-bit microcontroller and a fast
GPS receiver is built in by default. The blu costs 500 dollars
Collapsible and there is also a separate Bluetooth controller available in
Drones especially the larger models are quite awkward the form of a wrist band.
when considering their size. They are not easily transported
because of the four or more protruding motor supports. It is On a wire
sometimes possible for the propellers to be removed easily, Why would you design a quadcopter thats attached to the end
but even then the supports still protrude a considerable way. of a cord? Nevertheless that is exactly what has been done with
Some manufacturers have solved this with a construction that the Fotokite Phi, a project that is collecting funding on Indiegogo
includes a collapsible mechanism. Often a kind of umbrella to enable production to begin [2]. The Fotokite Phi hovers on a
mechanism is used for cable behind you and follows you around without the need to
this, but there are control it via a smartphone or remote control. The range is a
also other few meters and the cable holder contains a kind of remote con-
ways. The trol which can be used to set the height and orientation of the
Web Links
[1] www.mydroidworx.org/blu.html
[2] www.indiegogo.com/projects/fotokite-phi-tethered-uav-for-aerial-filming
[3] http://skyworksas.com/eedu/
[4] www.kickstarter.com/projects/1528442751/first-water-proof-drone-with-sonar-fish-finder
[5] http://snakerivershootingproducts.com/
Help! This one we havent been able to figure out in the lab. So far we failed to get this pigheaded buck-
converter under control. What are we doing wrong? Were stuck for ideas...
With hindsight it is easy to say, but maybe I should not have ammeter. For IC2A we require a 5-V power supply voltage,
picked this IC (LM2677T-ADJ, Ed.) said a colleague in our lab this is generated by IC3, an LM317. C4, C5 and R10/C13 are
who was tasked with designing a new laboratory power sup- required to make the regulator more stable under load. The
ply. Even with a fixed voltage divider for 30V, a pulsed load time has come for a prototype in hardware.
of several amps has drastic consequences.
Without an external load, the output of our prototype had
Perhaps we have to take a step back and start from the begin- a minimum voltage of about 0.3V. With a 40- load the
ning. The design began with the idea to build a bench supply lowest adjustable output voltage was about 0.017V. Not
with the following specifications: bad, considering the absence of a negative bias voltage. The
measured efficiency is also not at all bad at nearly 94% with
Adjustable output voltage of 0-30V 30V/5A at the output.
At least 3A with current limiting
Stable under typical lab applications The next test, a pulsed load of 5A with a 50% duty cycle, was
less encouraging. The output voltage collapsed like a house of
This is a fairly loose description and it offered the designers cards and was far from stable. There was no combination of
a wide choice of potential implementations. And because our choke and output capacitor for the output filter (L1/C10-C12)
name is not Elektor for nothing, and we have not acquired our to be found that worked properly. Upping to 82H instead of
good reputation with copied circuits and lack of original ideas, 22H for L1 changed practically nothing. The only advan-
we naturally did not choose the easiest and most obvious path. tage was that the voltage during the pulse load only collapsed
But then you do have the increased likelihood of surprises. As and not bounced back to a nasty voltage above the set output
happens to be the case with this circuit. voltage (except for a small overshoot). A larger output capac-
itor had a positive effect on the pulse-load regulation at lower
After some foraging around a few chip manufacturers, looking voltages, but caused an even worse drop of output voltage at
for interesting possibilities, we came across the LM2677T-ADJ higher voltages (> 20V). At about 50% duty cycle the regu-
from Texas Instruments. Relatively simple, high efficiency, lation of the controller was also a little more unstable, which
good voltage regulation and a maximum output current of 5A has its consequences for the current limit controller.
all sound ideal. So we set to work.
Shorting all the grounds together also gave a slightly better
And soon there was the first schematic, v0.01. We assumed result. A large ground plane on the top is probably essential
a (reasonably) stable input voltage of 36V (K1). P-channel (the prototype was a single-sided design), but this is unlikely
JFET T1 prevents switch-on and switch-off artifacts. The feed- to result in an appreciable improvement in stability. Simulations
back input is used for setting the output voltage. By selecting using Webench (webench.ti.com) result in various combinations
an active control loop (with opamps IC2B and IC2D), we can of filter components for a range of different output voltages...
also implement the current limit at the same time. With IC2A Perhaps the LM2677 is very sensitive to the ripple at the out-
and a shunt resistor (R12) we make the drive circuit for an put caused by the pulse load?
Experimenting with an LC-filter output filter. The regulator in our power supply would have to
(82H and 220F) connected to be able to supply at least 8A in order to handle a pulse of
a normal DC power supply and 5A without any problems...
a pulsing load resulted in a The internet offered no consolation for this problem. At least,
small surprise: at a 1.32kHz we havent been able to find anything concrete about it. We
(approximately the resonant are hardly the first to stumble over this?! On the other hand:
switching frequency) pulse how realistic is such a pulse load?
load and 50% duty cycle We can, of course, also limit the power supply at a lower load
the DC current through the current, but that would be a shame. At a constant load there
coils is about equal to half is no problem supplying 5A.
the peak current. Strangely Is this typical behavior for all buck-converters with an output
enough this looks to be less filter at heir output? Perhaps the output filter is brought into
on the scope, but a mul- (series) resonance? Because it goes wrong when the switch-
timeter just indicates half. ing frequency of the load is in the vicinity of the resonant fre-
But there is also an AC-com- quency of the output filter. Perhaps a parasitic current flows
ponent, at the frequency of the somewhere?
load of course. This was nearly sinu- What do you think of the efficiency? A switching load will, in
soidal. In our test the combined peak of principle, cause a voltage over-shoot, but because the voltage
DC+AC turned out to be one and a half regulator attempts to keep the output voltage constant, the
times as big as the maximum current energy stored in the LC circuit can only escape in the form of
when the load was not switched. That a current, hence the current peak.
is: of you load a power supply with 3A Share your opinion with us. Email jan on editor@elektor.com;
continuous, then you would expect an subject [buck]. To be continued...
average of 1.5A when switching the load at (150487)
a 50% duty cycle. The peak current is then suddenly nearly
4.5A when the switching frequency of the load is equal to
the resonant frequency of the
Summers gone but Elektor.Labs is still on fire! To prove it, heres another compilation of whats new in
our user-driven, DIY projects virtual laboratory. Lots of projects, most of them suitable for the average
electronics hobbyist, so having reading these pages, go ahead and check out whats new!
Merry Xmas
Eeeerh, Summer Vacation!
Just to make it clear:
Were not yet hibernating just now; just
making sure were in time for the fes-
tive season. This Christmas ball consists
of a 4x8 LED matrix controlled by an
ATmega328P. That makes it easy to
http
program using an Arduino Uno. Its ://po.s
t/xm
still in the prototype stages, but the asba
ll
PCB and the proper (festive) soft-
ware will be coming soon!
MLX90393
software-defined 3-axis magnetometer
By Clemens Valens
Sensors are primordial to most electronics projects; without them circuits would not (have any) function.
Most sensors measure physical quantities that are analogue by nature and using their noise-sensitive
signals is not always easy. But digital electronics has come to the rescue and many modern sensors
integrate signal processing circuitry and a serial interface. In this article we show you how to use a state-
of-the-art tri-axis magnetometer without calculating a single resistor value.
The MLX90393 tri-axis magnetometer tometer and it is part of the Triaxis prod- for the X- & Y-plane, they must be dou-
is one of the latest magneto products uct family, a family of sensors that use bled for the Z-plane, see inset for units).
by Belgian sensor specialist Melexis. the Hall Effect for measuring changes in To compensate for thermal drift the chip
Another sensor from this manufacturer magnetic flux density. Other family mem- includes a thermometer that measures
that you may have heard of is the popu- bers are the MLX90333 3D joystick posi- the temperature of the sensor.
lar MLX90614 digital infrared thermome- tion sensor and the MLX90363 program- According to Melexis the MLX90393 is
ter, used in several Elektor projects. The mable position sensor. Applications of the software-defined. We have to take this
automotive industry is a large consumer device range from measuring the Earths with a grain of salt because there is no
of Melexis products and your car proba- magnetic field (compass) to complex 3D software to be loaded on the device for
bly contains several of them (unless you position sensing, gesture recognition and it to work in a user-defined way; what
drive an old-timer). non-contact switching. To make all these they mean is that the sensor can be con-
applications possible the devices sensitiv- figured by software. Ten 16-bit registers
What is it? ity is programmable: minimum full-scale allow you to specify in quite some detail
The official product name of the equals to about 5mT, the maximum full- what kind of output you may expect from
MLX90393 is Triaxis Micropower Magne- scale is around 70mT (values given are the sensor.
0R
0R
the device will have an SPI (3-wire and
4-wire modes available, up to 10MHz) or
IC interface (four different addresses;
R_A1_0 R_A0_0
speeds 10kHz, 100kHz and 400kHz). C1
* *
0R
0R
Reading the datasheet closely it seems 12 11 10 9
100n
that it can even do IC and SPI at the CON1
13
U1
8
2k2
2k2
EXP
0R
6 SENB/CS
Using it
The MLX90393 is housed in a tiny
3x3mm 16-pin QFN case, making hand
soldering of the chip difficult. Luckily Mel-
exis has designed a handy break-out or
INT/TRIG
evaluation board (EVB) for it (Elektor
INT
shop reference 150209-91 [3]) that is 2 1
easy to use. Also provided are C++ librar- 140555 - 11
For those who suffer from sleep onset insomnia it may be useful at night in bed
while drinking a hot cup of cocoa (keeps Alzheimer away, it appears) to review the
units that are used for magnetic quantities.
Magnetic flux density or magnetic induction, or simply magnetic fields, used to be
measured in gauss (G), but in the SI system this unit was replaced by the tesla
(T). One gauss is defined as one maxwell per square centimeter (Mx/cm). The
maxwell is the pre-SI unit for magnetic flux (previously called a line) and has
been replaced by the weber (wb). 1Mx = 10-8Wb, so 1G=10-8Wb/cm. 1G is
also equal 100T and so 1T = 1Wb/m (note the switch from cm to m). But,
since T is equal to Vs/m, one gauss is equal to 10-4kg/(Cs). Because the tesla is
quite large to express the Earths magnetic field and other natural phenomena in,
geophysicists tend to use the gamma (), where 1=1nT. The henry (H) is the
unit for inductance, closely related to magnetism: H = Wb/A = Tm/A = s.
Close up of the MLX90393 evaluation board If you made it this far, you should consider consulting a sleep specialist.
(EVB).