Saturday, August 31, 2013

USB TO RS232 converter

This project lets you conveniently connect any computer with USB ports directly to a simple, traditional connector  the 9-pin RS-232,It converts the electrical signals from a USB<–>serial TLL convertor to the RS-232 standard. So in a nutshell,it converts a USB port into a standard but basic serial port.

                                                          

 The voltage level adaptor is a MAX3232 from Maxim. This industry-standard part comprises two transmitters and two receivers, ideal for our USB<–>serial convertor, which itself offers the four fundamental signals of an RS-232 standard port, namely TXD (Transmit Data), RTS (Request To Send), RXD (Receive Data) and DTR (Data Terminal Ready).



Simple Logic Probe

This circuit effectively functions as a logic-level indicator or logic probe for TTL circuits. It gives an indication of any of the following four conditions that might be found on a typical digital circuit and thus provides a versatile troubleshooting aid:
1. Line high (logic 1)
2. Line low (logic 0)
3. Line tri-state (high impedance)
4. Line changing between high and low state alternately (pulsating).
The logic probe is powered from the power supply of the digital equipment under test. The logic state of the line under test is indicated by two LEDs (LED1 and LED2). If the line being probed is at logic 1 (high) state, LED2 would glow brightly. If the line is at logic 0 (low) state, LED2 would be off. If the line is at tri-state or open then LED2 would be dimly lit (about half of its full brightness). If the line has a pulsating signal or a clock signal, LED1 would flash on and off at a rate of 1 Hz. Thus LED2 gives an indication of static signal states, while LED1 indicates dynamic signal conditions on the line being probed. The various states of LED1 nd LED2 are summarised in Table I. In order to obtain a visible indication of a clock signal presence on LED1, a divider, which comprises two monostable multivibr- ators, is made use of. The monoshots are realised using IC1 (dual timer 556). The output of the first monoshot section (pin 5) is applied to the trigger input (pin 8) of the second timer. Assume a clock frequency of 10 kHz is applied to the probe tip. The falling edge of the clock at pin 6 of IC1 triggers the first monoshot section. The output of the first monoshot stays high for around 0.5 seconds and then goes low. This low going edge triggers the second monoshot section, making its output (pin 9) high for around 0.5 seconds. While pin 9 is high, the first monoshot section is prevented from being retriggered with the help of transistor T1. When pin 9 reverts back to the low state, the first monoshot can be retriggered. This arrangement ensures that LED1 flashes ‘on’ and ‘off’ at a visible rate of around 1 Hz, thus indicating a clock presence on the line under test. The circuit will detect clock frequencies between 1 Hz and 100 kHz, approximately. For any clock frequency within this range, LED1 will flash at a constant rate of 1 Hz. When the probe tip is connected to a line at logic 1, currents flowing through resistors R9 and R10 add up in LED2 and make it glow brightly. When probe tip is connected to a line at logic 0, the voltage at the junction of resistors R9 and R10 is not sufficient to turn on LED2 (hence it remains off). When the probe is not connected any- where or is connected to a tri-stated line, LED2 remains dim because of current flowing through R9 only. The whole circuit can be enclosed in a small plastic tube with LED1 and LED2 exposed. A pin can be used as the probe tip. The usefulness of this logic probe is limited to low frequency digital circuits.
                                   
                                 

Wireless On-Off Switch

Small and simple circuit, Suitable for home appliances

Normally home appliances are controlled by means of switches, sensors, etc. However, physical contact with switches may be dangerous if there is any shorting. The circuit described here requires no physical contact for operating the appliance. You just need to move your hand between the infrared LED (D2) and the phototransistor (Q1). The infrared rays transmitted by D2 is detected by the phototransistor to activate the hidden lock, flush system, hand dryer or else. This circuit is very stable and sensitive compared to other AC appliance control circuits. It is simple, compact and cheap. Current consumption is low in milliamperes. The circuit is built around an IC CA3140, D2, phototransistor and other discrete components.
Circuit Diagram:



