Arduino hangs if more than 4x DMDs declared

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
User avatar
stryker
Posts: 255
Joined: Sat Jan 14, 2012 2:44 pm

Arduino hangs if more than 4x DMDs declared

Post by stryker » Sat Jul 06, 2013 2:54 pm

Hi

I've been chasing this issue now for about 3 weeks. Our project will use 6 DMDs, arrayed 3 wide and 2 tall. I hit an issue where the sketch hangs in setup() if I declare

Code: Select all

DMD dmd(3,2); 
but it continues on fine if I use any combination of dimensions that arrive at 4 or fewer. I first thought I was out of RAM on the ATmega328 so rewrote the code to put literals into progmem, and commented out big chunks of the code. I added a heap of debugging print()s to show the available bytes of RAM at each step and after a short time ended up with a spreadsheet tracking how much RAM I had free, and calculated that for every additional DMD in that declaration, 64 bytes was consumed (2x2, 4x1 & 1x4 reported the same memory use).

Regardless, presuming it was RAM that's the killer difference between a 4 and 5 or 6 DMD in code, I needed to free up 128bytes...and now with 3x2 declared I have far more available RAM than when it originally had with 2x2 and it still doesn't work.

Then I uploaded the sketch to the ATmega with a ISP programmer and freed up another 500bytes or so more, and it still hangs in the same place so I'm convinced now it's not RAM.

Is there something fundamental that changes at the 4 DMD threshold? The line which it appears to hangs on is the Timer1.attachInterrupt. Commenting that out makes the sketch execute just as surely as declaring dmd(2,2), though that could be a red herring of course.

Other hardware in this project includes two MCP23008 I2C IO expanders, a DS1307 RTC, and 20x4 I2C LCD as well as a 1-wire DS18B20 thermometer. If it's not RAM, where else should I be looking for the culprit here?

Thanks!
Geoff

Aussie_Wombat
Posts: 51
Joined: Tue May 22, 2012 12:52 pm
Location: Adelaide, South Australia

Re: Arduino hangs if more than 4x DMDs declared

Post by Aussie_Wombat » Sun Jul 07, 2013 6:56 am

Hi Stryker, I found a similar issue, some time ago, in this viewtopic.php?f=26&t=3639 thread. The panels were drawing very slowly. 1 pixel per second. I never really resolved it, and just went on with my pic32 variant( works with 4x3 ) 12 panels..and I hope my (7x3) 21 panel version.

Regards Dennis
[edit]

If You set the panels to 2x2 , but leave the othres attached, do you still get output, at the normal speed.?

[/edit]

User avatar
stryker
Posts: 255
Joined: Sat Jan 14, 2012 2:44 pm

Re: Arduino hangs if more than 4x DMDs declared

Post by stryker » Sun Jul 07, 2013 7:52 am

Hi Dennis,

I've got the 6 DMDs but until now have been writing the code with just one connected for testing. I haven't actually chained them all up yet so can't comment. Did you have any joy with slowing the refresh as per the response you received?

I wonder if it is a race condition where it never gets out of the DMD refresh cycle before it has to start it again? I'll try something down that path later tonight and report back.

Cheers ! Geoff

User avatar
stryker
Posts: 255
Joined: Sat Jan 14, 2012 2:44 pm

Re: Arduino hangs if more than 4x DMDs declared

Post by stryker » Sun Jul 07, 2013 9:55 am

Oh my. Setting the interrupt to 7ms the code gets through setup() with a 3x2 DMD array declared

Code: Select all

  Timer1.initialize(7000); 
Dennis I really wish I'd contacted you sooner! Looks like the race condition suggestion could have been on the money. Hopefully the 'flicker' mentioned for refresh longer than 5ms isn't too bad. Any idea what the default refresh rate is on the PIC in contrast?

Will post again once we have the 6x DMDs in a frame and can see what the result is.
Geoff

Aussie_Wombat
Posts: 51
Joined: Tue May 22, 2012 12:52 pm
Location: Adelaide, South Australia

Re: Arduino hangs if more than 4x DMDs declared

Post by Aussie_Wombat » Mon Jul 08, 2013 8:03 am

Hi Geoff,

I found that if I had all 9 panels connected, and only told the arduino there was 3x1 then all of the panels worked, but obviously the last 6 were just out of sync with the first 3.

I was working on two controllers at the same time. The Arduino, and a Maximite Monochrome(pic32) . I just picked the one that worked for the number of panels I wanted to use. I timed the routine I added to the MMBasic source code, and it was just under a millisecond for one panel, and rose to 1,5 millisecond for 6 panels. So I assume I can still use the 5 ms refresh rate for the 21 panels .

