Radio Transmitter

For your comments, suggestions, or your looking for a circuit or design, or a electronics designer, please send you Inquiries to pcb1001@gmail.com. We are happy to help and attend to your concerns.

Tuesday, May 26, 2009

UltraSonic Radar

This is a very interesting project with many practical applications in security and alarm systems for homes, shops and cars. It consists of a set of ultrasonic receiver and transmitter which operate at the same frequency. When something moves in the area covered by the circuit the circuits fine balance is disturbed and the alarm is triggered. The circuit is very sensitive and can be adjusted to reset itself automatically or to stay triggered till it is reset manually after an alarm.


How it Works

As it has already been stated the circuit consists of an ultrasonic transmitter and a receiver both of which work at the same frequency. They use ultrasonic piezoelectric transducers as output and input devices respectively and their frequency of operation is determined by the particular devices in use.

The transmitter is built around two NAND gates of the four found in IC3 which are used here wired as inverters and in the particular circuit they form a multivibrator the output of which drives the transducer. The trimmer P2 adjusts the output frequency of the transmitter and for greater efficiency it should be made the same as the frequency of resonance of the transducers in use. The receiver similarly uses a transducer to receive the signals that are reflected back to it the output of which is amplified by the transistor TR3, and IC1 which is a 741 op-amp. The output of IC1 is taken to the non inverting input of IC2 the amplification factor of which is adjusted by means of P1. The circuit is adjusted in such a way as to stay in balance as long the same as the output frequency of the transmitter. If there is some movement in the area covered by the ultrasonic emission the signal

that is reflected back to the receiver becomes distorted and the circuit is thrown out of balance. The output of IC2 changes abruptly and the Schmitt trigger circuit which is built around the remaining two gates in IC3 is triggered. This drives the output transistors TR1,2 which in turn give a signal to the alarm system or if there is a relay connected to the circuit, in series with the collector of TR1, it becomes activated. The circuit works from 9-12 VDC and can be used with batteries or a power supply.


Construction

First of all let us consider a few basics in building electronic circuits on a printed circuit board. The board is made of a thin insulating material clad with a thin layer of conductive copper that is shaped in such a way as to form the necessary conductors between the various components of the circuit. The use of a properly designed printed circuit board is very desirable as it speeds construction up considerably and reduces the possibility of making errors. Smart Kit boards also come pre-drilled and with the outline of the components and their identification printed on the component side to make construction easier. To protect the board during storage from oxidation and assure it gets to you in perfect condition the copper is tinned during manufacturing and covered with a special varnish that protects it from getting oxidised and also makes soldering easier. Soldering the components to the board is the only way to build your circuit and from the way you do it depends greatly your success or failure. This work is not very difficult and if you stick to a few rules you should have no problems. The soldering iron that you use must be light and its power should not exceed the 25 Watts. The tip should be fine and must be kept clean at all times. For this purpose come very handy specially made sponges that are kept wet and from time to time you can wipe the hot tip on them to remove all the residues that tend to accumulate on it. DO NOT file or sandpaper a dirty or worn out tip. If the tip cannot be cleaned, replace it. There are many different types of solder in the market and you should choose a good quality one that contains the necessary flux in its core, to assure a perfect joint every time. DO NOT use soldering flux apart from that which is already included in your solder. Too much flux can cause many problems and is one of the main causes of circuit malfunction. If nevertheless you have to use extra flux, as it is the case when you have to tin copper wires, clean it very thoroughly after you finish your work. In order to solder a component correctly you should do the following:

  • Clean the component leads with a small piece of emery paper.
  • Bend them at the correct distance from the component�s body and insert the component in its place on the board.
  • You may find sometimes a component with heavier gauge leads than usual, that are too thick to enter in the holes of the p.c. board.
  • In this case use a mini drill to enlarge the holes slightly. Do not make the holes too large as this is going to make soldering difficult afterwards.
  • Take the hot iron and place its tip on the component lead while holding the end of the solder wire at the point where the lead emerges from the board. The iron tip must touch the lead slightly above the p.c. board.
  • When the solder starts to melt and flow wait till it covers evenly the area around the hole and the flux boils and gets out from underneath the solder. The whole operation should not take more than 5 seconds. Remove the iron and allow the solder to cool naturally without blowing on it or moving the component. If everything was done properly the surface of the joint must have a bright metallic finish and its edges should be smoothly ended on the component lead and the board track. If the solder looks dull, cracked,or has the shape of a blob then you have made a dry joint and you should remove the solder (with a pump, or a solder wick) and redo it.
  • Take care not to overheat the tracks as it is very easy to lift them from the board and break them.
  • When you are soldering a sensitive component it is good practice to hold the lead from the component side of the board with a pair of long-nose pliers to divert any heat that could possibly damage the component.
  • Make sure that you do not use more solder than it is necessary as you are running the risk of short-circuiting adjacent tracks on the board, especially if they are very close together.
  • When you finish your work cut off the excess of the component leads and clean the board thoroughly with a suitable solvent to remove all flux residues that may still remain on it.
  • There are quite a few components in the circuit and you should be careful to avoid mistakes that will be difficult to trace and repair afterwards. Solder first the pins and the IC sockets and then following if that is possible the parts list the resistors the trimmers and the capacitors paying particular attention to the correct orientation of the electrolytic.