Parts:
R1 = 470R
R2 = 100K
R3 = 3.3K
R4 = 10K
D1 = 1N4007
D2 = IR LED
Q1 = L14F1
RL = 5Vdc Relay
IC = CA3140
Q2 = BC548

Circuit Operation:
When regulated 5V is connected to the circuit, D2 emits infrared rays, which are received by phototransistor Q1 if it is properly aligned. The collector of Q1 is connected to non-inverting pin 3 of IC1. Inverting pin 2 of IC1 is connected to voltage-divider preset R4. Using preset R4 you can vary the reference voltage at pin 2, which also affects sensitivity of the phototransistor. Op-amp IC1 amplifies the signal received from the phototransistor. Resistor R3 controls the base current of transistor BC548 (Q2). The high output of IC1 at pin 6 drives transistor Q2 to energies relay RL1 and switch on the appliance, say, hand dryer, through the relay contacts. The working of the circuit is simple. In order to switch on the appliance, you simply interrupt the infrared rays falling on the phototransistor through your hand. During the interruption, the appliance remains on through the relay. When you remove your hand from the infrared beam, the appliance turns off through the relay. Assemble the circuit on any general-purpose PCB. Identify the resistors through colour coding or using the multimeter. Check the polarity and pin configuration of the IC and mount it using base. After soldering the circuit, connect +5V supply to the circuit.


Water Level Indicator




Description

                 Figure shows the circuit diagram of the ' Water Level Indicator '. Here I have used copper plates and led for making this circuit. Pure water does not conduct but available water already has some ions. Here is the right copper plate has ground potential so when the water reaches the first left copper plate, the low LED will glow. When the water reaches the higher position, the full LED will glow.

USB tester

USB tester
4 St







This simple device allows you to check the correct working of the USB ports of any computer, using a green led and message from your operative system.
It will allow you to test the proper assembly of any port without risking any expensive device.
If you normally work fixing computers this is a must in your tool kit.

Ps: I'm from Argentina so let me know any grammar mistake

Step 1: The circuit




The circuit is very simple using only some discrete components.
The operation is simple, you connect it to the USB port, if it's okay, the green LED is lit in all its intensity and you will have a message from your operative system telling you than a USB device has been detected. If the polarity is reversed the red LED is lit in all its intensity. Any other combination causes lit one of the two LED but very dim.

You will need:
The PCB (see step 2)
The USB connector (see step 3)
Two 22K resistors
One 1k resistor
One 100 ohm resistor
One 1.5 k resistor
One 3v3 zener diode
One 1N4148 diode
Two leds (green and red)


Step 2: The board









The PCB is very small and simple.
I made it using the method of ironing.
PDF file annexed contains the design ready for printing.

usb.pdf(595x841) 14 KB
Step 3: The connector









This project seeks to be economical so you're not going to buy a connector. We will recycle a cable that does not work.
First we remove the plastic guard with a knife.
Then remove the remains of cable and solder it new terminals.
Finally I soldered two terminals to the metallic body to keep it firmly attached to the PCB:
Step 4: Soldering components








The components are easy to weld.
Try not to overheat the diodes and not allow shorts in the PCB.
Use the second image as an assembly guide


Friday, August 30, 2013

AVR programmer on PIC

Just from pure passion to see how low-end PIC exercises AVR, I made this programmer.
Basically it is STK500 port on PIC16F1825. I took this
one, did some clean-up, wrote new hardware layer for PIC16 and voila - new programmer is born. It was done in one evening and night, ready to work in the morning. I didn't bother with USB (though there is a lot of DIP USB MCUs from microchip), as It would contain extreme amount of ICs - probably one more than this implementation - and I wanted to keep it simple and transparent. One can use FT232RL instead of MAX3232.



