Power Supply for Neat OLED

alband

Senior Member
Morning all,

I've purchased an OLED for use with a PICAXE project (same project as a while ago with the avago mouse sensor). It's a cool little thing, only 52x36 and very small, but that is what I want.

OLED:

I received it yesterday and all was going swimmingly until I took a closer look than I previously had, at the 16v power requirement.
I'd been banking on using an LM2577, which again, I've already bought. My proposed power train was: 7.4v li-poly feeding one step down regulator for logic circuit (2.8v) and one step up regulator for the OLED "drive" (16v).

The problem is this line in the bigger datasheet which I'd overlooked:
The VCC [16v] must be float, when it is not active, to conform to the required power ON/OFF sequences. This can be achieved with a relay or true shut down charge pump.
The manufacturers recommend using a "MAX8574EUT+T" regulator since it leaves the output floating when in shutdown mode. They even provide a prototyping circuit with it for about £8 which is a bit steep, but fair enough. But the delivery is friggin £12 from mouser! For something that'll probably only cost about £1 to send!

CPC on the other hand offer free delivery on anything placed online. You order one SMD cap today, you pay £0.60, you get it tomorrow. You realise you needed two, you buy another - wonderful.

So the question is, can we come up with a 16v power supply that can be switched to a floating state by the PICAXE, using parts from CPC?

Options I've thought of so far:
  • Relay, as suggested in datasheet, to switch my LM2577. Two issues with this: 1) space, it would need to be a pretty small relay as the circuits are fitting in very small spaces. There's room for surface mount components, but nothing too tall. 2) Doesn't seem like a very elegant solution. To meet the power-on requirements, it would need to be normally off, so the coil would need a constant current to keep it on when in use. The battery is small so this would wear it out quite quickly. To solve that, it would need to be bi-stable, which would require more driver transistors, another PICAXE pin (I think?) and probably a bigger relay. A relay also just kind-of seems like overkill for what is needed - surely there's a better solution?
  • Any other true shutdown regulators? I've looked on CPC and there are a few step up switching regulators that offer shutdown, but none say how the output is treated during shutdown. Does anyone know of a switching regulator with true shutdown, like the MAX8574EUT+T, but that can be bought for less that £12 in UK?
  • Can my LM2577 be switched off in any other way? Using an FET to drive it for example? This is where my lousy circuitry knowledge becomes obvious.
  • Are there any other options?

As for the OLED itself. It's a great little module. Would have been £60.74 if I'd bought the prototype power supply board from mouser at the same time. I managed to get it working with spimode11e and have already got it displaying stuff. I'm having some difficulties with the SPI commands but I think this may be sorted with a more proper power supply. I'm pulling out the driver wire when necessary.

Thanks in advance!

David
 

hippy

Technical Support
Staff member
A Google search for the IS-CHPMP charge pump assembly seems to suggest it is available from a number of sources and perhaps with cheaper delivery options than Mouser.
 

alband

Senior Member
Unfortunately, I can't find any that are any cheaper. "IS-CHPMP" brings several results from the US, "IS-CHPMP UK" is more useful, however, the shipping charges for the results are £12 minimum shipping for mouser and digikey, and £18 minimum for future electronics.
Those are the only suppliers I can find, other than alibaba.
 

elanman99

Senior Member
I have not read all the specs and datsheet in detail but I'm not sure what the 'float' requirements are. At first I thought they were suggesting an isolated (free from ground) supply but it seems the requirement is to fully isolate the pin from the supply. Could this not be done just with a series transistor?

What I do like is the positive spin they put on the pixel aging process!

I seems they don't degrade with use, but just just 'acquire diminished brightness' (Note 8 of the Handling Details)

Ian
 

alband

Senior Member
Regarding the life expectancy:
OLED technology is progressing in fast pace. We anticipate increasing the OLED life to 30,000 hrs in 2010 and 50,000 hrs by end of 2012. The initialization value may change with the future revisions of the product however all other design parameters stay the same.
It being 2014 and no mention of any improvements to this module, my hope for this is somewhat diminished.

Yeah, I'm not too certain what they want for 'float' either (other than people to buy their own prototype board). To collate all I've found about the VCC requirement:

