Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts

1/07/2013

An Arduino Compatible - CP2102

Standard Arduino boards use FTDI’s FT232RL to interface with computer’s USB port. Since FT232R is just a USB to UART converter, it is possible to build an Arduino compatible USB interface using other USB to UART chips.

One such alternative is Silicon Labs‘ CP2102. I particularly like this USB to UART transceiver because very few extra components are required for it to work. As an added benefit, this chip is also cheaper than the ubiquitous FT232R. Of course, there are also a few trade offs. First of all, CP2102 does not provide a bit bang interface (the X3 pins on the Arduino board on the other hand can be used for bit bang operations, but the X3 pins are not soldered with header pins by default and thus for the average users no bit bang support should not be an issue). Secondly, CP2102 does not have the configurable general purpose I/O pins to drive the TX/RX LEDs. There are other minor differences as well (for instance the maximum transmission speed for FT232R is 3Mbps while CP2102 tops at 1Mbps. Both chips are more than adequate for the maximum 115,200 baud rate supported in Arduino environment), but they do not affect the performance in our application of interfacing with Arduino.

Here is the schematics for using CP2102 with ATmega328p (the circuit below is compatible with the Arduino IDE):





if you compare the above circuit with the official Arduino Duemilanove board you will see that the interfacing portions (RXD, TXD and TDR) are virtually identical.
Since CP2102 comes only in QFN-28 packaging, some people might find it slightly harder to deal with than TSSOP. Using the prototyping method I mentioned a few months back though, it is fairly straightforward to use the chip on a standard perf-board nevertheless. No special tools or stencils are needed. The following picture shows the USB to UART converter portion of the Arduino, which can be used to replace the FT232 break out board. I chose to break out the converter so that I could use it in other projects that require serial connections.



If you are running Linux, you do not need any third-party device drivers. All recent Linux kernels support CP210x via the usbserial kernel module. Once connected, you should be able to use dmesg and see these messages:

    [ 8333.572512] usb 8-2: new full speed USB device using uhci_hcd and address 3
    [ 8333.744748] usb 8-2: configuration #1 chosen from 1 choice
    [ 8333.785114] usbcore: registered new interface driver usbserial
    [ 8333.785161] USB Serial support registered for generic
    [ 8333.785221] usbcore: registered new interface driver usbserial_generic
    [ 8333.785222] usbserial: USB Serial Driver core
    [ 8333.792419] USB Serial support registered for cp210x
    [ 8333.792460] cp210x 8-2:1.0: cp210x converter detected
    [ 8333.920011] usb 8-2: reset full speed USB device using uhci_hcd and address 3
    [ 8334.076745] usb 8-2: cp210x converter now attached to ttyUSB0
    [ 8334.076760] usbcore: registered new interface driver cp210x
    [ 8334.076762] cp210x: v0.09:Silicon Labs CP210x RS232 serial adaptor driver

If you are running Windows, you will need to install the royalty-free driver from Silicon Labs directly.

Under Linux, CP210x shows up as a a ttyUSB device. You can use the Arduino IDE to program your ATmega328p’s just as you would with an official Arduino. Serial communication via the serial monitor works the same way as well. Like the official Arduino, the above circuit also automatically resets whenever you upload a program.
 


12/26/2012

Recharge a 9V NiMh battery with a Solar Panel / Constant Current Generator LM317LZ

 
If you enjoyed the previous post solar-powered Arduino board, you should keep reading this one as well to improve your solar power generator. In fact, with that setup the 9V battery would decay too soon: A NiMh (Nichel – metal hydroxide) battery must be recharged with a constant current generator, a solar panel alone is not.

In order to do so, we can assemble a quite simple circuit using the following components:

    LM317M or LM317LZ
    A 200Ohm trimmer
    10Ohm resistance
    A LED to check if the current is actually flowing








The core of this circuit is the integrated three-terminal adjustable linear voltage regulator LM317. The ‘adj’ pin is a control terminal that is used to adjust the output current. So, the trick is to use a variable resistor (in our case, a trimmer with a small resistance put in front of it) to set the current at a definite value.

With an input DC voltage of max 24V, and the resistances shown in the diagram, one can obtain an output current of:

I_out = 1.2/(10 + R_trim) [A]

This current must be less than 1/10 of the battery output, e.g. for a 750mAh battery the output current must be less than 75mA. As usual, it is customary to insert a capacitor (100uF should be ok) in parallel at the input node to smooth out fast-varying voltages.

12/17/2012

Accelerometer, Arduino and Processing - MMA7260Q



Accelerometers can measure acceleration and tilt (angle). They are used in many devices nowadays such as Mobile phones (iPhone), Gaming consoles and gadgets (Nintendo Wii), Navigation (GPS navigators, Airplanes), and etc. In physical computing accelerometers are used to measure device’s position relative to the ground.  A simple Accelerometers can measure acceleration along one axis. Here, a simple program is presented that interfaces a 3-axis MMA7260Q accelerometer from Sparkfun to an Arduino board.

Use a MMA7260Q “triple Axis Accelerometer Breakout board” from Sparkfun. Connect the board as shown below to an Arduino board:







Be careful while making connections to your Arduino, not to misconnect the Negative and Positive supply.


Download the code for Processing and Arduino in a zip package . Unzip and upload the code provided for the Arduino to your Arduino board. Then run the code provided for Processing. Press ‘X’, ‘Y’, ‘Z’ key on your keyboard to see the real time graph for the corresponding axis on your screen.
The Arduino code sends three consecutive bytes by serial baudrate of 9600. On the computer side the processing program gets the data and translates the bytes (each byte for one axis[X,Y,Z]) into a graph representation.

12/10/2012

Two Wire Arduino Knight Rider PCF8574




This tutorial shows how to interface eight LEDs to an Arduino using only two Arduino pins. This is made possible by using a PCF8574 I/O expander IC. A “Knight Rider” display is shown on the LEDs.

The suggested sequence of building the circuit is:

    Insert the PCF8574 IC
    Make power and ground connections to the IC
    Connect pin 1, 2 and 3 of the IC (U1) to ground
    Insert capacitor C1 (100n) and wire it between power (5V) and ground (GND)
    Insert the eight LEDs with anodes (longer pin) on the left
    Connect resistors R1 to R8 between the LED anodes and the top breadboard rail (5V)
    Wire the cathode of each LED to the correct pins on the IC
    Connect R9 and R10
    Connect the two wires from Arduino pins A4 and A5 to the IC
    Connect the Arduino 5V to the top breadboard rail and GND to the bottom breadboard rail

You may have noticed that the breadboard circuit swaps the position of the LEDs and resistors from the circuit diagram – e.g. R1 and D1 swap positions. This will make no difference to how the circuit operates. It has only been done to simplify the breadboard circuit.