Well, what more? It works with both AVRstudio and avrdude. It has no ESD protection, but for recreational use (I don't like AVR very much) it is acceptable.
There is a lot of other programmers, as good (or better or worse) as this one. This is nothing special - I made it for sheer passion of PIC-AVR interracial marriage.

USB Battery Pack


Builtin batteries in gadgets have some advantages: they have more power and capacity, they last longer and they are usually lighter than replaceable batteries. But they have a huge disadvantage as well: when they are empty you're out of power until you are back at home to charge them.
Foosel found a solution for this problem: a simple battery box to attach to any USB chargeable device. When I first saw it, I knew I needed to have one my self.
 
              
The idea is simple. Use two standard AA batteries and some electronics to power your device through an USB cable. The electonics are needed to convert the 3 Volts of input delivered by your batteries to the 5 Volts wanted by the USB specs.
This weekend I went to a local electronics dealer and bought the necessary parts (I had the neededtin already).
Unfortunately I have no knowledge of electronics whatsoever, so I was doing a blind flight there. I assembled all the parts as shown in Foosel's circuit plan. But when I checked the output voltage, my multimeter showed 55 Volts instead of the wanted 5. I was lost.
Luckily Foosel was nice enough to have a look at a few images I sent her and quickly found the problem. I had bought a different version of the DC/DC converter. Like hers, mine was labeled LT1073 but while she used the CN8 version I had bought the CN8-5. From what I understood from her explanation, my version had the functionality of two resistors used in her original circuit already built in. So the solution was to remove those two resistors.
I did as told and finally got the correct output voltage :-). Here is a photo of my final box with the new circuit plan as overlay.

Here are the parts I used:
Name
Description
R1
100 Ohm Resistor
403130
C1
100µF Capacitor (axial)
471674
C2
100µF Capacitor (axial)
471674
D1
1N5818 Diode
164828
L1
68µH Inductor
535710
IC1
LT 1073 CN8-5 DC/DC Converter
171573
X1
Female USB A Connector
716258
Mount for 2 AA Batteries
615625
Battery clip for the mount
624691
Breadboard
528404
There were some things which took me a while to figure out.
There was no mark about the cathode and anode sides of the capacitors – I finally found the data sheet for them. The positive pole is where the dent is – this might be an obvious standard, but I didn't know and couldn't find any info about it.
Be sure to attach the positive pole and ground to the correct pins of the USB jack. If done the wrong way round, your devices will not recognize the power source. Refer to the pinout on the right.
Make sure your contacts below the board will not touch the metal of the tin. I mounted the board on some pieces cut from a wine cork using two component epoxy glue. The hole for USB connector was cut with a dremel, the connector it self was fixed with hot glue.

My board layout could probably be much tighter. From what I learned later it is very bad style to attach parts diagonally.

GSM Multifunction Alarm with SIM900


It’s small but packed with features. The GSM alarm we present today, sports a PIR motion sensor, can be battery operated and it’s capable to communicate via GSM. It can transmit alarm conditions and receive commands from remote. It’s also capable to indicate problems such as is insufficient voltage supply or tampering.
It’s not so conventional for antitheft system: to integrate a movement sensor, a PIR motion sensor and a temperature probe in a single appliance: all this accompanied by an SMS sending GSM / GPRS module. This circuit was born as a very versatile, ready to use, built-in alarm system: no installation is required, you can just drop it and it’s ready to work. It’s not by chance that is designed to be battery operated: it also features a battery state control to check the power.
Moreover, it has two digital inputs, one which was is set up to detect tension: with it, you could detect important conditions such as the state of a protection system or even other parameters of various kinds, simply by adding additional sensors.


The diagram

All is quite simple, since most of the tasks are managed by a PIC18F46K20 (U1), all is powered between 6 and 32 VDC (even unregulated), thanks to a DC / DC buck converter configuration that is present in the circuit.
The switching regulator is based on the MC34063 (U2), used in the classical configuration of a winding inductance series PWM regulator, whose output voltage depends on the energy stored in L1, the output voltage from the DC / DC is stabilized with reference to the potential demoted to pin CII by the resistive divider R3/R4.
The two components are designed to get 4 V in C8 and C9.

