Monday, September 20, 2010

12 Volt 20 Amp Solar Charge Controller

Introduction

The SCC3 is a solar charge controller, its function is to regulate the power flowing from a photovoltaic panel into a rechargeable battery. It features easy setup with one potentiometer for the float voltage adjustment, an equalize function for periodic overcharging, and automatic temperature compensation for better battery charging over a wide range of temperatures. The SCC3 is able to handle reverse polarity connection of both the battery and photovoltaic panel. The design goals of this circuit were efficiency, simplicity, reliability and the use of field replaceable parts. A medium power solar system can be built with the SCC3, a 12V (nominal) solar panel that is rated from 100 milliamps to 20 amps, and a lead acid or other rechargeable battery that is rated from 500 milliamp hours to 400 amp hours of capacity.

It is important to match the solar panel's current rating to the battery's amp-hour rating (C). A typical maximum battery charging current is C/20, so a 100 amp hour battery should have a solar panel rating of no greater than 5 amps. It is advisable to check the battery manufacturer's data sheets to find the maximum allowable charge current, then choose a PV that does not exceed that value. On the other hand, if the solar panel output current is too low, the battery may never become fully charged.
With a few parts changes, the SCC3 circuit can work as a 24V/15A solar charge controller. The 24V parts differences are shown on the schematic.


Specifications (12V version)

  • Nominal Battery Voltage: 12V.
  • Solar Charging Current: 0 to 20 Amps continuous.
  • Recommended Battery Capacity: 0.5 to 400 Amp Hours.
  • Photovoltaic Panel Voltage Ratings: 12V Nominal (17-24V Open Circuit Voltage, 36-48 cell typical).
  • Absolute maximum PV input voltage (not sustained): 26VDC
  • Photovoltaic Panel Power Ratings: 1W to 240W (90ma - 20A Short Circuit Current).
  • Voltage Drop During Charging: 0.5V @ 10A, 1V @ 20A.
  • Float Voltage Adjustment Range: 13V-15V (range can be altered).
  • Float Voltage Variation during charging: +/- 0.03V
  • Equalize Mode Voltage Increase: 1.5 Volts.
  • Charge Controller Temperature Compensation: -7.5mV/Degree C.
  • Night Time Battery Current Drain: 0.8 - 1.8ma.
  • Fuse Type: 20 Amp ATO automotive fuse.
  • Board Dimensions: 3.5" wide by 3.0" deep by 0.95" tall.
  • Fits into a standard 4" X 4" electrical utility box, can be mounted on the cover plate.
  • Board Mounts: 3X 4-40 screws on 1/4" spacers.
  • Assembled Weight: approximately 60 grams (2oz).

Theory

The circuit activation section uses op-amp IC4 wired as a comparator to switch power on for the rest of the SCC3. When the PV voltage is greater than the battery voltage, IC4 turns on and sends power to voltage regulator IC3. Diode D2 prevents damage to IC4 if the battery is connected with reverse polarity. IC3 produces a regulated 5 Volt power source. The 5V is used to power the SCC3 circuitry, it is also used as a reference for the battery float voltage comparator IC1a. The float voltage comparator IC1a compares the battery voltage (divided by R1/VR1 and R3) to the 5V reference voltage (divided by R5 and R6). The comparison point is offset by the thermistor TM1 for temperature compensation. The comparison point is also modified by the Equalize switch, S1 and R2. The output of IC1a goes high (+5V) when the battery voltage is below the float voltage setting. The output goes low when the battery voltage is above the float voltage setting. This provides the charge/idle signal that controls the rest of the circuit.
The charge/idle signal is sent to IC2a and b, a pair of D-type flip-flops. The flip-flops are clocked by the IC1b phase-shift clock oscillator. The clocking causes the flip-flop outputs to produce a square wave charge/idle signal that is synchronized with the frequency of the clock oscillator. The two halves of IC2 operate in synchronization, IC2a is used to drive the PV current switching circuitry, IC2b is used to drive the charging state indicator LED either red (charging) or green (floating).
The clocked charge/idle signal switches bipolar transistor Q1 on and off. The Q1 signal is used to switch power MOSFET Q2, which switches the solar current on and off through the battery. The solar charging current flows through the heavy lines on the schematic. Diode D1 prevents the battery from discharging through the solar panel at night. Fuse F1 prevents excessive battery current from flowing in the event of a short circuit. Transzorb TZ1 absorbs transient voltage spikes that may be caused by lightning.

Use

Connect the solar panel to the SCC3 PV terminals, connect the battery to the SCC3 battery terminals. Put the solar panel in the sun, the battery will charge up. In systems where the battery is frequently deep-discharged, the equalize switch should be occasionally turned on for a period of several hours to a full day. This increases the charge of the battery's weaker cells.
When the battery is low and the sun is shining, the LED will be red. As the battery reaches the float voltage, the LED will quickly alternate red/green. When the sun goes down, the LED will shut off.

SCC3 Circuit Extensions

Secondary Battery Charger

 

The above circuit may be used if you wish to charge a remote secondary battery. The #1156 lamp limits the secondary battery's charge current to a maximum of 2 amps, it also protects the remote wiring from high currents in the event of a short circuit. The wiring should be rated to handle more than 2 amps of current, #16 or #14 gauge wire is recommended. Other lamps may be used for setting different maximum charge current values. The Schottky diode prevents a load on the main battery from discharging the secondary battery. The diode has a .5V drop, so the secondary battery will always stay .5V below the main battery's maximum (float) voltage setting. A wet cell lead acid main battery and a gell cell secondary battery will work well in this configuration. Float voltages for gell cell batteries are lower than for wet cell batteries.

Dump Load Controller

A Dump Load Controller circuit can be used to feed excess solar power to an auxilliary load such as a heating resistor. The dump load circuit can be constructed from a second SCC3 kit using custom wired jumpers. The dump load circuit monitors the PV voltage. When the PV has charged the battery and the battery reaches the SCC3 float voltage setting, the SCC3 PV circuit opens up and the PV voltage rises. The dump load circuit detects this higher PV voltage and connects the dump load to the PV. For 12V systems, the dump load circuit should be adjusted so that it activates at a PV voltage of around 15V. The dump load resistor should be connected across the terminals labeled "Dump" in the schematic. For the optimal dump load power transfer, the value of the dump load resistor should be chosen so that it pulls the PV voltage down to the PV panel's rated maximum power point during full sun conditions. The dump load resistor should have a power rating that is greater than the PV panel's maximum output wattage rating.
The dump load controller provides a low-quality power source. The power is only available when the main battery becomes fully charged and when it is available, it comes in pulses. Dump load power would be suitable for running a heating resistor or a catalytic electrolyzer for splitting water into hydrogen and oxygen.
 Dump Load Controller circuit

(C) 2009, G. Forrest Cook
Source: http://www.solorb.com/

FM Transmitter MAX2606 using USB

USB FM Transmitter MAX2606

This MP3 Player FM transmitter can be used to listen to your own music throughout your home. The transmitter circuit use no coils that have to be wound. When this FM transmitter used in the car, there is no need for a separate input to the car stereo to play back the music files from your MP3 player.


 
 This FM transmitter use a chip made by Maxim Integrated Products, the MAX2606. The VCO (Voltage Controlled Oscillator) in this IC uses a Colpitts oscillator circuit. The variable-capacitance (varicap) diode and feedback capacitors for the tuning have also been integrated on this chip, so that you only need an external inductor to fix the central oscillator frequency.