Abs Max: 0.0V to +19.0V
Recommended: 15.0V - 17.0V
Bottom of page 5 of shorter pdf: Power ON/OFF Sequence diagram. This indicates a minimum of a whole 3us between logic supply being applied and VCC (drive) being supplied. It also indicates VCC must turn off before VDD (logic supply) during power off sequence.
Page 4 of longer pdf:
3. VCC (16V) Requirement
The VCC must be float, when it is not active, to conform to the required power ON/OFF sequences. This can be achieved with a relay or true shut down charge pump.
Care must be taken in the design so upon power up the VCC is not activated. For your convenience in prototype stages we have made a charge pump. It provides more than 20mA at 16V output from 2.4V to 5.5V input. It has shut down pin to activate/disable. It provides enough current for up to four modules.
The charge pump part number is IS-CHPMP.
Page 5 of longer pdf:
Initialization procedure upon power up for OLED switch (64x48) and OLED display (52x36)
1. By design VCC should be disabled upon power up.
2. The Reset pin should be set to low for 3 μs and then set to high.
3. Enable VCC.
Page 12:
Following procedure needs to be followed for turning off the OLED.
1. Transmit the command to turn off the OLED display. Transmit AEH Display off
2. Disable the VCC.
3. Turn off the VDD power.
...so I'm going to need brown out detection if I want any hope of just turning it off!
Last page:
Does the power up/down sequence have to be followed?
Yes. The power up sequence must be observed. If VCC powers the circuit before VDD is activated the circuit could latch and damage the OLED. For the power down sequence VCC can not be present after VDD is off. Simultaneous turn off is possible as long as VCC is examined to confirm that it does not have too much capacitance charge after turn off.
Taken from the MAX8574EUT+T datasheet, page 5:
OUT: Output. The output voltage is present to 15V. Connect a 1μF ceramic capacitor from OUT to GND. In shutdown, OUT is pulled to GND by an internal 7.5MΩ resistor.
Does that help?
SW: Isolation Switch Output. Internally connected to the drain of a p-channel MOSFET used to isolate the output from the input during shutdown. Connect a 4.7μF ceramic capacitor from SW to GND. If True Shutdown is not required, SW can be left open with the input supply connected directly to the inductor.
Or that?
Top diagram on page 6 may also be useful.
From page 7:
Shutdown (SHDN)
Drive SHDN low to enter shutdown. During shutdown the supply current drops to 0.05μA (typ), the output is disconnected from the input, and LX enters a high impedance state. The capacitance and load at the output determine the rate at which VOUT decays. SHDN can be pulled as high as 6V regardless of the input and output voltages.
...
The MAX8570 family features True-Shutdown mode, disconnecting the output from the input with an internal pchannel MOSFET switch when shut down.
That's all the info I can find. Does it sound like the OLED VCC could be driven through a transistor of FET, allowing it to be switched?

Thanks for the help thus far,

David.
 

Goeytex

Senior Member
The attached circuit should work.

To turn power on to the display >>>> Low b.5
To turn power off ( float) >>>>>>>> Input b.5

Note: I looked at at the datasheet and it seems the Vcc supply current requirement is minimal. Therefore the base resistor in the attached circuit can be
increased to 4K7 or even higher.
 

Attachments

Last edited:

alband

Senior Member
Fantastic! Looks like just the kind of thing I'm after. Is the 2N2907 specific, or will any general purpose PNP do? Thanks for the hint about the resistor :)
 

Goeytex

Senior Member
Any GP PnP will do.

The OLED datasheet does not show placing a capacitor for the 16V Vcc near the module. So unless there is a problem I would not put one there. If a capacitor is placed there or IF there is a capacitor there internal to the module, when Vcc is removed the capacitor will discharge and could discharge through the transistor placing 16V on the Picaxe I/0 pin. The Picaxe internal ESD diodes should clamp this to 5v , but the clamping effect is enhanced by some series resistance. This is why the base resistor should be as high as possible and still allow > 16V @ 20ma to be supplied to the OLED module.

Assuming a minimum gain of 50, a 10K resistor should work fine with only about 70mv dropped across the transistor. So try a 10K first.
 
Last edited:

alband

Senior Member
Brilliant, I'll go try that now. The ".tran 10m" doesn't mean anything does it? Thank again Goeytex
 

Goeytex

Senior Member
I used LTSPICE to model and simulate the circuit. The "tran 10m" tells SPICE to do a transient analysis of the circuit for 10ms.
 

alband

Senior Member
Ah ok, just wanted to make sure I wasn't making a mistake.

I'm having some trouble though...

Using a BC327, which I believe should do. I'm fairly certain I've got it connected correctly. With flat-side facing me, I have left (C) connected to OLED, middle (B) connected to 10k then to PICAXE (pin A.3 leg 5 on 28X2) and right (E) connected to power source.

