SPI 4 digit 7 segmet displays

Anything not related to a specific project.

SPI 4 digit 7 segmet displays

Postby touch » Fri Sep 14, 2012 5:17 pm

I picked up some cheap 4 digit 7 segment displays over on eBay for $10 + shipping. They Include a SPI PT6961 driver chip built in that deals with PWM and Multiplexing, saves on microcontroller ports & current limiting resistors. Figured someone here may have a use for them!

I posted a little more info here http://www.43oh.com/forum/viewtopic.php?f=8&t=3225

Image

http://www.ebay.com/itm/10-New-Oasis-4- ... 2ec116e572
touch
Newbie
Newbie
 
Posts: 31
Joined: Wed Feb 15, 2012 10:50 pm

Re: SPI 4 digit 7 segmet displays

Postby CheezeWiz » Fri Sep 21, 2012 11:38 pm

I bought 3 packs of these..I suppose because I could :)

What pin is the STB pin? is that CS on the BusPirate?

I have the ground/clock/vcc pins connected, where do the other pins get plugged into this thing?

Code: Select all
#include <SPI.h>

const int slaveSelectPin = SS;
const char DISP[16] {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x58, 0x5e, 0x79, 0x71};

void setup() {
  pinMode (slaveSelectPin, OUTPUT);
  SPI.begin();
  SPI.setBitOrder(LSBFIRST);
  SPI.setDataMode(SPI_MODE2);
}

void loop() {
  //set display to 6x12 segments
  digitalWrite(slaveSelectPin,LOW);
  SPI.transfer(0x02);
  digitalWrite(slaveSelectPin,HIGH);
 
  //set to writing mode, auto incrament address after data write
  digitalWrite(slaveSelectPin,LOW);
  SPI.transfer(0x40);
  digitalWrite(slaveSelectPin,HIGH);
 
  //first clear 8 bytes of the display RAM
  digitalWrite(slaveSelectPin,LOW);
  SPI.transfer(0xC0);
  for(int i=0; i<8; i++){
      SPI.transfer(0x00);
  }
  digitalWrite(slaveSelectPin,HIGH);
 
  //display on, max brightness
  digitalWrite(slaveSelectPin,LOW);
  SPI.transfer(0x8F);
  digitalWrite(slaveSelectPin,HIGH);
 
  //count through 0-9,a-f
  for(int i=0; i<16; i++){
      digitalWrite(slaveSelectPin,LOW);
      SPI.transfer(0xC0);
      SPI.transfer(DISP[i]);
      digitalWrite(slaveSelectPin,HIGH);
      delay(500);
  }
}


^^^ Is not my code, its located here
http://www.43oh.com/forum/viewtopic.php ... f&start=10

Thanks,
--Aaron
CheezeWiz
Jr. Member
Jr. Member
 
Posts: 55
Joined: Fri Mar 04, 2011 4:16 pm

Re: SPI 4 digit 7 segmet displays

Postby touch » Sat Sep 22, 2012 12:28 am

yes, STB is CS, here's the pinout:

Pin out is as follows, starting from the pin closest to PIN1 on the SOP32 chip.
VCC, STB, CLK, DIN, DOUT, GND.

I don't have a bus-pirate but I believe it would be:
STB = CS
CLK = CLK
DIN = MOSI
DOUT = MISO
touch
Newbie
Newbie
 
Posts: 31
Joined: Wed Feb 15, 2012 10:50 pm

Re: SPI 4 digit 7 segmet displays

Postby CheezeWiz » Sat Sep 22, 2012 9:21 am

Hey thanks,

It seems like I'm trying to shoot the side of a barn with a shot gun blind folded and not really knowing which direction to point at this time...

