Datalogging (5Hz) + displaying on 18 4digits 7-segments displays

Hi guys,

In my everlasting datalogging & arduino learning project, I now want to display the logged values to some 7-digit displays.

The heart of the system would be an arduino MEGA acquiring some analog signals through it's internal ADC + some other digital values through a MUX/ADC shield + frequency counting a TTL signal (up to 3kHz).

Now, in between acquiring and logging/sending the values to serial, I'd like to display them on 4-digits 7-segment displays and maybe a 16x2 LCD.

So to sum it up :

[u]Acquisition (5Hz max) :[/u] - 8 analog values - 8 digital values (through a thermocouple shield) - 3 frequency counters (1 up to 50Hz, 1 up to 100Hz, 1 up to 3kHz)

[u]Displaying :[/u] - (19x) 4-digits 7-segments displays - 16*2 LCD display

Now, I guess I'd need some displays with a serial backpack or something to that effect. I'm still learning so forgive the approximations...

Now, I tried with success a simple 16*2 LCD and the library is very simple to use. I'm guessing there are some equivalent libraries to control several 7-segments displays on the same line or so but wouldn't 19 displays and possibly an LCD be too much for the MEGA to compute? I know libraries can be sometimes a bit heavy to process but I definitely don't have the skills (for now!) to go deeper and code it myself...

Do you think a MEGA would have the firepower to do it all at the same time?

Have you got any suggestions on what HW / SW to use?

Thanks for the help!

Marc

This sounds rather like a dog-chasing-car situation...

The Mega's firepower may be an issue, but you might consider your own firepower first, and how good you are going to be at reading 95 4-digit numbers every second.

Hi Nick,

Indeed, that's a lot for one man but in this case it's mostly meant to be a "public" display, not a control mean for a single person.

Marc

marc426: in this case it's mostly meant to be a "public" display, not a control mean for a single person.

I think the same applies. Perhaps a graphic, rather than numeric, display would be more appropriate.....

Can send the data to MAX7219s to display on 5V, 7-segment displays.
Each can control 8 digits, so daisy chain 9 of them for 18 4-digit displays.
Can send data out really quick with SPI, need to send an address and then data.

Or send the data to 72 shift registers (non-multiplexed), can do that at 8 MHz speed in about 75uS.

MAX7219-MAX7221.pdf (451 KB)

Ok, I have to look into the MAX7219.

Is there a way that I could calculate how much time it'd take to send the necessary data to 9 of them?

Thanks,

Marc

Lets say you had 9 chipselect lines, one for each device to make the programming simpler:
Further lets say port D bits 2-3-4-5-6-7 and port B bits 0-1-2 were used for chip select.
Further lets say the 72 bytes for the digits were in an array.

Then you could have 9 loops like this to send the data out, using SPI at 8 MHz.

for (x=1; x<9; x=x+1){  
PORTD = PORTD & 0b11111011; // clear CS  bit
SPI.transfer (x); // data register address, from 1 to 8
SPI.transfer (dataArray[x-1]); // data from arra
PORTD = PORTD | 0b00000100; // set CS bit
}
// an repeat for the other devices
for (x=1; x<9; x=x+1){  
PORTD = PORTD & 0b11110111; // clear CS  bit
SPI.transfer (x); // data register address, from 1 to 8
SPI.transfer (dataArray[8+(x-1)]); // data from array
PORTD = PORTD | 0b00001000; // set CS bit
}
for (x=1; x<9; x=x+1){  
PORTD = PORTD & 0b11101111; // clear CS  bit
SPI.transfer (x); // data register address, from 1 to 8
SPI.transfer (dataArray[16+(x-1)]); // data from arra
PORTD = PORTD | 0b00001000; // set CS bit
}
for (x=1; x<9; x=x+1){  
PORTD = PORTD & 0b11011111; // clear CS  bit
SPI.transfer (x); // data register address, from 1 to 8
SPI.transfer (dataArray[24+(x-1)]); // data from arra
PORTD = PORTD | 0b00010000; // set CS bit
}
// etc, working thru the rest of PORT and then into PORTB

Now you have 9 loops, each loop executes 8 times taking about 40 clock cycles each for the port writes and SPI transfers, so 2880 clocks total, about 180uS (0.18mS).
Each execution of a for loop takes about 12uS, there are 72 passes, so add another 864uS.

The SPI.transfers can be replaced with
SPDR = dataArray[24+(x-1)];nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
(maybe 1 more nop?)
to go the fastest, just over 1uS/byte (17 clocks).
If you dropped all the for loops, and inlined the whole thing, that’d be the fastest:
(72 x 2) * 17 clocks for data + (72 x 2) x 2 clocks for the port writes * 1/16000000 = 171uS.
Maybe 189uS if the port writes takes 4 clocks.
Really have to code it & test with a logic analyzer or a scope to measure it, don’t even need the harware.
Running on a Mega, you’d have plenty of memory to do that.