I've not connected the OLED to it just yet, so the collector is floating. I'm measuring the collector with the multimeter. The trouble is, I'm only getting 16v from it, whatever I do. Here is my code:
Code:
SYMBOL SS = C.0
SYMBOL RES = C.1
SYMBOL DC = C.2
SYMBOL LED = C.7
SYMBOL Vcc = A.3

input Vcc
low RES
hspisetup spimode11e, spifast

setup:
	pause 10
	high RES
	pause 5000
	low Vcc
	high LED
	pause 5000
	input Vcc
	low LED
	pause 5000
	end
It should just turn the Vcc supply on and off one, with an LED showing its state. But I'm just getting continuous 16V. I've also tried replacing "input" commands with "high". No difference. I believe A.3 should be ok as an input. Any ideas?
I want to be reasonably sure before I connect the OLED since it cost £50.

Cheers,
David
 

Goeytex

Senior Member
The transistor needs a load, otherwise you measure leakage voltage. So for testing place a 200 ohm resistor between the collector & ground.
 

Goeytex

Senior Member
I made a mistake in the first diagram. The Picaxe cannot directly drive the PNP. See the diagram below. Tested to work on the bench here. This is the circuit I use to sequentially power up RF modules and various displays.

FYI, The Emitter and Collector are reversed on the BC series transistors compared to 2N2907 / 2N3904
 

Attachments

Last edited:

hippy

Technical Support
Staff member
The transistor needs a load, otherwise you measure leakage voltage. So for testing place a 200 ohm resistor between the collector & ground.
Perhaps I am not understanding something, but it seems the need is to produce a supply which can be entirely isolated ( "floating" ), no leakage voltages or currents ?
 

Goeytex

Senior Member
Does a Picaxe pin really "float"? Or what does float really mean? The floating Picaxe pin has a very high impedance (on the order of mega ohms) and leakage current can be measured as a high impedance DVM connected to the floating pin will measure a voltage ( leakage). The collector of the PNP will have a very high impedance, similar to the "floating" Picaxe pin. The leakage current will be very very small. Something like 16 picoamps. If this is enough to adversely effect the power up / power off of the module the to the point that it will not operate, then i would suggest that the module is very poorly designed. I suspect it will work just fine. In any case, there is no chance that 16 picoamps will do any harm.

What you quoted above was my comment regarding leaving the output of the PNP "floating" when attempting to measure the on/off voltage while testing the circuit. The module will supply the "load" when in circuit.

If "float" means absolutely no leakage ( absolute open circuit) then the only good solution would be something like a 1 Form A reed relay.

http://www.mouser.com/ProductDetail/Hamlin/HE721A0510/?qs=sGAEpiMZZMv4tz1TW/ArE8fLXcOxkjuWnjVGOdil4a8=
 
Last edited:

alband

Senior Member
It looks like it does boil down to what the OLED actually needs, and it doesn't seem to want to tell us. However, we do know that the MAX8574 DOES give it what it needs. I've attached a schematic of the MAX8574 internal circuit with the typical application circuitry tacked on. I've also labelled and relabelled it a bit for clarity. It's all taken from page 7 of the datasheet for reference though. Is it possible from that diagram to deduce what the actual state of the output from the MAX is during shutdown, and therefore what we need to achieve?

My analogue circuitry knowledge is poor so this may be utter rubbish...
"SW and LX" seem to be the pins actually creating the output, I don't think FB is providing any power. So the way the MAX treats those internally is having each connected to the drain of a FET. Taken from the datasheet, during shutdown:
LX enters a high impedance state
[SW is] internally connected to the drain of a p-channel MOSFET used to isolate the output from the input.
So perhaps could something similar be created externally? For example using an n-channel FET with source connected to my regulator, and drain to the OLED? Maybe add another FET going from the power supply to GND to be turned on during "shutdown"?

Thanks for the continued efforts
 

Attachments

JimPerry

Senior Member
What you quoted above was my comment regarding leaving the output of the PNP "floating" when attempting to measure the on/off voltage while testing the circuit. The module will supply the "load" when in circiut.

If "float" means absolutely no leakage ( absolute open circuit) then the only good solution would be something like a 1 Form A reed relay.

