Showing posts with label Serial. Show all posts
Showing posts with label Serial. Show all posts

Thursday, September 26, 2013

mbedR3uino: mbed adapter for Arduino shields

The mbedR3uino is a vertical shield adapter for the mbed prototyping platform.  It provides compatibility with standard Arduino shields including the pins added to Arduino Uno R3 to make shields more independent between main boards.

This is the project I wanted three years ago.  Finally the need, inspiration, materials, and dependent projects converged.  The ability to easily add pluggable hardware to the mbed had been demonstrated when I created the In-between Shield for mbed which plugged into the mbed workshop board adding flash memory to the mbed which plugged into the shield. 

 
I have developed a number of prototype shields for Arduino using a ProtoShield that have been compatible with my various Arduinos, Netduinos, and other development boards providing plug compatibility with Arduino shields.  With the addition of the new R3 pins: SCL, SDA, IOREF some more platform independence has occurred allowing the shield (or at least its I/O) to run at the same voltage as the target platform, and a standardization of the location of the I2C pins.  The SPI pins which were originally reserved for ICSP or initial programming of the Arduino also became a standard.  I opted to skip the SPI/ICSP pin compatibility and stick with the Uno SPI pin layout for simplicity; a future version should include the SPI/ICSP pins in their expected location.  An R3 version of the ProtoShield was found here and I had seeedstudio build the PCBs.

The mbedR3uino is named because mbeduino was already taken.  Inserting the R3 in the name gives it some uniqueness while expressing its meaning.  The adapter consists of two pluggable pieces.  The first plugs into the workshop board above the mbed providing a footprint identical to the mbed.  Components were added to the ProtoShield to plug it into the first piece, and wire the connections to the Arduino R3 headers.  The result is that Arduino shields can be connected to the mbed.


Standard height 0.45" header pins were used to connect the ProtoShield to the above mbed adapter.  The above mbed adapter used taller 0.7" header pins so the PCB barely clears the height of the mbed, only touching the mini USB socket.  Since my prototyping boards have solder terminals only on one side, and to keep them clean looking I try to solder only on the bottom, hidden from view, I used needle nose pliers to push the pins so the plastic is flush with the top of the pins, and then carefully solder the pins from the bottom of the board not getting them too hot or the pin could waver out of place.  Once all the pins are soldered into place they hold very securely.

Note that the mbed workshop board or equivalent is required.  It already provides SD, Ethernet, and USB connectivity.  I have a revA board which pin 9 is held high to 3.3V (intended for SD card detect?), so to allow it to be used for the UART, I cut the trace on the workshop board.  An alternative to using the workshop board would be to have dual row headers and connect the columns for all pins 1-40, as done in my mbed Text LCD development board.  It is relatively easy to also solder a USB B connector, and an Arduino shield can be used for an SD card.  Connecting an Ethernet jack directly to the mbed can be done using a breakout board.

All the available pins on the mbed are either connected to the Arduino headers, or a few are broken out for additional expansion: since the workshop board already uses pins 5-8, they were left as an expansion; CAN and battery lines are implemented as jumpers for expansion.  Analog pins and power pins are where they should be, one UART is wired to D0/D1 for Arduino compatibility, and one SPI is wired for original Uno compatibility (D13-D10).  One pair of I2C pins are in the new R3 location, and the same pins are also wired to the same location as done with the Leonardo: D2/D3.  The remaining D14 and PWM pins are wired to the remaining Arduino header pins.  The schematic below shows how I chose to map the pins between the boards.

Schematic - Click on image to view larger

Saturday, September 3, 2011

Serial Text LCD

Serial Text LCD module
This project connects a Text LCD display to a microcontroller or PC via a single serial transmission line (plus power).
One of the challenges of integrating a text LCD display is the number of pins to connect. A display module typically has 16 lines, with 11 for data and control. That's a lot of lines for a microprocessor to handle. One way to handle it is to get an I/O expander (I2C or SPI), another way is to use a serial protocol such as a UART. The advantage of have a UART compatible text LCD display module is that it can be controlled with just a single TX line. The downside is using up one of (or your only) microcontroller's UART transmission line, unless you can use software UARTs.

backside
Prototype with serial connections

My requirements included performing a very simple firmware implementation.  I didn't want to spend a lot of effort creating the module.  And I wanted to learn the communications with the LCD module, so limiting to just a text interface was not desired.  I ended up implementing a 6-bit raw protocol, and writing a .NET program to talk to the LCD using 4-bit mode.  I already had some firmware for my 485 monitor that I quickly adapted for use with the LCD.  Bytes are received serially on the RX line, then output to the PORTB, of which 6-bits are wired to the LCD.  After echoing the raw hex back on the TX line (for diagnostics, not necessary for operation), the data byte is strobed with bit 5 cleared to finalize communication with the LCD.  I ended up expanding on the .NET program to have a form where what is typed on the screen is efficiently updated to the LCD screen.

I want to interface with 3.3V microcontrollers, and I want the cost to be low, so I used an available PIC18F26K22 I had received as a sample from Microchip, with the circuit using 5V from USB stepped down to 3.3V with a voltage regulator for the CPU.  The LCD runs at 5V, accepting 3V logic from the CPU.  The latest version of the circuit has an added jumper to select whether the PIC runs at 3.3V or 5V, which in turn determines the I/O voltage levels of the module.  The five port socket includes 5V, 3.3V (output), Ground, TX (output), and RX.  Minimally only 5V, Ground, and TX need to be connected.  This PIC is currently configured to run at its top speed of 64MHz! (This may be overkill for just driving an LCD.)  The LED in the circuit is a heartbeat to show that the PIC is running.