The supply voltage to the IC should be between 2.7 and 5.5 V, the current consumption is between 2 and 4 mA. With values like these it seemed a good idea to supply the circuit with power from a USB port. A common-mode choke is connected in series with the USB connections in order to avoid interference between the circuit and the PC supply.

The stereo signal connected to K1 is combined via R1 and R2 and is then passed via volume control P1 to the Tune input of IC1, where it causes the carrier wave to be frequency modulated. Filter R6/C7 is used to restrict the bandwidth of the audio signal. The setting of the frequency (across the whole VHF FM broadcast band) is done with P2, which is connected to the 5 V supply voltage.

The transmitter PCB designed uses resistors and capacitors with 0805 SMD packaging. The size of the board is only 41.2 x 17.9 mm, which is practically dongle-sized. For the aerial an almost straight copper track has been placed at the edge of the board. In practice we achieved a range of about 6 metres (18 feet) with this. There is also room for a 5-way SIL header on the board. Here we find the inputs to the 3.5 mm jack plug, the input to P1 and the supply voltage. The latter permits the circuit to be powered independently from the mains supply, via for example three AA batteries or a Lithium button cell. Inductor L1 in the prototype is a type made by Murata that has a fairly high Q factor: minimum 60 at 100 MHz.

Take care when you solder filter choke L2, since the connections on both sides are very close together. The supply voltage is connected to this, so make sure that you don’t short out the USB supply! Use a resistance meter to check that there is no short between the two supply connectors before connecting the circuit to a USB port on a computer or to the batteries.

P1 has the opposite effect to what you would expect (clockwise reduces the volume), because this made the board layout much easier. The deviation and audio bandwidth varies with the setting of P1. The maximum sensitivity of the audio input is fairly large. With P1 set to its maximum level, a stereo input of 10 mVrms is sufficient for the sound on the radio to remain clear. This also depends on the setting of the VCO. With a higher tuning voltage the input signal may be almost twice as large (see VCO tuning curve in the data sheet). Above that level some audible distortion becomes apparent. If the attenuation can’t be easily set by P1, you can increase the values of R1 and R2 without any problems.

Measurements with an RF analyzer showed that the third harmonic had a strong presence in the transmitted spectrum (about 10 dB below the fundamental frequency). This should really have been much lower. With a low-impedance source connected to both inputs the bandwidth varies from 13.1 kHz (P1 at maximum) to 57 kHz (with the wiper of P1 set to 1/10).

In this circuit the pre-emphasis of the input is missing. Radios in Europe have a built-in de-emphasis network of 50 μs (75 μs in the US). The sound from the radio will therefore sound noticeably muffled. To correct this, and also to stop a stereo receiver from mistakenly reacting to a 19 kHz component in the audio signal, an enhancement circuit is published elsewhere in this issue (Pre-emphasis for FM Transmitter, also with a PCB). Author: Mathieu Coustans, Elektor Magazine, 2009

