Thursday, February 24, 2011

How To Check and Use Serial Ports Under Linux - (Serial port interfaceing in LINUX)

How To Check and Use Serial Ports Under Linux

by Vivek Gite
How do I check and configure serial ports under Linux for various purposes such as modem, connecting null modems or connect a dumb terminal?

Linux offers various tools. Linux uses ttySx for a serial port device name. For example, COM1 (DOS/Windows name) is ttyS0, COM2 is ttyS1 and so on.

Task: Display Detected System's Serial Support

Simple run dmesg command
$ dmesg | grep tty
Output:
[   37.531286] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[   37.531841] 00:0b: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[   37.532138] 0000:04:00.3: ttyS1 at I/O 0x1020 (irq = 18) is a 16550A

setserial command

setserial is a program designed to set and/or report the configuration information associated with a serial port. This information includes what I/O port and IRQ a particular serial port is using, and whether or not the break key should be interpreted as the Secure Attention Key, and so on. Just type the following command:
$ setserial -g /dev/ttyS[0123]
Output:
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: 16550A, Port: 0x1020, IRQ: 18
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
setserial with -g option help to find out what physical serial ports your Linux box has.

Linux serial console programs

Once serial ports identified you can configure Linux box using various utilities:
  1. minicom- The best friendly serial communication program for controlling modems and connecting to dump devices
  2. wvidial or other GUI dial up networking program - a PPP dialer with built-in intelligence.
  3. getty / agetty - agetty opens a tty port, prompts for a login name and invokes the /bin/login command.
  4. grub / lilo configuration - To configure serial port as the system console

Ref: cyberciti.biz/faq/find-out-linux-serial-ports-with-setserial

Telephone Switch For Phone Recorder Project



Introduction To Phone Recorder
This phone recorder project will enable you to record both sides of your telephone conversations. One constructed, this switch will allows you to automatically turn on your tape recorder when you pick up the handset of your telephone. Note that your tape recorder must have both a MIC socket and a REMOTE socket on it so that this device can plug into the recorder and control it. This circuit is designed to work for the newer 1.5V and 3V tape recorders as well as the usual 6V or 12V ones.

Phone Recorder Circuit Description

The circuit falls into two parts and these can be easily seen in the diagram. On the left are the connections to each telephone line and to the MIC socket of the tape recorder. The diode and capacitors ensure that no DC voltages pass through to the input of the MIC while the RC network clips large transients. On the right is the circuit which detects when the handset has been lifted and which then turns on the FET. The trim pot adjusts the voltage level of this circuit.
The voltage of the normal telephone line is between 40 to 60 volts (depending on country and telephone system.) When you pick up the handset of the telephone the voltage falls to between 6 and 12 volts. It is this drop in voltage which is used to control the tape recorder through the REMOTE connector. When the line voltage is high the base of the BC548 is pulled high so the transistor is turned on. This pulls the gate of the FET down to less than 1 volt. This shuts off the FET. (N channel enhancement mode FET's need drain bias positive and a positive gate to turn on.)
When the line voltage falls (that is, the handset is picked up) the BC548 will turn off; adjust the trimpot if it does not. So the FET gate potential rises to the 10 volts set by the zener diode. This turns the FET on to high efficiency conduction mode. Different recorders may have different polarities in their REMOTE sockets. To allow for this a PCB mounted switch has to be added to the board which will reverse the polarity of the REMOTE switch just by switching it.

Once completed, place your tape recorder next to the phone. Plug in the 2 sockets (MIC & REMOTE) into the recorder. Put in a casette tape and push 'play'. If the device has been put together correctly either of two things will happen: the tape in the recorder will start to play or it will not.
1. If it does not play then pick up the phone handset. If the tape now starts to play then the device is working. Put the handset down, depress the play and record buttons and the tape will now record when the handset is raised.
2. If the tape plays then either of two things need adjustment:
a) move the position of the trimpot across its range of positions and see if this stops the playing. If it does then lift the handset to see if the playing starts. It should. The device is ready for use.
b) if adjustment of the trimpot does nothing then the REMOTE switch needs to be switched to the other position. Do this and repeat the steps as outlined above.The device should now work.





Phone Recorder Parts List


ref:  electronics-project-design.com/PhoneRecorder.html

Tuesday, February 22, 2011

Electronic Timer Switch



Electronic Timer Switch
This electronic timer switch project is a good project to build to simulate the presence of occupants in a house. In these days when security is becoming more of a concern when no one is at home, having this device will deter the thief from breaking in. When power up, after 60 minutes, the relay will turn ON for 100 secs, OFF for the next 100 secs, and ON again for 100 secs before OFF again for the next 60 mins. This sequence will be repeated. A device such as a lamp that is connected to the relay will turn ON and OFF according to this timing.


Schematic Diagram

The schematic of the project is as shown below.



