' =========================================================================
' Authors... Timothy Gilmore
' File...... Absen-OF20V_v1.sxb
' Purpose... Use with Absen OF20V 16x8 2RGB module.
'
' =========================================================================
' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
' Program code to use ....
' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------
DEVICE sx28, oschs2, TURBO, STACKX, OPTIONX
FREQ 20_000_000
' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------
CL PIN RA.0 OUTPUT 'J1-9
ST PIN RA.1 OUTPUT 'J1-11
OE PIN RA.2 OUTPUT 'J1-13
R1A PIN RB.0 OUTPUT 'J1-1
R1B PIN RB.1 OUTPUT 'J1-2
G1 PIN RB.2 OUTPUT 'J1-3
B1 PIN RB.3 OUTPUT 'J1-4
R2A PIN RB.4 OUTPUT 'J1-5
R2B PIN RB.5 OUTPUT 'J1-6
G2 PIN RB.6 OUTPUT 'J1-7
B2 PIN RB.7 OUTPUT 'J1-8
' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------
modules CON 2 'number of 16x8 display modules
' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
pos VAR Byte
slice VAR Byte
bitmask VAR Byte
info_bit VAR Byte(2)
data_bit VAR Byte(2)
alpha VAR Byte
ctr VAR Byte
color VAR Byte
' =========================================================================
PROGRAM Start
' =========================================================================
' -------------------------------------------------------------------------
' Subroutine Declarations
' -------------------------------------------------------------------------
ST_see SUB 0
SPI SUB 0
Clear SUB 0
' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------
Start:
ctr = modules * 8 'calculate total DATA elements
ctr = ctr - 1
color = 0
[B]Displays:
OE = 1 'disable display for setup
FOR alpha = 0 TO ctr 'progress through the DATA "message"
pos = alpha
READ fig_1 + pos, data_bit(0)
READ fig_2 + pos, data_bit(1)
SPI
NEXT alpha
ST_see
color = color + 1
IF color > 3 THEN
color = 0
ENDIF
PAUSE 1000
GOTO Displays[/B]
' -------------------------------------------------------------------------
' Subroutine Code
' -------------------------------------------------------------------------
SUB Clear
' --- Clear unused colors ---
R2A = 0
R1A = 0
R2B = 0
R1B = 0
G2 = 0
G1 = 0
B2 = 0
B1 = 0
ENDSUB
SUB SPI 'SHIFTOUT the data bits (Serial Peripheral Interface)
' ---- SPI Begins! ----
bitmask = $80
RB = RB | %00010001 'set for R2A and R1A
FOR slice = 1 TO 8
info_bit(0) = data_bit(0) & bitmask '0 or bitmask only
info_bit(0) = info_bit(0) MAX 1 'info_bit(0) / bitmask - 0 or 1 only
info_bit(1) = data_bit(1) & bitmask '0 or bitmask only
info_bit(1) = info_bit(1) MAX 1 'info_bit(1) / bitmask - 0 or 1 only
ON color GOTO R2A_R1A_out, R2B_R1B_out, G2_G1_out, B2_B1_out
R2A_R1A_out:
Clear
R2A = info_bit(1) 'top half data bits
R1A = info_bit(0) 'bottom half data bits
GOTO Clock_it
R2B_R1B_out:
Clear
R2B = info_bit(1) 'top half data bits
R1B = info_bit(0) 'bottom half data bits
GOTO Clock_it
G2_G1_out:
Clear
G2 = info_bit(1) 'top half data bits
G1 = info_bit(0) 'bottom half data bits
GOTO Clock_it
B2_B1_out:
Clear
B2 = info_bit(1) 'top half data bits
B1 = info_bit(0) 'bottom half data bits
GOTO Clock_it
'the RB bits have been set, ready to pulse clock for external latch
Clock_it:
CL = 1 'Clock pulse
CL = 0 'Clock pulse
bitmask = bitmask SHR 1 '0_$80, 1_$40, 2_$20, 3_$10, 4_$08, 5_$04, 6_$02, 7_$01, 8_$0...
NEXT slice
ENDSUB
SUB ST_see 'latch data, enable line
ST = 1 'bop ST
ST = 0 'bop ST
OE = 0 'enable display
PAUSEUS 100 'set for brightness
ENDSUB
' ---------- Display DATA ---------
fig_2: 'Hidden Message TOP HALF (Smiley)
DATA %01000100, %10001000, %00110100, %10000001, %11000010, %00011000, %00100010, %00010001 '1st (top module)
DATA %00100001, %00000000, %00000000, %11000011, %00000000, %00111100, %01001000, %00000000 '2nd (bottom module)
fig_1: 'Hidden Message BOTTOM HALF (Smiley)
DATA %00000000, %00010010, %00111100, %00000000, %11000011, %00000000, %00000000, %10000100 '1st (bottom module)
DATA %10001000, %01000100, %00000110, %01100000, %00000110, %01100000, %00010001, %00100010 '2nd (top module)
What I'm not following is what you are saying "You only need to load the shift registers and toggle or pulse the LE (Latch Enable) line."
I am doing this now but how is this PWM?
My first paragraph simply suggests you don't want to use the Output Enable lines for loading the driver shift registers.How does this give me 256 shades of let's say RED leds? Are you refering to the SXB PWM command or are you saying that if I pulse the Latch line at a certain frequency I will have PWM?
I'm not following you there.
You should only latch or strobe data from the shift registers onto the output pins after you've sent all 64 bits of data for all four sets of LEDs (all 256 LEDs), unless you're only updating a single set of 64 LEDs. If you're only updating a single set of 64 LEDs then you should send 64 bits before toggling the latch line. Strobing or latching data onto the outputs 8 bits at a time would result in a jumbled display. Is this why you were turning off the displays while loading data?Normally the Latch line is just toggle in with a high then a low:
ST = 1
ST = 0
or more specifically in the ST_see subroutine:
SUB ST_see 'latch data, enable line
ST = 1 'bop ST
ST = 0 'bop ST
OE = 0 'enable display
PAUSEUS 100 'set for brightness
ENDSUB
And thats about it. This happens after every 8 bits (1 byte) is clocked out.
You then state:
You should be able to use almost any PWM period with this display and simply adjust the duty cycle between 0% and 100% to adjust the display brightness. If the OE (Output Enable) inputs are "active low" and the PWM output is "active high" then the display brightness will be inversely proportional to the PWM duty cycle setting.
How is this accomplished without a PWM hardware pin on the SX chip - or are you saying to use the SXB PULSOUT command instead of toggling the Latch? See earlier posting about PULSOUT command.
The problem I see with using this "PWM" command is that it is analog based because you need to add a resistor and capacitor integrator circuit on the output of the SX pin. I don't think this it what we want to do if using /OE.
Nor will you, what you have is a message board controller!What I don't see on this display is PWM control
Write8R8D(PCA9635write, PWM(index), 0x63)
Write8R8D(PCA9635write, PWM(index+1), 0x96)
Write8R8D(PCA9635write, PWM(index+2), 0xFF)
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?