http://www.mouser.com/ProductDetail/Hamlin/HE721A0510/?qs=sGAEpiMZZMv4tz1TW/ArE8fLXcOxkjuWnjVGOdil4a8=
Available in UK http://spiratronics.com/dil-reed-relay-5v.html delivery is only £1.45 for any order :confused:
 

alband

Senior Member
Re-writing this post as I made a programming mistake:

I'm trying your second circuit Goeytex. I'm still having trouble but I really don't know what's going on.

I'm using a 10k resistor instead of the OLED load (not 200 because my resistors are only 1/4W). I'm still using a BC327 instead of the 2N2907. I've actually got a 2N3904 for the NPN.

With the 2N3904 as the NPN, I get no voltage for the OLED, only voltage spikes when powering the whole circuit up/down. I had the 2N3904 the wrong way round at one point, so decided to try another NPN in case I blew it. Trying with a 2N2222a I get constant 16V.

With both transistors, there's no change in voltage at the collector of Q2 (NPN). That presumably means the switching just isn't happening for some reason? e.g. PICAXE is failing to drive the NPN?
 
Last edited:

Goeytex

Senior Member
The manufacturers recommend using a "MAX8574EUT+T" regulator since it leaves the output floating when in shutdown mode.
The output voltage of the MAX8574 is set by using a voltage divider R1/R2.

If we select 20K for R2, for a 16V output the value of R1 will be 20K * (16/1.226) -1 or ~ 240K. Therefore the "impedance"
seen by the LED module will ~260K. The efective output of the MAX8474 is no longer "floating" as the LED module sees the 260K to ground.

Is seems to me that we may be misinterpreting the term "floating" in regard to the power supply reqirement. Clearly the MAX8574 circuit
will have significant impedance due to the resistors. It is only "floating" internally and floating in the same manner as the PNP transistor
in the circuit that I supplied.

The common NPN/PNP switch circuit that I posted will have less impedance than the MAX8574 circiut and will be closer to "floating" than
the MAX8574 circuit, In fact, it may be beneficial to place a 200K resistor from the PNP collector to ground as well as a small capacitor.
 

Goeytex

Senior Member
Remember, collector / emitter pins on the BC327 and the 2N3904 are opposite. With the 2N3904 pins pointing down and flat facing you, the emitter is on the left. With the BC327 the emitter is on the right.

If you continue to have problems. Take a photo of the breadboard ( neat wires please) and let us have a look. It is a simple circuit and should not be giving you this kind of trouble.
 

alband

Senior Member
Aha! Success, I think.

Using the 2N2222a, if I replace the "input" commands with "high" commands, it switches, providing 16V from the PNP. "low" or "input" commands make the output go down to 0v. As PICAXE pins default to inputs, this means that upon power-up of the whole device, there is no voltage until the program request it, which is what I need.

Ah... at this point I've noticed you changed the commands in your diagram Goeytex. I just didn't read them! What an idiot, sorry :eek:

It still doesn't work with the 2N3904, so would it be safe to assume, I've bust that particular transistor by putting it in the wrong way round?

My only question now is, should it be safe to connect it to my OLED? Using the 2N2222a, without the 10k load resistor, the output now seems to "float", in that it wobbles around just above 0v while switched off, so all would seem ok.

Are there any extra checks or safety measures I can take to try to ensure I don't bust my OLED?

Thanks again, David
 

alband

Senior Member
The output voltage of the MAX8574 is set by using a voltage divider R1/R2.

If we select 20K for R2, for a 16V output the value of R1 will be 20K * (16/1.226) -1 or ~ 240K. Therefore the "impedance"
seen by the LED module will ~260K. The efective output of the MAX8474 is no longer "floating" as the LED module sees the 260K to ground.

Is seems to me that we may be misinterpreting the term "floating" in regard to the power supply reqirement. Clearly the MAX8574 circuit
will have significant impedance due to the resistors. It is only "floating" internally and floating in the same manner as the PNP transistor
in the circuit that I supplied.

The common NPN/PNP switch circuit that I posted will have less impedance than the MAX8574 circiut and will be closer to "floating" than
the MAX8574 circuit, In fact, it may be beneficial to place a 200K resistor from the PNP collector to ground as well as a small capacitor.
That sounds good. Ceramic of electrolytic capacitor? And would about 1uf do?
 

alband

Senior Member
What's the capacitor for, may I ask? Will it not dampen the switching of the output, cause it to stay higher for longer? Will I therefore need to take this extra time into account in the programming to make sure the OLED power isn't on while the logic power isn't?
 

Goeytex