The core of this electronic timer switch project uses a CD4060B binary counter. The binary counter has 10 outputs and the counter are counted by configuring the oscillator. Every negative clock will trigger the counter of the IC internally.
The timing of the circuit is affected by resistor R3(1M ohm) and capacitor C2(0.1uF). By connecting the four outputs in an AND configuration, the transistor Q1 will only turn ON if all the 4 outputs are in logic "1". If any of the logic is "0", the transistor will remain OFF.
For a complete cycle, the transistor will be ON twice when the output at pin 15, QJ goes to logic "1" and "0" twice when the other outputs QL, QM and QN remain at "1". When this happen, the relay K1 will switch status accordingly. The timing of the switching can be changed by changing the resistor values R2, R3 and C2. Download the data sheet of CD4060B from Texas Instrument website for more details.
Note that since the oscillator is not using crystal, the timing may not be as accurate compared to the ideal calculation. In most cases, fine tuning the resistor and capacitor are good enough to make this project a success. To check whether the circuit is working, connect a LED in series with a 390 ohm resistor at output QD. It will flash ON and OFF as the oscillator oscillates.


Parts List
ref: electronics-project-design.com/electronictimerswitch.html




Tuesday, February 8, 2011

Time Delay Circuit - using 555 Timer

Time Delay Circuit
In the design of analog circuits, there are times when you would need to delay a pulse that came into a circuit before being used for the next process. This time delay circuit uses a 555 timer to delay a pulse that comes in to a maximum time of 75 seconds. The timing of the delay can also be changed by changing the resistor value of VR1 and the capacitor value of E based on the time delay formula of t=0.69RC.
In order for the output to go high, the reset pin of 555 timer (pin 4) must be high and the TRIGGER pin (pin 2) voltage level must be below a third of the level of the power supply to the IC. When there is no pulse being applied to the input, transistor Q1 will turn ON and capacitor E is charged.




Once a pulse is applied to the input, transistor Q1 will turn OFF and pin 4 reset pin is held to high. This caused the capacitor E1 to be discharged through VR1 resistor. The time delay will depend on the discharged of capacitor E to a third of the supply before the output of 555 goes high. Experiment with different values of VR1 and E to get different time delay.
If the maximum value of potentiometer is set to 5M ohm, the time delay of the pulse will be 75 seconds.


Parts List



ref: electronics-project-design.com/timedelaycircuit.html

Constructional Countdown Timer Project using 555 Timer

ntroduction to Countdown Timer
In this Countdown Timer project, a 555 IC, a counter IC and a transistor switch to activate a relay either ON/OFF (mode selected by a jumper) as soon as the counting period is over. The circuit consists of an oscillator, a ripple counter and two switching transistors.

Oscillator
The 555 is configured in the standard astable oscillator circuit designed to give a square wave cycle at a period of around 1 cycle/sec. A potentiometer is included in the design so the period can be set to exactly 1 second by timing the LED flashes. A jumper connection is provided so the LED can be turned off. As soon as power is applied to the circuit counting begins. The output pulse from pin 3 of the 555 is fed to a the clock input pin 10 of the 14-stage binary ripple counter, the 4020 (or 14020.)

Ripple Counter
The counter output wanted is set by a jumper. Ten counter outputs are available: 8/16/32/64/128/256/512/1024/4096 and 8192 counts. If the 555 is set to oscillate at exactly 1.0Hz by the on-board trimpot then the maximum timer interval which can be set is 8192 seconds (just over 2 hours.) At the end of the counting of the countdown timer period a pulse is output on the pin with the jumper on it. The 14020 ripple counter advances its count on each negative transistion of the clock pulse from the 555. So for each output cycle of low-high-low-high the count is advanced by two. It can be set to an zero state (all outputs low) by a logic high applied to pin 11.
In this circuit C3, R4 and D1 are arranged as a power-on reset. When power is applied to the circuit C3 is in a discharged state so pin 11 will be pulled high. C3 will quickly charge via R4 and the level at pin 11 falls thus enabling the counter. The 14020 then counts clock pulses until the selected counter output goes high. D1 provides a discharge path for C3 when the power is disconnected.
You can change the components values of R1 and C1 to set the 555 count frequency to more than 1.0 Hz. If you change the count to 10 seconds then a maximum timer delay of 81920 seconds, or 22.7 hours, can be obtained.
Transistors
The output from the 4020 goes to a transistor switch arrangement. Two BC547 are connected so that either switching option for the relay is available. A jumper sets the option. The relay can turn ON when power and counting start then turn OFF after the count period, or it can do the opposite. The relay will turn ON after the end of the count period and stay on so long as power is supplied to the circuit. Note that the reset pin of the 555 is connected to the collector of Q1. This enables the 555 during the counting as the collector of Q1 is pulled low.

Schematic Diagram




Parts List




ref: electronics-project-design.com/CountdownTimer.html


Tuesday, February 1, 2011

Construct a Unipolar Stepper Motor Control Driver

