(03-12-2015 07:23 AM)Marcus von Cube Wrote: (03-11-2015 10:58 PM)MarkHaysHarris777 Wrote: But still, even at that, with all 24 bars 'ON' my little display is drawing about 184 mA. Even limiting the current a dual twelve digit seven seg display would draw a little more than 1.3 amp---
I'm not aware of any seven segment display device that is not multiplexed. The human eye is so slow that you will not notice a flicker unless you move the device in front of you. Multiplexing will reduce the power requirements to what a single digit or segment (depending how far you go with multiplexing) draws.
Greetings, well, its Christmas at my house again (also with lights!) as some kind soul has shipped to me (free as in free beer!) a pair of
JTRON PN297686 8 digit seven segment multiplexed display units utilizing two(2) 74HC595 built-in shift registers. I'm very impressed that I may actually have a workable solution to my proposed Wang 700c replica (in the sometime near future, but that's another story).
This little display draws a whopping 12 mA with all bars on (multiplexed) and although flickering slightly can be maintained by the Raspberry PI (while doing other things). If I actually put them in my Royal (and I might) I will program an Atmega328 AVR dedicated to the job of MCU over these little gems. A BIG FAT 'Thank You!' to whomever sent these beauties to me... they arrived in the mails yesterday, and I spent some hours over-night writing some python code to handle them. Hi-res pics first, and some code... then some comment:
You can read my
seven segment python driver code on-line, or in-line here:
Code:
########################################################################
# JTRON PN297686 2x595 Multiplexed Seven Segment LED Display Driver
#
# jtrondrv.py
#
# Mark H. Harris
# 24 March, 2015
#
########################################################################
#
# This sample python code is written for the Raspberry PI b+.
#
# author: Mark H. Harris harrismh777@gmail.com
# license: GPLv3
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MECHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENCIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
########################################################################
#
# The JTRON PN297686 is an 8 digit multiplexed LED seven segment display
# utilizing two 74HC595 shift registers, in a small form factor measuring
# 7cm x 2cm x 1cm. The display requires an external MCU of some type (this
# driver code running on a Raspberry PI) including Arduino type AVR, or
# other. The display expects a serial write of 16 bits, the high order byte
# of which is the segment(s) bar code (see digitROM) for displaying the
# charcter, and the low order byte of which is the digit select; that is
# which digit will 'turn on'. The bars are cathode, so 1 is off, 0 is on.
# The digit select is hight order bit(left digit) low order bit(right digit).
# This sample code logically inverts segments so that the 1's in the digitROM
# are 'ON' codes. The high order bit is the decimal point, and the other
# bits follow according to standard with segments g; f; e; d; c; b; a. To
# turn on the decimal point logically 'OR' the digitROM code with 0x80.
# The serial write of 16 bits is shifted in high order first. As an example
# digit code, then position. The code 0x6d80 will display a '5' in the 'first'
# leftmost digit. (see digitROM below)
# The MCU must refresh the display constantly. The quicker this occurs the
# less flicker will occur and the more even the display brightness will be,
# At any one time only one digit is being powered, but vision persistance
# makes them appear as if all digits are 'ON' at once. Now a bit about the
# display pins.
# Vcc is 3v3 supplied from the Raspberry PI (DO NOT USE the 5v Supply!). Gnd
# is ground potential. SCLK is the SPI clock (this is the clock that shifts
# the bits into the display registers. RCLK is the 'latch' strobe pulse; on
# leading edge signal the registers 'latch' their inputs to the LED bar
# outputs. DIO is the data I|O pin. These pins are defined further in the
# code below.
#
# This is sample code only. Please don't email me and tell me all the things
# that are wrong with it, how insecure it is, and how best to improve it. It
# is provided in the hopes that it will help someone else make use of this
# display with a minimal headache.
#
# Once the module is imported (an 8 will walk across the display) dispPI() will
# display the value of PI (you will notice some flicker). The routine called
# decimalCounter(1000000) will start a counter up to the number you set. There
# is less flicker here since leading zeros are supressed and less digits are
# 'ON' initially.
#
# enjoy! mhh
#
########################################################################
# Get the Raspberry PI GPIO library, to use RPi IDLE3 must be run as sudo
import RPi.GPIO as GPIO
import time
# These are the three magic SPI BCM pins for the JTRON display
# SPI clocking, GPIO BCM pin numbering
sClockPin = 20
# Latch enable, 'latches' register inputs to outputs
rClockPin = 22
# Data I|O, bits are shifted in here
dioPin = 24
# This python dictionary contains the segment codes for the digits 0-9
# (you, of course, could add hex codes too ! )
digitROM = {0:0x3f,1:0x06,2:0x5b,3:0x4f,4:0x66,5:0x6d,6:0x7d,7:0x07,8:0x7f,9:0x67}
# Initialize the GPIO of the Raspberry PI
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# Set the SPI pins for output
GPIO.setup(sClockPin, GPIO.OUT)
GPIO.setup(rClockPin, GPIO.OUT)
GPIO.setup(dioPin, GPIO.OUT)
# This routine provides the clock pulse 'strobe' that shifts in a single bit
def sClock(clockPin):
GPIO.output(clockPin, 1)
time.sleep(0.000030)
GPIO.output(clockPin, 0)
# This clock pulse 'latches' the shift register inputs to the LED outpus
def rClock(clockPin):
GPIO.output(clockPin, 1)
time.sleep(0.000010)
GPIO.output(clockPin, 0)
# Here we are actually shifting xvalue into the shift registers, which is
# accomplished in two 8 bit writes, the first (high order) is the digit, and
# the second (low order) is the position...
def binDisplay(xvalue, dio, sClk, rClk):
binDigit = int(0x8000)
for n in range(8):
if (int(xvalue) & int(binDigit)):
GPIO.output(dio, 0)
else:
GPIO.output(dio, 1)
sClock(sClk)
binDigit /= 2
binDigit = int(0x0080)
for n in range(8):
if (int(xvalue) & int(binDigit)):
GPIO.output(dio, 1)
else:
GPIO.output(dio, 0)
sClock(sClk)
binDigit /= 2
rClock(rClk)
# binDisplay() driver used to simply the call in the code elsewhere
def bDisplay(xvalue):
binDisplay(xvalue, dioPin, sClockPin, rClockPin)
# digit display using digitROM. dispDigit(7,2) will display a '7' in
# position 2, numbered from the left at 1.
def dispDigit(digitVal, digitPos):
if (digitPos==8):
xvalue=int((digitROM[digitVal]*256 | 0x8000) + 2**(digitPos-1))
else:
xvalue=int(digitROM[digitVal]*256 + 2**(digitPos-1))
binDisplay(xvalue,dioPin, sClockPin, rClockPin)
# This code will display a decimal value using a refresh counter 'scanVal'
# to loop quickly through the digits (yes, there is flicker). Some of the
# refresh 'looping' is shared by the decimalCounter() and some is here...
# Ultimately, a dedicated MCU should refresh these displays. An Arduino
# type AVR should have the job of keeping the display active, while getting
# serial data for display from external... another project.
def decimalDisp(dValue, scanVal):
dTemp=dValue
for m in range(scanVal):
zeroFlag=0
dValue=dTemp
for n in range(8,0,-1):
tens=int(dValue//(10**(n-1)))
if (not zeroFlag and tens>0):
zeroFlag=-1
rmdr=int(dValue%(10**(n-1)))
if (zeroFlag):
dispDigit(tens, n)
dValue=rmdr
# Our counter will count up to dValue. This loops through the numbers in
# range, calling decimalDip(number, 15) for a display refresh scanVal of 15.
# This is 'one' way to do this, not the best, but we have no dedicated MCU.
def decimalCounter(dValue):
for n in range(dValue):
decimalDisp(n, 15)
bDisplay(0x0000)
# On initialization this code 'walks' an '8' with decimal point across the
# display. This 'resets' the display and tests the digits 'al on' condition.
def testDigits():
rClock(rClockPin)
for n in range(16):
sClock(sClockPin)
rClock(rClockPin)
binDigit=int(0x80)
for n in range(8):
digit=int(0xff00 + binDigit)
bDisplay(digit)
binDigit /=2
time.sleep(0.50)
bDisplay(0x0000)
# self explanatory
def clearDisplay():
bDisplay(0x0000)
# self explanatory
def dispPI():
while True:
decimalDisp(int("31415927"), 15)
testDigits()
To actually use these little gems requires programming a dedicated AVR that handles the 'large' data shift register internally and also handles the fast display refresh; a dedicated ATmega328 would do very nicely. Its on my back burner.
Thanks again to the person who sent these displays to me. I really appreciate it.. and I've had a ton of fun working with them. Somebody at the Raspberry PI foundation will appreciate it too, I'm sure... passing the part numbers and python code along for somebody to enjoy. Thanks!
Cheers,
marcus