I have successfully connected a Maximite to a Blutooth device, over a serial connection, Then used an android phone app to send text data to the dmd display to be output, via bluetooth...

regards Dennis.

TheRevva

Re: Arduino hangs if more than 4x DMDs declared

Post by TheRevva » Sun Oct 06, 2013 11:00 pm

Hi guys'n'gals,

Please excuse me 'butting in' to your topic, it's just that I _might_ have an explanation for you.
Looking through the default code in the library, it APPEARS to be setting the SPI clock to a rather s-l-o-w frequency. (The associated comment in the code states that it's set to 2MHz, but the actual code uses the divide-by-128 mode).
Assuming your AVR clock is 16MHz (We all HATE assumptions!), and assuming that you leave the default divisor as 128, then your SPI clock is ACTUALLY only running @ 125KHz!!!
With one quarter of the display being refreshed every time the TimerOne tick occurs, it means that there are 512 / 4 (128 pixels) * number of chained panels shifted out over the SPI bus on every tick.

Well.... This is all fine until your try to chain in the FIFTH (or more) module.
The SPI bus needs to send out 1/4 of the pixels every time TimerOne does a tick. With five panels, that equates to 512 / 4 * 5 pixels which is 640 pixels. Since the SPI bus is clocked at 125kHz (8uS period), this will take around 5120uS (5.120mS) let alone the extra overhead in toggling the OE and LATCH pins. This is (obviously!) longer than the TimerOne tick, so as soon as the interrupt routine has finished doing it's 1/4 update and returns to the mainline, the NEXT time tick has already occurred. Therefore, there is precisely ZERO available CPU time to actually do anything useful (such as actually spending time to write a pixel into the display buffer).

A potential cure is strikingly simple. All you need to do is to increase the SPI clock frequency to a more 'suitable' value. I would suggest that changing SPI_CLOCK_DIV128 to SPI_CLOCK_DIV16 will be adequate for UP TO 32 daisy chained panels. (i.e. Bump it from 125kHz to 1MHz). Looking at the overall construction of the DMD panel I would GUESS that it could probably still work with an even faster clock, but keeping it lower will help to limit a bit of generated RFI. (I'd recommend AGAINST turning on the DMD anywhere close to a radio aerial as I suspect it would positively SWAMP any radio signals with the harmonics!)
(Although you COULD use that generated RFI to 'play a tune' on your radio... LOL The AM band would probably give the best results...)

User avatar
stryker
Posts: 255
Joined: Sat Jan 14, 2012 2:44 pm

Re: Arduino hangs if more than 4x DMDs declared

Post by stryker » Mon Oct 07, 2013 1:39 am

Thanks that's a very nice find. We've just got our custom PCBs and the initial testing with 6 displays visibly flashes so you might have helped shortcut that debugging process some! Not sure how long before we get back to this one but will report on results when we do.

Thanks again,
Geoff

clibin009
Posts: 329
Joined: Mon Oct 23, 2017 2:57 am

chenjinyan

Post by clibin009 » Fri Jan 12, 2018 3:01 am

mbt shoes
louboutin
ray ban wayfarer
canada goose outlet
ugg outlet
michael kors uk
moncler schweiz
nfl jerseys wholesale
ugg boots on sale
air max
polo shirts
coach outlet online
vibram five fingers
longchamp outlet
adidas football boots
ugg boots
coach outlet
michael kors outlet
swarovski
cheap nfl jerseys
michael kors handbags
nike outlet store
mont blanc
scarpe mbt
the north face
adidas wings
ugg outlet
michael kors outlet
uggs outlet
scarpe hogan
ugg boots
ugg boots
adidas jeremy scott
cheap mlb jerseys
nike sb
nhl jerseys
cheap ray bans
michael kors outlet clearance
cheap nhl jerseys
michael kors
tory burch
pandora rings
canada goose jackets
michael kors handbags
moncler
ugg clearance
giuseppe zanotti shoes
coach outlet online
cheap nfl jerseys
cheap rolex watches
kate spade
michael kors outlet
coach handbags
ugg boots
tory burch
jordans
louboutin
nike air force
jordans
michael kors handbags
nike air
balance shoes
salvatore ferragamo
air max
nike outlet
oakley sunglasses
north face
coach factory outlet online
fitflops
birkenstock
nike football boots
timberland outlet
ralph lauren
ugg australia
michael kors
ugg
nike tn
birkenstock outlet
coach outlet online
pandora charms
nike blazer
ralph lauren outlet
ray ban sunglasses
pandora jewelry
ralph lauren uk
coach factory outlet online
coach outlet online
pandora jewelry
fitflops outlet
ray ban sunglasses
the north face
jordan retro
coach outlet online
timberland boots
hermes
polo ralph lauren
moncler
ugg outlet
coach outlet online
nike free run
nike uk
stan smith shoes
ugg boots sale
pandora jewelry canada
birkenstock sandals
north face uk
burberry scarf
canada goose jackets
longchamp
pandora jewelry
louboutin
coach factory online
ralph lauren
canada goose
air max
polo ralph lauren outlet
michael kors outlet
true religion jeans
oakley sunglasses wholesale
ralph lauren
michael kors outlet online
ugg outlet
burberry outlet
uggs
adidas yeezy
tory burch outlet
ray ban
air jordan 14
supreme outlet
kate spade handbags
ugg boots
nike outlet
north face jackets
ray ban
ray ban
ralph lauren uk
michael kors outlet
longchamp
louboutin
supreme uk
mont blanc pens
true religion jeans
prada
beats by dre
cheap jordans
nike factory outlet
jordan
ugg canada
ugg boots
nike huarache shoes
moncler outlet
coach outlet online
north face outlet
burberry scarf
tommy hilfiger
jordans
ray ban
ugg outlet store
coach factory outlet
nba jerseys
north face
oakley sunglasses
michael kors outlet
nike store uk
oakley sunglasses
louboutin
true religion jeans
flops
cheap mlb jerseys
the north face
under armour outlet
canada goose outlet
michael kors taschen
canada goose outlet
nike air max
pandora charms
tory burch outlet
true religion jeans
coach outlet
christian louboutin
ray ban
ray ban
ugg
jordan shoes
nike air max
ugg outlet
ferragamo outlet
ugg pas cher
moncler pas cher
polo ralph lauren
air jordan
michaelkors outlet online
moncler
coach
basketball shoes
uggs
juicy couture outlet
canada goose jackets
canada goose jackets
pandora uk
mac cosmetics
kate spade
moncler
air jordan
jordans
snapbacks wholesale
hermes outlet
ray ban sunglasses
ralph lauren
canada goose sale
michael kors outlet
cheap ugg boots
cheap ugg boots
polo ralph
manolo blahnik shoes
polo ralph
canada goose jackets
coach handbags
adidas outlet store
moncler outlet
flops
north face outlet
ugg italia
ralph lauren uk
mlb jerseys
coach outlet
ugg boots
north face jackets clearance
ugg outlet
burberry outlet canada
uggs
flip flops
doudoune canada goose
ugg boots
uggs outlet
ugg
coach outlet online
polo ralph lauren
oakley sunglasses
ray ban sunglasses
adidas stan smith shoes
swarovski crystal
uggs outlet
air jordan
flip flops
north face jackets
michael kors outlet
jordan shoes
uggs outlet
nike air max
polo ralph
timberland pro
jordan
north face
uggs outlet
replica watches
ugg boots
longchamp outlet
jordan shoes
canada goose
hermes birkin bags
north face uk
polo ralph lauren
adidas superstar
canada goose
red bottom shoes
jordan shoes
pandora
mcm bags
nike factory outlet
adidas uk
ray ban sunglasses wholesale
ugg
canada goose outlet
adidas shoes
prada handbags
coach factory outlet
supra shoes
burberry outlet online
louboutin
moncler
baseball jerseys
michael kors outlet
kate spade
north face
air max
supreme
uggs outlet
oakley sunglasses
coach factory outlet
adidas outlet
cheap oakley sunglasses
oakley canada
michael kors handbags
ugg boots
mulberry handbags
north face
canada goose jackets
ugg boots
true religion
coach outlet
canada goose
ugg boots
michael kors outlet
north face outlet
coach factory outlet
louboutin
uggs outlet
christian louboutin
timberland boots
ugg
oakley sunglasses
ferragamo shoes
ugg boots
louboutin
prada
kate spade
moncler outlet
hermes uk
canada goose canada
the north face
nike outlet
timberland boots
north face
ugg canada
oakley vault
doudoune canada goose
ugg outlet
coach outlet
oakley sunglasses
cheap nfl jerseys
nfl jerseys wholesale
canada goose sale
moncler jackets
prada bags
moncler
jordan shoes
true religion jeans
moncler
soccer jerseys
canada goose jackets
blackhawks jersey
ray ban sunglasses
longchamp handbags
moncler
coach
moncler jackets
nike air huarache
ralph lauren
pandora jewelry canada
longchamp
mont blanc pens
superdry clothing
converse shoes
louboutin
jordan pas cher
ugg boots
kate spade outlet
canada goose
ugg boots
ralph lauren
cheap nfl jerseys
adidas shoes
20181.12chenjinyan

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests