Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic 18f458 to noritake VFD-model#: CU20045-UW5A

Status
Not open for further replies.

dvlee

Newbie level 3
Joined
Apr 17, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,378
Hi,
Got this program I've been working on for some time now to get a VFD (vacuum fluorescent display) to show the messages inputted by a computer or sensor readings. I'm having difficulty getting it to compile. I've altered it so many times, it's becoming a bit frustrating. Can someone help me out here? The last build, using MPLABV8.84, seems to suggest definition inconsistencies with the macros in the header files, but on checking, the formatting appears correct still the error messages. I'm also thinking equivalence in terms of an LCD and also in terms of the connections to this VFD which has a 14-pin connection.
Here's what I got. Thanks.


//3.4-LCD 04-tue17-12
// The following program requires the pic18f458 MCU to send to a noritake Vacuum Fluorescent Display (model:CU20045-UW5A)
// the basic "Hello World" character string.

#pragma config OSC = HS, OSCS = ON
#pragma config BORV = 45, PWRT = ON, BOR = ON
#pragma config WDT = ON
#pragma config DEBUG = ON, LVP = ON, STVR = ON

#include<p18f458.h>

#define TRISD // Output for PortD.
#define LATD
#define TRISBbits.TRISB0 // Output for pins B0-2, pin D7.
#define LATBbits.LATB0
#define TRISBbits.TRISB1
#define LATBbits.LATB1
#define TRISBbits.TRISB2
#define LATBbits.LATB2
#define TRISDbits.TRISD7
#define LATDbits.LATD7
#define LCD_data PORTD
#define LCD_rs PORTBbits.RB0
#define LCD_rw PORTBbits.RB1
#define LCD_en PORTBbits.RB2
#define LCD_D7 PORTDbits.RD7


void ms40();
void LCD_busy();
void LCD_init();
void LCD_senddata(unsigned char var);
void LCD_command(unsigned char var);
void LCD_sendstring(unsigned char *var);


void ms40()
{
int i;
for(i=0;i<9000;i++);
}

void LCD_busy()
{
LCD_D7 = 1; //Make D7th bit of LCD as i/p
LCD_en = 1; //Make port pin as o/p
LCD_rs = 0; //Selected command register
LCD_rw = 1; //We are reading

while(LCD_D7) //read busy flag again and again till it becomes 0
{
LCD_en = 0; //Enable H->L
LCD_en = 1;
}
}

void LCD_init()
{
LCD_data = 0x38; //Function set: 2 Line, 8-bit, 5x7 dots
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command

LCD_data = 0x0F; //Display on, Curson blinking command
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command

LCD_data = 0x01; //Clear LCD
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command

LCD_data = 0x06; //Entry mode, auto increment with no shift
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy();
}

void LCD_senddata(unsigned char var)
{
LCD_data = a; //Function set: 2 Line, 8-bit, 5x7 dots
LCD_rs = 1; //Selected data register
LCD_rw = 0; //We are writing
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
}

void LCD_command(unsigned char var)
{
LCD_data = var; //Function set: 2 Line, 8-bit, 5x7 dots
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in instruction register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
}

void LCD_sendstring(unsigned char *var)
{
while(*var) //till string ends
LCD_senddata(*var++); //send characters one by one

}


void main()
{
TRISD = 0b00000000;//PORT D, RB0-2, RD7 for output.
LATD = 1;
TRISBbits.TRISB0 = 0;
LATBbits.LATB0 = 1;
TRISBbits.TRISB1 = 0;
LATBbits.LATB1 = 1;
TRISBbits.TRISB2 = 0;
LATBbits.LATB2 = 1;
TRISDbits.TRISD7 = 0;
LATDbits.LATD7 = 1;

ms40();
LCD_init();
LCD_command(0x83);
LCD_sendstring('HELLO WORLD');

}
 

#define TRISD // Output for PortD.
#define LATD
#define TRISBbits.TRISB0 // Output for pins B0-2, pin D7.
#define LATBbits.LATB0
#define TRISBbits.TRISB1
#define LATBbits.LATB1
#define TRISBbits.TRISB2
#define LATBbits.LATB2
#define TRISDbits.TRISD7
#define LATDbits.LATD7

These statements do nothing?
All these bits are declared in the header file.
 
  • Like
Reactions: dvlee

    dvlee

    Points: 2
    Helpful Answer Positive Rating
To the person who took my query last time:

Good Morning. Did the transfer of the program to the MCU using the EPICWIN software for the CP-VIC V3 board I'm using. However, when the jumper connections were made from the VFD to the board pin header and the board powered up, nothing, even though I detect the required 5V on pin 2 of the VFD. Even adjusting the contrast control pot, still nothing from the display. If the hex file code works well for an LCD, assuming a one-to-one correspondence in terms of the number of pins for both, shouldn't the VFD come to life? Not sure where I'm going wrong here. Did the connections according to this schematic obtained from mikroelectronika:-- .

---------- Post added at 15:43 ---------- Previous post was at 15:40 ----------

...Oh forgot, the connections were not made exactly as shown in the schematic. Could not do that of course since the pins I used for the 4 bit communication (for now, although desiring 8 bit) are 0,1,2,7 of Port B. Did the connections using the data sheet for the VFD.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top