Monday, March 10, 2014

Using a Dot Matrix LED with an Arduino and Shift Register


sing a Dot Matrix LED with an Arduino and Shift Register


The Siemens DLO7135 Dot matrix LED is one amazing piece of optoelectronics. It's billed as a 5x7 Dot Matrix Intelligent Display (r) with Memory/Decoder/Driver. Along with that memory, it's got a 96-character ASCII display set with upper and lower case characters, a built-in character generator and multiplexer, four levels of light intensity, and it all runs on 5V.

That's a lot to live up to, and at $16 a pop, it definitely should. While spending half the day at my favorite local electronics shop I found a bin full of these for $1.50 a piece. I left the store with several.

This instructable will show you how to connect to these dot matrix LED's and display characters using an AVR-based Arduino. If you've read any of my previous guides, you may get the idea that I'm often in favor of the most parsimonious solution, and you wouldn't be wrong, even if I do fall short of the goal from time to time. Therefore, I'll also go another step in this instructable and show you how you can reduce the number of I/O ports needed to drive these big, honkin' dot matrix LED's.
DLO7135.pdf(612x792) 173 KB

Step 1: Get the Goods...

For this short little project, you will need:

  • an AVR-based microcontroller like an Arduino or any of it's ilk. These instructions could probably be adapted to your MCU of choice.
  • a DLO7135 dot matrix LED or other in the same family
  • an 8-bit shift register like the 74LS164, 74C299, or 74HC594
  • a breadboard
  • hookup wire, wire cutters, etc.
A soldering iron isn't needed, although I use one later; you can get by without it.

Step 2: Directly Connect to the LED Display

Lay out your small list of parts and grab the LED. Place it on the breadboard centered somewhat, straddling the midline groove. The first part of connecting takes place all on the left side of the LED. Pin #1 is located at the top left as indicated by the triangle/arrow. I put the pin functions on a picture for your reference as you're reading or connecting up your LED.

The Left Side

Positive and Negative
Starting at the top left, connect Vcc to 5V. It's maybe a good idea to not have your board powered until you get the entire left side completed; the LED can be bright if you're trying to see small holes to poke in wires. Connect the bottom left GND to ground.

Lamp Test, Chip Enable and Write
The 2nd and 3rd from the top on the left are Lamp Test and Chip Enable. These are both negative logic, meaning they are enabled when they are at a logical 0 instead of 1. My picture below should have bars over them, but I didn't annotate that for any of them. The LT pin when enabled lights up every dot in the dot matrix at 1/7th brightness. It's more of a pixel test, but the interesting thing about the LT pin is that it doesn't overwrite any character that's in the memory, so you if you have several of these strung together (they have a 20ft viewing distance), strobing LT can make it look like a cursor. To ensure it's disabled, connect it to 5V.

The CE and WR pins are also negative logic and are required to be enabled for this smart device to be written to. You could micromanage these pins with spare I/O ports on your microcontroller, but we won't bother here. Just connect them to ground to keep them enabled.

Brightness Levels
There are four programmable brightness levels on the DLO family of LEDs:

  • Blank
  • 1/7 Brightness
  • 1/2 Brightness
  • Full Brightness
BL1 HIGH and BL0 LOW is 1/2 brightness. Both HIGH is full brightness. Set it to whatever you like. Again, if you have I/O ports to spare and it's important enough to you, this can also be controlled by your Arduino.

That wraps up the left side. If you bring power to your board you should see the LED light up. Play with the brightness controls and the lamp test to get familiar with it, if you're curious.

The Right Side

The right side consists of entirely data ports. The bottom right, pin 8 or D0 to be precise, represents the Least Significant Bit in the 7-bit character. The top right, pin 14 or D6 represents the Most Significant Bit. This lets you know what order to shuffle your bits when writing to the LED.

When you have the data input ports wired up, find seven empty digital I/O ports on your Arduino or AVR and connect them. You'll probably want to remember what data output port on your AVR goes to which data input port on the LED.

Now you're ready to push some data onto that smart LED. Are you trembling with excitement yet? I know I am...

Step 3: Specifying a Character to be Displayed