Solder then the transistors and the diodes taking care not to overheat them during soldering. The transducers should be positioned in such a way as they do not affect each other directly because this will reduce the efficiency of the circuit. When you finish soldering, check your work to make sure that you have done everything properly, and then insert the IC�s in their sockets paying attention to their correct orientation and handling IC3 with great care as it is of the CMOS type and can be damaged quite easily by static discharges. Do not take it out of its aluminium foil wrapper till it is time to insert it in its socket, ground the board and your body to discharge static electricity and then insert the IC carefully in its socket. In the kit you will find a LED and a resistor of 560 � which will help you to make the necessary adjustments to the circuit. Connect the resistor in series with the LED and then connect them between point 9 of the circuit and the positive supply rail (point 1).

Connect the power supply across points 1 (+) and 2 (-) of the p.c. board and put P1 at roughly its middle position. Turn then P2 slowly till the LED lights when you move your fingers slightly in front of the transducers. If you have a frequency counter then you can make a much more accurate adjustment of the circuit. Connect the frequency counter across the transducer and adjust P2 till the frequency of the oscillator is exactly the same as the resonant frequency of the transducer. Adjust then P1 for maximum sensitivity. Connecting together pins 7 & 8 on the p.c. board will make the circuit to stay triggered till it is manually reset after an alarm. This can be very useful if you want to know that there was an attempt to enter in the place which are protected by the radar.

Componets:

R1 = 180 KOhm
R2 = 12 KOhm
R3, 8 = 47 KOhm
R4 = 3,9 KOhm
R5, 6, 16 = 10 KOhm
R7, 10, 12, 14, 17 = 100 KΩ
R9, 11 = 1 MOhm
R13, 15 = 3,3 KOhm
C1, 6 = 10uF/16V
C2 = 47uF/16V
C3 = 4,7 pF
C4, 7 = 1 nF
C5 = 10nF
C8, 11 = 4,7 uF/16
C9 = 22uF/16V
C10 = 100 nF
C12 = 2,2 uF/16V
C13 = 3,3nF
C14 = 47nF
TR1, 2, 3 = BC547 , BC548
P1 = 10 KOhm trimmer
P2 = 47 KOhm trimmer
IC1, 2 = 741 OP-AMP
IC3 = 4093 C-MOS
R = TRANSDUCER 40KHz
T = TRANSDUCER 40KHz
D1, 2, 3, 4 = 1N4148

Tuesday, May 12, 2009

Port-Powered Temperature Meter

This is a four-channel temperature measurmet adapter that works without external power supply. It will suitable for measureing temperature and logging its data with a PC. The circuit diagram is very simple and no adjustment is required, everybody will able to build it with ease :-)


Specs. Micro-controller ATtiny15L (Atmel)
Number of channels Four channels
Measurement Range -40°C to +105°C (0.1°C/step)
or raw A-D value
Measurement Error ±0.5°C (at room temperature)
Sensor 103AT (Semitec)
Power Supply Supplyed from COM port (typ. 5mA)
Cost Approx. 1200JPY (All parts)

HARDWARE

Micro-controller

I chose an Atmel ATtiny15L for this project. It is the only device that has a built-in 10bit A-D converter in the 8 pin AVRs. The A-D converter has a bandgap reference and differencial amplifire as its front-end. The AVR core is clocked by only internal RC oscillator (calibrated to 1.6MHz), any other clock souce cannot be used. Also 25.6MHz clock source that 16x multiplied from core clock is available for timer/counter. This means that a fast PWM output can be generated. Therefore the ATtiny15L has good analog I/O capabiltity.

In this project, the A-D converter is used as four channels, single-ended, no gain and VREF from Vcc configuration. However RSTDISBL fuse must be programmed in order to use pin #1 as one of the analog inputs, an AVR programmer that can program in HVS mode is required.

Power Supply

The devices that works on the COM port without external power supply, such as serial mouse, are powered from the COM port. When an application program opens COM port, ER and RS signals will go high. The high level voltage is from 6V to 12V at most PCs, and it can supply 5mA at least. This is sufficient for low power micro-controllers.

Sensors

Four 103AT precision thermisters are used as temperature sensor. Its variation is very small, its temperature - resistance error at room temperature is ±0.3°C. The error of series resisters should be within ±0.5% to enable calibration-free design.

FIRMWARE

The program only respond the values of each channel to the PC by trigger command. The temperature - resistance curve of the thermister is not linear so that the raw A-D value is linearlized and converted to temperature value in software process. When replace the thermister with any oters, the linearlization table in the source code must be re-built. The raw A-D value can also be read, it will be used as voltage meter.

The trigger command is one "T" or "R" character, returened results are the temperarute for "T" command, raw A-D value for "R" command. Each value is separated by a comma and terminated by a .

Free Firmware

Monday, May 11, 2009

Digital Capacitance Meter

This is a simple capacitance meter which can measure capacitance value easy. There are some measurement methods for capacitance, at one time the capacitance was measured with a impedance bridge or a dip meter. Recently typical capacitance meters can measure capacitance and some additional characteristics from current vector by applying AC voltage to the Cx. Some simple capacitance meter use integration method that measureing transient response of the R-C network. There are some construction kits based on this method.


