Jump to content

Little help with setting up an OLED


Altitude

Recommended Posts

This pinning/connection schema is the same as usual, but omit pins 3, 15 and 16. However, the 6582 apparently runs the display in 4-bit mode so you can also omit pins 7-10 if you run the display with 4-bit mode code.

Hawkeye posted a 4-bit VFD driver that can be hacked into getting the Newhaven to behave. I got sidetracked on this during the server move and holidays, but I intend to post my code as soon as work begins anew and I can get back to this topic.

/J

Link to comment
Share on other sites

I know the troubles, had a Newhaven clone (Electronic Assembly) for some time (until it burned on me for no reason) - it stayed nicely black after wiring - then after a few hours of hacking, I managed to get nice (oled ftw) but still garbage output, it looked like it was expecting 8-bit input, but the MB6582 is wired only for 4-bit mode, init failure so to say...

Methinks, that the state, jojjelito is in currently in with his driver adaptation is similar - if you want to try your codes, you can use VFD driver as a base (4-bit access) or wait for him to shed light on some yet dark areas :-).

As another alternative, after a talk with Wilba, he told me, that it is possible to alter the MB6582 to use 8 display data lines - in that case, I´d expect the "garbage" display driver to work - ask Wilba for moar info. Why and how that works, is out of my understanding though (aren´t those 4 lines used anywhere else on the MB6582?).

Wilba, did you manage to get your OLED up and running (the Electronic Assembly one)?

Greets,

Peter

Edited by Hawkeye
Link to comment
Share on other sites

Hope I didn´t miss anything:

a) checkout - use subversion to checkout the latest mios8 sources

b) toolchain - manage to compile your own midibox sid -> and test upload mb6582.hex to your first core.

c) replace app_lcd.inc in mb6582 directory with your new version (e.g. the downloaded one from my thread)

d) adjust main.inc to use custom display type 7, i think.

e) adjust makefile to include app_lcd .inc

f) test with garbage instructions in new app_lcd.inc, if it is compiled (compiler should be annoyed)

g) adjust initialization code in app_lcd.inc

h) compile new version

i) upload to first core

Edited by Hawkeye
  • Like 1
Link to comment
Share on other sites

  • 6 months later...

Ok, I am back on this.

I tried Hawkeye's VFD driver and unless I am doing something wrong when making the hex, it does not seem to work (black screen)

I simply replaced the app_lcd.inc file in the SRC folder and built the app. I did verify it was reading the file like suggested above by just putting garbage in the file. Any steps I missed here? I could not find where to set the custom LCD in the main.inc. I did not include that file in the makefile either. If anyone would like to point out any errors in my ways here, please feel free since I am clueless on how to perform steps d-g above.

After some searching, I did find this site which addresses the initialization commands for my specific display: http://www.elcojacobs.com/controlling-an-oled-character-display-with-arduino/ its for arduino, but I figured someone who understands the commands might find it useful.

Edited by Altitude
Link to comment
Share on other sites

Hiya!

Hawkeye's VFD driver does some 4bit magic. I tweaked it to use a more Newhaven-centric display init in the main SID app, but I missed out on the fact that there's display init also done in the bootloader!

I assume you use the Newhaven 4x20 OLED .

Currently I'm tied up with my modular, but it would be fun to get this display business done. Maybe the Newhaven requires less tweaking if we re-jig it to use 8 bits instead. I remember looking the display PCB and the PDF and shaking my head, at the time I trouble correlating the actual board with what is described in the manual... Better look again.

/J

Link to comment
Share on other sites

I need to refresh my memory, but here's from my app_led.inc from when I was on it. Not sure if it's the latest, we need to cross-check this against the data sheet again:



USER_LCD_Init

	;; notify that no graphical LCD is connected

	bcf	MIOS_BOX_CFG0, MIOS_BOX_CFG0_USE_GLCD


	; (Initialization of Ports: done in Init_Ports)

	SET_BSR	USER_LCD_STATUS

	clrf	USER_LCD_STATUS, BANKED


	movlw	100			; 100 ms delay

	call	MIOS_Delay


        bcf     USER_LCD_LAT_RW, USER_LCD_PIN_RW	; LCD_WRITE

        bcf     USER_LCD_LAT_RS, USER_LCD_PIN_RS	; USER_LCD_PIN_RS_0


	;; initialize LCD

	movlw	0x3

	movwf	USER_LCD_LAT_D

	rcall	USER_LCD_Strobe_Set

        movlw	10			; 10 ms delay

	call	MIOS_Delay

	rcall	USER_LCD_Strobe_Clr

        movlw	10			; 10 ms delay

	call	MIOS_Delay


	movlw	0x3

	movwf	USER_LCD_LAT_D

	rcall	USER_LCD_Strobe_Set

        movlw	10			; 10 ms delay

	call	MIOS_Delay

	rcall	USER_LCD_Strobe_Clr

        movlw	10			; 10 ms delay

	call	MIOS_Delay


	movlw	0x3

	movwf	USER_LCD_LAT_D

	rcall	USER_LCD_Strobe_Set

        movlw	10			; 10 ms delay

	call	MIOS_Delay

	rcall	USER_LCD_Strobe_Clr

        movlw	10			; 10 ms delay

	call	MIOS_Delay


	movlw	0x2

	movwf	USER_LCD_LAT_D

	rcall	USER_LCD_Strobe_Set

        movlw	10			; 10 ms delay

	call	MIOS_Delay

	rcall	USER_LCD_Strobe_Clr

        movlw	10			; 10 ms delay

	call	MIOS_Delay


        movlw	50			; 50 ms delay

	call	MIOS_Delay


	movlw	0x2B			; Function set		

	rcall	USER_LCD_Cmd

	movlw	0x08			; Display Off		

	rcall	USER_LCD_Cmd

	movlw	0x01			; Display Clear

	rcall   USER_LCD_Cmd

	movlw	0x06			; Entry Mode Set to Auto Increment

	rcall   USER_LCD_Cmd

	movlw	0x02			; Home Command

	rcall   USER_LCD_Cmd

	movlw	0x0C			; Display ON

	rcall   USER_LCD_Cmd


	movlw	0x00			; set cursor to zero pos

	rgoto	USER_LCD_CursorSet


Link to comment
Share on other sites

one thing I noticed looking at the guy who ran in on the arduino was that all his delays we much longer than your values, maybe thats the issue?

I like the run in 8 bit mode idea though.. The MB6582 board is provisioned for it but I'll need to dig through the documentation and see if I can figure it out since I dont know anyone who's done it

Link to comment
Share on other sites

Ahh. Think I got my delays from the datasheet, but that don't mean that they suffice whistle.png

I wonder if it's not easier to grok how to modify the OLED board jumpers to make it run in a more sane 8-bits? If we're lucky we don't have to mess around with the init that much if it's similar enough to a HD44780...

Link to comment
Share on other sites

Where are the jumpers? Am I missing something that obvious? It should be perfectly compatible with the HD44780, I use the 16x2 ones in the shruthis i build and they work perfectly without any modification, its just a drop in for the LED backlit ones

Edited by Altitude
Link to comment
Share on other sites

Had a nice talk with Wilba about that last year - you can reconfigure/bridge the MB6582 baseboard to allow 8-bit display connectivity - then (he said) the OLED might work right out of the box - how it is done, he must explain to you (would be nice to document it somewhere :).

Many greets!

Peter

Link to comment
Share on other sites

Oh, cool!

I'm not 100% sure this was my latest or greatest, I found it in a working directory in my lab PC at work. It looked familiar enough, but it's possible I went ahead and changed more stuff in my compile/source dir. I'll take a gander at this vs the data sheet later tonight.

Link to comment
Share on other sites

Sheesh!

The code I posted is deffo something unfinished: I looked at pp21 in the Newhaven datasheet:

For 4bit display init, I think that all the funky business with


movlw   0x3

        movwf   USER_LCD_LAT_D

        rcall   USER_LCD_Strobe_Set

        movlw   10                      ; 10 ms delay

        call    MIOS_Delay

        rcall   USER_LCD_Strobe_Clr

        movlw   10                      ; 10 ms delay

        call    MIOS_Delay