... I *Think I know what the mode I need to setup in the bus Pirate
Going though the setup modes...
Mode 5
1, 30Khz
Clock polarity setup: It lists Idle Low Default and Idle High, peeking at the data sheet it looks like when STB/CS is low data gets transmitted when CS is high nothing happens, so this tells me that it idle's when its high.... is this a good assumption on my part...
Input Sample Phase = 1 Default
2 /CS *Default
Select output type 2 *default

Looking at the code the guy provided that I posted above I would guess that you type something like this on the SPI> Line

SPI> 0x02,0x40,0xc0,0x8f
However no dice.
Right now I don't see any lit segments... Am I just doing something completely stupid here?

Thanks!

--Aaron
CheezeWiz
Jr. Member
Jr. Member
 
Posts: 55
Joined: Fri Mar 04, 2011 4:16 pm

Re: SPI 4 digit 7 segmet displays

Postby touch » Sat Sep 22, 2012 11:25 pm

Idle high is correct, but you need to keep STB low between when you send the address command (0xc0) and when you write to the ram (0x8f). I bet the buspirate is raising the STB after it sends 0xc0.
touch
Newbie
Newbie
 
Posts: 31
Joined: Wed Feb 15, 2012 10:50 pm

Re: SPI 4 digit 7 segmet displays

Postby CheezeWiz » Sun Sep 23, 2012 8:20 pm

.. DO you have an example of what I could try sending to light up "something/anything" to know if I'm on the right track?

I'm kinda supprised no one has any examples for this yet.

--Aaron
CheezeWiz
Jr. Member
Jr. Member
 
Posts: 55
Joined: Fri Mar 04, 2011 4:16 pm

Re: SPI 4 digit 7 segmet displays

Postby ian » Mon Sep 24, 2012 7:49 am

you need to control the strobe. That is CS so use [] to lower/raise it. Maybe:

[0x02,0x40,0xc0,0x8f]