After power-on-reset, the microcontroller, initializes its I/O settings: RB0 reads the state of the motion sensor, RB1 and RB2 serve to detect the logical condition in inputs IN1 and IN2; RB3 reads the state of the P1 button and RB4 the logical condition of the output of the passive infrared radar PIR. The latter normally has zero on OUT and 5-volt pulses when detects something in its field of action. P1 button serves for the local management of the operation mode.
Note that both IN1 and IN2 are protected by a diode which prevents the application to RB1 and RB2 of voltages exceeding that with which the microcontroller is powered. In the case of  PIC18F46K20, a voltage below 1 V or a short circuit of IN1 or IN2 corresponds to the low logic state, while the opening of said inputs or the application of a DC voltage of 1 to 5 V generates 1.
The AN0 line is an input assigned to the A / D converter contained in the microcontroller and reads the value of the voltage supply through the resistive divider formed by R1 and R2.
The RC0 line is initialized by the PIC as a bidirectional I / O, as it serves to communicate with the temperature sensor, which, in our case is a Dallas DS18B20. This sensor is very precise and it’s capable of measuring temperatures between -5 and 150 ° C with an accuracy of ± 0.5 ° C (in -10 ÷ 85 ° C), making them available over a serial line, in this case going to the RC0 pin of the microcontroller.
Let us now look to the outputs: RD6 and RD7, used to manage the lighting of the LD1 and LD2 LEDs .
Regarding the cellular module, this is an FT900M based on the SIMCOM SIM900. The microcontroller contains a UART that accessible from pins 44 (transmission) and 1 (reception): it’s used to communicate with the GSM module.
The set of I/Os is completed by RC5 and RD0: the first one controls the switching of the GSM (via a transistor arranged in the base) while the second line provides to phone reset when necessary; in any case after the initialization after resetting circuit.

BOM
[code]
R1: 10 kohm (0805)
R2: 1 kohm (0805)
R3: 2,2 kohm (0805)
R4: 1 kohm (0805)
R5: 0,1 ohm 1W (1206)
R6: 330 ohm (0805)
R7: 330 ohm (0805)
R8: 4,7 kohm (0805)
C1: 100 nF (0805)
C2: 470 µF 6,3 VL (X)
C3: 470 µF 6,3 VL (X)
C4: 100 nF (0805)
C5: 22 µF 25 VL (D)
C6: 100 nF  (0805)
C7: 100 nF (0805)
C8: 470 µF 6,3 VL (D)
C9: 100 nF (0805)
C10: 100 nF (0805)
C11: 100 pF (0805)
C12: 22 µF 25 VL (D)
L1: 22 µH
U1: PIC18F46K20-I/PT
U2: MC34063AD
LD1: LED red 5 mm
LD2: LED green 5 mm
P1: Microswitch
D1: GF1M
D2: GF1M
D3: MBRA140TRPBF
MOV: Motion sensor
PIR: PIR sensor

TEMP: DS18B20+
[/code]
How it works
The system is designed to be configured via SMS and, when alarms are triggered, it sends one ore more SMS to the numbers stored in a secial list, to warn one or more persons.
Our system fires an alarm on the verification of one or more of the following conditions:
- the IN1 input changes state, moves at high or low state,
- the motion sensor detects a vibration
- the PIR sensor detects presence,
- the temperature goes out of a preset range
- the supply voltage drops below a certain value

When one of these events occurs, the circuit sends a text message to te contact list.
You can also set a custom message for each event.
RB2 is used to activate and deactivate the alarm: leaving it open or putting a high logic level, after an interval can be set between 0 and 59 seconds with the SMS command TATT, the circuit will be activated.
After activation of IN1, the green LED LD2 will flash until activation.
You can also ask the device to send a text message when activated.
You can define a sensors inhibition time thanks to the SMS command INI:xx, ( xx is the time in minutes). Inhibition time is to avoid multiple alarms for the same event. caused by something that produces more pulses (such as an unstable contact in IN2, an oscillating temperature around the threshold value etc..).
One particular feature of the circuit is the Sleep mode, useful to prolong the operating time when the circuit is battery powered: sending the SLEEP:xxx command the system goes to a sleep mode (low power) for xxx seconds. During this mode, the operation is minimal, ie, the circuit neither detects any alarm, nor it sends or reads i ncoming SMS. Sleep mode suspends every xxx seconds, when the circuit queries the phone to verify the arrival of messages and move on the execution of commands.