Senior Member
Try without the cap first. A 100nf cap would be for decoupling. Probably not necessary.

I think it's ok to test. The only things that might harm the display are over voltage or possibly reverse supply voltage .
 

hippy

Technical Support
Staff member
My only question now is, should it be safe to connect it to my OLED? Using the 2N2222a, without the 10k load resistor, the output now seems to "float", in that it wobbles around just above 0v while switched off, so all would seem ok.
I am not so sure that 0V is the same as "floating". Added: Are you actually reading 0V or just lack of current ?

One of the diagrams in the datasheet shows Vcc being (somewhat) raised once the display electronics is being powered before the external Vcc is applied. Would this "0V" affect things adversely ?

I don't know and it seems even the recommended Vcc driver may behave the same way, not be truly "floating", and only a relay would provide for that.

The key issue seems to be current into and/or out of Vcc when the electronics isn't powered but it's not well defined what the exact issue is and what needs to be avoided.
 

Goeytex

Senior Member
I am not so sure that 0V is the same as "floating". Added: Are you actually reading 0V or just lack of current ?
With the 10K test load removed there is not enough current to read much of anything considering the the impedance of the meter. .


One of the diagrams in the datasheet shows Vcc being (somewhat) raised once the display electronics is being powered before the external Vcc is applied. Would this "0V" affect things adversely ?
The data brief explains this raised voltage to be the result of ESD protection circuitry between Vdd & Vcc.
 

alband

Senior Member
With 200k resistor to ground:
Voltage: Spike when circuit is powered up/down. 0V when switched off with transistors.
Current: Spike when powered up/down. 0A when switched off with transistors.​

Without 200k resistor to ground:
Voltage: Spike when circuit is powered up/down. ~0.16V when switched off with transistors, varies.
Current: Larger spike when powered up/down. 0A when switched off with transistors.​

All measurements with multimeter with black cable on ground and red on collector of PNP. Red cable moved on multimeter to accommodate voltage/current measurements.

Added: I'm concerned about the voltage/current spikes. The meter didn't read anything over an amp with the 200k, but did without. Also, since they're so short, just because it didn't say "1A" doesn't mean there wasn't 1A briefly, does it? You are saying I should use the 200k in parallel with the OLED though, so we should only need to consider the smaller spikes?
 

Goeytex

Senior Member
You really need a scope to view voltage/current the spikes. If you are concerned about these, then add a 100nf capacitor from Vdd to ground and test again.

Consider that the LED module will provide about a 3K load. Any tests with no load are meaningless.

Consider also that the module has built in ESD protection.

However, if you are this paranoid about connecting the LED module, then I suggest you call the manufacturer for advise when they open in about an hour or so.

Phone: 480-991-0942
Fax: 480-998-1435
Toll Free: 877-2BUYNKK
(877-228-9655)

http://www.nkkswitches.com/ContactUs.aspx
 
Last edited:

alband

Senior Member
Ah, I see the need for the capacitor now. Need to go out but will test that when I get back. Once again, thanks for the help thus far! :)
 

Goeytex

Senior Member
Also, you have not given any information on the 16v supply. What is it ? Many supplies need a minimum load in order to regulate properly. I might suggest placing a 5 - 10K resistor from the emitter of the PNP to ground to put a minimum load on the regulator. This may or may not be needed depending upon what is being used as the 16v supply.
 

alband

Senior Member
The supply is an LM2577 switching regulator connected to a 7.4v li-poly. The regulator is actually one of these and although not identical, the circuit seems pretty similar to page 3 of this

I've tried adding a 0.1uf capacitor. I'm still seeing spikes (4v and 1A highest seen), though I've discovered these are present if I just connect the negative of the multimeter to the ground of my breadboard - the positive of the regulator is completely unconnected. These seems like it's something to do with capacitances in the multimeter doesn't it? Whatever it is, I don't understand it, but it seems like the spikes I'm seeing on the multimeter can't be relied upon. Like you say, this is an oscilloscope's job.

One thing of not is that an LED connected where the OLED would be does not flash when the circuit is powered up/down. I don't know if that would be enough indication of safety? (I made sure 16v didn't go through the LED!)
 

Goeytex

Senior Member
One thing of not is that an LED connected where the OLED would be does not flash when the circuit is powered up/down. I don't know if that would be enough indication of safety? (I made sure 16v didn't go through the LED!)
I am not sure what you are hoping to accomplish here. Seems to me that you would want to put a something like a 2K resistor in series with the test LED and see that the LED flashes when you toggle the Picaxe I/0 pin.