plus the 50ms wait need to go away. The datasheet starts with Power on. Wait more than 1ms for power stablization. I dunno why all those other delays are there in the code, need to check with Hawkeye. Then we should send function set where:
[Function Set:

RS R/W DB7 DB6 DB5 DB4

0 0 0 0 1 0

0 0 0 0 1 0

0 0 1 0 X X

And then do some waiting for the busy flag.

Then on to display off. Busy flag wait.

Display clear. Wait for busy flag.

Entry mode set. Wait for busy flag.

Home command. Wait for busy flag.

Display on.

Let there be light!

Edited by jojjelito
Link to comment
Share on other sites

I'll try to e-mail you the entire thing when I'm back at work tomorrow. Basically all the init business is below the wait 50ms code in the above example. I'm not sure about all the waiting around before that though.

We should double-check the values I set, and make sure that Hawkeye's

USER_LCD_Cmd does it's thing correctly (i.e send 2x4bits plus wait for the busy flag).

/J

Link to comment
Share on other sites

  • 1 year later...

Tried this OLED with MBSID. With default driver it reboots after "Launching CS" message and characters looks like shifted 1 pixel. 

post-9659-0-55174500-1382982620_thumb.jp

 

There's 8-bit demo code with initialization example.

 

void LCD_initialize(void)
{
	 RES=0;
	 Delay(200);
	 RES=1;
	 Delay(200);

	 Write_Command(0x2a);  //RE=1
	 Write_Command(0x71);  //Function Selection A
	 Write_Data(0x00);	//Disable internal VDD
	 Write_Command(0x28);  //RE=0,IS=0
	 Write_Command(0x08);  //display OFF

	 Write_Command(0x2a);  //RE=1
	 Write_Command(0x79);  //SD=1  OLED command set is enabled
	 Write_Command(0xD5);  //Set Display Clock Divide Ratio/ Oscillator Frequency 
	 Write_Command(0x70);  
	 Write_Command(0x78);  //SD=0   OLED command set is disabled
	 Write_Command(0x08);  //5-dot font width, black/white inverting of cursor disable, 1-line or 2-line display mode
	 Write_Command(0x06);  //COM0 -> COM31  SEG99 -> SEG0,
	 Write_Command(0x72);  //Function Selection B. Select the character no. of character generator    Select character ROM
	 Write_Data(0x01);  //CGRAOM 248 COGRAM 8   Select  ROM A
	 Write_Command(0x2a);  //RE=1
	 Write_Command(0x79);  //SD=1  OLED command set is enabled
	 Write_Command(0xDA);  //Set SEG Pins Hardware Configuration  
	 Write_Command(0x10);  //Alternative (odd/even) SEG pin configuration, Disable SEG Left/Right remap
	 Write_Command(0xDC);  //Function Selection C  Set VSL & GPIO   
	 Write_Command(0x00);  //Internal VSL  represents GPIO pin HiZ, input disabled (always read as low)
	 Write_Command(0x81);  //Set Contrast Control   
	 Write_Command(0x8F);  
	 Write_Command(0xD9);  //Set Phase Length   
	 Write_Command(0xF1);  
	 Write_Command(0xDB);  //Set VCOMH Deselect Level (  
	 Write_Command(0x30);  //0.83 x VCC

	 Write_Command(0x78);  //SD=0   OLED command set is disabled

	 Write_Command(0x28);  //RE=0,IS=0
	 Write_Command(0x01);  //Clear Display
	 Write_Command(0x80);  //Set DDRAM Address

	 Delay(1000);
	 Write_Command(0x0C);  //Display ON

	 Write_CGRAM(font);


}

 

I tried with 8-bit connection (OLED's jumpers allows to switch interface modes) and edited clcs/app_lcd.inc so it's initialisation part look like this:

	;; initialize LCD

	movlw	0x2a			;
	rcall	USER_LCD_Cmd
	movlw	0x71			; 
	rcall	USER_LCD_Cmd

	movlw	0x0
	movwf	USER_LCD_LAT_D
	rcall	USER_LCD_Strobe_Set
	rcall	USER_LCD_Strobe_Clr
	movlw	50			; 50 ms delay
	call	MIOS_Delay
	rcall	USER_LCD_Strobe_Set
	rcall	USER_LCD_Strobe_Clr
	movlw	50			; 50 ms delay
	call	MIOS_Delay
	rcall	USER_LCD_Strobe_Set
	rcall	USER_LCD_Strobe_Clr

	movlw	0x28			; 
	rcall   USER_LCD_Cmd
        movlw	0x08			; 
	rcall   USER_LCD_Cmd
        movlw	0x2a			; 
	rcall   USER_LCD_Cmd
        movlw	0x79			; 
	rcall   USER_LCD_Cmd
        movlw	0xD5			; 
	rcall   USER_LCD_Cmd
        movlw	0x70			; 
	rcall   USER_LCD_Cmd
        movlw	0x78			; 
	rcall   USER_LCD_Cmd
        movlw	0x08			; 
	rcall   USER_LCD_Cmd
        movlw	0x06			; 
	rcall   USER_LCD_Cmd
        movlw	0x72			; 
	rcall   USER_LCD_Cmd

	movlw	0x0
	movwf	USER_LCD_LAT_D
	rcall	USER_LCD_Strobe_Set
        movlw	10			; 10 ms delay
	call	MIOS_Delay
	rcall	USER_LCD_Strobe_Clr
        movlw	10			; 10 ms delay
	call	MIOS_Delay

        movlw	0x2a			; 
	rcall   USER_LCD_Cmd
        movlw	0x79			; 
	rcall   USER_LCD_Cmd
        movlw	0xDA			; 
	rcall   USER_LCD_Cmd
        movlw	0x10			; 
	rcall   USER_LCD_Cmd
        movlw	0xDC			; 
	rcall   USER_LCD_Cmd
        movlw	0x00			; 
	rcall   USER_LCD_Cmd
        movlw	0x81			; 
	rcall   USER_LCD_Cmd
        movlw	0x8F			; 
	rcall   USER_LCD_Cmd
        movlw	0xD9			; 
	rcall   USER_LCD_Cmd
        movlw	0xF1			; 
	rcall   USER_LCD_Cmd
        movlw	0xDB			; 
	rcall   USER_LCD_Cmd
        movlw	0x30			; 
	rcall   USER_LCD_Cmd
        movlw	0x78			; 
	rcall   USER_LCD_Cmd
        movlw	0x28			; 
	rcall   USER_LCD_Cmd

	movlw	0x01			; Clear Display
	call	USER_LCD_Cmd
	bcf	MIOS_LCD_TIMEOUT1, 7, BANKED	; everything ok, make sure that LCD_TIMEOUT, bit 7 is cleared
	
	movlw	0x80			; without these lines the LCD will not work
	rcall	USER_LCD_Cmd		; correctly after a second USER_LCD_Init

        movlw	100			; 100 ms delay
	call	MIOS_Delay

	movlw	0x0c
	rcall	USER_LCD_Cmd
	movlw	0x00			; set cursor to zero pos
	rgoto	USER_LCD_CursorSet

 

 

- initialization ok, works with lcd7 example, characters ok, but when i compile MBSID with this driver - moving garbage on screen.

 

Than I tried to add initialisation sequence from demo code to Hawkeyes app_lcd.inc but no luck in 4-bit mode. Black screen with no signs of life.

Was my attempt correct and what should i try next?

Jojjelito, you say that there can be problems with USER_LCD_Cmd, could it be the cause of 4-bit mode fail?

 

 

Edited by Schrabikus
Link to comment
Share on other sites

based on what nILS said, it can be done but would need to major rework of the firmware since an extra pin would be needed to take the place of the one used for the CAN interface.  If I spoke better C, id do it since a 4x20 OLED for the MBSID would be really nice..

Edited by Altitude
Link to comment
Share on other sites

Little progress!

Found this: http://www.midibox.org/dokuwiki/doku.php?id=wilba_mb_6582

 

you can run in 8-bit mode by using two PIC pins from port E to replace the two PIC pins being used by the CAN bus. Solder those jumper pads on the bottom side, run the change device ID app to use custom LCD driver, the custom LCD driver file should already be in the source code of the MB-SID V2 application and compiled in. If you want to run other applications, you'll need to copy that custom LCD driver file into those source directories and rebuild those applications.

 

Reconnected D2, D3 OLED lines to J5 pins 1,2 according to mb6582 PCB

added my custom init sequence to app_lcd.inc in midibox_sid_v2/src

(it's USER_LCD_Data and USER_LCD_Cmd functions stores bits 3:2 into port E bits 2:1)

 

Now it loads, with some special character bugs and reboot every 30 seconds (can't figure out what causes it)

post-9659-0-78177600-1382975741_thumb.jp

post-9659-0-77106100-1382975926_thumb.pn

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...