DOGM162 problems - Page 1
Forum section: electronics / general

author: TheWinterSnow
author_rank: Contributor
timestamp: May 07, 2015, 05:56:05 am
content: I purchased a DOGM162 with an Arduino Mega2560 some weeks ago. Because I was intending to write my code in C and since no readily available libraries fore the DOGM series exist I have had to write the code on my own. Unfortunately the code does not work, or rather, I can not get anything to display on the screen. I am using the 8-bit communication because I have enough pins in my project and the data sheet of the device has little information about 4 bit and SPI, at the moment I am trying to explore the science of the device and get it displaying simple text. I do not have a logic analyzer and I only have an analog O-scope so I can't see what my code is doing at the port level and I have been wrangling to get AVR studio to work because I can't get VS Shell to install (keeps giving me an error). I have no clue what it is doing and I have no clue if my code is working or if I don't have things connected right (which I am sure I do) or if my LCD is bunk.I would at least like to make sure my code is correct, can anyone look over it and see. I did the initialization based on the datasheet and it is supossed to set everything up inclusing a blinking cursor then I took it further and made it add the Character 'A' to the screen. When I plug everything up I get nothing.Code:#define F_CPU 16000000UL#include <stdio.h>#include <avr/io.h>#include <util/delay.h>#include <inttypes.h>uint8_t triggerHold = 10;uint8_t E = 0x04;// enable bit mask (0000 0100) bit 2uint8_t RS = 0x02;// RS bit mask (0000 0010) bit 1// Generates a pulse for the enable bitvoid clk(){PORTK ^= E;// Enable pin low_delay_ms(triggerHold);// Delay for some timePORTK ^= E;// Enable pin high_delay_ms(triggerHold);// Delay again for some time}// -----------------------------------------------------------------------------------------------// Function to initialize DOGM162 @ 5V operationvoid LCD_init(){/* =================* PORT K bit layout* =================** 0000 0001 (PIN 0) = R/W* 0000 0010 (PIN 1) = RS* 0000 0100 (PIN 2) = E**//* =================* Pin Definitions* =================** R/W:Low = WriteHigh = Read* RS:Low = CommandHigh = Data* E:Enable (falling edge)**//* =================* LCD Initilization* =================** -----------------------------------------------------------* Port Initialization commands given in the DOGM162 Datasheet* -----------------------------------------------------------** Port F is set to the command** Pin 2 @ PORTK sets enable bit low, clocking the data on POTTF* Delay holds the enable bit low for duration 'triggerHold'* Pin 2 @ PORTK sets enable bit high, followed by another short delay* Delays poll the MPU while the LCD is executing the command** Port F is set to next command* Rinse and Repeat**/// Function SetPORTF = 0x39;// PORTF = 0011 1001 (move to instruction table 1 (0,1))clk();// Bias SetPORTF = 0x1C;// PORTF = 0001 1100clk();// Power ControlPORTF = 0x52;// PORTF = 0101 0010clk();// Follower ControlPORTF = 0x69;// PORTF = 0110 1001 (follower on, amplfied ratio = x1 or unity)clk();// Contrast SetPORTF = 0x74;// PORTF = 0111 0100 (contrast set to 4)clk();;// Function SetPORTF = 0x38;// PORTF = 0011 1000 (move to instruction table 0 (0,0))clk();// Display OnPORTF = 0x0F;// PORTF = 0000 1111 (Display on, cursor on, cursor position on)clk();// Clear DisplayPORTF = 0x01;// PORTF = 0000 0001 (Clear display)clk();// Entry Mode SetPORTF = 0x06;// PORTF = 0000 0110 (I/D high, increment 1 position)clk();}// -----------------------------------------------------------------------------------------------// Writes data to LCDvoid LCD_write(){PORTF = 0x41;// ASCII for the character 'A'PORTK |= RS;// Set RS high to accept dataclk();PORTK &= ~RS;// Set RS low to accept commands}// ===============================================================================================// ===============================================================================================// main programint main(void){// initialize ports//PORT F handles 8-bit data line//PORT K handles E, RS and R/WDDRK = 0xFF;// Set PORT K to outputDDRF = 0xFF;// Set PORT F to outputPORTF = 0x00;// Set PORTFPORTK = E;// Set PORTK (enable pin high)// initialize LCDLCD_init();// write to LCDLCD_write();// infinite loop to keep MPU goingwhile(1){}return 0;}As you can see I like comments and it should be easily understandable.Here is the datasheet:http://www.lcd-module.com/eng/pdf/doma/dog-me.pdfAny pointers would be great, thanks.

author: picandmix
author_rank: Frequent Contributor
timestamp: May 07, 2015, 09:40:19 am
content: Not used that exact display but typically you have to set it up in a different way to a 'standard' lcd as shown here.http://www.sonsivri.to/forum/index.php?topic=11259.0To prove your hardware works, it migh be better to first use a C++ example from the Arduino forum, searching on EADOG 162 brings up several entries.http://forum.arduino.cc/index.php?topic=36891.0https://www.pjrc.com/teensy/td_libs_DogLcd.html

author: bobcat
author_rank: Regular Contributor
timestamp: May 07, 2015, 10:29:50 am
content: You can not use XOR to toggle the enable pin.QuoteYour function should look like this:void clk(){PORTK &= ~E; // Enable pin low_delay_ms(triggerHold); // Delay for some timePORTK |= E; // Enable pin high_delay_ms(triggerHold); // Delay again for some time}Also the PSB, CSB, R/W, RS, and RESET pins have to connected and driven correctly. It's all there in the data sheet.

author: TheWinterSnow
author_rank: Contributor
timestamp: May 08, 2015, 01:20:11 am
content: Yeah, I knew that either method would work, but it is probably better off leaving the enable low and setting/resetting instead of toggling.PSB, CSB RS and R/W were all properly hardwired to either 5v or GND based on the configuration.I moved over the the arduino platform and used a DogLcd library and it still isn't doing anything to the screen, so now I think I am troubleshooting if I have a dead LCD. I am making a shield for it to make sure I have solid connections. Did a quick PCB for it and already sent it off the the fab, will have to keep my fingers crossed.

author: picandmix
author_rank: Frequent Contributor
timestamp: May 08, 2015, 11:12:03 am
content: Found my old Dog 163 display, previously used with a Pic, and followed the Arduino wiring and software from this site, all works well, with either the 162 or 163 software.RS is controlled by the software.https://code.google.com/p/doglcd/

author: linux-works
author_rank: Super Contributor
timestamp: May 08, 2015, 05:30:27 pm
content: I bought some of those 'display on glass module' (that's what DOGM stands for, btw):I got mine to work but it was a long time ago. the teensy guy (paul) does have a library for it.I would not use all the wires I used (go for serial or 4bit at most) but the displays are actually kind of nice.if you can't get yours working, I may be able to find my old displays and try them again. it would be arduino based, though.