It also seems to me that you are having a dilemma.

1. The test equipment yo have is inadequate to see "spikes" that may or may not exist. I suspect they do not.
2. You have a rather expensive module that you do not want to damage. Quite Understandable
3. You do not trust that the circuit I provided is "safe". (Common circuit used in millions of applications.)
4. The power supply is a cheapo from Ebay. (Unable to view output with a scope.)
5. You are therefore afraid to connect the OLED module.

I am afraid I cannot offer you any more at this point than to get a good scope and verify, or contact the manufacturer for advise.
 

alband

Senior Member
I suppose you're right, it is a dilemma.

So, I just tried it, and it works! Happy days :)

Thanks for the circuit then, I'll be buying SMT versions of the transistors some time soon. Now I just need to figure out how the heck to program this thing.

I'm facing two problems:

1. AFAIK, if I want to change a given number of pixels' colour, I need to send the data for all those pixels in one PICAXE command. So to change just one row is:
Code:
pixel = %00011000
hspiout (pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel... x104
2. The pixels are meant to be in the form of: "BBBBBGGGGGGRRRRR". So "%1111100000000000 would be bright blue. However, it's behaving more like "BBBRRGGG". I think it's somehow stuck in 256 colour mode, but the initialisation settings should be putting it in 65536 colour mode. Also, in 256 colour mode, it should be "BBBGGGRR" - so the green and red seem to be the wrong way round. I think this could be because each pixel needs two bytes and hspiout sends on a one-byte-at-a-time basis? Is that right?

Anyway, programming issues are more up my street (trust me, I have loads!) so I'll work at this for a bit. Here's my code if anyone fancies lending a hand, or indeed has this OLED and needs something to work from (god forbid!).

Thanks all again :)

Code:
SYMBOL SS = C.0
SYMBOL RES = C.1
SYMBOL DC = C.2
SYMBOL LED = C.7
SYMBOL Vcc = B.0
symbol pixel = w0
symbol pdata = w1
symbol row1 = w2
symbol row2 = w3
symbol col1 = w4
symbol col2 = w5
symbol row = w6
symbol black = %00000000
symbol red = %00011000
symbol blue = %11100000
symbol green = %00000111

input Vcc
low RES
setfreq m16
hspisetup spimode11e, spifast

setup:
	pause 10
	high RES
	gosub driveOn
	
	low SS
	low DC
	hspiout ($81,$0E)
	hspiout ($82,$13)
	hspiout ($83,$12)
	hspiout ($87,$0F)
	hspiout ($A0,$70)
	hspiout ($A1,$00)
	hspiout ($A2,$1C)
	hspiout ($A4)
	hspiout ($A8,$23)
	hspiout ($AB,$00,$0B,$08,$0F,$12)
	hspiout ($AD,$8E)
	hspiout ($B0,$0B)
	hspiout ($B1,$44)
	hspiout ($B3,$30)
	hspiout ($B9)
	hspiout ($BB,$12)
	hspiout ($BE,$3C)
	hspiout ($AF)
	high DC
	pixel = green
'	low DC
'	hspiout ($15,$2F,$2F)
'	hspiout ($75,$0C,$1C)
'	high DC
	
	goto repeat
	
repeat:
'	sertxd ("=========")

	for row1 = $00 TO $23
		low DC
		row2 = row1 + 1
'		sertxd (#row1,",",#row2,CR,LF)
		hspiout ($15,$16,$49)
		hspiout ($75,row1,row1)
		high DC
		hspiout (pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel,pixel)
'		pdata = 0
'		for pixel = 1 TO 1872
'			if pixel = 936 then
'				pdata = 256
'			end if
'		NEXT pixel
	NEXT row1
'	pause 1000
'	inc pixel
	goto repeat
	
driveOn:
		high Vcc
		high LED
		return
		
driveOff:
		input Vcc
		low LED
		return
 

alband

Senior Member
Ok, I've reached my limit of understanding and would appreciate some guidance :rolleyes:

I've narrowed down the two problems and will outline them afresh now: (wasn't sure weather to make this a new thread or not?)