Sleep mode enables automatically only if the circuit is turned off, or if the IN1 is at a low logic level.
If the circuit is on sleep, but you need to read data you can awaken it momentarily in two ways: locally, by pressing the P1 button, or remotely, making a phone call to it. Upon awakening, we can send an SMS command to read the data we want, the circuit will respond and then will automatically go back to sleep.

Configuration

All circuit settings can be made ​​by SMS: note that the system will only accept SMS from phone numbers stored in the approved numbers list, a maximum of 8. This list is the same to which the system will send the SMS to. Alternatively you must send commands accompanied by a password, which by default and following a reset (imposed by SMS).
The command to store a new number is the following (a SMS containing the text): NUMxnnnnnnnnnnnpwd, where x is the position (1 to 8) where to save the number amd pwd is the current password (required if the SMS command originates from a phone is not in the list and needed when you store the first number)
The pwd is due in any case if the position is already taken by another number. Each number can be up to 19 characters and must contain the national prefix.
You can also query the device to find all the numbers stored: just issue the command SMS NUM?;pwd.
Our device implements also an Easy Setup functionality: after switching on, keeps waiting for a phone call and then saves the caller’s phone number and enters the normal operation.
Once you stored the numbers in the list, you must define which ones to send SMS alarms. The command is SMSxxxxxxxx:ON or SMSxxxxxxxx:OFF, where xxxxxxxx is the position in the list where the numbers are stored.
For example, SMS1346: ON sets that the numbers in positions 1, 3, 4 and 6 will receive the SMS. OFF will than deactivate the corresponding SMS sending.
At the first start and after each reset, the tracker sends SMS to all numbers stored.
Certain commands can be executed only when accompanied by a password: the default password (reset after every hard reset of the system) is 12345, and you can replace it by issuing the command PWDnewpwd, pwd, where newpwd is the password to be stored and pwd is the current one.
A reset, which restores the default settings and clears phone numbers list is done thanks to the RESpwd command, where pwd is the current password.
You can send text messages containing multiple comma separated commands, and with a special command, you can disable answers to some of the commands by inputting the command RISP.

Let’s disuss of how to manage the alarm functions. Let’s start with the temperature. By sending the TEMPcommand you get the current temperature, by ALLMAX:YXX and ALLMIN:YXX (where y is the sign and xx corresponds to the Celsius degrees) you can set maximum and minimum temperatures (before issuing alarms).
Temperature settings can be reset by sending the command TRES. The ALL?   command instead queries the system, which responds with the currently
set temperatures. Temperature alarms are activated by the SAT:1 command: to deactivate you can issue the SAT:0 command. The setting will be stored until reset.

Let’s look at the commands of the motion alarm: SAM:1 enables sensor, and SAM:0 disables it, settings are saved until hard reset.
The PIR sensor, is activated and deactivated via SAP:1, SAP:0 commands. The settings are kept until reset as well.

Command SAI:1 and  SAI: 0 activate and deactivate control on the IN2 input line. The commands to define what the system should consider an alarm are the following: LIV:A  makes the input sensitive to the logic high, LIV: B activates it with zero and LIV:V activates the alarm when there’s a change in the logic level. The LIV? command asks the system to send a text message containing the current setting for the IN2 alarm input.
Command: SAV:1 gives alarm if the battery voltage drops below 6 volts; with SAV: 0 we can disable this function.

To get an SMS when circuit is activated (meaning IN has been activated) you must send the command AVV:1; you can disable this feature with AVV:0.

IP Address Checker