Forum Index > Projects > LED Pegboard and Matrix Projects
 Real time serial communication with Peggy 2?
 |  Printable Version
By: Anonymous: voxel () on Monday, May 26 2008 @ 03:08 PM PDT (Read 15298 times)  
Anonymous: voxel

Hello,
First off I'd like to say great work on the Peggy 1 & 2! I've been experimenting with the MAX7219 and an Arduino and have been looking at somehow designing a modular panel design similar to the Peggy with limited success as I am mostly a beginner in the hardware end of things. The Peggy has some really cool features and I'm seriously considering buying a couple! I had a few questions though...

Firstly, with the Arduino I have been able to implement a real-time serial communication with a MAX7219 and a 8x8 LED matrix to interact with mouse movement, audio levels, etc. What are the limitations, if any, on the animation capabilities of the Peggy2? Seeing as though the Peggy2 is running the same ATMega168, would it be possible to set up a serial connection to perform real-time animation?

Also, does the Peggy 2 feature per-LED brightness?

Thanks in advance!





       
   
By: Anonymous: voxel () on Monday, May 26 2008 @ 03:10 PM PDT  
Anonymous: voxel

One other thing I forgot to ask also is would it be possible to trim the top edge of the board to place multiple Peggy 2's side-by-side as well as top-to-top?





       
   
By: Windell (offline) on Monday, May 26 2008 @ 07:12 PM PDT  
Windell

with the Arduino I have been able to implement a real-time serial communication with a MAX7219 and a 8x8 LED matrix to interact with mouse movement, audio levels, etc. What are the limitations, if any, on the animation capabilities of the Peggy2? Seeing as though the Peggy2 is running the same ATMega168, would it be possible to set up a serial connection to perform real-time animation?

One of the things that you should keep in mind is that 25x25 is a lot bigger than 8x8-- almost ten times as many LEDs. The primarly limitation is on available RAM. Only a few frame buffers will fit in RAM at a time-- we haven't really explored enough yet to give hard numbers on that. (We can probably be much more efficient.) You can also leverage the available flash space to store a number of frames of animation and quickly switch between them.