This project uses the integration method. There is an advantage that the resulut can be got as a digital data directly because it bases measurement of time, accurate analog circuit is not required and its calibration can be done easy by using a micro controller. Therefor the integration method is suitable for hand built capacitance meter with high realizability.

Hardware

To measure a charge time, only a voltage comparator, a counter and some glue logics are needed. However, a microcntroller (AT90S2313) is used for this project to realize the system easy. In point of fact, I had thought that analog comparator in the AVR is not useful. But I found that the compare output can also be used as a captureing trigger of TC1. This is a nice feature for that use :-)
The integration circuit can be simplified like shown in the circuit diagram. The threshold voltage is generated by divider registers. It seems not stable to valiation of supply voltage however the charge time is not affected by the supply voltage. You will able to find that voltage terms can be erased when apply formure 2, VC1/E term is dtermined by only divide ratio. This advantage is the essence found in the NE555 timer IC. Ofcourse the supply voltage must be steady during integration.

According to the foundation, measure integration time with only one threshold voltage will do. However input voltage of near ground level is little difficult to use due to following reasons.

  • Voltage not drop to 0 volt. Capacitor voltage will not be discharged to zero volt. It require a time to discharge capacitor to sufficientaly low voltage for measuring operation. It will expand measureing interval. Saturation voltage at discharge switch is also increase this effect.
  • There is a time beween start to charge and then start timer. It will cause a measurement error. This can be ignored on the AVR because it requires only one clock cycle for that sequence. Any other microcontroller may rquire to consider this problem.
  • Leakage current on analog input. Accrding to AVR data sheet, the leakage current on analog input is increased near zero volt. This will cause a measurement error.

To avoid to use near zero volt, two threshold voltages VC1(0.17 Vcc) and VC2(0.5 Vcc) are used and measure t2-t1(0.5RC). This can avoid avobe problems and comparator delay/offset will also be canceled. As for the leakage currnet, circuit board should be kept clean to minimize surface leak.

The supply voltage is generated with a DC-DC converter powered from a 1.5V AA cell. The swiching power supply is not suitable for measurement circuit but it seems not affected by ripple voltage because two ripple filters are applied. I recommend to use a 9V 6LR61 battery and a 78L05 instead, and do not omit BOD or you will be afflicted with EEPROM data collaption.
Calibration

When power is on first time, full segment, "E4" and ten several pF will be displayed. This value means stray capacitance on the circuit. The stray capacitance can be canceled by SW1. Two reference capacitors of 1nF and 100nF are needed to calibrate the capacitance meter. If you could not obtain the reference capacitors, accurate capacitors within ±1% can be used insted. This capacitance meter does not have any trimmer pot, it performs the calibration by reading the reference capacitor and saving gain adjustment value in full automatic operation.

To calibrate low range: First, adjust zero with SW1. Next, tie pin #1 and #3 of connector P1, set a 1nF reference capacitor and push SW1.

To calibrate high range: Tie pin #4 and #6 of connector P1, set a 100nF reference capacitor and push SW1.

"E4" at power on means calibration value in the EEPROM has been broken. It will never be displayed if once calibration is performed. As for zero adjustment, it is not saved into the EEPROM, it will require each time power-on or any jig is attached.

Free Firmware


Sunday, May 10, 2009

Radio Spectrum Monitor

This is an experimental work to monitor a spectrum pattern in radio band, and is a continuous project from Audio Spectrum Monitor. To analyze the spectrum of an input signal, I chose an Atmel AVR micro controller that used in the Audio Spectrum Monitor to process FFT. When think it easy, it can be thought that sample an input RF signal directly and analyze it will do. However, you will able to recognize that there are some technical difficulties from following reasons.


  1. The acquisition unit must have a sufficient speed and accuracy that covering over the radio frequency range. As for AM radio band like this project, fast 12 bit ADC and specific controller will able to cover this range. However there is no proper ADC for UHF band.
  2. Number of samples to meet required frequency resolution, fSAMP/fFUND samples, becomes too large. When monitor an AM radio band around 1 MHz in frequency resolution of 500 Hz, over 4000 samples will be required at least. And when monitor a VHF band in same frequency resolution, how many samples will be required...


