![]() | ![]() | ![]() |
| | #1 |
|
I am using a Parallax SX28 micro-controller chip to control 2 cascaded Absen-OF20V 16x8 RGB modules from China. See attachments. What I don't see on this display is PWM control. The SX28 chip has a PWM command but it is used with a resistor and capacitor to create an analog voltage. I don't see how this can be used with this SPI display (very similar to the way a 74HC595 works). I do have Latch, /OE, CLK and Serial Data In and Serial Data Out on each of the cascaded chinese MBLOCK MBI5024GF constant current LED driver ICs. Currently I can turn on any of the 3 RGB LEDs over both of the 2 cascaded modules. Eventually I will have many more cascaded modules. The SXB (BASIC) program was saved as a .TXT file (instead of the usual .SXB file) I am new to PWM and need to know how to do this in a BASIC like language that the SX chip uses (SX/B). Can I get any help on this? ALSO - I am currently using a spreadsheet to calculate the correct DATA statements since this display uses a different way to push data to the data streams (2). Is there a better way to do this? I should be able to modify the design for Serial port control and send out TEXT pages from HyperTerminal. But that is about it on my programming ability to the PC. Ideas for this too? Thanks! | |
| |
| | #2 |
|
The PWM is PWM (done in software) an the cap & resistor simply form an integrator (simple D/A)
| |
| |
| | #3 |
|
I would think that you could PWM the common anode/cathode of the display with a good size logic level mosfet (IRLZ44?). To vary individual led brightness than use different controller chips like a NXP PCA9635 (16 bit, I2C bus).
| |
| |
| | #4 |
|
Thanks for the input. The common Anodes of each of the R, R2, G, and B leds are all tied to Vcc (+5vdc) on the PCB of the Absen 16x8 module so all I have to work with are the signals coming off of the input/output jacks on the modules themselves being (RA1, RA2, G1, B1, RB1, RB2, G2, B2, /OE, Latch, Clock, Serial Data In, Serial Data Out, and some Grounds). Currently I can shift out 64 bits in both top and bottom data streams per module and do this in any color (R, R2, G, B) but I don't know how PWM can be applied to SPI signals). What I see by doing Google searches shows PWM being applied to a single output of either R, G or B but not a data stream like SPI. Keep comming with the help please. Thanks! Last edited by tdg8934; 19th October 2008 at 08:12 PM. | |
| |
| | #5 |
|
Haven't read your data sheet, but it looks like an HC595 (with 16 outputs), so controlling the /OE could do the trick if it doesn't mess with the serial input. Normally you tie the /OE low and forget about it, but switching to high is supposed to give a high impedance state on the outputs. Unless the controller has a PWM function built in, you are not going to PWM the outputs with SPI. You could control the /OE with your PC-USART-microcontroller interface. | |
| |
| | #6 |
|
Nickelflippr, You are right about that it acts like a '595 with 16 outputs. In my previously attached SXB (TXT) program listing of the SX28 code, you will see that I set /OE high initially (e.g. OE = 1), then after the data gets clocked, I set /OE low (e.g. OE = 0) all from the SX28 micro-controller. I also pulse out the Latch signal after the data is clocked out. The reason I am mentioning this is that I saw in some posted circuits by Mike, that he ties OE and Latch (ST) together and calls that the PWM signal as sent to the micro-controller (probably a PIC). Do I connect /OE to the Latch? Do I pulse out the tied together signals after the data gets clocked out? What does the micro-controller do to these pins? The problem I see with using /OE (with or without ST {Latch}), is that the module has all of the /OE lines on all of the cascaded MBI5024GF led drivers tied together. So this means that setting /OE high or low will affect ALL of the LED outputs not individual Red, Red2, Green, Blue LEDs to get 256 shades. Am I right about this? I don't see that the MBI5024GF has PWM built in BUT the Absen-OF20V 16x8 RGB module (which has these cascaded MBI5024GF LED drivers) states in it's data sheet (previously attached) that the all the LEDs have 256 Greys which tells me that they are suposed to be able to do PWM "SOME HOW??" Also these Absen-OF20V 16x8 RGB modules are used in huge outdoor LED display signs with full 36 bit color. This again infers that PWM must be possible. However, these modules are cascaded by the 100's to form these huge outdoor signs. They are normally controlled by a custom PCI card with Ethernet and DVI for video input. I am trying to find a way to basically re-create something on a simpler scale that can be controlled by a Parallax SX28 micro-controller and not by this card because the PC software is not that good. It will be connected to a PC at sometime, probably via Serial or (USB-to-Serial) to send the data from a custom software program - maybe Visual Basic. Is this still possible. I hope you and others can see my intentions. Thanks for listening and your assistance. | |
| |
| | #7 |
|
No, you don't want to tie the OE and LATCH lines together on your OEM boards. I tie them together on my designs because I'm multiplexing the the buss for use as column or row driver lines during the "display on" portion of each scan cycle and for use as DATA and CLOCK lines during the "display off" or "blanking" portion of each scan cycle. For PWM brightness control you would drive the OE (Output Enable) line on the driver ICs with a PWM signal which has a PWM "period" equal to the scan time (the time each section of the display is on). I can't tell from only a brief look at your code and the data sheets what you're using for a display refresh rate, or if the display is even multiplexed. Mike | |
| |
| | #8 |
|
Thanks for your input and clarification. It's good to hear from you again. OK so that explains the OE and LATCH situation. /OE will be the PWM signal. You state "each section" - are you refering to individual RGB LEDs or each MBI5024GF LED driver (for PWM on 16 outputs). I am using a 20 MHz resonator and for now simply looping the Display routine over and over. The display is not multiplexed but all of the LED anodes are tied to VCC (+5vdc). It is SPI like 16 output 74HC595's that are cascaded a few dozen times. I just clock out 64 bits of data from DATA statements that are READ in to the SX/B program. The SX/B "PWM" command is as follows: PWM Pin, Duty, Duration Function Convert a digital value to analog output via pulse-width modulation. Pin is any SX IO pin (RA.0 .. RA.7, RB.0 .. RB.7, RC.0 .. RC.7, RD.0 .. RD.7, RE.0 .. RE.7). Duty is a variable or constant (0 - 255) that specifies the analog output level (0 to 5V). Duration is a variable or constant (0 - 255) that specifies the duration of the PWM output in milliseconds. Quick Facts Units in Duration 1 ms Average voltage equation Average Voltage = (Duty ÷ 255) x 5 volts Duration 5 x R x C (suggested) Notes Pin is output while PWM active, then switched to input mode Explanation Pulse-width modulation (PWM) allows the SX (a purely digital device) to generate an analog voltage. The basic idea is this: If you make a pin output high, the voltage at that pin will be close to 5V. Output low is close to 0V. What if you switched the pin rapidly between high and low so that it was high half the time and low half the time? The average voltage over time would be halfway between 0 and 5V (2.5V). PWM emits a burst of 1s and 0s with a ratio that is proportional to the duty value you specify. The proportion of 1s to 0s in PWM is called the duty cycle. The duty cycle controls the analog voltage in a very direct way; the higher the duty cycle the higher the voltage. In the case of the SX, the duty cycle can range from 0 to 255. Duty is literally the proportion of 1s to 0s output by the PWM instruction. To determine the proportional PWM output voltage, use this formula: (Duty ÷ 255) x 5V. For example, if Duty is 100, (100 ÷ 255) x 5V = 1.96V; PWM outputs a train of pulses to create (through an RC network) an average voltage of 1.96V. In order to convert PWM into an analog voltage we have to filter out the pulses and store the average voltage. The resistor/capacitor combination shown below will do the job. The capacitor will hold the voltage set by PWM even after the instruction has finished. How long it will hold the voltage depends on how much current is drawn from it by external circuitry, and the internal leakage of the capacitor. In order to hold the voltage relatively steady, a program must periodically repeat the PWM instruction to give the capacitor a fresh charge. Just as it takes time to discharge a capacitor, it also takes time to charge it in the first place. The PWM command lets you specify the charging time in terms of PWM duration. The timing for the units in Duration is one millisecond. How do you determine how long to charge a capacitor? Use this rule-of-thumb formula: Charge Time = 5 x R x C. For instance, the circuit below uses a 10 kO (10 x 103 ohm) resistor and a 1 µF (1 x 10-6 uF) capacitor: Charge time = 5 x 10 x 103 x 1 x 10-6 = 50 x 10-3 seconds, or 50 milliseconds. PWM RB.0, 128, 50 ' charge to 2.5 volts, 50 ms After outputting the PWM pulses, the SX leaves the pin in input mode (1 in the corresponding bit of the pin's TRIS register). In input mode, the pin's output driver is effectively disconnected. If it were not, the steady output state of the pin would change the voltage on the capacitor and undo the voltage setting established by PWM. Keep in mind that leakage currents of up to 1 µA can flow into or out of this "disconnected" pin. Over time, these small currents will cause the voltage on the capacitor to drift. The same applies for leakage current from an op-amp's input, as well as the capacitor's own internal leakage. Executing PWM occasionally will reset the capacitor voltage to the intended value. PWM charges the capacitor; the load presented by your circuit discharges it. How long the charge lasts (and therefore how often your program should repeat the PWM instruction to refresh the charge) depends on how much current the circuit draws, and how stable the voltage must be. You may need to buffer PWM RC circuit output with a simple op-amp follower if your load or stability requirements are more than the passive circuit can handle. 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. Another option might be to use a "PULSOUT" command: PULSOUT Pin, Duration {, Resolution} Function Generate a pulse on Pin with a width of Duration * Resolution. Pin is any SX I/O pin (RA.0 .. RA.7, RB.0 .. RB.7, RC.0 .. RC.7, RD.0 .. RD.7, RE.0 .. RE.7). This pin will be set to output mode. Duration is a variable or constant that specifies the pulse width in Resolution units. Resolution is an optional constant (1 - 255) that specifies the units for Duration, in increments of 10 microseconds (default value is 1 when not specified). Quick Facts Units in Resolution 10 µs (0.01 ms) Minimum pulse width 10 µs Maximum pulse width 650.25 ms (byte), 167.11 s (word) Explanation PULSOUT sets Pin to output mode, inverts the state of that pin; waits for the specified Duration x Resolution x 10 microseconds; then inverts the state of the pin again returning the bit to its original state. The pulse width is the product of Duration and Resolution. In the following example, a pulse of 50 microseconds will be generated on RA.0 PULSOUT RA.0, 5 ' 50 µs pulse The Resolution parameter gives the programmer a great deal of flexibility with PULSOUT. In the follow example, a stream of pulses will be created, each with a different pulse width: Main: FOR idx = 1 TO 10 PULSOUT RA.0, idx, 10 ' pulses from 100 to 1000 µs PAUSE 1 ' delay 1 millisecond NEXT GOTO Main By combining Duration and Resolution, pulses from 10 microseconds to 167.11 seconds can be generated. Does either of these 2 commands look usable here or do I do something completely different to the /OE line ? Thanks again! | |
| |
| | #9 |
|
Perhaps if you explained how you're driving the display? How many times do you send 64 bits of data to a set of driver ICs to update the entire display?
| |
| |
| | #10 |
|
Mike, Here is the program (with an explaination at the end): Code: ' =========================================================================
' 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
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
' -------------------------------------------------------------------------
' 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)
The Displays routine is the Main routine. It does the following: 1. Disable OE (e.g. OE = 1 or high) 2. READ in 8 Bytes (e.g. 64 bits) for the lower 1/2 data stream of the module 3. READ in 8 Bytes (e.g. 64 bits) for the upper 1/2 data stream of the module 4. Call out the SPI subroutine which does the following: 4a. Select which color input for the data (e.g. Red, Red2, Green or Blue) 4b. Clock the previously READ in data into that Color input jack on the module. 4c. Continue the clocking for each of the 8 bits (bytes) of the data. 5. Pulse the Latch (e.g. ST = 1, ST = 0) now that the data has been clocked 6. Now enable OE (e.g. OE = 0 or low) to enable the LED outputs with the 64 bits of (red, red2, green or blue) data for both the lower and upper data streams. 7. Then there is a 100 u sec delay. If you do not have any delay the program probably runs too fast and the display is dimly lit. 8. Next there is a simple DEMO color output cycling routine to display the smiley face data for 1 second in red LEDs and then 1 second in red2 LEDS, then 1 second in green LEDs and finally 1 second in blue LEDs. The 1000 mSec pause prettymuch eliminates the need for a uSec Pause in the previous step. 9. The routine repeats itself over and over again. NOTE: I have (2) Absen OF-20V RGB 16x8 modules connected so there are DATA statements for 2 displays (or 128 bits for the lower data stream and 128 bits for the upper data streams) - (e.g. 64 bits per module data stream) Are you looking for runing times? I'm not sure on how to calculate this. Last edited by tdg8934; 19th October 2008 at 11:54 PM. | |
| |
| | #11 |
|
Perhaps I'm interpreting the display data sheets incorrectly. The data sheets suggest (to me) that you have latched outputs for 256 LEDs (64 Red, another 64 Red, 64 Green, and 64 Blue). If that's the case, you have a non-multiplexed display which can display data indefinitely after you load the driver shift-registers and latch or strobe the shift register data onto the driver output pins. You should not have to do anything with the OE (Output Enable) line. You only need to load the shift registers and toggle or pulse the LE (Latch Enable) line. 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. Best luck. Mike | |
| |
| | #12 |
|
Mike, You are correct that this is not a multiplexed display. It has latched outputs and I could just tie the /OE line to ground but thought it should happen after it was latched so I used an output line for /OE as I have plenty of I/O pins. 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? 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. 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. | |
| |
| | #13 | ||||
| Quote:
Quote:
Quote:
Quote:
| |||||
| |
| | #14 |
|
Mike, You are right, I do latch and enable after all of the data is out there and ready to be - not just after 8 bits (1 byte). So it sounds like I am doing everything right except for my original concern being PWM. I have seen some PWM code for the SX chip but it is written for 16 or 64 channels which apparently is for multiplexed displays and I don't know if it can be used for SPI latched displays. If I did have a hardware or software way to create PWM, where would the pin go to on my display (on /OE or the Latch input jack pin)? Thanks for all your help. | |
| |
| | #15 | |
| Quote:
You want the square wave output from the PWM pin not an analog voltage so don't add a resistor and cap'. Drive the Output Enable inputs directly from the PWM pin. For example, setup your PWM period to 200 Hz and adjust the duty cycle from 255 (0% brightness, display off) to 0 (100% brightness). This affects the brightness of all four sets of LEDs being displayed. If you're trying to accomplish color control by displaying Blue LEDs at 25% brightness and Red LEDs at 50% brightness and Green LEDs at 40% brightness, the PWM mechanism is not going to do it for you without a major software driver overhaul. Mike <added> That PWM command in one of your previous posts doesn't look quite right. That "duration" parameter is wierd. Perhaps you really don't have a built-in PWM peripheral. Last edited by Mike, K8LH; 20th October 2008 at 01:36 PM. | ||
| |
|
| Tags |
| display, learn, led, pwm, rgb, spi, type |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| determine P type or N type diode | shermaine | General Electronics Chat | 7 | 5th October 2008 02:34 AM |
| help me learn | dre22 | General Electronics Chat | 12 | 29th August 2006 01:03 PM |
| LCD display driving method/waveform type | Futterama | Electronic Projects Design/Ideas/Reviews | 8 | 12th January 2006 05:00 PM |
| I want to learn! | Macka | General Electronics Chat | 16 | 4th November 2005 03:18 PM |
| need help i want to learn | timi | Electronic Projects Design/Ideas/Reviews | 2 | 11th December 2003 04:18 PM |