1. The mapping for the colour for each pixel should either be "BBBBBGGGGGGRRRRR" or "BBBGGGRR" depending whether the OLED is in 8 or 16bit mode. So "red" would be "%0000000000011111" or "%00000011".
However, what I am actually experiencing is "BBB##GGG###RR###", where "#" means "don't care". So it seems to be 8bit spread over 16bit :confused: The datasheet doesn't go into any detail as to how 8bit mode would be done, but surely that wouldn't be how it works, given it has no benefit in needing to send less data. I'm also initialising the OLED in 16bit mode and don't see any reason why that shouldn't be getting through. Other commands I send are being received just fine, e.g. contrast settings, row/column positions etc.

2. The display is refreshing very slowly, much slower than it should be capable of. Currently, I can only set on half of the screen at a time using one long hspiout command. When the command is sent, its effect (say, setting pixels to green) "sweeps" across the screen from top left to bottom right. The interesting thing is, if I increase the PICAXE clock frequency, this is accordingly speed up - PICAXE 2x fast, screen takes 1/2 time. However, changing the spimode {spifast,spimedium,spislow} has no effect at all.
I'm currently running at either m16 or em32. With spifast at em16, the spiclock should be 4Mhz, so that's 500000 bytes per second. Setting half the OLEDs pixels requires 1872 bytes to be sent. At that speed, it should take 0.003744 seconds. So it should be able to do that >260 per second. As it stands, it visibly takes about 1/4 second for it to "sweep" across half the screen.

Another last thing - when sending hspiout commands, is it possible to send word variables? I've tried this and it just seems to lop off half the bits to make a byte.

This is my code with the last line lopped short, I doubt it would display well with it. Attached is full version:
Code:
SYMBOL SS = C.0
SYMBOL RES = C.1
SYMBOL DC = C.2
SYMBOL LED = C.7
SYMBOL Vcc = B.0
symbol pixel = b0
symbol pdata = w1
symbol row1 = w2
symbol row2 = w3
symbol col1 = w4
symbol col2 = w5
symbol row = w6
symbol black = %00000000
symbol red = %00011000
symbol blue = %11100000
symbol green = %00000111
symbol temp = b14

input Vcc
low RES
setfreq m16
hspisetup spimode11, spifast

setup:
	pause 10
	high RES			'reset OLED
	gosub driveOn		'turn on Vcc
	
	low SS			'spi chip select
	low DC			'set OLED to "command mode"
	hspiout ($81,$0E)
	hspiout ($82,$13)
	hspiout ($83,$12)
	hspiout ($87,$0F)
	hspiout ($A0,$70)		'$70 should set it to 16bit mode
	hspiout ($A1,$00)
	hspiout ($A2,$1C)
	hspiout ($A4)
	hspiout ($A8,$23)
	hspiout ($AB,$00,$0B,$08,$0F,$12)
	hspiout ($AD,$8E)
	hspiout ($B0,$0B)
	hspiout ($B1,$44)
	hspiout ($B3,$30)
	hspiout ($B9)
	hspiout ($BB,$12)
	hspiout ($BE,$21)
	hspiout ($AF)
	high DC
	goto repeat
	
repeat:
	do
		pixel = black		'choose a colour
		gosub clearHalfScreen	'set that colour
		pause 4000
		pixel = blue
		gosub clearHalfScreen
		pause 4000
		pixel = green
		gosub clearHalfScreen
		pause 4000
		pixel = red
		gosub clearHalfScreen
		pause 4000
		high DC
	loop
	
driveOn:
		high Vcc
		high LED
		return
		
driveOff:
		input Vcc
		low LED
		return
		
		
clearScreen:
		low DC
		hspiout ($15,$16,$49)	'sets window to full width
		hspiout ($75,$00,$11)	'and top half
		high DC
		gosub clearHalfScreen	'sets that window
		low DC
		hspiout ($15,$16,$49)	'sets window to full width
		hspiout ($75,$12,$23)	'and bottom half
		high DC
		gosub clearHalfScreen	'sets that window
		return
		
clearHalfScreen:	'pixel * 1872
		hspiout (pixel,pixel,pixel,pixel,pixel,pixel...
		return
Thanks all :)


EDIT: above and attached code is wrong, see post 36 for amended version!
 

Attachments

Last edited:

hippy

Technical Support
Staff member
Another last thing - when sending hspiout commands, is it possible to send word variables? I've tried this and it just seems to lop off half the bits to make a byte.
That is correct; HSPIOUT only sends 8-bit values. A word can however be sent as two bytes, for example to send the 16 bits in 'w0' ...

HSpiOut ( b1, b0 )

So basically you need to make your 'pixel' variable a word variable and then send its two component parts ...