.NET program and hex diagnostics 
Schematic


I plan to immediately use this module with other PIC, Arduino, and Netduino projects.  Writing the .NET program allowed me to more easily learn the LCD protocol than debugging the firmware.  I may expand the firmware to move more of the LCD protocol into the PIC18 firmware, or at least have that option.  Other possibilities are to implement I2C and/or SPI interfaces.

Update: In addition to Windows, I have had success using this module with the mbed, LPCXpresso 1769, chipKIT Max, and Arduino. 

Wednesday, August 3, 2011

PIC24 USB + Serial Development Board



Two main emphasis of this board are USB and Serial as well as using socketed components.  The 28-pin PIC24FJ64GB002 can perform as either a USB host or USB device, using jumpers to select between the connected USB socket.  The USB jumpers are also configured so when the PIC is USB host using the USB-A connector to attach a thumb drive, the USB-B connector may be configured to attach to an FTDI FT232RL chip to act as USB serial.  Using a USB-A to USB-B adapter, both the PIC and the FTDI chips could be active as USB devices. 

Two serial channels are jumpered for either RS-485 or RS-232 (DB-9 connectors not shown), or the second serial channel can be jumpered to the FTDI USB serial connection.  As configured here, RS-485 uses RX/TX with RTS to select whether reading or writing.  RS-232 can use RX/TX with CTS/RTS.  The ICSP (in circuit serial programming) connection in the lower left works with ICD or PICKit programmers, and shares the lines that provide CTS/RTS, so jumpers are provided to choose between those functions.  The PIC24 has quite a few 5V tolerant inputs, but I ran out of enough of them, so a 5V/3V3 logic level conversion board is socketed to read the CTS lines at 3.3V from the 5V MAX232 and MAX233

Voltage regulators are included to power 3.3V and 5V buses, accepting power from USB or 7V-12V external power.  Each module has a power jumper to effectively disable them.  The USB sockets have jumpers to selectively attach power to the 5V bus.

One SPI channel is also configured, allowing connection of features such as a micro SD card and/or SPI Ethernet.  This board specifically supports connection of a Microchip's PICtail Ethernet (ENC28J60) board.   

Sunday, July 31, 2011

RS-485 module

RS-485 is a single duplex, differential, multi-drop capable serial communications method.  This module has TTL level I/O pin header including 5V, RX, TX, read enable, transmit enable, and ground.  Wiring was done above board for self documenting.  LEDs are included for the TTL lines.  Jumpers are provided to connect a 180 ohm RS-485 termination resistor, source or receive 5V to the RS-485 socket, and whether to tie the read and transmit enable lines together.  The RS-485 socket accepts a screw terminal connector (not shown).  The voltage regulator is included for translating incoming voltage (7V-20V) to 5V.  This circuit is built around the Linear Technology RS485 transceiver LT1785.


Saturday, July 30, 2011

TTL/RS-232 module



I developed this TTL/RS232 module using a typical MAX232 chip.  It is a RS-232 serial communiations transceiver with two transmit and two receive channels.  It converts from TTL logic (0V=low, 5V=high) to RS-232 signals (approximately -10V to +10V in this case); see the datasheet for more specifics.  The 6 pin header has 5V, GND, RX, TX, DTR, CTS.  The 10 pin header includes all the DB-9 pins, with the DB-9 female connector attached via ribbon cable and socket.  This model of the Maxim chip uses 0.1uF capacitors.  I could have used the MAX233 which has is an extra 2 pins wide but doesn't need any added capacitors so is easier to work with.  LEDs are included to show send/receive and cts/rts activity.  Two of the resistors for the LEDs ended up on the reverse side of the board.


Wednesday, July 27, 2011

FTDI USB to Serial module

This FT232RL is a popular chip used for converting TTL level serial lines to/from USB serial.  You can find it used with Arduino micro cpus and similar.  The chip supports any voltage logic.  Here it is using 3.3V or 5V logic depending on the jumper setting.  A 3.3V regulator is included on chip.

I used a breakout board from SparkFun to adapt the 28-pin SSOP to 0.1" pitch headers.  This was my first attempt at soldering a surface mount chip.  I was successful soldering the important pins.  Using dual row header sockets, I was able to construct this as a prototype module, making all pins available for use.  LEDs are present for power, RX, and TX.   Sample circuits are available in FTDI's datasheet.

Monday, July 25, 2011

PIC18F2550 RS-485 Adapter

Here is the first RS-485 monitor or adapter I built in small quanity.  I started with a RS-485 board from Modtronix, and used their prototype daughter board to add a USB connector (note: required two simple cuts to get USB to work).

My firmware for the PIC18F2550 adapts USB serial to RS-485 and vice versa (bidirectional).  It bridges the gap between the PC and 9-bit RS-485 protocols.

Also, here is a breadboarded version from scratch that uses identical firmware.  The RS-485 A/B wires are not show, would leave the LTC1487 chip at pins 6/7.  A USB B socket breakout board is used to help prototype the circuit.