Saturday, August 31, 2013

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