Pages: 1 [2]   Go Down
Author Topic: SPI: Writing 20 bits of data?  (Read 1773 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Im not sure if thats the right part of the forum.... so im sorry if its not smiley
Im biulding myself a VFD tube clock with 6 IV-6 tubes, and two really small ones for the dots.
Ive got the theory alv figured out, BUT I only have 2 max6921, so thats for driving 4 tubes right?
ive been thinking... can I multyplex those tubes? As together, Bs together, Cs together.... and only switching Grounds on and off, either with high transistors or spare outputs on 6921?

Am I thinking in a right direction. Is this even possible?

Thanks for ur answers in advance.

regards from Slovenia smiley
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 435
Posts: 23597
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

MAX6921 is 20 outputs, two are 40  outputs.
http://www.maximintegrated.com/solutions/led_vfd_drivers/parts.mvp/scpk/1336/pl_pk/0

tube datasheet
http://www.tube-tester.com/sites/nixie/dat_arch/IV-6.pdf

So you appear to need 7 segment drivers/tube
6 x 7 = 42m, so you're a couple short.

Do you need 6 full digits? Perhaps have the left-most digit just be 1 or Off, and only use 2 segments.
Then 5 digits * 7 + 2 segments = 37, and you can use 3 remaining for periods in between pairs of digits:
1H.MM.SS,

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 58
Posts: 3979
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You might try modifying a Soft SPI library if you need custom word length.

Logged

Examples can be found in your IDE.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16459
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I needed to shift out 25 bits of serial data to two 16 bit serial series connected shift registers wired to the SPI pins. I just would do the transaction as four consecutive 8 bit write operations and just let the first 7 bits sent fall out to the bit bucket of the far shift register.

Lefty

Logged

Worst state in America
Offline Offline
God Member
*****
Karma: 23
Posts: 663
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Make the delay(1) a delayMicroseconds(1)!  SPI is fast (most devices support 10MHz).  Also digitalWrite takes more than 1us anyhow!

Agreed. Digital read and write are HORRIBLY slow. I replaced some "digitalWrite" lines in a VFD driver with PORT = xxx and got an almost TENFOLD increase in speed!
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 435
Posts: 23597
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

spikey is sort of thread hijacking...
40 bits is 5 bytes, nothing custom needed.
Code:
SPI.transfer(byte0);
SPI.transfer(byte1);
SPI.transfer(byte2);
SPI.transfer(byte3);
SPI.transfer(byte4);
digitalWrite (latchPin, LOW);
digitalWrite (latchPin, HIGH);
/* Load Input. Data is loaded transparently from the internal shift register to the output
latch while LOAD is high. Data is latched into the output latch on LOAD’s rising
edge, and retained while LOAD is low.*/
or do a little for:next loop instead of 5 discrete writes
Code:

for (x=0; x<5; x=x+1){
SPI.transfer(displayData[x]);
}
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 58
Posts: 3979
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Make the delay(1) a delayMicroseconds(1)!  SPI is fast (most devices support 10MHz).  Also digitalWrite takes more than 1us anyhow!

Agreed. Digital read and write are HORRIBLY slow. I replaced some "digitalWrite" lines in a VFD driver with PORT = xxx and got an almost TENFOLD increase in speed!

Are you perhaps thinking of analog reads?
Because digital read is a matter of reading a register.

Analog read takes a bit over 100 microseconds.

This loop in my ultrasonic sensor code runs in just about 1 microsecond per pass. How do I know? I count the passes in echo and I compare them to micros() which is what I use to estimate sound travel distance. The numbers are very close even with many 1000's of passes.

Code:
  mikros = micros();

  //  Test distance = (high level time * sound velocity (340M/S) / 2)
  echo = 0UL;
  while ( ( digitalRead( ECHO )))
  {
    echo++;
    if ( echo > 1000000UL )
    {
      echo = 0UL;
      break;
    }
  }

  mikros = micros() - mikros;


And yeah, I need to add a temperature sensor since Mach 1 varies with temperature.
As now, my project is only good to a bit under an inch where 2mm should be possible.

Logged

Examples can be found in your IDE.

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@CrossRoads
losing a few is a great idea, thanks! I wil definitely be thinking along those lines.

@GoForSmoke
I was actually considering this, but only as the last resort, thanks for a reply tho

@CrossRoads
yeah I know... really sorry about that :/
uu, loop idea looks promising smiley-grin

well anyways, thank you, both of you, thats pretty much all I needed to know.
If I need anything else, I will open a new thread.

cu all
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How do I send 20 bits of data if the SPI sends everything in 8-bit sections?

The answer to your question is right there in the datasheet.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What page describes sending 20 bits, dhenry? It isn't divisible by 8.
Logged

Pages: 1 [2]   Go Up
Jump to: