631
Vos projets et Montages d'Électronique / Re : boite decade de resitances
« le: Avril 07, 2017, 12:16:16 pm »
C'est quand même bien! Beau travail. La seule lecture douteuse est la 10000... 5% d'écart.
Le Forum est maintenant chiffré (préambule https). Bien sûr, des liens externes insérés dans les sujets vont demeurer inchangés. Mais la composition des pages du Forum est désormais sécurisée. Si des problèmes d'affichage surviennent, veillez à vider votre cache pour ce site.
// LCD Initialisation
send_cmd_lcd(FOUR_BIT_INIT); // Sets the interface to 4 bits. Must be sent first.
send_cmd_lcd(FOUR_BIT_INIT2); // Sets the interface to 4 bits, display to 2-lines, character size to 5x8. Must be sent second.
send_cmd_lcd(ENTRY_INC); // Set the character entry mode to cursor increment to the right
send_cmd_lcd(DDRAM_L1_C1); // Set the DDRAM address location
// transfer custom-made characters into CGRAM of display
// Right arrow character transfer into CGRAM
send_cmd_lcd(CGRAM_CHAR_1_ADDR); //Position the pointer to first CGRAM character line-1 address
for (i=0; i<=6; i++)
{
send_char_lcd(Arrow_rgt_Array[i]);
}
// Left arrow character transfer into CGRAM
send_cmd_lcd(CGRAM_CHAR_2_ADDR); //Position the pointer to second CGRAM character line-1 address
for (i=0; i<=6; i++)
{
send_char_lcd(Arrow_lft_Array[i]);
}
// Complete LCD Initialisation
send_cmd_lcd(CLR_DISP); // Clear display and bring cursor home
send_cmd_lcd(DISP_ON); // Turn on display
// Character displaying section. Here, a simulation of an antenna rotator is shown.
while(1)
{
/* i=0;
send_cmd_lcd(DDRAM_L1_C1); // Set the DDRAM address location for line 1, column 1.
send_char_lcd('A'); // Sends character
send_char_lcd('z'); // Sends character
send_char_lcd('\x00'); // Sends character
send_char_lcd(' '); // Sends character
send_char_lcd('2'); // Sends character
send_char_lcd('8'); // Sends character
send_char_lcd('5'); // Sends character
send_char_lcd('\xDF'); // Sends character
send_cmd_lcd(DDRAM_L2_C1); // Set the DDRAM address location for line 2, column 1.
send_char_lcd('E'); // Sends character
send_char_lcd('l'); // Sends character
send_char_lcd('\x01'); // Sends character
send_char_lcd(' '); // Sends character
send_char_lcd('3'); // Sends character
send_char_lcd('7'); // Sends character
send_char_lcd('\xDF'); // Sends character
*/
send_str_lcd(DDRAM_L1_C1,"ALLO toi!\x00");
}
/* lcd_driver.h
v1, February 2009
TARGET device: PIC18F2220
Compiler: SourceBoost's BoostC for PIC
IDE: SourceBoost IDE
Make sure you assign the LCD lines as follows:
- In the main program .c object file, assign the lcd_port variable to @PORTA, @PORTB, @PORTC or @PORTD
based on the PIC port to which the LCD is wired to.
- In the main program .c object file, assign the lcd_tris variable to @TRISA, @TRISB, @TRISC or @TRISD
based on the PIC port to which the LCD is wired to.
- Connect the LCD signals to the selected PIC port as follows:
PIC port pin 0: LCD DB0 signal
PIC port pin 1: LCD DB1 signal
PIC port pin 2: LCD DB2 signal
PIC port pin 3: LCD DB3 signal
PIC port pin 4: LCD E signal
PIC port pin 5: LCD RW signal
PIC port pin 6: LCD RS signal
*/
// Constants and Masks Definition
#define LCD_READ_TRIS 0b00001111 //The mask used to set the LCD port to read
#define LCD_DATA_CLEAR_MASK 0b11110000 //Used to clear the LCD transmitted character nibble on the LCD port.
#define LOW_NIBBLE_MASK 0b00001111 //Used to isolate the low nibble of a char.
#define RS 6 // LCD Register Select control line
#define RW 5 // LCD Read/Write control line
#define E 4 // LCD Enable control line
#define LCD_BUSY_FLAG 3 // This is the LCD Busy flag bit position
#define DISP_ON 0b00001100 // Display on
#define DISP_ON_CURS_ON 0b00001110 // Display on, Cursor on
#define DISP_ON_CURS_ON_BLNK 0b00001111 // Display on, Cursor on, Blink cursor
#define DISP_OFF 0b00001000 // Display off
#define CLR_DISP 0b00000001 // Clear the Display
#define RET_HOME 0b00000010 // Bring the cursor back home
#define LCD_SHIFT_RIGHT 0b00011100 // Shift entire display right by one position
#define LCD_SHIFT_LEFT 0b00011000 // Shift entire display left by one position
#define CURS_SHIFT_RIGHT 0b00010100 // Moves cursot right by one position
#define CURS_SHIFT_LEFT 0b00010000 // Moves cursot left by one position
#define ENTRY_INC 0b00000110 // Sets the cursor move / display shift mode to move right
#define ENTRY_INC_S 0b00000111 // Sets the cursor move / display shift mode to move and shift right
#define ENTRY_DEC 0b00000100 // Sets the cursor move / display shift mode to move left
#define ENTRY_DEC_S 0b00000101 // Sets the cursor move / display shift mode to move and shift left
#define FOUR_BIT_INIT 0b00000010 // Sets the cursor move / display shift mode to move and shift left
#define FOUR_BIT_INIT2 0b00101000 // Sets the cursor move / display shift mode to move and shift left
#define DDRAM_L1_C1 0b10000000 // Least Significant 7-bit are for DDRAM address
#define DDRAM_L2_C1 0b11000000 // Least Significant 7-bit are for DDRAM address
#define CGRAM_CHAR_1_ADDR 0b01000000 // Least Significant 6-bit are for CGRAM address
#define CGRAM_CHAR_2_ADDR 0b01001000 // Least Significant 6-bit are for CGRAM address
char check_busy_lcd(void) // Checks if LCD is busy or ready. 1=busy, 0=ready
{
unsigned char lcd_busy;
lcd_tris = LCD_READ_TRIS; // Set RA6 - 4 = outputs, RA3 - 0 = inputs
clear_bit(lcd_port, RS ); // Set LCD for Command mode
set_bit(lcd_port, RW ); // Setup to read busy flag
set_bit(lcd_port, E ); // Set E high
delay_ms(1);
lcd_busy = test_bit(lcd_port,LCD_BUSY_FLAG); // Read Busy flag value
clear_bit(lcd_port,E); // Set E low
delay_ms(1);
set_bit(lcd_port,E); // Set E high to read other nibble (to flush LCD buffer)
delay_ms(1);
clear_bit(lcd_port,E); // Set E low
clear_bit(lcd_port, RW ); // Setup to write to LCD later
lcd_tris = 0b00000000; // Set RA6 - 4 = outputs, RA3 - 0 = outputs
return lcd_busy; // Send the busy flag to calling code
}
void send_char_lcd(char lcd_char) // This routine checks the busy flag, returns when not busy
{
while(check_busy_lcd() == 1); // Wait for LCD to become idle
lcd_port = 0; //Clear all bits on the LCD port
lcd_port = lcd_port | (lcd_char >> 4); // transfer the high character nibble into the data bits)
clear_bit(lcd_port, RW ); // Setup to write to LCD
set_bit(lcd_port, RS ); // Set LCD for Data mode
set_bit(lcd_port, E ); // Set E high
delay_ms(1);
clear_bit(lcd_port,E); // Set E low
lcd_port = lcd_port & LCD_DATA_CLEAR_MASK; // Clear the character bits on the port
lcd_port = lcd_port | (lcd_char & LOW_NIBBLE_MASK); // transfer the low character nibble into the data bits
set_bit(lcd_port, E ); // Set E high
delay_ms(1);
clear_bit(lcd_port,E); // Set E low
}
void send_cmd_lcd(char lcd_char) // This routine checks the busy flag, returns when not busy
{
while(check_busy_lcd() == 1); // Wait for LCD to become ready
lcd_port = 0; //Clear all bits on the LCD port
lcd_port = lcd_port | (lcd_char >> 4); // transfer the high character nibble into the data bits)
clear_bit(lcd_port, RW ); // Setup to write to LCD
clear_bit(lcd_port, RS ); // Set LCD for Command mode
set_bit(lcd_port, E ); // Set E high
delay_ms(1);
clear_bit(lcd_port,E); // Set E low
lcd_port = lcd_port & LCD_DATA_CLEAR_MASK; // Set LCD for 4-bit interface and clear the character bits on the port
lcd_port = lcd_port | (lcd_char & LOW_NIBBLE_MASK); // transfer the low character nibble into the data bits
set_bit(lcd_port, E ); // Set E high
delay_ms(1);
clear_bit(lcd_port,E); // Set E low
}
void send_str_lcd(char lcd_addr, const char* lcd_str) //This routine sends a string of characters to the display in consecutive positions.
{
send_cmd_lcd(lcd_addr); // Set the DDRAM address location for line 1, column 1.
for(i = 0; i <= (strlen(lcd_str) - 1); i++) // Repeat sending characters until the null terminator (0x00) is found
{
send_char_lcd(lcd_str[i]);
}
}
J'ai bien trouver un datasheet pour une diode rectifier S3V80 qui est une diode de 800v 3.5 A .. dois je en déduire que ma référence S3V84 serais une 840V ?