The character set that's used on this CMOS LED is your run-of-the-mill ASCII starting at 0x20 (decimal 32; a space) and ending at 0x7F (decimal 127; a delete, although represented on the LED as a cursor graphic). So, having the LED display a character entails nothing more than pushing the a logic 1 or 0 on your data output pins, usually followed by a WR pulse, but I'm foregoing that for this exercise.

So, you've written down or remembered what pins go to what ports, right? I chose PD[2..7] and PB0 (digital pins 2 through 8 in Arduino-speak). I don't normally suggest using PD[0..1] because I dedicate it to my serial communication back to a FreeBSD box, and Arduino's et al. map those pins to their FTDI USB communication channel, and although "they" SAY pins 0 and 1 will work if you don't initialize serial communication, I have never been able to use those pins as normal digital I/O. In fact, I spent two days trying to debug a problem when I tried to use PD0 and PD1 and found that they were always HIGH. *shrug*

It would probably be good to have some sort of external input, like maybe a keypad, a pushwheel or thumbwheel switch, or maybe even input from a terminal (my ArduinoTerm isn't ready for prime time just yet...). The choice is yours. For now, I'm just going to illustrate how to get the code to get the character you want onto the LED. There is a zipfile for download including the source code and Makefile and there's also a short movie showing the LED printing out its character set. Sorry for the crappy quality of the video.

The code below prints the string "Welcome to my Instructable!" then cycles through the entire character set that the LED supports.
DDRD = 0xFF; // OutputDDRB = (1<<DDB0); char  msg[] = "Welcome to my Instructable!";uint8_t i;for (;;){    for(i=0;i<27; i++)    {        Print2LED(msg[i]);           _delay_ms(150);    }     for(i=0x20; i<0x80; i++)    {        Print2LED(i);        _delay_ms(150);    }    Print2LED('*');}

The port output is taken care of in the Print2Led() function.
voidPrint2LED(uint8_t i){ PORTD = (i << 2); if (i & 0b01000000)     PORTB = (1<<PINB0); else     PORTB = (0<<PINB0);}

The code and Makefile is included in a zip file below.

Step 4: Conserve I/O Ports with a Shift Register

So now our microcontroller can send data to the dot matrix LED but it's using eight I/O ports. That excludes using an ATtiny in an 8-pin DIP package, and even with a newer Arduino sporting an ATmega328p that's a lot of I/O ports for one LED. We can get around this, however, by using an IC called a shift register.

A moment to "shift" gears...
A shift register can be understood best by thinking about the two words that make up its name: "shift" and "register." The word shift refers to how the data is moving through the register. Here (as in our Arduino and microcontrollers, in general) a register is a location that holds data. It does this by implementsing a linear chain of digital logic circuits called "flip flops" that has two stable states that can be represented by either a 1 or 0. So, by putting eight flip flops together you have a device that is capable of holding and representing an 8-bit byte.

Just as there are several types of flip flops, and several variations on a theme of shift registers (think up/down counters and Johnson counters), there are also several types of shift registers based on how data is latched into the register and how that data is output. Based on this, consider the following types of shift registers:

  • Serial In / Parallel Out (SIPO)
  • Serial In / Serial Out (SISO)
  • Parallel In/ Serial Out (PISO)
  • Parallel In / Parallel Out (PIPO)
Two of note are SIPO and PISO. SIPO registers take data serially, that is, one bit after another, shifting the previously input bit over to the next flip flop and sending the data out on all inputs at once. This makes a nice serial to parallel converter. PISO shift registers, conversely, have parallel inputs, so all bits are entered at once, but are output one at a time. And you guessed it, this makes for a nice parallel to serial converter. The shift register we want to use to reduce the number of I/O pins would allow us to take those 8 IO pins we used earlier and reduce them down to one, or maybe just a couple, considering we may need to control how we input the bits. Therefore, the shift register we'll use is a Serial In / Parallel Out.

Wire up the shift register between the LED and Arduino
Using a shift register is easy. The hardest part is just visualizing the data output pins and how the binary digits will end up in the IC, and how they will eventually show up on the LED. Take a moment to plan this out.

1. Attach 5V to pin 14 (top right) and take pin 7 (bottom left) down to ground.
2. The shift register has two serial inputs but we'll only be using one, so connect pin two to 5V
3. We won't be using the clear pin (used to zero out all outputs) so leave it floating or attack it to 5V
4. Connect one digital IO port to pin one of the shift register. This is the serial input pin.
5. Connect one digital IO port to pin 8 (bottom right). This is the clock pin.
6. Connect your data lines from Q0 to Q6. We're only using 7 bits because the ASCII character set only uses seven bits.

I used PD2 for outputting my serial data and PD3 for the clock signal. For the data pins, I connected Q0 to D6 on the LED and continuing that way (Q1 to D5, Q2 to D4, etc). Since we're sending out data serially we will have to examine the binary representation of each character we want to send, looking at 1's and 0's, and outputting each bit on the serial line. I've included a second version of the dotmatrixled.c source along with a Makefile below. It cycles through the character set and displays all even characters (if it's weird thinking that a letter could be odd or even, think about the binary representation for a moment). Try to figure out how to make it cycle through displaying all odd characters. You can further experiment with the connections between the shift register, the dot matrix LED, and your Arduino. There are several control features between the LED and the register that can allow you to fine-tune your control about when data is displayed.

So....we've gone from having to use eight I/O ports to only using two!

Step 5: Summary

In this instructable, I have presented the DLO7135 dot matrix LED and how to make it work. I've further, discussed how to reduce the number of required I/O ports from eight to only two using a shift register. The DLO7135 dot matrix LED can be strung together to make very eye catching and interesting marquees.

I hope you had fun reading this instructable! If there's any improvements you think I could make or suggestions you'd like to give on this or any of my 'ibles, I'm happy to hear them!

Cheap lcd screen for the Arduino.

Cheap lcd screen for the Arduino.

We have used the pda with a desktop computer (robot) and with the Nslu2. Here we are going to use an old pda with serial port.to act as an lcd. Everyone either has one or knows someone who has an old pda that they do not use anymore.  Ask them if you can borrow it get get it cheap. Though it is not demonstrated here, you could also use the pda for input,  Therefore you can easily interact with your Arduino using the proper programming.Another advantage of using the serial lcd is that you have more pins freed for use than with a parallel lcd screen.An lcd takes up less room that a tv and is lighter to carry around.

Step 1: Needed:

Pda with lcd termial software and rs232 interface/
rs232 to ttl interface.
4 pin female header like from a cdrom cable.
Arduino.
Arduino IDE

Step 2: Pda.

We will be using and old Palm III and cradle.
ptelenet. prc is installed.

Under linux with a properly set serial port:

Now to get the Pda working with the unit. The Palm pda will not work as is as a dumb terminal, so I had to install a program on to it from another computer called ptelnet.prc using a usb to serial interface. The Palm has an interface cable that will plug directly into the 9 pin serial port on the back of the computer or into an usb to rs232 converter cable..

For linux: (Other systems will vary on how to do this).
$ sudo apt-get install pilot-xfer
$ pilot-xfer -p /dev/ttyUSB0 -i ptelnet.prc

Set serial 9600-8-n-1

Step 3: DB9 Gender.

Most rs232 interfaces come with a female end assuming you will adapting to a standard rs232 port. I ordered a male because I wanted to allow the pda cable with the standard female end to plug into it directly with out a gender changer.

Step 4: Rs232 to TTL interface.

Rs232 has a higher voltage than the Arduino uses. You have to have some electronics to deal with the voltage differeinces.

1. Get an arduino rs232 shield. (You may need a femaie-female gender changer adapter)
2. You can get a pre-made adapter. Easiest.
3. You can get a dip Integrated circuit (aka IC). (Make sure to get some 1uF or 10uF capacitors while you are at it)
4. You can make one from discrete electronic parts you might have laying around.

Notice: Use any electronic circuit at your own risk.  I will not be responsible for any or all issues. Get a professional to help if you are unsure.

Step 5: Cdrom header cable.

To adapt the header on the rs232-ttl interface you will probably need cdrom cable end (wires and header) to connect to the Arduino. Like to use cable where all the wires are not bundled up. Otherwise you will have to strip com insulation back to have enough length to connect to the Arduino. IF the cable has headers on both ends, there is usually a metal tab that will release the wires from the header without having to cut the header off. 

Step 6: Upload the code.

Enter the code into the arduino ide and then run it with the pda attached!. Note: You may want to remove the back light commands if your pda does not support them. You should be able to easily cut and paste into the Arduino IDE.

Minimal code:

[code]

void setup()
{
  Serial.begin(9600);
}

void loop()
{  
  Serial.print("It's working! ");
  Serial.print("\n");
  delay(1000);
}

[/code]
or this should work as well

[code]
/*
 * Hello World!
 *
 * This is the Hello World! for Arduino. 
 * It shows how to send data to the computer
 */


void setup()                    // run once, when the sketch starts
{
  Serial.begin(9600);           // set up Serial library at 9600 bps
}

void loop()                       // run over and over again
{
  Serial.println("Hello world!");  // prints hello with ending line break
  delay(1000);
}


[/code]

Step 7: Connect it all.

Remove the programmer and then hook it all up. (Be sure the Arduino has it's own power source.). You should see results immediately.

Pda and serial cable >> gender changer if needed >> rs232tottl adapter >> cdrom audio cable >> correct points on the Arduino. (rx, tx, +5, and ground.)


Note: if your pda has a db25 rs232 end, you will need to get an rs232 db25 to db9 adapter.

Step 8: Not so cheap screen.

Build Your Own BARBOT using Arduino

0
Ever wanted a robotic liquor server?
I purchased a Lynxmotion robotic arm last year and an Arduino (deci) to play around with. I had it serial controlled with a joystick and it was a great way to start in robotics. More recently I wanted to take on another micro-controller related project for a university science fair. Since it was going to be hosted at the on-campus pub, I thought it would be fitting to build a robot that would dispense alcohol into shot glasses.
Build Your Own BARBOT Arduino
I hope this instructable is easy to understand and I will try to include as much detail as possible so that anyone could make one for under 200 dollars. Please vote and comment on this instructable. It is my first one and I hope to make even better ones in the future.
DISCLAIMER: It is a experimental project and will require some basic electronic skills such as soldering and AVR programming. Modifications may cause damage to your micro controllers if you are not careful (since you are working with liquids). I DO NOT claim any responsible for such misfortunes. As well, this project is not fully documented as I was tight on time completing it, therefore more detail may be added as time goes on. If you have any question, please ask and I will be happy to help.
PS. During the build I discovered that there is competition and audience for this kind of robotics and to my surprise it is under the same name “BarBot” (link: robogames.net/barbot.php). I hope no one is angry that I used the same name. I do wish I could attend Robogames though.

Step 1: From Concept to Reality

My first step was to consider my available resources. I had 5 servos, a 14″ by 14″ piece of 1/4″ polycarbonate, the Arduino, and a few servo brackets from Lynxmotion. (Purchase from www.robotshop.ca/)
Then I considered the features required:
Liquor Reservoir (I wanted at least 3 containers of minimum 500ml each in volume)
Tray for the shot glasses (I wanted at up to 4 shots to be served at once)
Human Interface (Controls for the selection of type of liquor to be intuitive)
Liquor Selector (A mechanism that chooses the selected type of liquor to dispense)
Dispensing volume controller (A mechanism that allows the control of volume of liquid per shot)
Initially, the idea was to directly use the robotic arm and attach a liquor dispensing mechanism to it, but this proved to be difficult due to a number of factors. First, I did not have proper sized valves so it was difficult to figure out how to transport the liquid to the dispenser on the arm without interruption. Second, I had 1/4″ tubing (sourced locally at a hardware store) but it was not the silicone type and therefore not very flexible (too much torque will be required for the servo).

Major Components in Project

The tray arm is made from:
1 x Lynxmotion “L” Connector Bracket
(www.robotshop.ca/lynxmotion-connector-bracket-asb-06b-3.html)
1 x Lynxmotion Long “C” Servo Bracket
(www.robotshop.ca/aluminum-long-c-servo-bracket-asb-05-3.html)
1 x Lynxmotion Multi-purpose Servo Bracket
(www.robotshop.ca/lynxmotion-aluminum-multi-purpose-servo-3.html)
1 x Hitec HS-645MG Servo, although a cheaper HS-422 would do as well.
(www.robotshop.ca/hitec-hs422-servo-motor.html)
4 x Small Snap-action switches with levers. There are great inexpensive contact sensors I got from All Electronics, a great online store
(www.allelectronics.com/make-a-store/item/SMS-242/SMALL-SNAP-ACTION-SWITCH-W/-LEVER/1.html)
1 ft of Multi-wired cord (8 strands needed) I got this great 10-strand cable that is useful for situation such as this.
(www.allelectronics.com/make-a-store/item/10CS22/10-CONDUCTOR-SHIELDED-CABLE-W/-DRAIN/-/1.html)
The next idea was to have the dispenser be stationary and have the tray with the glasses move under it. This had a few advantages: no need for a mechanical liquor sector as the tray could just move under the selected liquor container, and less torque would be needed for the main servo since the tray is horizontal and weight of the glasses (acting vertically) could be supported through structure.
The images below highlight some of the ideas, with them evolving to the final sketch at the end. Funny thing is I know AutoCAD and SolidWorks, but prefers to draw them because I get most of my ideas right before I go to bed (I have pen and paper prepared under the bed just for that :P).

Step 2: Building the Supporting Structure.

I had a piece of polycarbonate left over from an underwater camera case I built last year. Originally it was destined for a computer case mod that I started but never finished. I felt bad for it as it was just sitting there waiting to be useful. It was a 14″ by 14″ square, so just over a square foot. Unfortunately it is also the only material for this project that I do not know where a good and well-priced source could be found. I hope avid readers of this instructable could provide their insight on this matter (so I could update this).
Own BARBOT
I am a fan of circles, and since the tray would be traveling in an arc, I decided to build the base based on circles (its a pun, I love puns). The main dimensions are based on the material constraints, so its pretty easy to see the general size of the whole structure by looking at the image below. However, the dimension are also based on the size of the shot glasses I used as well as the size of the Lynxmotion servo bracket (I wanted the tray to have the same curvature as the base so it looks like two intersecting half-circles).
I found that the easier way to prototype for structures like this is to build a 1:1 scale out of cardboard (this was faster for me than CAD and can provide similar insight on whether your designs will be feasible. Attached are pictures of the frame built with cardboard.

Arduino Thermometer,7-Segment

Arduino Thermometer(7-Segment)

Using a dual 7-segment display, a DS18B20 temperature sensor and a couple of shift registers I figured that I could build a digital thermometer.

 

Step 1: Temperature Sensor

The sensor I'm using is the DS18B20, it's a 3pin sensor that just requires a single input pin from the arduino. Multiple sensors can be hooked together, however I'm just using one for this project. As with a lot of different sensors there's a handy library that makes it particularly easy to get the temperature in centigrade or fahrenheit, it's the Dallas_Temperature library available here and a spec sheet for the sensor available from maxim.

To connect it to the arduino connect the ground pin on the sensor to a ground pin on the arduino, put a 4.7k resistor between pin 2 and pin 3 on the sensor, connect pin 3 to 3.3v from the arduino and then connect pin 2 to digital input on the arduino. Once this is done, we're ready to read the temperature!

Step 2: Controlling the Display

I chose to use a dual 7-segment , it didn't take long to figure out the pin outs, however an issue was the number of pins this would require from the arduino if I hooked it up directly, a massive 16. With two shift registers hooked up together this could reduce the number of pins required to only 3, as the two shift registers require on

Arduino Step Sequencer

I was wondering about on making a sequencer, a big 16 step sequencer was what I wanted to make. To it's full extension with lots of features including single leds for each step, midi input and output, etc. Then I realised that I should start from a more basic model and then maybe tweak around to see what I can do. So while surfing the web and between other small sequencer projects I found this arduino sequencer, named "arduino punk console" after the simple tone output device from the 555 (atari punk console) and using the arduino as the tone generator.
So here goes a simple project which can later be modified and used in different projects, check last step for more detail on stuff to do with this sequencer.
Schematic, code and original idea is from Beavis Audio, everything can be found at there website:
www.beavisaudio.com

Here is a little preview video I made: