jayanth.devarayanadurga
Banned
- Joined
- Dec 4, 2012
- Messages
- 4,280
- Helped
- 822
- Reputation
- 1,654
- Reaction score
- 791
- Trophy points
- 1,393
- Location
- Bangalore, India
- Activity points
- 0
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 //********************************************************************** // C-Programm for driving a MAX7219 // a 8 digit number is printed in a string (sprintf) // and then send to the MAX7219 //********************************************************************** #define Data7219 RB0_bit #define Load7219 RB1_bit #define Clk7219 RB2_bit const unsigned char Font_B[16]= { 0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70, 0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47 }; void Send7219 (char,char); void Send7219byte(char); void MAX7219init(); void Display(unsigned long int); //********************************************************************** void main (void) { TRISB = 0x00; PORTB = 0x00; MAX7219init(); Display(47110815);//my_weird_number while(1){Display(47110815);} //my_weird_number} } //********************************************************************** void MAX7219init() { Data7219 =0; Load7219 =0; Clk7219 = 0; Send7219(0x09,0x00);//Decode Mode Send7219(0x0A,0x05);//Brightness Send7219(0x0B,0x07);//Scan limit Send7219(0x0C,0x01); Send7219(0x0F,0x00); } //********************************************************************** void Send7219 (char Digit,char Data) { Send7219byte(Digit); Send7219byte(Data); Data7219=0; Load7219=1; Load7219=0; } //********************************************************************** void Send7219byte (char byte) { unsigned char I; for(I=0;I<8;I++) { if (byte & 0x80) Data7219=1; else Data7219=0; Clk7219=1; byte<<=1; Clk7219=0; } } //********************************************************************** void Display (unsigned long int My_number) { unsigned char i,string[8]; LongToStr(My_number, string); for (i=0;i<8;i++) { if (string[i] == 0x20)//0x20 is ASCII " " Send7219(i+1,0); //send MAX7219 " " to MAX7219 else if (string[i] <= 0x39) Send7219(i+1,Font_B[string[i] - 0x30]);//0-9 else Send7219(i+1,Font_B[string[i] - 0x57]);//A-F } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 //********************************************************************** // C-Programm for driving a MAX7219 // a 8 digit number is printed in a string (sprintf) // and then send to the MAX7219 //********************************************************************** #define Data7219 RB0_bit #define Load7219 RB1_bit #define Clk7219 RB2_bit const unsigned char Font_B[16]= { 0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70, 0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47 }; void Send7219 (char,char); void Send7219byte(char); void MAX7219init(); void Display(unsigned long int); //********************************************************************** void main (void) { TRISB = 0x00; PORTB = 0x00; ANSEL = 0x00; ANSELH = 0x00; ADCON1 = 0x00; CM1CON0 = 0x00; CM2CON0 = 0x00; MAX7219init(); Display(47110815);//my_weird_number while(1){;}//Display(47110815);} //my_weird_number} } //********************************************************************** void MAX7219init() { Data7219 =0; Load7219 =0; Clk7219 = 0; Send7219(0x09,0x00);//Decode Mode Send7219(0x0A,0x05);//Brightness Send7219(0x0B,0x07);//Scan limit Send7219(0x0C,0x01); Send7219(0x0F,0x00); } //********************************************************************** void Send7219 (char Digit,char Data) { Send7219byte(Digit); Send7219byte(Data); Data7219=0; Load7219=1; Load7219=0; } //********************************************************************** void Send7219byte (char byte) { unsigned char I; for(I=0;I<8;I++) { if (byte & 0x80) Data7219=1; else Data7219=0; Clk7219=1; byte<<=1; Clk7219=0; } } //********************************************************************** void Display (unsigned long int My_number) { unsigned char i,string[8]; LongToStr(My_number, string); for (i=0;i<8;i++) { if (string[i] == 0x20)//0x20 is ASCII " " Send7219(i+1,0); //send MAX7219 " " to MAX7219 else if (string[i] <= 0x39) Send7219(i+1,Font_B[string[i] - 0x30]);//0-9 else Send7219(i+1,Font_B[string[i] - 0x57]);//A-F } } //**********************************************************************
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 #define Data7219 RB0_bit #define Load7219 RB1_bit #define Clk7219 RB2_bit const unsigned char Font_B[16]= { 0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70, 0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47 }; unsigned long value; void Send7219 (char,char); void Send7219byte(char); void MAX7219init(); void Display(unsigned long int); void main (void){ TRISA = 0xFF; TRISB = 0x00; PORTB = 0x00; ANSEL = 0x00; ANSELH = 0x00; ADCON1 = 0x00; CM1CON0 = 0x00; CM2CON0 = 0x00; MAX7219init(); Display(47110815);//my_weird_number if(1014500<=value<=1014999); while(1){;}//Display(47110815);} //my_weird_number} } void MAX7219init() { Data7219 =0; Load7219 =0; Clk7219 = 0; Send7219(0x09,0x00);//Decode Mode Send7219(0x0A,0x05);//Brightness Send7219(0x0B,0x07);//Scan limit Send7219(0x0C,0x01); Send7219(0x0F,0x00); } void Send7219 (char Digit,char Data) { Send7219byte(Digit); Send7219byte(Data); Data7219=0; Load7219=1; Load7219=0; } void Send7219byte (char byte) { unsigned char I; for(I=0;I<8;I++) { if (byte & 0x80) Data7219=1; else Data7219=0; Clk7219=1; byte<<=1; Clk7219=0; } } void Display (unsigned long int My_number) { unsigned char i,str[17], string[8]; LongToStr(My_number, str); for(i = 3;i<11;i++)string[i-3] = str[i]; for (i=0;i<8;i++) { if (string[i] == 0x20)//0x20 is ASCII " " Send7219(i+1,0); //send MAX7219 " " to MAX7219 else if (string[i] <= 0x39) Send7219(i+1,Font_B[string[i] - 0x30]);//0-9 else Send7219(i+1,Font_B[string[i] - 0x57]);//A-F } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 #define Data7219 RB0_bit #define Load7219 RB1_bit #define Clk7219 RB2_bit const unsigned char Font_B[16]= { 0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70, 0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47 }; unsigned long value; void Send7219 (char,char); void Send7219byte(char); void MAX7219init(); void Display(unsigned long int); void main (void){ TRISA = 0xFF; TRISB = 0x00; PORTB = 0x00; ANSEL = 0x00; ANSELH = 0x00; ADCON1 = 0x00; CM1CON0 = 0x00; CM2CON0 = 0x00; MAX7219init(); Display(47110815);//my_weird_number if(1014500<=value<=1014999); while(1){;}//Display(47110815);} //my_weird_number} } void MAX7219init() { Data7219 =0; Load7219 =0; Clk7219 = 0; Send7219(0x09,0x00);//Decode Mode Send7219(0x0A,0x05);//Brightness Send7219(0x0B,0x07);//Scan limit Send7219(0x0C,0x01); Send7219(0x0F,0x00); } void Send7219 (char Digit,char Data) { Send7219byte(Digit); Send7219byte(Data); Data7219=0; Load7219=1; Load7219=0; } void Send7219byte (char byte) { unsigned char I; for(I=0;I<8;I++) { if (byte & 0x80) Data7219=1; else Data7219=0; Clk7219=1; byte<<=1; Clk7219=0; } } void Display (unsigned long int My_number) { unsigned char i,str[17], string[8]; LongToStr(My_number, str); for(i = 3;i<11;i++)string[i-3] = str[i]; for (i=8;i>0;i--) { if (string[i] == 0x20)//0x20 is ASCII " " Send7219(i+1,0); //send MAX7219 " " to MAX7219 else if (string[i] <= 0x39) Send7219(i+1,Font_B[string[i] - 0x30]);//0-9 else Send7219(i+1,Font_B[string[i] - 0x57]);//A-F } }
4MHz crystal and exactly the same project settings as you have in your .rar project file.What Clock did you use? I am using 4 MHz and I see only 2 or 3 digits and it flickers.
How to fix the reverse?
void Display (unsigned long int My_number)
{
unsigned char i,str[17], string[8];
LongToStr(My_number, str);
for(i = 3;i<11;i++)string[i-3] = str[i];
for (i=0;i<8;i++)
{
if (string[7-i] == 0x20)//0x20 is ASCII " "
Send7219(i+1,0); //send MAX7219 " " to MAX7219
else if (string[7-i] <= 0x39)
Send7219(i+1,Font_B[string[7-i] - 0x30]);//0-9
else
Send7219(i+1,Font_B[string[7-i] - 0x57]);//A-F
}
}
I have never used floating point with PICs, but I imagine you would use the FloatToStr library function.And tell me how to display floating point values.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 /* 8 X 7-Segment Drived C Code Author Jayanth Devarayanadurga Data 12/05/2013 */ #define Data7219 RB0_bit #define Load7219 RB1_bit #define Clk7219 RB2_bit const unsigned char Font_B[16]= { 0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70, 0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47 }; unsigned long value; void Send7219 (char,char); void Send7219byte(char); void MAX7219init(); void Display(unsigned long int); void main (void){ TRISA = 0xFF; TRISB = 0x00; PORTB = 0x00; ANSEL = 0x00; ANSELH = 0x00; ADCON1 = 0x00; CM1CON0 = 0x00; CM2CON0 = 0x00; MAX7219init(); Display(47110815);//my_weird_number while(1){;}//Display(47110815);} //my_weird_number} } void MAX7219init() { Data7219 =0; Load7219 =0; Clk7219 = 0; Send7219(0x09,0x00);//Decode Mode Send7219(0x0A,0x05);//Brightness Send7219(0x0B,0x07);//Scan limit Send7219(0x0C,0x01); Send7219(0x0F,0x00); } void Send7219 (char Digit,char Data) { Send7219byte(Digit); Send7219byte(Data); Data7219=0; Load7219=1; Load7219=0; } void Send7219byte (char byte) { unsigned char I; for(I=0;I<8;I++) { if (byte & 0x80) Data7219=1; else Data7219=0; Clk7219=1; byte<<=1; Clk7219=0; } } void Display (unsigned long int My_number) { unsigned char i,str[17], string[8]; LongToStr(My_number, str); for(i = 3;i<11;i++)string[i-3] = str[i]; for (i=0;i<8;i++) { if (string[7-i] == 0x20)//0x20 is ASCII " " Send7219(i+1,0); //send MAX7219 " " to MAX7219 else if (string[7-i] <= 0x39) Send7219(i+1,Font_B[string[7-i] - 0x30]);//0-9 else Send7219(i+1,Font_B[string[7-i] - 0x57]);//A-F } }
2 x 7219?What driver should I use to drive 15 digits?
7219 is the only driver I have ever used.Any MAX Driver you know?
You will also need to provide a space for exponent sign.What changes in the code have to be made in display routine? Just add check for '.' and display display '.' depending on the position of '.'?
Then 8 digits may be enough.My value will be something like this 999.999e+/-9. It will be only positive values.
I can not comment - never used either.What about MAX6954 and 6955? They use SPI and I2C.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 /* 8 X 7-Segment Drived C Code Author Jayanth Devarayanadurga Data 12/05/2013 */ #define Data7219 RB0_bit #define Load7219 RB1_bit #define Clk7219 RB2_bit const unsigned char Font_B[16]= { 0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70, 0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47 }; unsigned long value; unsigned char dpset = 0; void Send7219 (char,char); void Send7219byte(char); void MAX7219init(); void Display(float); void main (void){ TRISA = 0xFF; TRISB = 0x00; PORTB = 0x00; ANSEL = 0x00; ANSELH = 0x00; ADCON1 = 0x00; CM1CON0 = 0x00; CM2CON0 = 0x00; MAX7219init(); Display(230.14592);//my_weird_number while(1){;}//Display(47110815);} //my_weird_number} } void MAX7219init() { Data7219 =0; Load7219 =0; Clk7219 = 0; Send7219(0x09,0x00);//Decode Mode Send7219(0x0A,0x05);//Brightness Send7219(0x0B,0x07);//Scan limit Send7219(0x0C,0x01); Send7219(0x0F,0x00); } void Send7219 (char Digit,char Data) { Send7219byte(Digit); Send7219byte(Data); Data7219=0; Load7219=1; Load7219=0; } void Send7219byte (char byte) { unsigned char I; for(I=0;I<8;I++) { if (byte & 0x80) Data7219=1; else Data7219=0; Clk7219=1; byte<<=1; Clk7219=0; } } void Display (float My_number) { unsigned char i, string[23]; FloatToStr(My_number, string); string[8] = '\0'; for (i=0;i<8;i++) { if (string[7-i] == 0x20)//0x20 is ASCII " " Send7219(i+1,0); //send MAX7219 " " to MAX7219 else if ((string[7-i] <= 0x39)) Send7219(i+1,(Font_B[string[7-i] - 0x30]));//0-9 else Send7219(i+1,(Font_B[string[7-i] - 0x57]));//A-F if (string[7-i] == '.')//0x20 is ASCII " " if (string[7-(i+1)] <= 0x39) Send7219(i+1,(Font_B[string[7-(i+1)] - 0x30]) | (0b10000000));//0-9 else Send7219(i+1,(Font_B[string[7-(i+1)] - 0x57]) | (0b10000000));//A-F } }
/*
8 X 7-Segment Drived C Code
Author Jayanth Devarayanadurga
Data 12/05/2013
*/
#define Data7219 RB0_bit
#define Load7219 RB1_bit
#define Clk7219 RB2_bit
const unsigned char Font_B[16]=
{
0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,
0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47
};
unsigned long value;
unsigned char dpset = 0;
void Send7219 (char,char);
void Send7219byte(char);
void MAX7219init();
void Display(float);
void main (void){
TRISA = 0xFF;
TRISB = 0x00;
PORTB = 0x00;
ANSEL = 0x00;
ANSELH = 0x00;
ADCON1 = 0x00;
CM1CON0 = 0x00;
CM2CON0 = 0x00;
MAX7219init();
Display(230.14592); //my_weird_number
//Display(123.45678); //much easier to work with
while(1){;}//Display(47110815);} //my_weird_number}
}
void MAX7219init()
{
Data7219 =0;
Load7219 =0;
Clk7219 = 0;
Send7219(0x09,0x00);//Decode Mode
Send7219(0x0A,0x05);//Brightness
Send7219(0x0B,0x07);//Scan limit
Send7219(0x0C,0x01);
Send7219(0x0F,0x00);
}
void Send7219 (char Digit,char Data)
{
Send7219byte(Digit);
Send7219byte(Data);
Data7219=0;
Load7219=1;
Load7219=0;
}
void Send7219byte (char byte)
{
unsigned char I;
for(I=0;I<8;I++)
{
if (byte & 0x80)
Data7219=1;
else
Data7219=0;
Clk7219=1;
byte<<=1;
Clk7219=0;
}
}
void Display (float My_number)
{
unsigned char dispskip; // add 1 if "." found within string
unsigned char i, string[23];
FloatToStr(My_number, string);
string[9] = 0; // null terminate
string[8] = 0x20; // FloatToString returns 7 characters + ".", so blank the 9th
dispskip = 8; // initialise
for (i=0;i<8;i++)
{
if (string[dispskip-i] == 0x20)//0x20 is ASCII " "
Send7219(i+1,0);
//send MAX7219 " " to MAX7219
else if ((string[dispskip-i] <= 0x39))
Send7219(i+1,(Font_B[string[dispskip-i] - 0x30]));//0-9
else
Send7219(i+1,(Font_B[string[dispskip-i] - 0x57]));//A-F
if (string[dispskip-i] == '.'){//0x20 is ASCII " "
dispskip = 7; //
if (string[dispskip-i] <= 0x39)
Send7219(i+1,(Font_B[string[dispskip-i] - 0x30]) | (0b10000000));//0-9
else
Send7219(i+1,(Font_B[string[dispskip-i] - 0x57]) | (0b10000000));//A-F
}
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?