Code:
Symbol pixel     = w0 ; b1:b0
Symbol pixel.lsb = b0
Symbol pixel.msb = b1

;        BBBBBGGGGGGRRRRR
pixel = %1111100000000000

HSpiOut ( pixel.msb, pixel.lsb )
Your current scheme, sending the 'pixel' byte variable twice, is probably mangling the colours you are intending to set.
 

alband

Senior Member
That's a minor inconvenience about hspiout, but easy to get around as you show. However, I'm fairly certain it is reading the data wrong given the tests I've done. I have a feeling the data is going in alright, then for some reason it's being re-mapped in a weird way which is slowing it down. I'll try some more tests later today and clarify.

I've been doing some stuff with the built in graphics commands. Currently, I can make a 3x3 red dot move around on the screen using a POT with an excellent refresh rate - it's totally smooth. Using the built in graphics commands looks a lot more fruitful than trying to send a whole image at a time. I do however think it may also be possible to send a whole image using a for...loop instead of one huge hspiout command. Again, need to do some further testing.

For the moment though, I've realised much of the code in my previous post was wrong, so I'll edit it and attach an amended version here.

Cheers

View attachment OLED colour changer.bas
 

hippy

Technical Support
Staff member
It may be worth simply moving to 8-bit / 256 colour mode unless you have some specific need for 16-bit colour. Not only will that be much easier to handle you will be sending half as much data so that should also halve your update times.
 

alband

Senior Member
Switching to 256 is certainly a good idea. I only need bright red anyway! I think I've got the 16bit colour working, though I'm not sure. It needs a little more work. I've found pixel data can definitely be sent in a loop though, instead of one huge spiout command. That actually makes this OLED PICAXEable. It's still slow with a loop though, so the graphics commands are what I'll use. I'll post some code when it's more complete/neat.

Now that I'm confident on this OLED being usable in my design, I'm focusing on the circuitry for the rest of it. I mentioned this is geared towards a project that uses a mouse sensor, relating to this thread. Btw, apologies Hippy if that "Ummmm, I got it working though." was a bit dismissive. I think I confused matters saying the chip had a normal SPI interface, by which I meant the serial protocol, not the wiring. I think I understand now that a normal SPI interface has in/out on different wires, whereas that chip shared them. Anyway, I always appreciate your input!

I was planning on using that Avago chip (which Haku kindly donated!) with this OLED. However, in trying to figure out the circuitry this afternoon, I found two humdingers of problems. 1) The sensor is 5V so would require yet ANNOTHER switching regulator in an already cramped circuit. 2) The SPI interface doesn't have a chip-select pin so can't be used with other devices on the same SPI bus (right?).

After an afternoon of annoyed googling for solutions, I've thankfully managed to find a similar Avago part which is a) 3.3V, b) has a chip-select pin, c) has separate SPI in/out pins, d) has fewer external components :D There's also one on eBay! It's in Shenzhen, so will take a month or so to arrive, but (I think) I can wait. Given the price and otherwise stark availability, I'll have to.

TL,DR: The question is now, how far can an SPI interface be stretched? I'm going to need that mouse sensor sort of on the end of a cable. It only needs to be about 10cm long max, but still SPI is intended for short range coms. To have that sensor "a-la-stalk", I would need 7 wires running down the 10cm "stalk". So would SPI be able to stretch that distance? If so, what kind of shielding would the wires (presumably) need?

Thanks again for all inputs. I hope I can produce a reasonably useful chunk of code for use with this OLED for others' use.
David
 

alband

Senior Member
One other thing regarding that power circuit with the two transistors. I've found a surface mount version of the 2222a but can't find any SMT versions of the PNP transistors we were looking at. Would this transistor do the job? It's got a lower Collector Emitter Voltage Vces than the 2N2907 at 330mV compared to 400mV but perhaps more importantly, the DC Collector Current is -1.5A compared to 800mA of the BC327. Is that just a mistake and should be 1.5A?

Cheers,
David
 

Goeytex

Senior Member
It will probably work just fine. However, you don't really need a 1.5 amp transistor to supply < 20ma. Just about any General Purpose PNP will do. I would think that a BC857 should be available in S0T22 or SC70.

When I do a parametric search on the site you linked to as well as on FARNELL, I see quite a few SMT options with a collector/ emitter current ratings from 100ma to 500ma.

BC807, BC857,MMBT3906, PMBT4403, etc .... and a lot cheaper than the FMMT720
 
Last edited:
Top