To solve this difficulties, there is a generic method called Frequency Conversion. In brief, down-convert the RF signal to lower frequency with a mixer (multiplyer) before sampling stage. When process the signals as complex signal for the frequency conversion, it can handle negative frequency, and the center frequency can be moved to zero hertz without interference by image signals. This means that the sampling frequency higher than span frequency range will do. When monitor a 100 MHz band in span of ±1 MHz, it will be converted down to 0±1 MHz and sampled it in only 2 Msps. You may able to understand easy when explain it as `cut and paste' on the frequency domain. Actually, this kind of radio spectrum monitors are being supplied from some radio equipment vendors.

Hardware

In this project, an intermediate frequency signal from mixer output of an AM radio (fC=455kHz) is used as an input signal. It is converted again down to zero hertz in complex signal, so that the signal path, mixer and local oscillator, must be composed for complex signal processing. The complex signal is expressed in two wire IQ signal, the real part corresponds to I signal and the imaginary part corresponds to Q signal. The arithmetic circuits for IQ signal are realized in method of complex arithmetic. For example, a mixing circuit for IQ signals requires four multipliers and two adders from the formula:

(a1+jb1)(a2+jb2) = (a1a2-b1b2)+j(a1b2+a2b1)

Therefore the analog process of IQ signal requires large scale circuit compared to real signal process, so that the IQ signal is usually digitized after minimal analog process and following process are done in digital processor. In case of one input is real, only two multiplyer will do. By the way, when view a real signal as a complex signal, its spectrum pattern of positive part and negative part is line symmetrical. Real signal can be saied that the imaginary part is always zero. The case of complex signal becomes such state is: there are conjugate complex numbers, changed sign of the imaginary part (changed sign of frequency), for each complex frequency components. Therefore the real signal has symmetrical spectrum around the origin.

Software

The firmware samples IQ signal, analyze it in FFT algorithm and draw spectrum pattern into LCD module. These processes are done in refresh rate of approximately 60 times per second. IQ signal is sampled 128 points in samplig rate of 64 ksps at a time, span frequency of ±32 kHz around local frequency (455 kHz) can be monitored. Now horizontal scale (frequency) is labeled on the LCD but when measure local frequency of the radio receiver, the tuned frequency will able to be displayed under the spectrum bars - I became aware this idea during writing this document and implemented it in a hurry:-) When a local input from receiver is valid, frequency scale is appered in the LCD and tuned frequency is refrected.

The fast FFT routine is copied from audio spectrm monitor as is. Basically, FFT algorithm is in complex input/output, it can be used for complex signal with no modification unless it is optimized for real input. When input is a real signal, only half of result is valid because it is symmetrical around the origin. Ofcourse each domain of output is valid when input is a complex signal.

When apply a power, a menu window will apper and can be set working condition with a joystick. Each item can be selected with up/down action, changed with right action and enter running mode with push action. In running mode, up action hold/resume display, down action resets peak hold (if selected), left action redo automatic null (offset cancellation of ADC input) and push action returns to menu. Window function can also be selected, you will able to recognize difference between each window. Wave form mode monitors raw IQ signal but it will not useless.

Free Firmware

Adjustment

  1. Adjust local frequency to 455 kHz with TC1.
  2. Apply 455+10 kHz, 100mVP-P sin wave to the input port and set I and Q signal as same amplitude and quadrature phase at ADC input with VR1 and VR2. And confirm that DC levels are Vcc/2 (a little offset is negligible) and no distortion is recognized.
  3. Enter running mode. When a spectrum bar is 20 bins right from center, it is working successfully. If an image is appering at opposite position, adjust VR1 and VR2 to eliminate it carefully. A peak appearing center at start is due to left DC offset of IQ signal, it will be nulled automatically.

An AM super heterodyne radio receiver is used as a signal source. It may be modified to export mixer output and local oscillator output (this can be ommited). When it is a transister radio, large local frequency component (tuned freqency + IF) will pass through the mixer due to the mixer will be cheap emitter injection type. This affects dynamic range of DBM input, so that unnecessary signals above IF must be filtered out with a LPF. When IF frequency of radio receiver is 450 kHz, please read "455" in this page to "450".

GPS Data Logger

I have got a GPS module last year and I built a GPS data logger that records position data from the GPS module. The position data is output in NMEA-0183 format and store its sentence into any storage device. The position data can be processed with existing GPS utilities for interesting applications, such as Tracing the route on Google Maps (HTML source text).



Hardware



This is the inside of the built data logger and the circuit diagram. To store the tracking log, MMC/SDC is used for the recording media. The MMC/SDC is the most suitable purpose to collect the logged data to the PC. The GPS data logger is mainly used on automobile, so that its power supply circuit should pass the load dump surge immunity test. The operating power is got from only ACC line for good usability, and power switch is ommited. To detect brown-out and power-off, input supply voltage is monitored with the microcntroller. The controller part works at 3.0 volts and the GPS module works at 5.0 votls are tied via a level converters each other.

Software

When a positioning is established and a valid RMC sentence is detected, logging operation is started with a log file named in current UTC time YYMMDD.log. When same name is already existing, it starts to store from end of the file.

Because the operating power is got from ACC line, power-off will occure asynchronously regardless of the operating state. When power-off is occured, open file in write mode must be closed quickly during operating power is retaining in the capacitor, or the log file will be lost. In this project, when supply voltage is continuously below 8.0 volts for 10 milliseconds, it reecognizes that power-off and close the log file.

Free Firmware

Thursday, May 7, 2009

Graphic MP3 Player

The MP3 players consist of only semiconductor parts and no complex mechanics. This is a great feature for electronics handicrafts because it can be built easy with the same performance as commercial products except for the appearance. After a long blank in MP3 project, I built a new one again as the second MP3 project.


The first MP3 project was Pocket sized MP3 Player built with an MP3 chipset that obtained by chance. I have completed some projects of MP3 application for my business but not for hobby because I have no practice of listening music at the outdoors. Why did I built it in pocket size? Because that was only an impulse and nothing else. BTW, the MP3 player is being used in my car as a car MP3 player :-)

Now, there are many easy-to-use MP3 decoders that integrates DSP, DAC and amplifier on a chip. As the result, the MP3 player becomes to a popular project for electronics handiworks and everybody is enjoying to build it as their original project. One day I got to want to build an MP3 player by a reason (described below) and decided to start a new project. This is a regular project on the MP3 player after 8 years. I designed it as a desktop player because portable player is not useful for me.


Hardware

Below image shows the block diagram and the circuit diagram of built MP3 player. It has a feature that it has a large color LCD and a touch screen. Followings describe on each block.

Controller

A V850ES/JG2 (NEC Electronics) is used for system control. This is a 32-bit RISC microcontroller with 256KB flash and 24KB RAM. It was not that well known for electronics handiworks but somebody will be interesting in it because the V850 board was bundled as supplement of magazine in this year. For ordinary MP3 players, most 8-bit microcontroller is sufficient to build it. However this project requires a microcontroller with external memory interface because the controller must handle large amount of image data. Of course any popular microcontrollers, such as Renesas SH2 and H8, will able to be used as well. The reason why I chose the V850 is from its very low power consumption and the serial interface is easy-to-use better than Renesas's one. The V850ES/JG2 can run at 20 MHz but it is used at 14.7 MHz (4xPLL from 3.68 MHz xtal) to deliver a clock signal to MP3 decoder and LCDC.

Storage Media

SD Memory Card is the de facto standard of flash memory card. It can be attached to the microcontroller via a few signal lines. FAT format is used to store data files in it so that the project using the memory card must implement the FAT file system. Fortunately, there are various FAT libraries on the web as freeware so that everybody can use the memory card in their project with ease.

LCD Module

A 4″ color STN-LCD module in resolution of 320x240 is used for the display. Recently the price of color TFT-LCD are going falling and color STN-LCD will soon be shut out of the market. This project was started to to use this LCD module before it decays in the junk box.

A touch screen is attached on the LCD module, so that command buttons can be omitted. A CCFL is used for the back light and a CCFL inverter is required to drive the back light.

LCD Controller

The LCD module in this degree of resolution with built-in display buffer is not available and it must be refreshed by external circuit like CRT display system. Therefor it requires an additional LCD controller on the board to drive the graphic LCD module. The display buffer (RAM) is integrated in the LCDC or attached externally. In this project, an S1D13705 (EPSON) is used for LCD control. The S1D13705 has 80KB integrated display buffer and it can display in resolution of 320 by 240 with 8-bit color depth (256/4096 indexed color). It can be attached to the host controller via a 16-bit SRAM like interface.

The LCD module requires a 3.3V logic supply and an LCD bias supply (21-25V/3mA). Generally, the contrast of the STN-LCD in high drive duty ratio is affected by ambient temperature, so that a contrast dial is required to adjust the contrast. The contrast dial varies the LCD bias voltage. In this project, the contrast is adjusted automatically in software with a thermister put on the LCD module and a D-A converter.

MP3 Decoder

Recently VS10xx family (VLSI Solutions) is used for most home-built MP3 projects because it is easy to obtain and use. The VS10xx is designed for portable audio equipments and can drive a headphone directly. However it has only analog outputs and no digital (I2S) output, so that the VS10xx is not good when require an I2S output to attach an external DAC besides the analog performance is not good for Hi-Fi audio.

I chose STA013 (ST Microelectronics) for MP3 decoding. The STA013 have been released at the dawn of the MP3 format and widely used as a well known MP3 decoder chip. It has only digital (I2S) output, so that a proper audio DAC is required. This is an advantage on electronic handiworks because it can use various DAC chips and output audio data in SPDIF format with DAI encoder.

The STA013 has an integrated PLL oscillator to generate an audio timing clock (384fs) depends on DSP clock. If there is a jitter on the sampling clock, SNR of the analog output will be worse especially on Sigma-Delta DAC. Therefore the PLL power should be tightly filtered and pay attention to parts layout around the loop filter.

Analog Block
A PCM1748KE (BurrBrown) is used. The analog performance on the data sheet is not so bad but it is a little difficult to achieve expected performance because it is a Sigma-Delta DAC.

A post-filter is required at DAC output but only a slow roll-off one will do due to integrated 8x over sampling digital filter. In this circuit, the DAC output is filtered with a LPF+buffer and then output it as a line output and there is no speaker out. Therefore the MP3 player is used with any audio power amplifier.

The line output is tied to ADC input of the microcontroller. This is to get amplitude of the line output and display it as a level meter on the LCD. Generally an envelope detector is used for the audio level meter. In this project, to eliminate the envelope detector, the microcontroller samples waveform in sampling rate of 1kHz and detects peak-to-peak value from 20 samples. There will be dip points on the frequency response but there is no problem because this is for only a visual effect.

Building the MP3 Player

The circuit board must be embedded into a space in height of 10mm, so that the allowable height of the components on the circuit board is less than 6mm. Most of components used in this project ware surface mounted device. They are mounted on the proto-board directly and wired with UEW. This method requires soldering skill and practices but there is an advantage that it can achieve the density of double layered PCB or more. The FPC connector (0.5mm) easily creates solder bridge due to its terminal forms, so that solder the wire to the terminal via a stripe PCB instead of solder the wire directly.

The built circuit board is embedded with the LCD module into the case. The case is a clear acrylic case SK-16 (110x78x32mm) sold from Akizuki. Its depth was too long for this project, so that I cut down it to 25mm, paint black from inside and put an aluminum sheet for electromagnetic shield.

Free FirmWare

YUV(YCbCr) to RGB converter

Recently, most digital video equipments, such as video recorder, DVD player and TV game, have component video output. The component video signal is like RGB video signal, but it cannot connect to RGB monitor directly. Thus I designed and built YUV(YCrCb) to RGB converter to use old TV monitor or video equipment which does not have component video input.


For old RGB monitor....no, my principal aim is to generate RGB signal from component signal from PlayStation 2 for scan converter because recent shipped PlayStation 2 fixes configuration of video output format to component video when used as DVD player :-( Converting the component signal into RGB signal can enjoy the game and DVD with high quality picture. However, the PlayStation 2 can be fixed to RGB output configuration with only a jumper wire. If you wish to get only RGB signal from the PlayStation 2, I recommend this way instead :-)

The theory of RGB to YUV conversion

The component video signals are generated by separating a luminance component and two chrominance components from RGB signals with following formulae:

Y = 0.299R + 0.587G + 0.114B Luminance component

R-Y = R - (0.299R + 0.587G + 0.114B)
= 0.701R - 0.587G - 0.114B Chrominance component (Red)

B-Y = B - (0.299R + 0.587G + 0.114B)
= -0.299R - 0.587G + 0.886B Chrominance component (Blue)

Note: These parameters are for SDTV(525/625), not for HDTV(750/1120).

G-Y crominaice component can also be generated. However, to restore the RGB signal, Y and two chrominance components will do. The G-Y component contains least chrominance in the three chrominance components so that this term is omitted to minimize conversion error.

When restore RGB signals from component signals, following formulae are applied.

R = Y + (R-Y)
G = Y - 0.51(R-Y) - 0.186(B-Y)
B = Y + (B-Y)

The contents of component video signal are these three signals, Y, R-Y and B-Y. You will able to understand that these are loss-less conversion. However, in order to reduce overall video signal band-width to be recorded or transmitted, the band-width of chrominance components are reduced and some compression processes are applied. Human eyes are sensitive to luminance but not sensitive to chrominance. The quality of chrominance components, such as band-width, SNR and digitizing resolution, can be reduced compared with luminance component.

The chrominance signal levels at the transfer line are normalized to luminance amplitude because it is easy to A-D, D-A conversion and transmittion processes. Following are attenuation ratio for the chrominance signals:

Cr = 0.713(R-Y)
Cb = 0.564(B-Y)

And sync pulse is added to luminance signal as -0.3V pulses. These are the component video signals that is appering at input/output point. Typical signal levels at the interface connector are from -0.3V to +0.7V for luminance signal, ±0.35V for chrominance signals.

Hardware

To convert component video signals into RGB video signals, the alithmetic circuit composed with some OPAMPs is used. However, only it is not sufficient to build complete set, some glue logics are also required.

Most video signal outputs except some high end equipments are AC coupled, DC restore circuit is needed to video input part. To remove sync pulses added to Y signal, blanking circuit is also required. These function should apply for completed process. The timing generator for the functions is realized with only a CPLD because to realize it with discrete components will be complex. Following images show the generated wave form of blanking pulse and clamping pulse. Top one is Y input, below two are /BLANK and /CLAMP. Left image is near horizontal blanking area, right image is near vertical blanking area.

Relationship of picture quality between component video and its source

Difference between component video signal and YC video signal is the transfer method of chrominance components.

At YC video signal, a color sub-carrier is modulated by two chrominance signals with quadrature balanced modulation, and transferred as a chrominance signal. Therefore, the band-width of chrominance signals are reduced to half of the sub-carrier frequency. At NTSC video format, I,Q signal which is shifted 33 degree from R-Y,B-Y axis is used instead of R-Y,B-Y signal, the band-width for I signal is 1.5 MHz, for Q signal is 0.5 MHz. However, most video decoders seem decode in R-Y,B-Y axis and both signals are limited to 0.5 MHz.

At component video siglal, two chrominance signals are transferred with two separated lines directly. This is full band-width transmittion. When video signal is from TV game whose source is RGB video buffer, difference between component signal and YC signal appers conspiculusly as some effects shown in following images. In this case, component signal is better than YC signal.

NTSC Test Signal Generator

A video test pattern generator will be needed when calibrate or test video equipments. To characterize system performance and understand it quantitative, wave form monitor, vector monitor and related video measurement equipments will be required. Some generic patterns, shch as color bars, cross hatch, dots and full field, are also used for home video creation to calibrate video monitors without any measurement equipment.


This kind of test signal generators for personal use are often found as construction kits, however, most of the kits are designed on cheap analog method and the wave form is not accurate, therefore it cannot be used as a standard signal in fact. I designed and built a digital video test signal generator in order to generate accurate reference signals which can be used for calibration and measurment of video montors and home built video equipments.



Basic Design

Supported test patterns

The test signals used for electronics handiworks are required at least, plus some additional test signals are also implemented. However most test signals are used with wave form monitor, vector monitor, spectrum analyzer and others. An oscilloscope will able to be used instead of the wave form monitor in most case.

Color video signal format

This signal generator uses a three channel DAC to generate Composite video signal (CVBS) and S video signal (Y/C separated) at the same time, left one channel is not used in NTSC format. It is assigned for one of the color components of Y/CB/CR video format. This feature was not planned some years ago, but it has been added when started to draw the schematic this year, because NTSC television system might be obsoleted in the near future. The two different video format, component video and NTSC video, work in exclusive.

Specifications

Used LSIs DAC: MB40988 (Fujitsu)
MCU: ATmega161 (ATMEL)
PLD: XC95108 (Xilinx)
Output terminals CVBS: RCA pin jack
Y/C: 4pin Mini-DIN (S1)
Y/CB/CR: 14pin D type half pitch connector (D2)
Output impedance Video out: 75 ohm
ID out: 10 kohm
NTSC output
D1 output (480i) Timing: SMPTE 170M (RS-170A), Setup=0IRE (NTSC-Japan)
CVBS output: Y=714mV, Sync=-286mV, Burst=286mVp-p
Y/C output: Y=714mV, Sync=-286mV, Burst=286mVp-p
Y/CB/CR output: Y=700mV, Sync=-300mV, CB/CR=±350mV
D2 output (480p) Timing: SMPTE 293M
Y/CB/CR output: Y=700mV, Sync=-300mV, CB/CR=±350mV
Sampling 8bit x 3, 28.63636MHz
Power Supply AC100V 50/60Hz, <5w style="font-weight: bold;">

Hardware

Genarating a video signal

To generate any video signal, generic frame memory architecture will be used at most case. All samples of the video frame are stored into the frame memory and they are read in sequence and fed to video DAC. The difference between video signal generator and PC's video system is: which is stored into the frame memory, whole wave form including blanking/sync pattern or only pixel values in visible area.

The samplig frequency is 4 fsc (approx. 14.3MHz) at least. This is the typical value on the NTSC video system. However when use 4fsc for video measurements, an excellent video filter which has very sharp cut off, flat group delay and aperture effect compensation, is requied. This is very expensive and difficult to obtain. I chose 8 fsc (approx. 28.6MHz) for this project in order to decrease requirement to the post filter, like over sampling technic.

Wave form memory

The frame memory size is number of samples per line * number of lines per frame. In this case, memory size of 1820 * 525 = 1M samples is required for the frame memory, and the samples must be read out in transfer rate of 8fsc (cycle time of 35 nsec) continualy. An SDRAM is the best for shch use. However I have some small junk SRAMs (32 Kbyte) used for cashe memory, and I wanted to use these chips for the frame memory under recycle spirit :-)

To store the test pattern into the small memory, any data compression process is required. I had an eye to a point that the video test signal tend to repeats same line patterns. When store only the line patterns used in the frame and select the required line pattern for each line, the memory size and downloading time will able to be reduced drastically. Ten several line banks will do for the most test patterns except for patterns change vertically, such as picture, monoscope and vertical sweep. Luminance component and chrominance component are separated into two channels. The luma signal has many kind of patterns at vertical blanking area, the chroma signal is fliped every line. The effeciency of compression ratio can be improved when separated the NTSC signal into luma and chroma components. Y/C signal can be generated at the same time.

This compression technic can be applied to only NTSC format because the chroma subcarrier at the PAL system, fh*283.75+25 Hz, slips its SC-H phase in rate of 360 degrees per frame, each chroma line patterns in a frame are not the same. SECAM is out of the question. For these video formats, complete frame memory is needed. Don't ask me :-p

Controller

An Atmel ATmega161 is used as controller. It manages user interface, downloading the wave form data to the line memory and selecting wave form for each line under line sequense list. The line patterns are shrinked to 1/2-1/50 based on its monotony of luma and periodicity of chroma, The shrinked data is stored to a serial EEPROM and expanded at downloading, 59 frames (100 Mbytes) are packed into 40 kbytes. Therefore two compression process are applied and attained the total compression ratio of approx. 1/2500.

Analog Outputs

A three channel DAC is used. One channel is assigned for a luma channel, left two channels are for chroma channels. The reason of two DAC channels are assined to chroma is to support Y/CB/CR component output. Of course NTSC mode and component mode cannot be used at the same time. The DAC outputs are filtered, bufferred and then output. CR components placed at inverting input is to compensate frequency response due to aperture effect.

Contorl Panel

Two digits numeric LEDs indicate the frame pattern currently output and one of two video format incicater at the corresponding connector is lit. The frame pattern is selected with a dial and set by clicking the dial. Numeric LEDs blink during the pattern selection.

Video Line Selector

When measure video signal with oscilloscope, video line selector is very useful to find a scan line. The line selecter generates trigger pulse at selected line, oscilloscope will display only selected line. This is a very simple video line selector.


Now, I have a Tektronix TDS3032B digital oscilloscope for home use. It can also be implemented video line selecter feature with a video module, any external accessory might not be needed. But this project has started before purchasing the new one, so that I achieved the project to open to the public.

Specifications:
Trigger mode All-line, Both-field, Odd-field, Even-field, An Odd-field in superframe, An Even-field in superframe
Control panel Display: 16cols x 1row LCD module
Conrol: UP button, DOWN button, MODE button
Interface Video input: CVBS/Y Input/Through (75ohms or Hi-Z)
Trigger out: TTL level (rise edge)
Power supply DC 5..12V, 20mA

HARDWARE

There are many video line selecter projects from of old, most line selecters are composed with a sync-separator and some counter ICs. In this project, all of counter/trigger function are processed by a microcontroller without external counter. Therefore, the circuit diagram could be very simple and it has many function.
Compsite sync pulses separated from input video signal are tied to external interrupt of an AVR and a flip-flop. Processing trigger output only software cannot avoid propagation delay and jitter, so that made the trigger edge pass through to the trigger output directly. Sync separator is composed by discrete parts, however, LM1881 is recommended if it is in stock. Test pins are for monitoring the clamped wave form.

SOFTWARE

Firmware for NTSC and PAL

Foreground task processes only user interface. Counting incoming syncs and trigger control are procecced by interrupt driven background tasks. AVR has very high performance, it will able to be implemented some additional functions. Any customized trigger mode or superimposing line marker will easy to implement with modifying the firmware or expanding some external components.

Line counting

First, 16 bit timer/counter is initialized as free running counter with 1.25MHz source clock and compare register is set to 65. The value will reach 79 while a horizontal period. The line counting process is driven by external interrupt (INT1). In this interrupt, when timer/counter has exceeded 60 (3/4H), the timer/counter is cleared and line counter is increased. If timer/counter is less than 60, the interrupt is half-H pulse, the line counter is not updated.

Trigger

After line counter is updated, if the value (next line) matches trigger line, trigger request flag is set. Compare match interrupt (timer/counter maches 65) is occured every 10µs before next line start. In this interrupt, if the trigger request flag is set, reset to external flip-flop is released and next sync edge will pass through the flip-flop. The flip-flop is reset agan by the external interrupt process. The trigger pulse width is approx. 2µs.

Detecting vertical sync pulse

8µs after external interrupt occured, sync level is sampled and stored it into shift register (left shifted). If the interrupt is at half-H, exit with no process. If it is start of line, compare the value of shift register and 0b11111110 (sync pattern at start of vertical sync). Only line 4 in odd field will match this condition. When the vertical sync is detected, set line conter to 4. This process is before updating line counter.

Detecting no signal

If no sync is detected for 20ms, timer/counter overflow interrupt will occure. In this interrupt, no signal flag is set and the condition is informed main task. The no signal flag is cleared by external interrupt (INT1).

Tuesday, May 5, 2009

GPIB to RS-232 converter

This project fills the need of anybody who has a test instrument with the GPIB port and likes to get the screen dump on his PC without any GPIB card. It emulates the HP7470A operation on the GPIB side, and outputs the HP-GL data at the RS-232 port to be read and stored on the PC by any suitable software. The operation of this interface is not just limited to plotter emulation: any data intended to be received by a GPIB Device (addressable or listener only) can be captured and brought out to the RS-232 port, including raw data from the instrument or rasterized data for a GPIB graphic printer. GPIB addresses and other set-and-forget parameters can be modified and permanently stored using a simple setup menu. It is based on a PIC16F628A microcontroller, and the PCB size is just 7x7.5cm.



SCHEMATIC AND DETAILS

The hardware of Pic-Plot interface is quite simple: the active components are just a PIC16F628A, a 5V regulator and three transistors. External connections are a GPIB connector, a Serial port and a DC power connector.



The microcontroller does all the necessary jobs to emulate GPIB Device functionality, in both Listener and Talker mode, by recognizing addressing, commands and managing the Handshake lines. Controller mode is not needed for the intended functionality, and therefore is not supported. Once the device is addressed and it receives data from the Talker, the same data are forwarded to the COM port at 9600 baud: the hardware UART inside the PIC16F628A generates the serial data going to the PC through the RS232 port. Only in Setup mode the data flow is bidirectional at the same baud rate. The RS-232 connector on the interface is a standard male DB-9, and should be connected to the PC using a null-modem female-to-female serial cable.

PCs missing the COM port but equipped with an USB port can be still used with the aid of an inexpensive USB to serial converter, provided that the necessary Virtual Com Port drivers are properly installed.

A jumper is provided to enter Setup mode: when Pic-Plot it powered with this jumper in the closed (short) position, then it starts-up in Setup mode. In this mode the microcontroller UART is used to read/change a few set-and-forget parameters. GPIB cable can be left connected to the instrument, but in Setup mode the GPIB port is not monitored by the Pic-Plot. For normal operation this jumper must be left open. More details about Setup mode can be found in the USE AND OPERATION section.

Power supply can be any voltage between 8 and 16V, and current drain is far below 20mA. With such a large supply requirements, a low-cost unregulated 12V wall adaptor can be used as a power source. Connector polarity is center positive (+). An interesting possibility for those who use the USB-to-serial bridge is to bypass the Pic-Plot 5V onboard regulator and spill the 5V supply from the USB connector mounted on the bridge. This solution of course asks for a simple modification of the bridge or a modified USB cable, then it is suggested only to people having the necessary technical skills to do things right. You can find details by clicking here, or you might prefer to see our new Pic-plot2 which directly supports GPIB-USB conversion.