Hello Don,
1)
Have you substituted an LCD for your VFD?
Don't have one; sent for 2 online yesterday 16x2 and 20x4, 5x7 dot matrix, arduino compatible.
-
The timing diagrams for your VFD are very similar to those of LCDs in terms of the signal sequence but the times are significantly different. At least one of the parameters specified on the VFD diagram does is not show up on the LCD diagrams.
I honestly don't see which one it is; I've compared each diagram and what I do see is that the LCD diagram gives the tEr and tEf (enable rise and fall times). I also see, as mentioned before, the tAS (address set up time) for the LCD is 40ns as compared to the 20ns, which I thought was the difference you were referring to.
Based strictly on the timing diagram for the vfd I have revised the two functions as follows, uploaded and nothing yet:
void lcdCommand( unsigned char cmnd )
{
LCD_DPRT = cmnd; // ready data lines
LCD_CPRT &= ~ (1<<LCD_RS); // RS low (ref.quiz:lower line on the timing diagram)to select the Instruction register.
LCD_CPRT &= ~ (1<<LCD_RW); // RW low to write instructions.
LCD_CPRT |= (1<<LCD_EN); // Enable pin high to latch data on the falling edge.
delay_us(.23); // Enable pin high for 230 ns to enable latching of instruction set.
LCD_CPRT &= ~ (1<<LCD_EN); // LCD_EN pin of PortB low after sending an instruction.
delay_us(.23); // Delay 230 ns between instructions sent.
}
//*******************************************************
void lcdData( unsigned char data )
{
LCD_DPRT = data; // ready data lines
LCD_CPRT |= (1<<LCD_RS); // RS pin high (ref.quiz:upper line on the timing diagram)to select the Data register.
LCD_CPRT &= ~ (1<<LCD_RW); // RW low to write instructions.
LCD_CPRT |= (1<<LCD_EN); // Enable pin set to latch data on the falling edge.
delay_us(.23); // Enable pin high for 230 ns to enable latching of data set.
LCD_CPRT &= ~ (1<<LCD_EN); // LCD_EN pin of PortB low after sending data byte.
delay_us(.23); // Delay 230 ns between instructions sent.
}
-
In any case your basic problem is that you still do not understand the relationship between whichever Timing Diagram you choose to follow and the code that you are attempting to use to implement that diagram. Specifically, you do not understand how the delays in the program relate to the information on the Timing diagram.
You are correct; I do not understand how exactly to implement the timing diagram for the device in terms of the delays required in the program. That's the reason why I came onto this forum for help in understanding how this is done in general so that I may simply do it on my own for any device when given the specifications sheet and it's timing diagrams, in addition to learning as much as can be garnered about every other aspect of successfully interfacing any microcontroller to any peripheral. I was given this task to do for quite some time now, and have tons of code variations for it, first with the PIC18F458, and when that fell through because of outmoded connection issues, now with the arduino uno.
-
You must compare those comments to the Timing Diagram that I used, the one for the VFD, for them to make any sense. After you do that you should be able to fix the errors that still exist and find out what is missing.
If I'm not mistaken, what could be missing (and which would replace the second delay), is with reference to these links:
-
LCD Tutorial for interfacing with Microcontrollers: Checking LCD busy flag - Rickey's World of Microcontrollers & Microprocessors):
?BF - the Busy Flag
The Busy Flag is a status indicator flag for LCD. When we send a command or data to the LCD for processing, this flag is set (i.e BF =1) and as soon as the instruction is executed successfully this flag is cleared (BF = 0). This is helpful in producing and exact ammount of delay. for the LCD processing.
To read Busy Flag, the condition RS = 0 and R/W = 1 must be met and The MSB of the LCD data bus (D7) act as busy flag. When BF = 1 means LCD is busy and will not accept next command or data and BF = 0 means LCD is ready for the next command or data to process
- http://www.8051projects.net/lcd-interfacing/busyflag.php:
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
#define LCD_DPRT PORTD // configuring PortD for data
#define LCD_DDDR DDRD
#define LCD_DPIN PIND
#define LCD_CPRT PORTB // utilizing PortB pins for the control.
#define LCD_CDDR DDRB
#define LCD_CPIN PINB
#define LCD_RS 0 // control pin assignments.
#define LCD_RW 1
#define LCD_EN 2
#define LCD_D7 3
//*******************************************************
void delay_us(unsigned int d)
{
_delay_us(d);
}
//*******************************************************
void LCD_busy()
{
DDRD = DDRD &= ~ (1<<LCD_D7); //Make D7th bit of LCD as input
DDRB = DDRB |= (1<<LCD_EN); //Make port pin as output
LCD_CPRT &= ~ (1<<LCD_RS); //Selected instruction register
LCD_CPRT |= (1<<LCD_RW); //We are reading
while(LCD_D7){ //read busy flag again and again till it becomes 0
LCD_CPRT &= ~ (1<<LCD_EN); //Enable H->L
LCD_CPRT |= (1<<LCD_EN);
}
}
//*******************************************************
void lcdCommand( unsigned char cmnd )
{
LCD_DPRT = cmnd; // ready data lines
LCD_CPRT &= ~ (1<<LCD_RS); // RS low (lower line on the timing diagram)to select the Instruction register.
LCD_CPRT &= ~ (1<<LCD_RW); // RW low to write instructions.
LCD_CPRT |= (1<<LCD_EN); // Enable pin high to latch data on the falling edge.
delay_us(.23); // Enable pin high for 230 ns to enable latching of instruction set.
LCD_CPRT &= ~ (1<<LCD_EN); // LCD_EN pin of PortB low after sending an instruction.
LCD_busy(); // Wait for LCD to process the instruction.
}
//*******************************************************
void lcdData( unsigned char data )
{
LCD_DPRT = data;
LCD_CPRT |= (1<<LCD_RS); // RS pin high (upper line on the timing diagram)to select the Data register.
LCD_CPRT &= ~ (1<<LCD_RW); // RW low to write instructions.
LCD_CPRT |= (1<<LCD_EN); // Enable pin set to latch data on the falling edge.
delay_us(.23); // Enable pin high for 230 ns to enable latching of data set.
LCD_CPRT &= ~ (1<<LCD_EN); // LCD_EN pin of PortB low after sending data byte.
LCD_busy(); // Wait for LCD to process the instruction.
}
This compiles but when uploaded, still nothing.
Dave.