November 27, 2012 at 9:17 pm #20134
I am using a Peggy 2 to drive individual LEDs for a Railroad Museum display.
I have cut the number of rows driven by the board to increase brightness in the leds.
Would like to add another Peggy 2 to increase the number of points illuminated. Doing this would include the requirement that the 2 boards communicate so each Peggy board could do part of a display and hand off the other part of it to the 2nd Peggy.
The current code (1 Peggy board) looks like this;
…code snipped from source file …
Where the coordinates are ‘defined’ in an include file, and the variable(s) dly2 are initialized early in the code.
I want to increase the overall size of the program to increase running time beyond the capacity of the on-board memory.
Can an EPROM, or equivilant device, be added to hold the additional commands?
Perhaps a serial feed from another m
November 27, 2012 at 9:19 pm #21012
- This topic was modified 3 years, 5 months ago by Windell Oskay.
I hate this keyboard!
Perhaps a serial feed from another microcontroller with the EPROM.
Any suggestions are appreciated.
cheersNovember 28, 2012 at 3:19 am #21013
First off, I’m not sure how much you need to expand, but you can actually get a fair number of extra LEDs with the hardware that you have. The Peggy 2 has 25 rows and columns on board, but the LED driver chips actually support 32 columns. The extra seven columns are broken out on the PCB as A0 – A6, by U5. So, if you have six rows, using these extra pins will get you 42 extra LEDs. The only downside is that you’ll have to modify the code to include those extra locations.It is not possible to expand the program memory of the AVR microcontroller directly. While I suspect that it’s possible to use the code more efficiently– I’ve almost never filled up the full 32 kB! — I’ll try to suggest a few workarounds.– Use a larger AVR, for example the ATmega1284, which has 128 kB of program memory. This could be used as the “brain” of the Peggy, with some code changes. You could also use it as a “master” that sends serial commands to the two Peggy units over TWI (I2C).– Use a larger-AVR-based Arduino board, such as the Arduino Mega with the ATmega2560 processor– which has 256 kB of program space.– Use an off-board Arduino, with an appropriate shield, to read commands from an SD card and transmit them to the Peggy board(s) over TWI.– Store the commands on the computer, and stream them to the Peggy board(s) through a serial or TWI interface.November 29, 2012 at 7:32 pm #21014
The idea of using a processor with additional memory is the easiest method, so far, to increase run time.
More Memory = More Run Time.
To illustrate how I am applying the Peggyboard I will give an overview in pseudo-code.
The code snippet, in the first post, is a true representation of the program structure. I am only using the following verbs; ~.SetPoint(), ~.ClearPoint(), and ~.RefreshAllFast(). Is there a better way to code this? The application is to recreate the appearance of the Railroad Track Layout Status Board for the Cincinnati Union Terminal Control Tower. Each led illuminates 1 indicator showing Track Occupancy or Signal indications. A sequence illustrates the movement of trains in the Terminal ‘Yard’
A typical sequence is:
Refresh(3 seconds) ;
Refresh(2 Sec) ;
Refresh(2 Sec) ;
Is there a better way to code this?
Can there be Functions, or Macros, for repetative code sequences?November 30, 2012 at 4:53 pm #21015
Yes, you can use functions to simplify the operation and reduce the code usage. You could even define each of the “tracks” as an array that specifies the location of each dot, and then use loops to say something like:For each light on track XYZ:Turn on lightrefresh 2 secondsclear lightlight++December 1, 2012 at 8:59 pm #21016
As you refer to functions, am I correct in hoping that the syntax would be something like:
CUT.HardwareInit(); // Call this to init the hardware.
CUT.Clear(); // Erase the entire frame buffer.
~.Refresh(3 sec) ;
~.Refresh(3 sec) ;
I have not tried it yet, nor have I found any evidence of this technique in the examples I have found.
It would be a Huge help if it works.
ThanksDecember 2, 2012 at 4:02 pm #21017
The Peggy 2 runs Arduino code, and there are a wealth of examples of how to create functions and other types of program features on the Arduino site:For the most part, we’d recommend using the Peggy 2 specific functions for I/O (rather than the individual pin commands from within Arduino), but for everything else, you can follow the guides to structuring your program, using arrays and variables, and so forth.
- You must be logged in to reply to this topic.