As far as streaming data over the serial port, I have done most of that already as a proof of principle-- if you actually had some determination to get it done, I'm sure that you wouldn't have any trouble. What you need to do is add a software serial port (i.e., a six pin header plus four little wires) in the prototyping area, and download a software serial library (AF_SoftSerial library from http://www.ladyada.net/make/eshield/download.html ). Then, you can use a USB-TTL cable to communicate with the Peggy2 in "real time," which actually can take a few seconds for a large amount of data. This is reasonably straightforward-- I was already able to take my picture on a webcam (in Processing) and display that to the Peggy.

You can actually see my "hacked in" extra serial port in the lower-left corner of this picture:
http://www.flickr.com/photos/oskay/2472727681/in/pool-evilmadscientist/

Also, does the Peggy 2 feature per-LED brightness?

You can use multiple frame buffers buffers (as we have in our example code) to either create sequential frames or to display multiple levels of grey by refreshing them quickly. We think that 8 levels of grey works pretty well with a decent refresh rate.

One other thing I forgot to ask also is would it be possible to trim the top edge of the board to place multiple Peggy 2's side-by-side as well as top-to-top?

Yes, you can do it on your own, if you are careful. There are no traces on the top past the reach of the LEDs-- just "empty" border with holes to mount and/or hang the display.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Anonymous: voxel () on Tuesday, May 27 2008 @ 05:11 PM PDT  
Anonymous: voxel

Thanks for the quick reply Windell!

One of the things that you should keep in mind is that 25x25 is a lot bigger than 8x8-- almost ten times as many LEDs. The primarly limitation is on available RAM. Only a few frame buffers will fit in RAM at a time


Yeah, I would have to send approximately 100 bytes / frame (plus a few bytes of overhead info) and to get ~30fps, a baud rate of about 28800bps (or higher) would have to be maintained. I know the hardware serial hardware of the Arduino can handle this baud rate, and it looks like the AF_SoftSerial library can handle up to 57600bps, but would that be too much overhead for the processor?

Would it be at all beneficial to somehow "hack in" the Arduino as the main CPU? Or would it be easier/less hassle to set up an extra serial port to use for software serial?

One other thing I forgot to ask also is would it be possible to trim the top edge of the board to place multiple Peggy 2's side-by-side as well as top-to-top?


Yes, you can do it on your own, if you are careful. There are no traces on the top past the reach of the LEDs-- just "empty" border with holes to mount and/or hang the display.


Is there room (would it be safe) to drill small mounting holes between the LED sockets? (I'll most likely be using 5mm LEDs)

Thanks!





       
   
By: Windell (offline) on Tuesday, May 27 2008 @ 05:22 PM PDT  
Windell

...but would that be too much overhead for the processor?

I really don't know. The software serial does have significant overhead that steals time away from the display. If you need that kind of data rate, there are probably better ways to do this. Feeding the data one byte at a time via TWI from a separate Arduino is probably a good solution, for example. Then again, the Peggy itself could be modded to free up the hardware serial port, which would also be fast enough without overhead.

Would it be at all beneficial to somehow "hack in" the Arduino as the main CPU?

This doesn't make much sense to me-- the CPU on the peggy is already the same as that on an Arduino; there will be challenges and no benefits.

Is there room (would it be safe) to drill small mounting holes between the LED sockets? (I'll most likely be using 5mm LEDs)

Nope. Can't do that. But you *can* mount the LEDs exactly between the holes instead of on the grid; see the instructions for how to do that.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Anonymous: yincrash () on Tuesday, May 27 2008 @ 08:49 PM PDT  
Anonymous: yincrash

I'm also interested in putting in the serial ttl port.

Looking at the flickr photo, you ground the top pin and the bottom pin (let's call them 1 and 6) then just hook pin 4 to PB4 and pin 5 to PB2.

In the AFSoftSerial library, you just tell it to use those pins as RX and TX respectively?





       
   
By: Windell (offline) on Tuesday, May 27 2008 @ 09:49 PM PDT  
Windell

Looking at the flickr photo, you ground the top pin and the bottom pin (let's call them 1 and 6) then just hook pin 4 to PB4 and pin 5 to PB2.

In the AFSoftSerial library, you just tell it to use those pins as RX and TX respectively?


Let's hear it for high-res photos! The command to use is this:

AFSoftSerial mySerial = AFSoftSerial(12, 10); //Rx pin (PB4), TX pin (PB2)


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Anonymous: voxel () on Wednesday, May 28 2008 @ 05:56 AM PDT  
Anonymous: voxel

Nope. Can't do that. But you *can* mount the LEDs exactly between the holes instead of on the grid; see the instructions for how to do that.


I realized my original question was a little ambiguous. Just in case, I was asking about drilling small mounting holes between the LED sockets to be able to put screws through for mounting (if I removed the top portion to allow top-to-top (as well as side-by-side) placement of the Peggy panels.

Feeding the data one byte at a time via TWI from a separate Arduino is probably a good solution, for example. Then again, the Peggy itself could be modded to free up the hardware serial port, which would also be fast enough without overhead.


I'm not familiar with TWI (or I2C, which wikipedia says TWI is a derivative of) but I assume it would be similar to a 3-wire connection (which is what I've been using to experiment with my little MAX7219 setup). But I'll have to look into it if I decide to go that route.

This doesn't make much sense to me-- the CPU on the peggy is already the same as that on an Arduino; there will be challenges and no benefits.


I guess the 'benefit' that I was thinking of was having the hardware serial on the Arduino there to use. But if its not too complicated to add hardware serial to the ATMega168 on the Peggy (as mentioned above), then that would be a nice solution. Would that require that FTDI chip that is present on the Arduino?

I'm still pretty new to the 'hardware hacking' scene... But I'm very interested in learning and grateful for the help!
- John





       
   
By: Anonymous: voxel () on Wednesday, May 28 2008 @ 06:14 AM PDT  
Anonymous: voxel

Oh and I meant to mention an idea I had... (On a side note, I can't seem to find a registration for the forums anywhere??)
Probably too difficult/risky to do with Peggy 1 or 2, but possibly a v3 release or something. To make the display truly modular (for large displays) would it be possible to have the lower circuitry either on the back of the board (I realize this might get really cramped.. if not impossible) or maybe 'piggy-backing' (no pun intended) as a separate board behind the matrix panel?
Just a thought, as this was the approach I was trying for with my 8x8 LED panels, but in a way you've totally circumvented this by just making the panels 25x25 Smile





       
   
By: Windell (offline) on Wednesday, May 28 2008 @ 08:31 AM PDT  
Windell

I realized my original question was a little ambiguous. Just in case, I was asking about drilling small mounting holes between the LED sockets to be able to put screws through for mounting (if I removed the top portion to allow top-to-top (as well as side-by-side) placement of the Peggy panels.

If it's just a couple of holes, maybe. I'd look at the PCB files to see if there are any clear spaces that you might exploit.

I'm not familiar with TWI (or I2C, which wikipedia says TWI is a derivative of) but I assume it would be similar to a 3-wire connection (which is what I've been using to experiment with my little MAX7219 setup). But I'll have to look into it if I decide to go that route.

Yes, another simple serial protocol; happens to be on pins PC4 & PC5. The Arduino "Wire" library is for using TWI.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Windell (offline) on Wednesday, May 28 2008 @ 10:45 AM PDT  
Windell

Okay, my turn to do a multi-post post. Exclaimation

I guess the 'benefit' that I was thinking of was having the hardware serial on the Arduino there to use. But if its not too complicated to add hardware serial to the ATMega168 on the Peggy (as mentioned above), then that would be a nice solution. Would that require that FTDI chip that is present on the Arduino?

Okay... The ATMega168 on board *already* has a hardware serial port. When you hook up the USB-TTL cable, you are using this for input. However, we are reusing those two pins as part of the set of output pins that controls the LED matrix. So those two pins cannot be (normally) be used for serial communication at the same time that we're driving the LED array. (If and when there is a new version of the Peggy, this would be one of the things that I'd change. That could still be quite a while off.) You *could* rewire the lines that go to the two demultiplexer chips to work around this (and make corresponding software changes) but I suspect that this is not a very practical workaround for most people. So, the software serial works okay for low data rate communication (not 30 FPS, I'm thinking!), and TWI might work okay for faster communication. It's also possible that the SPI could be used as an input, but I'm not quite sure if or how that would work.

Would that require that FTDI chip that is present on the Arduino?

We are using the FTDI USB-TTL cable, which has the chip built in. This is an alternative to building in a chip on the board that lets you reuse the cable (and chip) in other places.

On a side note, I can't seem to find a registration for the forums anywhere??

Left-hand column, where it says "User Functions."

To make the display truly modular (for large displays) would it be possible to have the lower circuitry either on the back of the board (I realize this might get really cramped.. if not impossible) or maybe 'piggy-backing' (no pun intended) as a separate board behind the matrix panel?

Yes, we've thought of that as well. The Modern Device 8x8 uses through hole from both sides in their display and... we would rather not play that exact game. We could also add a piggyback board, but it adds more cost than you might think. (And it has the usual "mod problem": adds significant cost but does not add significant value for most users.) The other thing is this: I assert that nobody needs Peggy to tile better. 625 LEDs is already a lot to solder. (I *do* speak from experience!) Do you really want to solder two sets of 625 LEDs and put them side by side? If so, great! Peggy 2.0 tiles left-right just fine. But you want to do FOUR sets of 625 LEDs and put them edge by edge? Okay, you can trim off the top edges and do that too. You want to do SIX panels, you crazy person? Go right ahead: 2x3 is fine, trim 6 top edges and use the side by sides. So, we don't even run into a problem until you want to scale up to a 3x3 matrix-- 5625 LEDs to solder and several thousand dollars invested. At this point, controlling that mega matrix gets to be a little bit challenging, and you can probably find some lower alternatives where the assembly time does not become quite so infinite. On the other hand, we do have a few ideas for possible future projects that *might* make more sense to tile... but that's still a ways off. Wink


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: voxel (offline) on Thursday, May 29 2008 @ 10:46 AM PDT  
voxel

Yes, we've thought of that as well. The Modern Device 8x8 uses through hole from both sides in their display


Yeah, I had looked a the the Modern Device 8x8 kit before I discovered the Peggy2 but I think the cost of the Peggy2 is more cost-effective (and has closer/nicer led spacing). I briefly looked into getting some custom PCBs made, and in smaller 'personal' quantities they are quite expensive, so yeah I could see how a piggyback board would add significant cost without much benefit.
Also, I think my obsession with tiling is coming from my original idea to have my project being quite large (like large poster size, but with ~1000 leds) but I think the higher resolution on a smaller scale will ultimately look better.

We are using the FTDI USB-TTL cable, which has the chip built in. This is an alternative to building in a chip on the board that lets you reuse the cable (and chip) in other places.


Oh Okay! I did not realize that cable had the chip built in. So armed with this cable, some rewiring and software changes I could add full hardware serial to the ATMega168 on the Peggy2... Right? I think the hardware serial would be best because I'm considering putting two side-by-side and having them animate with real-time serial input from a PC.

Also, what are the specifications of the 'Optional AC Adapter' ? What might be a good single-power-adapter solution if I wanted to use two Peggy2's beside eachother?
Thanks!


Forum Apprentice
Apprentice

Status: offline

Registered: 05/28/08
Posts: 8

Profile Email    
   
By: Windell (offline) on Thursday, May 29 2008 @ 01:34 PM PDT  
Windell

So armed with this cable, some rewiring and software changes I could add full hardware serial to the ATMega168 on the Peggy2... Right?

Basically yes. (But note that we already support full hardware serial via USB with that cable and no other changes (for programming)-- we just don't support doing that at the same time as driving the LED matrix. As far as I'm concerned, this mod is borderline for too much work for the return.

I think the hardware serial would be best because I'm considering putting two side-by-side and having them animate with real-time serial input from a PC.

I disagree. Using the I2C (aka "TWI" or "wire"Wink interface is a better idea because they can be both addressed on the same bus, where each Peggy knows its own hardware address. With regular serial, you would need a separate serial port for each Peggy you want to talk to.

Also, what are the specifications of the 'Optional AC Adapter' ? What might be a good single-power-adapter solution if I wanted to use two Peggy2's beside eachother?

4.5 or 5 V regulated, with 600 mA+ capacity. You could split a single 5 V 1 A power supply between two.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: voxel (offline) on Thursday, May 29 2008 @ 04:19 PM PDT  
voxel

note that we already support full hardware serial via USB with that cable and no other changes (for programming)-- we just don't support doing that at the same time as driving the LED matrix.


What exactly do you mean by 'at the same time' ? Would it be possible to use the already-present hardware serial via USB for both programming and serial communication as is the case on the Arduino? (everything over same cable)

Using the I2C (aka "TWI" or "wire"Wink interface is a better idea because they can be both addressed on the same bus


Ah yes, that would be much better. Like I said, I'm not very familiar with I2C, but that sounds like it would work nicely. How would I go about implementing an I2C connection from my PC to the Peggy? Would I be able to do it using the TTL USB cable?

Thanks!


Forum Apprentice
Apprentice

Status: offline

Registered: 05/28/08
Posts: 8

Profile Email    
   
By: Windell (offline) on Friday, May 30 2008 @ 02:18 AM PDT  
Windell

What exactly do you mean by 'at the same time' ? Would it be possible to use the already-present hardware serial via USB for both programming and serial communication as is the case on the Arduino? (everything over same cable)

The basic idea is this: You hook up the USB-TTL cable and program the Peggy with the Arduino software. When the upload completes, the Peggy runs the program, for as long as you leave it powered on. You don't have to unplug the USB-TTL cable, it just works. When you want to change the program, you just upload a new one. (Unplug the USB-TTL cable when you feel like it.) Now, what does Peggy do when it runs a program? There are a lot of different things that it could do. One is to configure its PORTD pins to use the serial port and talk to another computer. Another is that it could configure the PORTD pins to drive the LED matrix. You get to choose. It can do one after another-- it could periodically pause the LED display-- potentially for a very short time-- and retrieve new data to display. The only time that you run into conflict is if you need to run the display at the same moment as using the *hardware* serial port. Again, I2C may be the way to go.

Ah yes, that would be much better. Like I said, I'm not very familiar with I2C, but that sounds like it would work nicely. How would I go about implementing an I2C connection from my PC to the Peggy? Would I be able to do it using the TTL USB cable?

You could still use the USB-TTL cable to do the programming, but you would need to generate the I2C signal from another source. Here are some ways to do it. Using a USB-equipped Arduino (or a BBB with the USB-TTL) may be one of the best USB-I2C adapters available, with the right program added, of course.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   



 All times are PDT. The time is now 08:44 PM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

Evil Mad Scientist Forum Archives — Read only!

Please visit our new forums for new discussions.


DIY Hardware for Electronic Art


The Original Egg-Bot Kit


Octolively
Interactive LED kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

My Account






Lost your password?