MP3 FM Transmitter Parts List
Resistors (all SMD 0805) R1,R2 = 22kΩ R3 = 4kΩ7 R4,R5 = 1kΩ R6 = 270Ω P1 = 10kΩ preset, SMD (TS53YJ103MR10 Vishay Sfernice, Farnell # 1557933) P2 = 100kΩ preset, SMD(TS53YJ104MR10 Vishay Sfernice, Farnell # 1557934) Capacitors (all SMD 0805) C1,C2,C5 = 4μF7 10V C3,C8 = 100nF C4,C7 = 2nF2 C6 = 470nF Inductors L1 = 390nF, SMD 1206 (LQH31HNR39K03L Murata, Farnell # 1515418) L2 = 2200Ω @ 100MHz, SMD, common-mode choke, 1206 type(DLW31SN222SQ2L Murata, Farnell #1515599) Semiconductors IC1 = MAX2606EUT+, SMD SOT23-6 (Maxim Integrated Products) Miscellaneous K1 = 3.5mm stereo audio jack SMD (SJ1-3513-SMT CUI Inc, DIGI-Key # CP1-3513SJCT-ND) K2 = 5-pin header (only required in combination with 090305-I pre-emphasis circuit) K3 = USB connector type A, SMD (2410 07 Lumberg, Farnell # 1308875)


Source: http://www.electronics-diy.com/

Friday, September 17, 2010

Video Object Tracking

Source: http://instruct1.cit.cornell.edu/
Adam Papamarcos (aip23@cornell.edu)
Kerran Flanagan (kaf42@cornell.edu)


We have created a real-time video object tracking / shape recognition device, and a fun game library to demonstrate its abilities
For our project, we wanted to push the video sampling and processing capabilities of the ATmega644 8-bit microcontroller. Using a high-speed analog-to-digital converter as an input device, we were able to sample a reasonably high-resolution grayscale image from a color camera's video output. Using this grayscale image, we are able to track objects and recognize shapes that stood out from the background by a customizable threshold.
From this system, we created a game called Human Tetris to show the shape recognizition capabillity. In this game, players must contort their bodies into shapes displayed on screen in a given amount of time. To demonstrate the potential for our device to expand to a larger game library, we also implemented a port of Brick Breaker. This game shows off the object tracking capability, where players must physically interact with the bouncing ball to keep it on screen and break bricks.



High Level Design

Almost all major gaming consoles are moving to user input systems involving tracking all or part of a player's body (see Nintendo Wii Remote, PlayStation Move, and XBox Project Natal). Our project setup is similar to Project Natal, which Microsoft claims to be a "controller-free gaming and entertainment experience", using a single sensor device (with at least camera and microphone) placed by the TV. We have demonstrated the feasibility of a basic motion-controlled gaming system using low-cost parts.
The system is based off of an ATmega644 microcontroller with two peripherals: a high-speed flash analog-to-digital converter, and an onscreen display device for video overlay. With just 4 kilobytes of RAM and a 20MHz clock speed, the MCU needs these peripherals to take some of the load off of its processing capabilities. Since we wanted to provide a real-time camera feed on the display (like a "mirror" for the player), and since the ATmega644 is not fast enough to generate a full color NTSC signal, we decided early on that we would use a color video camera module which outputs an NTSC signal directly.
The system accepts a color NTSC video signal, filters out the DC component, and samples the video stream at real-time speed. This sample is stored as a grayscale image in the MCU's memory which can be processed by the application. The onscreen display overlays shape information and game data for user interaction.

highlevel
High-level block diagram
Based on this system, we have implemented a video arcade game called Human Tetris, based on a Japanese game show event. In the game, contestants are faced with an oncoming solid wall with a shape cutout. The players must fit through the shape, or else they are thrown back into a pool of slime.

Our game displays a shape on the screen which the players must fit into within a short amount of time. If they succeed, they are faced with more difficult shapes and shorter amounts of time until they are inevitably "slimed". The game provides the player with real-time feedback by displaying the video on the screen with the device's interpretation of their shape.
Our project involves two standards: NTSC and SPI. NTSC is well-defined and is used as our input and output medium. SPI is more of an agreement than a standard, and our project uses it internally to the specifications of the microcontroller and on-screen display device.
Tetris is copyrighted and trademarked thoroughly, so attempts to turn this project into a product would have to be preceded by licensing talks or altering the aesthetics. "Human Tetris" is a commonly used description for the game show our game is based on, but the actual game play is not that of Tetris.

Hardware

Prototyping

Our finished product is neatly tucked onto a 2.5" x 3.8" custom printed circuit board, but for most of the design stage, we prototyped on an STK500, a solderless breadboard, and the ATmega644 custom target board. Our earliest prototyping simply involved working with the ATmega644 on the STK500, with the surface-mount peripherals soldered to breakout boards on a solderless breadboard, attached to the STK with long, loopy wires. We also used the large protoboards as an external power source to feed our substantial power requirements. Slowly, we weaned off our dependence on the STK and moved to using just the solderless breadboard and the target board, with an on-board power circuit. Once the PCB was set up, everything was contained

Design & Components

camera_mirror
Camera mounted in mirror enclosure
At the start, we decided in our high-level design that it was essential for the user to have real-time feedback of their position on the screen. This allows the player to correct their position on screen or move to an object. Since our microprocessor is not capable of outputting color NTSC, we decided to use a camera which outputs an NTSC signal directly. Then, we could split the signal for display and processing. We chose the CM-26N color video camera because it was moderately priced and simple to use: simply plug in power, and it outputs a video signal. It also has a few features we were not aware of when we bought it, such as auto-brightness. One thing that we did not realize until setting up the system was that a camera pointed at the player would not produce a "mirror" effect like desired; instead, if a player moves to the right, he will move left on the screen. To remedy this, we used a low-tech solution: we point the camera at a mirror to flip the image it sees and displays on the screen, so that the game feels more natural to the player.
The signal from the camera goes through an RC input filter which biases up the signal swing to about 0.5V to 2.0V. This is based on the MAX7456 datasheet's "Typical Operating Circuit", which specifies a 75 Ohm load resistor to ground and a 0.1uF input coupling capacitor. Originally we had intended to create two separate circuits for display and processing using current buffers, and a shift/gain op-amp for input into the analog-to-digital converter. However, it was simpler and worked just as well to use the same signal as an input to both devices; it did not produce any detrimental effects.
The signal from the camera went into the analog input of the TLC5540 flash ADC. Since this signal swung from about 0.5-2.0V, we set up a bottom reference voltage of 0V and a top reference voltage of 2.0V, using a combination of the ADC's internal voltage divider and a parallel resistor. This provided a good level of resolution for our application. We set up a clock output from the MCU to go into the sampling clock port of the ADC, so that we could control the clock speed through software. The 8-bit parallel output from the ADC went to the 8 pins on the MCU's port C. During prototyping, we experienced a lot of noise on these high-frequency digital signals, which produced some bad reads and unexpected behavior. The custom PCB brought these components must closer together with good traces between the two devices, which essentially eliminated all of these problems.


overall
Overall hardware components [large image]
The MAX7456 on-screen display (OSD) was used as our primary output device, to overlay characters and data on top of the video signal going from the camera to the TV. The SPI interface between the MCU and the OSD allowed high-speed communication for user feedback. It also took a lot of processing demands off of our MCU, since we could just tell the OSD what to do over SPI quickly, and the OSD would take care of the video overlay and timing issues. The OSD also provided some incredibly useful synchronization pulses for vertical sync and horizontal sync in the NTSC signal. We used these outputs to tell our MCU when to sample the video. We had a lot of trouble during the prototyping stage with bad writes to the OSD, most likely due to noise in the high-frequency communication on the SPI wires connecting the devices. Similar to the case with the ADC, when these components were carefully placed on the custom PCB, all of these issues disappeared, and the SPI communication could be cranked up to several MHz.
While we were originally planning on using the ATmega644 MCU, we wanted to sample the part, and we could only get samples of the ATmega644PA. These microprocessors are virtually identical (the 'P' is a low-power version of the chip, and the 'A' represents a manufacturing change). Virtually none of the hardware or software needed to be changed to accommodate this new chip. We opted to run the chip at the maximum clock speed of 20MHz for highest performance, but this is still below the threshold for direct video capturing or generation, which is why we had to use the two peripherals. We were also limited to the 4K of RAM, which limited the amount of pixels from the sampled image we could store. Otherwise, the MCU acted a central hub for the entire circuit: everything was controlled by the MCU, and it implemented all of the game and user interface logic. We determined that the current drawn by the total circuit was close to 0.6A (camera ~120mA, OSD ~430mA, flash ADC ~20mA, atmega644pa ~12mA), so we used a power adapter and created a power circuit that supplied up to 1 Amp of current. We used a 12V DC power supply, a 1A rectifier (1N4001), and a 5V voltage regulator (LM340T5). We also included a power switch to break the connection from the supply to the power circuit.
Our finished product contains an on-board power circuit with power switch, reset and user interface buttons, blinking LED heartbeat (with jumper to turn off), camera and program headers, exposed RX/TX ports for serial debugging, three surface mount chips (ADC, MCU, OSD), two crystals, several resistors and capacitors, a ground plane to reduce noise/interference, and an RCA jack for video output to a TV.

Custom PCB

custom_pcb
Close-up of custom PCB [large image]
About half way through the design stage, we realized that a custom PCB could be very beneficial to our project. After getting approval from Bruce Land, we decided that we would attempt to design and build a custom PCB after we had finalized our hardware design, budget and time permitting.
After we received and soldered components to the PCB, we found one small connection problem on the NTSC input circuit, which destroyed the signal. The resistor's lead in the RC circuit had to be moved to the other side of the capacitor [corrected PCB design file in schematics]. After a bit more debugging, the PCB worked perfectly. It essentially eliminated all of the noise and other issues we were having with our hardware. There were no longer any bad reads from the ADC or bad writes to the OSD. Everything behaved as it was designed, despite the high frequency signals we were sending between components.

Software

Our software consists of several major sections, corresponding to various hardware pieces and the various tasks required to achieve our goal. The first thing we developed was the driver for the on-screen display device, since that would be our only real output. Then we worked on getting video signal input. With input and output functioning, we moved on to data processing. Once we had a handle on how many resources we had left (in terms of memory and cycles), we moved onto writing the logic for program flow. With a simple shape-tracking library now at hand, we fleshed out the test code into Human Tetris and added Brick Breaker as a quick demonstration of the shape-tracking code's potential.

SPI Driver for On-screen Display

Talking to the MAX7456 On-Screen Display through the ATmega644's Serial Peripheral Interface proved to be an interesting challenge. Thankfully, someone had written an open-source library for doing so based on the ATmega162 architecture. Porting that to run on the ATmega644 was just a matter of reading data sheets and swapping register values for macros. However, the open-source library was based on bit-banging. Since Bruce Land covered using the ATmega644's hardware SPI in lecture, we upgraded our driver to use that. Writing to the SPI works very well, and works as fast or slow as we can set it. Unfortunately, we never got SPI reads to work and are not sure why. But since we only needed the MAX7456 for output and it has such a well-designed interface, this was not a problem. One way reading could have helped would have been to confirm writes, since noise was a major problem prior to using the PCB. To combat the noise, we just reset all configuration options right before every frame, and hoped for the best on transmitting the frame data.
Our first surprise lesson in writing all of the datasheet came when we tried flashing a complete set of new characters to the OSD's EEPROM character memory. Hardware constraints limit this action to only 8 characters at once (per on-off cycle). Since our output goals involved using the OSD to display much more than text, we needed a better option than programming and booting it 32 times over every time we altered our OSD images. Hooking up the OSD's reset line to an output that we could toggle allowed us to use one run of the microcontroller to program the entire character memory.
charset
Custom character set
Custom characters themselves were a cinch thanks to the same person that wrote the open source SPI driver. There exists a web page (see references) that will take a PNG image of all 256 characters and return a C header file of character data ready to be used by the open source driver. Our only issue here was that for some reason having an array of PROGMEM array pointers caused all the data to land in the Data memory, which was way above our 4kB limit. Using a rather long function to load the character data on a per-character basis solved the problem.
Part of our need for custom characters came from one of the OSD's limitations, it only displays 13 rows of 30 characters each in NTSC mode. Also each character pixel is either black, white, or transparent. But each character is 18x12, so NTSC "pixel" level display is still possible. We split each 18x12 character into a 3x2 grid of 6x6 sub-characters, giving us a 39 x 60 symbol screen resolution. 6 sub characters means 64 possible combinations of them, so we wrote makedots.m in Matlab to take a 6x6 pixel symbol and output all 64 combinations as an image ready to send to the character map conversion website. By keeping them in a clever order in PROGMEM, we could get our desired 18x12 output character by using 6 bit flags per character and then just adding the address of the blank to the sum. To get a 18x12 block from 6 pieces of 6x6 data, we just take the majority vote of the 6 pixels, with ties going to blanks.

NTSC Sampling

As one might imagine, getting a video signal into the ATmega644 proved to be quite a challenge. Talking to our flash ADC was rather trivial, since its only input from the micro controller was a clock. Things got less trivial when we realized the suggested clock minimum frequency was 5MHz, which is 1/4 of our own clock speed. We set up Timer 2 to control an output bit, so it could run independently of the CPU. Prior to using the PCB, we setteled for 1.25MHz as a balance between noise and temporal resolution. Once we had the PCB, running the ADC clock at 5MHz worked best.
ntscsignal
NTSC signal behavior. [Stanford EE 281, Laboratory Assignment #4 "TV Paint". See References]
With the clock set up, we had an 8 bit digital version of NTSC flying at our MCU. If we tried to read it all in, we would be out of RAM in 400 microseconds. Down-sampling was a necessity. 39x60 pixels not only down-sampled nicely to the OSD, it took up just over half our RAM. So we can only hold one "frame" at a time. Loading 39x60 out of a 242x338 signal meant sampling roughly every 6th pixel in every 6th line of an NTSC frame. Lucky for us, our OSD not only output NTSC, it output the horizontal and vertical sync pulses. We connected those directly to the ATmega644's hardware interrupts, so we could get fairly accurate responses to the start of every frame and the start of every line. The "porches" gave us time to context switch to the ISRs and do the book keeping necessary for down-sampling. 60 samples on a 51.5us line of data meant one sample every 0.85us, which is 17 cycles. To achieve this level of accuracy, we inserted NOPs into our C code until things lined up correctly. We also used microsecond delays and NOPs to center or reads along the visible data part of the horizontal line.
To get the sampling perfect, we needed something better than the imperfect display of our NTSC output. We connected up the UART and wrote a method to dump out a frame of data on to it. However, dumping a frame of data takes almost a minute, so we had to make it due so only after a button push. This made for excellent comparison of test images to read results, which were visualized using MATLAB. We also wrote a MATLAB function to read directly from the UART, which was sometimes more convenient. Viewing our raw data on the computer helped us notice when we had only a few pixels of either porch data or bad reads.

Input Filtering

A few pixels of bad reads would have been okay, but prior to using our PCB we had more than a few bad reads. There was substantial noise all over the circuit, and since we were mostly just moving data around, this was a big problem. We tried out several different approaches to filtering. First, we screened out all bad pixel reads and replaced them with the average of their neighbors. However, bad reads often occurred in clusters, so this did not work. Using a fixed gray value as a replacement worked better. Between down sampling and the noise, our output had a lot of flickering elements. Applying a simplified Gaussian Blur gave smoother results, but that went against our general goals of shape-matching. Averaging two frames of input together would have been great, but that would have required more RAM than we had. We tried out sampling more lines (so higher vertical resolution) and averaging on the fly, but the PCB arrived and squelched noise before we could get the timing right in that code.

Output Filtering

The PCB result was sharp and flawless, but the down-sampling effect was still causing an annoying flicker. Not wanting to have to slow down our game(s) just for the sake of flicker, we came up with a method of filtering our output based on our previous output, a moving average box filter of sorts. We still didn't have the memory to duplicate even a 13x30 output frame, but by repeating characters across many addresses we could use the address itself to store information. Looking at the last two lines of our character set, you can see we increment the address when there is positive info and decrement it when there is negative info. By capping the ends (so as to not overflow or underflow), we can display a nice running average over time with minimal memory and cycle cost. Our increments and decrements are set to 3, so it takes less than 3 frames for white to black changes and it takes at least 3 positives or negatives in a row to create a noise blip.
To avoid output flicker from frequently updating the OSD, we don't flush our output buffer to the OSD until the end of our main loop. Keeping this output buffer around is also what lets us do time-averaging of our output to avoid flicker. Another flicker that can appear is a nauseating collection of video signal artifacts when the OSD is displaying characters that are pixel level grids. For this reason our standard background is a loose 1 out of 4 pixels instead of a tight checkerboard pattern.

Timing

In order to run our games, we needed some sort of time base. Since we had a 20Mhz crystal and 20 is not a power of 2, we had to use Timer 1 to get a time base on the order of milliseconds. We settled on a 5ms time base as a balance between ISR executions and accuracy. That time base controls the game state and timers, but the main loop is actually triggered by the NTSC sync pulses. The vertical sync ISR activates the horizontal sync ISR for reading in a frame if a flag is set and the horizontal ISR sets the flag down when reading in a frame is complete. The main loop does the opposite, running when that flag is not set and raising it when finished. This way every time main executes it has fresh input. We run our tracking mode as fast as possible and our games at half that in order to make the OSD flicker less during gameplay.
We have 2 buttons for input, "toggle" and "enter", which are sufficient for a menu system. We run a de-bouncing flag-raising state machine to get meaningful input from sampling them at around 30Hz. We run a heartbeat LED at one second per cycle, so we can tell if things are working fine or not. In addition to the heartbeat LED, we keep a "Game Timer" at a 5-millisecond time base for game play purposes. We also sample the on-board ADC at 1Hz to get specified black level, which can be set by a trimpot to tune the game(s) to different environments. This live tuning is a bit more useful than just viewing exact values from a UART frame dump and guessing at a good threshold for detection.

Menu and System State

menu
Main menu
Our menu allows users to choose between the three games and the tracking mode. One button is used as a toggle to go to the next option and the other button is used as enter to select an option. The menu is a simple state machine. Each frame it displays the title, our names, and all the options with the current selection highlighted.
The state of the system is another state machine with states for menu, each of the games, tracking mode, and a win/lose screen. Each "frame" through the main loop activates the code for the appropriate state. The initial warning message is displayed for a few seconds the first time the menu state is activated, which is when the system turns on.

Games

The game state machines are based on the 1 millisecond base of "Game Time", and the logic is independent of the frame rate. This means we can speed up or slow down our frame rate as needed and not affect the game mechanics. The main state machine simply loads the input data from the video stream then calls out to game logic for each frame. In our game modes, we display the player's body as a collection of 12x18 character sized blocks for aesthetic value and decreased noise, as opposed to the 6x6 dots used for tracking mode.
Our Human Tetris game does the following. Each shape is displayed for 5 seconds. It is loaded into memory once, then player is displayed each frame using the moving average code (described above) to preserve the shape information. Once the shape and player are in the output buffer, simply looping through that buffer tells us how many "blocks" of the player's body are outside the shape. If more than a certain tolerance are outside, the player loses. If not, the game advances to the next shape until a victory screen is reached. The number of misses is only checked at the end of a shape's time.
We implemented a rather nice content pipeline for the Human Tetris shapes. One can place an arbitrary amount of images in a directory, and then run the MATLAB script imgs2progmem to get out a C header file with a single array holding all the shape data in program memory. The only restrictions are the input images must be 39 x 60 and black and white. It should be noted that the shapes are effectively stored as a bit vector (1 bit per block) in the C file. This compresses each shape to a mere 293 bytes, so we could fit a lot in program memory. The artist should keep in mind that the game currently displays shapes and players on a 13x30 grid (via averaging), so care should be taken when drawing the 39x60 sized shapes.
To demonstrate the extensibility of our shape tracking code, we also implemented a few other games:
brick_action
Example of Brick Breaker game
Our first additional game is Brick Breaker. The game world consists of bricks (3 characters wide), a bouncing ball, and the player's "bar" which is represented by character-sized blocks as in Human Tetris. The ball is actually on a 39x60 grid and is displayed as such. The ball bounces indefinitely and consistently. If it falls off the bottom of the screen the player loses a life. If it strikes a brick it damages the brick. If a player destroys all the (breakable) bricks before losing, the player will advance to the next level.
We have also added the Whack-A-Mole game to our project. The mole is composed of 2 rows of 3 characters, giving it a 36x36 pixel footprint. The moles are randomly drawn and removed, loosely based on the current time. The player must get his/her block representation onscreen to collide with a mole in order to "whack" it. Doing so removes the mole from the screen and awards the player with points. When the game time expires, the player's score and any remaining moles are visible.

Results

Speed and Accuracy

We can read in and display an image of 39x60 pixels at 30 frames per second. That is the meaningful maximum, since NTSC is actually only 30 frames per second of information. The signal runs at 60 frames per second, sending every other line every other frame. We only read on every other vertical sync to de-interlace the signal. Our output tends to flicker a little as a result of down-sampling (as opposed to averaging) the NTSC image data. There is currently a little streaking in the output where characters are shown due to noise in the OSD.
sample
Real image, captured image, and interpreted image after applying threshold.

Tracking Demo

object_tracking
An object being tracked, with its interpretation displayed in real-time
To demonstrate our speed and accuracy, we wrote a tracking demo that simply reads the NTSC signal and displays our full resolution output as fast as it can. In object tracking mode, we simply clear the output buffer, load in the input at 39x60 resolution, and display that. This demonstrates the accuracy and speed we were able to achieve.
At 30 frames per second, there is minimal lag on our interpretation of the image. We do not do any filtering in tracking mode. There is a little flicker along the edges due to our down-sampling method. This tracking mode proved very handing for general debugging and especially for getting the timing right for reading in an NTSC frame.

Game Safety and Usability

Anyone capable of movement can play the games in this project, and difficulty can be adjusted by adjusting one's difference from the camera. In this way the game can be adjusted for players of various sizes. The game is also only looking for dark colors, so light colored materials can be used to exclude parts of the image. Brick breaker is a nice alternative to human Tetris for any physically disabled players that might stumble upon our game.

Conclusions


Results vs. Expectations

When we drafted our proposal, our vision of the finished product is very similar to the device we have created. Much of the same hardware devices and software techniques we planned on using ended up in our final design. The main hardware drawback we experienced was that the NTSC decoder we had original planned on using was too fast for our MCU. Instead we had to select and use an ADC which would run independently and we could choose when to sample. In effect, since we only cared about the black-and-white signal, this was all we needed to achieve the same sampling effect we had originally planned on.
We have exceeded our expectations in both spatial and temporal resolution. We originally hoped to just barely have enough resolution for a stick figure and to process the image once every few seconds. We currently have enough resolution to recognize each other in debug images and are processing it all many times a second.
Next time adding sound to the game would make it much more enjoyable (and potentially deepen game play).

Conforming to Standards

Our project uses standard NTSC input and therefore the camera could be swapped. It also produces standard NTSC output, so any device capable of displaying that can be used.
We also use SPI internally. This is not exactly a standard, which probably explains why we only have it working in one direction.

Intellectual Property

We used open source code licensed under GPL v2 used as basis for our OSD SPI driver. The GPLv2 states that any code linking against the GPL v2 code must also be within the GPLv2 license. This probably limits our ability to monetize the project as it stands, since ownership cannot be claimed on GPL v2 code.
Tetris and its artwork are copyrighted and trademarked, so at the least we would have to change the name and some artwork in order to capitalize on our design. Brick Breaker is a new name for Breakout, and there is likely some ownership on the original design but currently many knock-offs exist.

Tetris ® and © 1985~2010 Tetris Holding. Tetris logo, Tetris theme song and Tetriminos are trademarks of Tetris Holding. The Tetris trade dress is owned by Tetris Holding. Licensed to The Tetris Company. Game Design by Alexey Pajitnov. Logo Design by Roger Dean. All Rights Reserved. All other trademarks are the property of their respective owners [Tetris.com].
Breakout is an arcade game developed by Atari, Inc and introduced on May 13, 1976 [Wikipedia].
The games we implemented are someone else's IP. Our driver is GPL-licensed, so no one can make money on our code unless they rip that out first. As Cornell University undergraduate students, we own our original ideas. If this project were to be published, the Tetris aesthetics would have to be replaced.

Ethical Considerations

We have done our best effort to conform to the IEEE Code of Ethics in the design and execution of this project.
Our project is essentially a motion tracking device for the consumer entertainment market. Since it is a class project, it has been created with no intention of profit and in accordance with the beliefs of the GPL. This combination of facts means it was created purely for learning and for fun. Therefore it seeks only to make the world a better place.
The game is based on video output, which means there is a chance it will trigger photosensitive seizures in some users. We have added a warning before the menu screen to alert users to this. We also take that opportunity to warn players about the dangers of motion-based games. Extreme play motions have been known to sometimes cause harm or damage. However, when played safely, our game(s) will improve the health of the user through the physical and mental activity involved.
We have been honest in the reporting of our results, and have strived to write code that does not lie. Our reported resolution is accurate, and our frames per second benchmark is as accurate as our clock will allow.
Because our game is based on video input, a user’s appearance and physical fitness will affect their interaction with the software. For this we recommend users consult with their doctor before playing and wear dark colors to aid the camera in tracking them.

Legal Considerations

Our project is a simple video home entertainment device. It does not release excessive EMF and should not cause any interference with other electronics. We have placed warnings in the game about the dangers involved in playing.

Appendices

A. Source Code

Source files

  • Lab5.c (20KB) – all the ISRs, initialization code, tracking output code, and main state machine
  • human_tetris.c (6KB) – human tetris game logic and data handling
  • brick_breaker.c (8KB) – brick breaker game logic including physics and data handling
  • whack_a_mole.c (5KB) – whack-a-mole game logic and data handling
  • max7456_learn.c (15KB) – contains code for writing to the OSD's progmem
  • max7456_spi.c (9KB) – our OSD driver
  • uart.c (5KB) – uart code from Bruce Land
  • LICENSE.TXT (18KB) – GNU general public license

Header files

  • lab5.h (3KB) – time constants and input and output functions
  • Levels.h (1KB) – progmem array storage of brick breaker levels
  • Shapes.h (9KB) – progmem array storage of human tetris levels
  • macros.h (1KB) – register setting and mathematical macros
  • human_tetris.h (1KB) – exposes game state machine function
  • brick_breaker.h (1KB) – exposes game state machine function
  • whack_a_mole.h (1KB) – exposes game state machine function
  • max7456_characters.h (176KB) – progmem arrays for all our custom characters
  • max7456_learn.h (3KB) – exposes our functions for sending custom characters to the OSD
  • max7456_spi.h (5KB) – exposes useful OSD driver functions
  • uart.h (1KB) – exposes necessary UART functions

MATLAB scripts

  • makeDots.m (2KB) – produces the 64 different 18x12 characters for arrangements of 6x6 dots
  • imgs2progmem.m (2KB) – takes a directory full of images and outputs C code shape arrays for brick breaker
  • cap.m (1KB) – used to grab MCU's image dump from serial interface
Download all files: code.zip (44KB)

. Schematics

schematic
Hardware schematic [full-size image]. Download schematic file: humantetris.sch (36KB).
pcb
Custom printed circuit board layout [full-size image]. Download pcb file: humantetris.pcb (31KB).

C. Parts List

 

rt Source Unit Price Quantity Total Price
ATmega644PA (8-bit MCU) Empire Technical sampled 1 $0.00
MAX7456 (on-screen display) Maxim-IC sampled 1 $0.00
TLC5540 (flash ADC) Texas Instruments sampled 1 $0.00
CM-26N (CMOS color camera) SparkFun $31.95 1 $31.95
custom PCB ExpressPCB $25.00 1 $25.00
12V power supply owned $5.00 1 $5.00
color TV owned owned 1 $0.00
RCA video cable owned owned 1 $0.00
RCJ-014 (RCA jack) DigiKey $0.66 1 $0.66
HC49US (27MHz crystal) DigiKey $0.63 1 $0.63
header pins lab $0.05 15 $0.75
jumper lab lab 1 $0.00
MP200 (20MHz crystal) lab lab 1 $0.00
2.1mm power jack lab lab 1 $0.00
1N4001 (1A rectifier) lab lab 1 $0.00
LM340T-5 (5V regulator) lab lab 1 $0.00
SPDT slide switch lab lab 1 $0.00
push button (NO) lab lab 3 $0.00
10μF capacitor lab lab 4 $0.00
0.1μF capacitor lab lab 8 $0.00
22pF capacitor lab lab 2 $0.00
100kΩ resistor lab lab 1 $0.00
10kΩ resistor lab lab 2 $0.00
1kΩ resistor lab lab 3 $0.00
300Ω resistor lab lab 1 $0.00
100Ω resistor lab lab 3 $0.00
75Ω resistor lab lab 2 $0.00

Acknowledgements

We would like to thank ECE 4760 Professor Bruce Land and all TA staff (especially our lab TA Jeff Melville), for help and support during the labs and over the course of the project. We thank them for the long lab hours and the parts stocked in the lab.
Additional thanks go to Mary Byatt, for the original idea of doing Human Tetris for our microcontroller project.
We would also like to thank several vendors for parts donations. We sampled several ATmega644PA chips from Empire Technical Associates, MAX7456 chips from Maxim-IC, and TLC5540 chips from Texas Instruments. We also sampled several other parts from Maxim-IC and Texas Instruments (including op-amps, decoders, etc) which did not make it into our final design.

Traffic Light Project

This project operates red, amber and green LEDs in the correct sequence for a single UK traffic light. The time taken for the complete red - red & amber - green - amber sequence can be varied from about 7s to about 2½ minutes by adjusting the 1M preset. Some amber LEDs emit light that is almost red so you may prefer to use a yellow LED.
The 555 astable circuit provides clock pulses for the 4017 counter which has ten outputs (Q0 to Q9). Each output becomes high in turn as the clock pulses are received. Appropriate outputs are combined with diodes to supply the amber and green LEDs. The red LED is connected to the ÷10 output which is high for the first 5 counts (Q0-Q4 high), this saves using 5 diodes for red and simplifies the circuit.
This project uses a 555 astable circuit to provide the clock pulses for the 4017 counter.



UK Traffic Light sequence Traffic Light


Parts Required

  • resistors: 470 ×3, 22k, 100k
  • capacitors: 0.1µF, 1µF 16V radial, 10µF 16V radial
  • diodes: 1N4148 ×6
  • LEDs: red, amber (or yellow), green
  • 1M preset, horizontal
  • 555 timer IC, such as NE555
  • 4017 counter IC
  • DIL sockets for ICs: 8-pin, 16-pin
  • on/off switch
  • battery clip for 9V PP3
  • stripboard: 20 rows × 21 holes


Stripboard Layout


Stripboard layout for traffic light project






Circuit diagram


Circuit diagram for 
traffic light project
 
 Download PDF version of this page
© John Hewes 2010, The Electronics Club, www.kpsec.freeuk.com





Thursday, September 16, 2010

Remote Chess

Remote Chess allows you play chess in real time against opponents anywhere in the world so long as there is an internet connection. All that it requires is a Remote Chess chessboard, a NTSC television, and a computer running Matlab.

High Level Design

Overview

Our project goal was to create a pair of chess boards for playing remote chess. These chessboards had to detect the movement of pieces and transmit data regarding those moves to each other. The transmission is sent using a serial connection, the range of this connection is extended through a Matlab script bridging the serial ports of two Computers which are connected to each other over the Internet. For our chess board to function, they needed to perform four separate tasks: scan each tile of the board for the presence or absence of a piece, compare this with previous values, communicate with the other board, and communicate with the user.

User Interface

The user’s input is as simple as moving his pieces on the board. Previous final projects have determined that moving pieces automatically is difficult and inaccurate; therefore we allowed the users to move the pieces themselves. The opponent’s moves are shown with a graphical representation on a TV screen. Since the player can see where his opponent has moved pieces by looking at the TV screen, he does not need to have his opponent’s pieces on his board.

Scanning the Board

Our technique for scanning the chessboard is derived from the keypad scanning method we developed for homework 4. We power the eight vertical columns on the chessboard in sequence, scanning each horizontal row before powering the next column. By doing this, we are able to check each tile to see if a piece is occupying it.
There are many ways to detect the presence of a piece. When we first started the project, we had not settled on which method we wanted to use. Our options included using photoresistors, reed switches, or Hall Effect sensors under the board, or using resistors or capacitors embedded in the pieces and having piece placement close a circuit. In the end we chose to use reed switches. The switches were cheap enough that we were able to sample 150 of them from Hamlin Electronics. They also allowed us to create the board without any exposed wiring or easily damaged components.
Reed Switches
Figure 1: Reed Switches
As shown by Figure 1, Reed switches are normally open. However, when a magnetic field is brought close to them, the switch will close. We used these to connect the vertical output lines to the horizontal input lines. Figure 2 displays how we initially thought this could work.

Chess Board with Reed Switches
Figure 2: Chess Board Reed Switches
Unfortunately this setup does not work. We went through a few different polling methods before we settled on our final version. For more information on how we scanned for pieces, please see the Software Design section.

Communication and Display

Our MCU connects to a computer through a serial connection. This computer then opens a socket with the computer that the other board is connected to and is used to transmit data back and forth between the two boards. We use a black and white TV set to show the full board, including the opponent’s pieces. Since all chess games start with the pieces in the same setup and only one move can be made during a player’s turn, it will be possible to keep track of where each piece is without having each generate a unique signature. By comparing the previous setup with the new setup after a move, we can determine which piece moved and if the move was legal.
Block Diagram
Figure 3: Block Diagram

Hardware and Software Design

Hardware Details

The main hardware component of our project was the boards that we made. In the end, two boards were made; one was converted from a glass chessboard and the other was constructed from foamcore. Each board had 64 reed switches attached to it. These switches were used to detect the presence of chess pieces on the board.
Switches

Main Operation Sequence

Each switch was located under one of the tiles on the board. When a chess piece with an embedded magnet was placed on the tile, the switch would go from open to closed. The strength of the magnets was just right, covering most of the tile but not interfering with adjacent switches. Each switch had two long leads attached to it. We took each row of eight switches and connected them to common input pin. Likewise, each column of eight was connected to one of the out put pins. To poll the circuit we set all of the output pins to high impedance except for one, which was set to ground. Since all of the inputs were pulled up to VDD, a closed connection from the low output to one of the inputs would pull it down. At the same time, a connection to one of the high impedance outputs would not affect the input voltage, and no piece would be detected. This setup allowed us to determine if a piece was present at any tile. We cycled through the outputs, setting one to low each time, and checked the inputs to see if there was connection to ground. Any connection meant that there was piece present on that tile.
This polling scheme led to one of our main obstacles. When we were first testing the board we found that a certain setup allowed the ground signal to pass to inputs that it was not supposed to be able to reach.
Ghost Piece
Figure 4: Ghosting Problem

An ‘L’ shaped configuration like the one shown above caused a ‘ghost’ piece to show up at the node that would turn the ‘L’ into a rectangle. At first we were puzzled by why this would occur. After spending some time investigating the matter, we discovered that the three closed circuits generated the following path:
Short Circuit Path
Figure 5: Short Circuit Path
To prevent this from happening, we had to place diodes between each input pin and the incident sensor leads. With diodes facing away from the pin, the high input was still able to be pulled down. However, the current from the second input pin could not pass through the diode and it was unable to pull any other inputs down. Once theses 64 diodes were heroically installed in each board the problem disappeared and we were left with functioning boards.
Fix
Figure 6: Short Circuit Solution
We also used two PCB boards with RS-232 serial communication functionality. These boards ran the MCU that polled the board, displayed the chess game on the BW TVs, and calculated the validity of moves. The serial communication was used to send valid moves from the MCU to a PC. The PC would then send the moves to another PC through a TCP/IP socket. This second PC would transmit moves that it received to its own MCU and would then communicate to the first PC and MCU in a similar fashion. This allows players to compete from two very spatially remote locations.
A serial interface was added to allow remote actuation of the gimbal mechanism and also to display useful messages for debugging. The USART is configured to run at 9600 baud, no parity, one stop bit, and no flow control. The remote_control function interprets key presses (WSAD) and moves the gimbal in the commanded direction. The adc_readout function displays the raw ADC values for each photocell to verify operation of the electrical circuit.

Software Details

Our C controller software consisted of several distinct parts. It used the video code from lab 4 (slightly modified to display larger characters and chess pieces) and chess piece bitmaps from a different group’s previous project (see conclusion) to display the game on our TVs. Our program used polling functions to communicate between the MCUs, and to scan the boards. We used polling functions (as opposed to interrupts) for serial communication because we did not want any code to interrupt the video display. Most of the code we wrote (over 800 lines) was for checking the validity of chess moves. These algorithms were not fast, our TV displays flickered each time a piece was picked up or put down. We found the flickering useful in testing, as it showed when a piece had successfully been detected.
Writing move validation algorithms was not easy in C, as many moves are verified as combinations of other moves. Castling, a move in which a king moves two squares, and a rook moves over the king, was particularly difficult to validate. There are many different conditions that must be satisfied before castling can be allowed. For example, every square between the king’s starting and destination point must be examined to see if it is threatened by the opponent’s pieces.
There were two principle software elements of our project. One of these was our C controller program, it ran on each MCU and was responsible for polling the board, check validity of moves, displaying moves on the TVs, and communicating moves over the serial connection. The other software element was our Matlab communication scripts. These forwarded data from the serial ports to each other.
When a game starts, the MCU program scans the board. It assumes the opponent will have all the necessary pieces, but it only displays the user’s pieces that it can detect. Before the first move is made, the user has the opportunity to wiggle or adjust pieces so that they are detected. Once the users are happy with their pieces, the Matlab scripts are initiated. Any sequence of characters entering the PC’s serial port followed by a terminator (we used ‘z’) is forwarded to the output of the other PC’s serial port. After five characters are transmitted, the direction of the forwarding changes.
When an MCU transmits or receives a move, it updates the screen to reflect the new position of the pieces on the board. It also prints the move (again in algebraic notation) alongside the board, for reference. After ten turns worth of moves (ten white and ten black) moves are overwritten starting from the top. Moves are numbered 0 to 99 to avoid confusion. Most games end before 100 moves. However, if games of 100 moves or longer are played, the first digit is replaced with a character. In this way, games of 390 moves are supported. There was not enough room on the screen for moves to be displayed with three digits. Games that reach 389 moves should be ended in a draw.
Our MCU program accommodates special cases. For example, when one of you pieces is taken, it understands that what it sees on the board is incorrect. Further input from the board is ignored until the piece is removed. Also, when you castle, you cannot make another move until the rook is in the proper place.

Results

After a lot of work, we finished our project. All of our initial goals were met and we even exceeded some of our initial plans. Since neither of us has worked with TCP/IP before, we were worried that it might be difficult to make Remote Chess really remote. However, with some of Bruce’s guidance and a little help from Thomas Craig we were able to write a Matlab program that imported Java to handle the serial and TCP/IP communication.
Both boards work wonderfully and we’ve removed all hardware problems that we encountered in development. A lot of work was spent soldering, taping, connecting, unsoldering, reconnecting, debugging, and testing the 256 leads that extend from our 128 reed switches. We were hit with a lot of unusual problems during development, but perseverance and an immense amount of lab time got us through it.
We also had issues with software. Our first few scanning routines failed for various reasons. Some had problems with pulling down the pulled-up inputs when there were a few in parallel. Other scanning routines suffered from coding issues like extra output lows resulting from shift operations. Luckily for us, we had built testing code previously. Due to this we had been able to work out the move checking code before we had to test the sensing code. This allowed us to isolate problems due to the scanning routines.
In the end it was all worth it when it came together and worked. Our Remote Chess set works wonderfully and we are very proud of the results of all of our hard work.

Conclusion

Remote Chess is safe and fun for everyone. With no large voltages present and no exposed wires, the game does not pose a hazard to its players. All connections were carefully soldered and covered in electrical tape for safety concerns. We really do not think that infants could swallow one of the chess pieces, so if you really need an ego boost you could play against a kid without worrying. Also, we use black and white images, so color blind people will not experience any difficulties playing our game. All in all, anyone who enjoys chess should enjoy our version as well.

In regards to the IEEE Code of Ethics, the ten points were followed. When we started the project, we were honest about what we planned to create. Through hard work we were actually able to go beyond the proposed abilities, but we we made the proposal in accordance to our best estimations. While working on the project we made sure to avoid conflicts of interest and did not take bribes. Work was done on the hardware to make sure that it presented no hazard to its players. Now that we are finished, we are posting this website so that others may benefit from our work and that we might receive feedback from the community.

Remote Chess exceeded our expectations. Detection and transmission was much faster than we had anticipated. That our project succeeded at all is extraordinary, and we owe thanks to all the people that helped us along the way. For the pictures of pieces that we displayed on our TV sets, we used the bitmaps created by the Spring 2007 group ‘Speech Recognition Chess’ by Kon-Hyong Kim (kk336), Tae Yong “Tim” Chung (tc228), and Kevin Jin-Ho Ham (kh272). For our remote serial connection, we were advised by Professor Bruce Land, and fellow student Thomas Craig. Most importantly, we owe our sensors to Hamlin Electronics, and Walter Zenczak in particular. He helped us select the type of Reed switch we used, and sampled us enough to make our boards. Without Hamlin’s generosity our project would not have made it under budget. We also need to thank Maxim-IC, who sampled us two MAX233CPPs, and Atmel, who has promised to send us two Mega32 chips. We would also like to thank our classmates Nate and Cathy, Nat for making new pieces for use from copper and solder to replace ones lost in the lab, and Cathy, for babysitting these pieces and naming them: a knight named Herman, and a pawn named Hamlin.

Throughout our project we were help by ECE 476’s TAs. We are especially thankful to Sam Lee and Rob Zimmerman. By talking to these TAs we were able to solve many of our problems. This class has been wonderful and we’d like to thank Professor Bruce Land for making the class what it is.

Appendices

 

Appendix 1: Budget

Part Quantity Cost Total Source
--
--
--
$43
--
Chess Set
1
$7.00
$7.00
Salvation Army
Custom PCB Board
2
$5.00
$10.00
ECE 476 Digital Lab
MAX233CPP
1
--
--
Sampled from Maxim-IC
Mega32 MCU
2
--
--
Sampled from Atmel
16 MHz Crystal Oscillator
2
--
--
ECE 476 Digital Lab
Passive Circuit Components
~20
--
--
ECE 476 Digital Lab
RS232 Connector
2
$1.00
$2.00
ECE 476 Digital Lab
DIP Socket
4
$.50
$2.00
ECE 476 Digital Lab
Power Supply
2
$5.00
$10.00
ECE 476 Digital Lab
Black and White TV
2
$5.00
$10.00
ECE 476 Digital Lab
Foamcore
1
$2.00
$2.00
The Cornell Store
Adhesive
1
--
--
Previously Owned
Sharpie
1
--
--
Previously Owned
Reed Switch
128
--
--
Sampled from Hamlin
Neodymium Magnets
16
--
--
ECE 476 Digital Lab

Appendix 2: Schematics

MCU output to TVs:

Schematic
Custom board for our MCUs:

Schematic

Appendix 3: Specific Tasks

Erik Jarva did almost all of the soldering: he made two PCB boards, and fixed both our chess boards by adding a total of 128 diodes to stop short circuits. He wrote the Matlab scripts that connect the PCs and forward the serial data from MCU to MCU.

William Baughman wrote almost all of the C code, including the verification algorithms and communication. He put magnets in most of the pieces, and constructed the stand for the glass board.

Both partners constructed the foam board, and spent many hours debugging code and testing the verification algorithms.

Appendix 4: References

We used the 59020-1-S-02-A Reed Switches from Hamlin Electronics:
Data Sheet
We used two MAX233 bridges by Maxim-IC:
Data Sheet
We used Digikey to buy our magnets:

Atmel sampled us to Mega32 MCUs:
The very important CIT Atmel Mega32 Data Sheet

Appendix 5: Handmade Pieces

While working on the project, two of our pieces were lost: a pawn and knight. Although we looked for them vigilantly, they were never found.

Luckily for us, one of our classmates, Nathan Chun, made us two replacements out of copper wire and solder. We owe him a big thanks for his contribution to our project. Below are some pictures of his awesome work.

Solder Knight
Solder Pawn

Appendix 6: Code

MCU Code:
C File Chess Code Header Video Code Header

Matlab Communication Code:
Receiver File Sender File

Appendix 7: Pictures (Click Pictures for Larger Version)

Early version of display
Picture 1: an early example of our display (our final code fixes an error displaying the row names and the moves.

Early version of display
Picture 2: the wires connecting our chess boards to our MCUs were color-coded.
Early version of display
Picture 3: our glass chess board.
Early version of display
Picture 4: our foamcore chess board.

Erik Jarva
eaj24@cornell.edu
William Baughman
wpb3@cornell.edu
http://instruct1.cit.cornell.edu/

AUTOMATIC ROOM LIGHT CONTROL WITH BI DIRECTIONAL VISITOR COUNTER

The objective of this project is to make a controller based model to count number of persons visiting particular room and accordingly light up the room. Here we can use sensor and can know present number of persons.
In today’s world, there is a continuous need for automatic appliances with the increase in standard of living, there is a sense of urgency for developing circuits that would ease the complexity of life.
Also if at all one wants to know the number of people present in room so as not to have congestion. This circuit proves to be helpful.



CIRCUIT DIAGRAM
RECEIVER CIRCUIT

The IR transmitter will emit modulated 38 kHz IR signal and at the receiver we use TSOP1738 (Infrared Sensor). The output goes high when the there is an interruption and it return back to low after the time period determined by the capacitor and resistor in the circuit. I.e. around 1 second. CL100 is to trigger the IC555 which is configured as monostable multivibrator. Input is given to the Port 1 of the microcontroller. Port 0 is used for the 7-Segment display purpose. Port 2 is used for the Relay Turn On and Turn off Purpose.LTS 542 (Common Anode) is used for 7-Segment display. And that time Relay will get Voltage and triggered so light will get voltage and it will turn on. And when counter will be 00 that time Relay will be turned off. Reset button will reset the microcontroller.Microcontroller based Visitor Counter.




http://projectsworld.files.wordpress.com/2010/05/room.gif

TRANSMISSION CIRCUIT

 

This circuit diagram shows how a 555 timer IC is configured to function as a basic monostable multivibrator. A monostable multivibrator is a timing circuit that changes state once triggered, but returns to its original state after a certain time delay. It got its name from the fact that only one of its output states is stable. It is also known as a ‘one-shot’.
In this circuit, a negative pulse applied at pin 2 triggers an internal flip-flop that turns off pin 7′s discharge transistor, allowing C1 to charge up through
R1. At the same time, the flip-flop brings the output (pin 3) level to ‘high’. When capacitor C1 as charged up to about 2/3 Vcc, the flip-flop is triggered once again, this time making the pin 3 output ‘low’ and turning on pin 7′s discharge transistor, which discharges C1 to ground. This circuit, in effect, produces a pulse at pin 3 whose width t is just the product of R1 and C1, i.e., t=R1C1.
IR Transmission circuit is used to generate the modulated 36 kHz IR signal. The IC555 in the transmitter side is to generate 36 kHz square wave. Adjust the preset in the transmitter to get a 38 kHz signal at the o/p. around 1.4K we get a 38 kHz signal. Then you point it over the sensor and its o/p will go low when it senses the IR signal of 38 kHz.
 PCB Design:
 http://projectsworld.files.wordpress.com/2010/05/comp1.jpg 

http://projectsworld.files.wordpress.com/2010/05/3.jpg 

Source: http://projectsworld.wordpress.com/ 

Labels

About Me

My photo
I am an electrical and electronics engineering kathmandu university batch 2007
 
ELECTRICAL AND ELECTRONICS PROJECT COLLECTION. Design by Wpthemedesigner. Converted To Blogger Template By Anshul Tested by Blogger Templates.