or ]0x02,0x40,0xc0,0x8f[

I have not looked at the datasheet though.
User avatar
ian
Crew
Crew
 
Posts: 10803
Joined: Mon Jul 06, 2009 6:14 am

Re: SPI 4 digit 7 segmet displays

Postby rajabalu » Mon Sep 24, 2012 10:58 pm

Aaron - Did you try turning on the power by using the W command after entering SPI mode?

Ian - If you don't mind can you take a look at the datasheet for PT6961? I have posted just the timing diagram for your reference. Any help about SPI setup for this device is greatly appreciated.

Image
rajabalu
Newbie
Newbie
 
Posts: 9
Joined: Mon Aug 27, 2012 7:03 pm

Re: SPI 4 digit 7 segmet displays

Postby CheezeWiz » Tue Sep 25, 2012 8:52 am

Rajabalu--

Yes I have the power on :O haha... reminds me of "The IT Crowd"
CheezeWiz
Jr. Member
Jr. Member
 
Posts: 55
Joined: Fri Mar 04, 2011 4:16 pm

Re: SPI 4 digit 7 segmet displays

Postby rajabalu » Wed Sep 26, 2012 7:34 pm

Aaron - I figured it out

Here are the Pin mappings:
VCC- 3V3
STB - CS
CLK - CLK
DIN - MOSI
DOUT - Not connected
GND - GND

Here are the Bus Pirate commands/setup:

HiZ>m
1. HiZ
2. 1-WIRE
3. UART
4. I2C
5. SPI
6. 2WIRE
7. 3WIRE
8. LCD
x. exit(without change)

(1)>5
Set speed:
1. 30KHz
2. 125KHz
3. 250KHz
4. 1MHz

(1)>1
Clock polarity:
1. Idle low *default
2. Idle high

(1)>2
Output clock edge:
1. Idle to active
2. Active to idle *default

(2)>1
Input sample phase:
1. Middle *default
2. End

(1)>1
CS:
1. CS
2. /CS *default

(2)>2
Select output type:
1. Open drain (H=Hi-Z, L=GND)
2. Normal (H=3.3V, L=GND)

(1)>2
Ready
SPI>L
LSB set: LEAST sig bit first
SPI>W
POWER SUPPLIES ON
SPI>[0x02][0x40][0x8F][0xC0,0x3F]
/CS ENABLED
WRITE: 0x02
/CS DISABLED
/CS ENABLED
WRITE: 0x40
/CS DISABLED
/CS ENABLED
WRITE: 0x8F
/CS DISABLED
/CS ENABLED
WRITE: 0xC0
WRITE: 0x3F
/CS DISABLED
SPI>

You should see 0 displayed on the LED Display.

Image
Last edited by rajabalu on Wed Sep 26, 2012 7:41 pm, edited 1 time in total.
rajabalu
Newbie
Newbie
 
Posts: 9
Joined: Mon Aug 27, 2012 7:03 pm

Re: SPI 4 digit 7 segmet displays

Postby CheezeWiz » Wed Sep 26, 2012 7:38 pm

... Sh1t I was literally [.] close...

What's the deal with the last part? the comma? in the syntax?

--Aaron
CheezeWiz
Jr. Member
Jr. Member
 
Posts: 55
Joined: Fri Mar 04, 2011 4:16 pm

Re: SPI 4 digit 7 segmet displays

Postby rajabalu » Wed Sep 26, 2012 7:44 pm

Aaron - The braces '[' and ']' need to be present for each command. We tried to do it all together like [0x02,0x40,0x8F,0xC0,0x3F] before. The correct call is [0x02][0x40][0x8F][0xC0,0x3F].
rajabalu
Newbie
Newbie
 
Posts: 9
Joined: Mon Aug 27, 2012 7:03 pm

Re: SPI 4 digit 7 segmet displays

Postby rajabalu » Wed Sep 26, 2012 7:46 pm

CheezeWiz wrote:... Sh1t I was literally [.] close...

What's the deal with the last part? the comma? in the syntax?

--Aaron

Comma is to hold the STB at the same level and send the next piece of information.
rajabalu
Newbie
Newbie
 
Posts: 9
Joined: Mon Aug 27, 2012 7:03 pm

Re: SPI 4 digit 7 segmet displays

Postby CheezeWiz » Wed Sep 26, 2012 11:49 pm

Well!

Very cool very cool.. Thank you!

So I ended up buying 30 of these things is there an easy way to chain them together?
This is another post I also have that Ian helped me with
viewtopic.php?f=4&t=4450&p=44598#p44598

Kinda want to make something neat with a bunch of these displays, but really not sure what...
in a week or so I'll have a total of 5 of those 16 char displays.
--Aaron
CheezeWiz
Jr. Member
Jr. Member
 
Posts: 55
Joined: Fri Mar 04, 2011 4:16 pm

Re: SPI 4 digit 7 segmet displays

Postby rajabalu » Thu Sep 27, 2012 4:35 pm

While we could use the CS/STB line to control the LED display of our choice, I am thinking simple daisy chaining the first display to the second will work. We need to try connecting the DOUT of the first display to the DIN of the second display and so on.. CLK, CS/STB, VCC and GND can be connected in parallel.

I am just guessing here that daisy chaining will work but I am not sure. I will try it out tonight and let you know. Or I need to bring my LaunchPad out to try this chaining effect. Writing a small program in Energia can loop through the data we need to push out (now that we know what commands to type from our Bus Pirate experiments).

I am surprised that you have 30 of these. So the chain will be a long one I suppose. :) What do you plan on using them for?

Since they do not have the decimal point connected, I am not sure whether I could make good use of these. I got 10 of them as they were sold as one lot. I am thinking of making a small clock for my daughter and she has a Lego enclosure ready for the display now. The rest of the displays, I am planing to use them as for displaying voltage, current and for a frequency counter. For me the segments are in green but the colons are in red and so they look funny.
rajabalu
Newbie
Newbie
 
Posts: 9
Joined: Mon Aug 27, 2012 7:03 pm

Next

Return to General discussion