Introduction To Stepper Motor Control
Stepping motors can be viewed as electric motors without commutators. Typically, all windings in the motor are part of the stator, and the rotor is either a permanent magnet or, in the case of variable reluctance motors, a toothed block of some magnetically soft material. They can be stepped at audio frequencies thus allowing them to spin quite quickly, and with an appropriate controller, they may be started and stopped at controlled orientations.
Stepper motors are used in many applications in our daily life. They include home appliances like air conditioners, automobile, radio antenna control, telescope control where the azimuth, elevation & focus must be varied independently, moving table positioning for test lab and other usage, and a host of other applications that one can think of. These applications required that the continuous stepping at varying speeds and a single stepping, fine control to get the final position.
This project is a Stepper Motor Control driver for 5, 6 & 8 lead unipolar stepper motors and they are common items that one can get easily from the open market.

Stepper Motor Control Motor Identification
This is straight forward because the number of wires coming out of the motor identifies it. Bipolar motors have 4 leads coming out of them. One winding is on each stator pole. These motors are not supported in this project.
Unipolar motors may have 5 leads but generally have 6 or 8 wires. In most of unipolar motors, the wires for the 6 & 8 types come out in two bundles of 3 or 4 wires. Unipole steppers have two coils per stator pole. In the 8 lead motors the 2 leads from the 2 coils from both stators emerge from the motor. In the 6 lead motors the two coils on each stator pole are joined (opposite sense) together before they emerge from the motor. In the 5 lead motors each of the two joined wires are themselves joined before they leave the motor. Figure below shows the schematic connections of the 3 types of unipolar motors.






In the 6 wire version, the resistance between the centre lead to the other two will be about 40 ohms while the resistance between the outer two leads will be twice that. Call the outer two leads in each of the two bunches of wires A & B, C & D. Solder them into those positions on the PCB. Note that it does not matter which way around the A/B, C/D leads go onto the pads.

In the 5 wire version, both + pads on the PCB are connected together. In the 5 wire motor these centre leads are connected internally. So to power a 5 lead stepper just connect the common centre tap lead from both phases to one of the + pads. The A/B, C/D leads are connected just as in the 6 lead motors.
In the 8 wire version, each bunch of 4 leads find the 2 pairs of wires connected to each phase of the motor. Take one of each and join them together. This is now the common lead to connect to the + pad just as in the 6 lead case. The remaining leads are A & B and C & D to the PCB.. Now there are 1, possibly 2, complications. First the common connection must join the coils in the opposite sense. This refers to the way in which they are wound. This means that the dot on one coil is joined to the no-dot end on the other coil in the diagram. There is no way to tell the sense of the coils unless you have the motor winding colour specification which for surplus motors is generally missing. So you just have to try it. Now if the wires are colour coded the same in both bundles this is just a matter of two possibilities to try. If the wires are not colour coded then there are four possibilities. You will not damage the motor during this testing if connections are wrong. The motor will either not work or oscillate to and fro when the power is connected.


Stepper Motor Control Circuit Description
This Stepper Motor Control works in either free-standing or PC controlled mode. In free-standing mode an internal square-wave oscillator based on IC2:B of the 4093 supplies timing pulses to the OSC output. The frequency of these pulses and thus the speed of the stepper motor is controlled by the trimpot VR1 (100K.) A series 1K resistor controls the maximum frequency. You may increase the value of this resistor for your own needs. These pulses are fed into the STEP input which is buffered and inverted by IC2:D. This helps prevent false triggering. Similarly, IC2:C buffers and inverts the DIRection input. A SPDT taking the input to +5VDC or ground controls the direction of rotation. IC3:C and D (4030 or 4070 exclusive OR gates) invert the outputs available at Q and /Q outputs of each of the flipflops (FF) IC4:A and IC4:B. The incoming step-pulses clock the FF, thus toggling the Q & /Q outputs and this turns the MOSFET’s on and off in sequence. The IRFZ44’s have a low on-resistance and can deliver up to 6A each without needing a heatsink. Power to the stepper motor is connected to V+ and GND terminals. There is a separate power supply to the 78L05 to power the IC’s. 8V – 12VDC will be sufficient. R2/C2 form a low-pass filter to filter fast-rise switching transients from the motor.
In computer-controlled mode use the three pads with pins DIR, STEP and GND. Switch the SPDT switch to EXTernal. The direction SPDT has no effect in external mode. Note if the STEP input is left floating the high impedence to the cmos logic gate might pick up noise and false step. Either connect to a PC or ground via a 10K resistor.
Connect the wires to the terminal block Apply power. Make sure the SPDT switch is set to INTernal. See if the motor is turning. If not then swap M1B & M2B wires only and check again. Now it should be turning. VR1 will vary the stepping speed. Figure below shows the Stepper Motor Control driver circuit that one can experiment.




Stepper Motor Control Parts List
Figure below shows the Stepper Motor Control parts list for this project.



ref: electronics-project-design.com/StepperMotorControl.html