Converting a PIC DVM to output decimal

jayanthd

Joined Jul 4, 2015
945
After some experiements with Proteus I found out that in A, B, C, D inputs of the 74H145 / 74HC145 the A is LSB and D is MSB because if A is taken as MSB and D as LSB and values 0x00 to 0x09 are assigned then multiple output channels will be low for some value. So, I assume this is incorrect.

I am attaching an image which shows for BCD values 0 to 9 only one output of the 74H145 will be low and LED connected to that particular channel will lit. In image the blue square at the pins represent low (0) and red square represent high (1).

74H145 outputs.png
 

Attachments

Thread Starter

Remembermyname

Joined Sep 6, 2015
91
When BCD input to 74H145 is 0x00 the output will be 0x1FF and so the 0th channel will be 0 and as cathodes of LEDs are connected to these channels the 0th channel LED will lit.
That is correct. From the list I provided above, it was inverted and incorrect.

My question is to display 0 will you use 1 LED connected to 0th channel or will you use 10 or 20 LEDs in series which take the same 10 mA current and make a pattern in the shape of 0 and lit it ?
To display 0 , 1 LED connected to 0 channel is used. Combination of LED to create a pattern is not used.

you send 0x2FF to the 10 LEDs bus and as it is hundredth place digit you turn ON transistor 1 for a while (say 3 ms)
then you turn OFF transistor 1 and then place 0x3DF on the 10 LEDs bus and turn ON transistor 2 for 3 ms and then turn it OFF then you place 0x3EF, on the 10 LEDs (cathodes) bus and turn ON 3rd transistor for 3 ms and this cycles infinitely.

So, first the 1st channel (of 10 channels) will be low (0) and hundredth place digit will be lit.
Then 5th channel will be low (0) and tens place digit will be lit.
Then 6th channel will be low (0) and units place digit will be lit.

This cycles infinitely. It appears that LED 2 of digit 1, LED 5 of digit 2 and LED 6 of digit 3 are all lit at the same time.
This is correct.!

If you want patterns then you will connect 10 to 20 LEDs in series for each channel (10 channels total) and make patterns of shape like 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

If LED bus has value 0x1FF then 0th channel will be low and there will be 10 to 20 LEDs in series in that channel and it will be made in the shape of 0 and so you will see a 0.
No pattern or combination of LEDs will be used to create the shape of a number. Only 1 out of 10 LEDs per column to indicate a single digit.
 

Thread Starter

Remembermyname

Joined Sep 6, 2015
91
The proteus simulator is most interesting. I would have to send the BCD to an actual 74HC145 to view this results or carefully follow the truth table in the datasheet. :D
 

jayanthd

Joined Jul 4, 2015
945
74H145 has 4 inputs. Just feed binary values 0 to 9 to it and see the outputs. Just See the A, B , C, D values in the truth table of the datasheet. I was not able to get a copy of its datasheet. If you have it please post a copy of it here. I am working on the code. I will finish it in 30 minutes.
 

Thread Starter

Remembermyname

Joined Sep 6, 2015
91
74H145 has 4 inputs. Just feed binary values 0 to 9 to it and see the outputs. Just See the A, B , C, D values in the truth table of the datasheet. I was not able to get a copy of its datasheet. If you have it please post a copy of it here. I am working on the code. I will finish it in 30 minutes.
The datasheet for the 74HC145 is available from Sanyo but at all locations, I am receiving it in Kanji/Hiragana and is difficult for me to read. I do however have the datasheet for the 74LS145 from Motorola. The truth tables should be the same between the two devices. I am posting both for the sake of clarity
 

Attachments

jayanthd

Joined Jul 4, 2015
945
I checked the 74LS145 datasheet and the values in the truth table matches with the array values I have used.

Ok. The array values I gave are correct. The array which starts with 0x1FF. I made the project using PIC18F46K22 but it is not yet working as needed. I earlier tried with PIC16F1826 but there is some problem with that proteus model. The code I earlier posted is correct.

Here I am posting the PIC18F46K22 version code and circuit. I am also attaching the mikroC PRO PIC project and Proteus 8.2 SP2 format file.

Problem might be related to Proteus or maybe a timing issue. I will try to fix it. If you have Proteus then you can simulate my file.

Using dsPIC or PIC24 chip which has atleast one 16 bit port will be easier to use. Just we can assing the 12 bit value to a 16 bit port. If you want I will try with a dsPIC33 in Proteus.

C:
unsigned int mask[] = {0x1FF, 0x2FF, 0x37F, 0x3BF, 0x3DF, 0x3EF, 0x3F7, 0x3FB, 0x3FD, 0x3FE};
unsigned long adcValue = 0, prevAdcValue = 0;
unsigned int display[3] = {0, 0, 0};
char select = 0;

//Timer1
//Prescaler 1:1; TMR1 Preload = 63536; Actual Interrupt Time : 2 ms

//Place/Copy this part in declaration section
void InitTimer1() {
    T1CON = 0x01;
    TMR1IF_bit = 0;
    TMR1H = 0xF8;
    TMR1L = 0x30;
    TMR1IE_bit = 1;
    INTCON = 0xC0;
}

void Interrupt() {
    if(TMR1IF_bit) {
        TMR1H = 0xF8;
        TMR1L = 0x30;
        //Enter your code here
        LATE = 0x0F;
        LATD = (LATD & 0x3F) | 0xC0;
        LATC = 0xFF;

        switch(select) {
            case 0:
                  if(display[0] != mask[0]) {
                        LATC = display[0] >> 2;
                        LATD = (LATD & 0x3F) | ((display[0] & 0x03) << 6);
                        LATE = 0b1110;
                  }
                  break;
            case 1:
                  if((display[0] == mask[0]) && (display[1] == mask[0])) {
                  }
                  else {
                        LATC = display[1] >> 2;
                        LATD = (LATD & 0x3F) | ((display[1] & 0x03) << 6);
                        LATE = 0b1101;
                  }
                  break;
            case 2:
                  LATC = display[2] >> 2;
                  LATD = (LATD & 0x3F) | ((display[2] & 0x03) << 6);
                  LATE = 0b1011;
                  break;

        };

        if(++select == 3)select = 0;

        TMR1IF_bit = 0;
    }
}



void main() {

    CM1CON0 = 0x00;
    CM2CON0 = 0x00;

    ADCON1 = 0x80;
    ADCON2 = 0b10110001;
 
    ANSELA = 0x01;
    ANSELB = 0x00;
    ANSELC = 0x00;
    ANSELD = 0x00;
    ANSELE = 0x00;

    TRISA = 0x01;
    TRISB = 0x00;
    TRISC = 0x00;
    TRISD = 0x00;
    TRISE = 0x08;

    PORTA = 0xC0;
    PORTB = 0x00;
    PORTC = 0x00;
    PORTD = 0x00;
    PORTE = 0x08;

    LATA = 0xC0;
    LATB = 0x00;
    LATC = 0xFF;
    LATD = 0xC0;
    LATE = 0x0F;

    Delay_ms(200);

    /*
    //Test Code
    LATE = 0x0F;
    LATD = (LATD & 0x3F) | 0xC0;
    LATC = 0xFF;
    display[0] = mask[1];
    LATC = display[0] >> 2;
    LATD = (LATD & 0x3F) | ((display[0] & 0x03) << 6);
    LATE = 0b1110;
    */
                     
    InitTimer1();

    while(1) {

           adcValue = (unsigned long)ADC_Read(0) * 300 / 1024;
           Delay_ms(20);

           if(prevAdcValue != adcValue) {

                 if((adcValue >= 0) && (adcValue < 10)) {
                          display[0] = mask[0];
                          display[1] = mask[0];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }
                 else if((adcValue >= 10) && ((unsigned int)adcValue < 100)) {
                          display[0] = mask[0];
                          display[1] = mask[(unsigned int)adcValue / 10];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }
                 else if((adcValue >= 100) && (adcValue < 1000)) {
                          display[0] = mask[(unsigned int)adcValue / 100];
                          display[1] = mask[((unsigned int)adcValue / 10) % 10];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }

                 prevAdcValue = adcValue;
           }
    }
}
edge lit display.png
 

Attachments

Last edited:

Thread Starter

Remembermyname

Joined Sep 6, 2015
91
Thank you so much for your hard work! I did try to compile the original code you posted in XC8. I do happen to have a PIC16F1827. Same as the 1826 but with more ram and a couple of extra little features.
Under XC8, It had a few issues with the code but compiled successfully. There is the HEX code I can try to load into the PIC. I will build out a prototype of the circuit and try in the meantime.
 
Last edited:

jayanthd

Joined Jul 4, 2015
945
This is the new code for PIC18F46K22 version. Schematic in previous post. I had made a silly mistake. In ISR code LATD and LATC were interchanged. I have fixed it but still in Proteus I see flickering. Test it in hardware and reply.

C:
unsigned int mask[] = {0x1FF, 0x2FF, 0x37F, 0x3BF, 0x3DF, 0x3EF, 0x3F7, 0x3FB, 0x3FD, 0x3FE};
unsigned long adcValue = 0, prevAdcValue = 0;
unsigned int display[3] = {0, 0, 0};
char select = 0;

//Timer1
//Prescaler 1:1; TMR1 Preload = 63536; Actual Interrupt Time : 2 ms

//Place/Copy this part in declaration section
void InitTimer1() {
    T1CON = 0x01;
    TMR1IF_bit = 0;
    TMR1H = 0xF8;
    TMR1L = 0x30;
    TMR1IE_bit = 1;
    INTCON = 0xC0;
}

void Interrupt() {
    if(TMR1IF_bit) {
        //Enter your code here
        LATE = 0x0F;
        LATD = 0xFF;
        LATC = (LATC & 0xFF);

        switch(select) {
            case 0:
                  if(display[0] != mask[0]) {
                        LATD = display[0];
                        LATC = (LATC & 0x3F) | ((display[0] & 0x300) >> 2);
                        LATE = 0b1110;
                  }
                  break;
            case 1:
                  if((display[0] == mask[0]) && (display[1] == mask[0])) {
                  }
                  else {
                        LATD = display[1];
                        LATC = (LATC & 0x3F) | ((display[1] & 0x300) >> 2);
                        LATE = 0b1101;
                  }
                  break;
            case 2:
                  LATD = display[2];
                  LATC = (LATC & 0x3F) | ((display[2] & 0x300) >> 2);
                  LATE = 0b1011;
                  break;

        };

        if(++select == 3)select = 0;

        TMR1IF_bit = 0;
        TMR1H = 0xF8;
        TMR1L = 0x30;
    }
}

void main() {

    CM1CON0 = 0x00;
    CM2CON0 = 0x00;

    SLRCON = 0x00;
   
    ADCON1 = 0x80;
    ADCON2 = 0b10110001;
   
    ANSELA = 0x01;
    ANSELB = 0x00;
    ANSELC = 0x00;
    ANSELD = 0x00;
    ANSELE = 0x00;

    TRISA = 0xC1;
    TRISB = 0x00;
    TRISC = 0x00;
    TRISD = 0x00;
    TRISE = 0x08;

    PORTA = 0x00;
    PORTB = 0x00;
    PORTC = 0x00;
    PORTD = 0x00;
    PORTE = 0x08;

    LATA = 0x00;
    LATB = 0x00;
    LATC = 0xC0;
    LATD = 0xFF;
    LATE = 0x0F;

    Delay_ms(200);

    /*
    LATE = 0x0F;
    LATD = 0xFF;
    LATC = (LATC & 0xFF);
    display[0] = 0x2FF;
    LATC = (LATC & 0x3F) | ((display[0] & 0x300) >> 2);
    */
   
    /*
    //Test Code
    LATE = 0x0F;
    LATD = (LATD & 0x3F) | 0xC0;
    LATC = 0xFF;
    display[0] = mask[1];
    LATC = display[0] >> 2;
    LATD = (LATD & 0x3F) | ((display[0] & 0x03) << 6);
    LATE = 0b1110;
    */
                       
    InitTimer1();

    while(1) {

           adcValue = (unsigned long)ADC_Read(0) * 300 / 1024;
           Delay_ms(20);

           if(prevAdcValue != adcValue) {

                 if((adcValue >= 0) && (adcValue < 10)) {
                          display[0] = mask[0];
                          display[1] = mask[0];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }
                 else if((adcValue >= 10) && ((unsigned int)adcValue < 100)) {
                          display[0] = mask[0];
                          display[1] = mask[(unsigned int)adcValue / 10];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }
                 else if((adcValue >= 100) && (adcValue < 1000)) {
                          display[0] = mask[(unsigned int)adcValue / 100];
                          display[1] = mask[((unsigned int)adcValue / 10) % 10];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }

                 prevAdcValue = adcValue;
           }
    }
}
 

jayanthd

Joined Jul 4, 2015
945
There was another mistake in ISR code. Fixed it but still display flickers. Have to do more testing.

Compile the code for 20 MHz HS Oscillator.

C:
unsigned int mask[] = {0x1FF, 0x2FF, 0x37F, 0x3BF, 0x3DF, 0x3EF, 0x3F7, 0x3FB, 0x3FD, 0x3FE};
unsigned long adcValue = 0, prevAdcValue = 0;
unsigned int display[3] = {0, 0, 0};
char select = 0;

//Timer1
//Prescaler 1:1; TMR1 Preload = 55536; Actual Interrupt Time : 2 ms
//Place/Copy this part in declaration section
void InitTimer1() {
    T1CON = 0x01;
    TMR1IF_bit = 0;
    TMR1H = 0xD8;
    TMR1L = 0xF0;
    TMR1IE_bit = 1;
    INTCON = 0xC0;
}

void Interrupt() {
    if(TMR1IF_bit) {
        //Enter your code here
        LATE = 0x0F;
        LATD = 0xFF;
        LATC = (LATC & 0xFF);

        switch(select) {
            case 0:
                  if(display[0] != mask[0]) {
                        LATD = display[0] >> 2;
                        LATC = (LATC & 0x3F) | ((display[0] & 0x03) << 6);
                        LATE = 0b1110;
                  }
                  break;
            case 1:
                  if((display[0] == mask[0]) && (display[1] == mask[0])) {
                  }
                  else {
                        LATD = display[1] >> 2;
                        LATC = (LATC & 0x3F) | ((display[0] & 0x03) << 6);
                        LATE = 0b1101;
                  }
                  break;
            case 2:
                  LATD = display[2] >> 2;
                  LATC = (LATC & 0x3F) | ((display[0] & 0x03) << 6);
                  LATE = 0b1011;
                  break;

        };

        if(++select == 3)select = 0;

        TMR1IF_bit = 0;
        TMR1H = 0xD8;
        TMR1L = 0xF0;
    }
}

void main() {

    CM1CON0 = 0x00;
    CM2CON0 = 0x00;

    SLRCON = 0x00;
   
    ADCON1 = 0x80;
    ADCON2 = 0b10110001;
   
    ANSELA = 0x01;
    ANSELB = 0x00;
    ANSELC = 0x00;
    ANSELD = 0x00;
    ANSELE = 0x00;

    TRISA = 0xC1;
    TRISB = 0x00;
    TRISC = 0x00;
    TRISD = 0x00;
    TRISE = 0x08;

    PORTA = 0x00;
    PORTB = 0x00;
    PORTC = 0x00;
    PORTD = 0x00;
    PORTE = 0x08;

    LATA = 0x00;
    LATB = 0x00;
    LATC = 0xC0;
    LATD = 0xFF;
    LATE = 0x0F;

    Delay_ms(200);

    InitTimer1();

    while(1) {

           adcValue = (unsigned long)ADC_Read(0) * 300 / 1024;
           Delay_ms(20);

           if(prevAdcValue != adcValue) {

                 if((adcValue >= 0) && (adcValue < 10)) {
                          display[0] = mask[0];
                          display[1] = mask[0];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }
                 else if((adcValue >= 10) && ((unsigned int)adcValue < 100)) {
                          display[0] = mask[0];
                          display[1] = mask[(unsigned int)adcValue / 10];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }
                 else if((adcValue >= 100) && (adcValue < 1000)) {
                          display[0] = mask[(unsigned int)adcValue / 100];
                          display[1] = mask[((unsigned int)adcValue / 10) % 10];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }

                 prevAdcValue = adcValue;
           }
    }
}
 

jayanthd

Joined Jul 4, 2015
945
This code is correct. Discard all previous codes. According to my code if adc input is 5V it will give adc result 299 and I can see the correct LEDs turning ON but there is flickering. Maybe it is a problem related to Proteus LED BARGRAPH model. Maybe the model is not designed for fast switching. Try this code in hardware with PIC18F46K22 circuit. Compile code for 20 MHz HS Oscillator.

For adc value 299 then the 2nd LED of 1st display (left most), 9th LEDs of 2nd and 3rd displays light up. Remember there are 0th to 9th channels. 0th channel LED represent 0 and 9th channel LED represent 9.

So, 299 is displaying correctly. Maybe it will work fine in hardware.

C:
unsigned int mask[] = {0x1FF, 0x2FF, 0x37F, 0x3BF, 0x3DF, 0x3EF, 0x3F7, 0x3FB, 0x3FD, 0x3FE};
unsigned long adcValue = 0, prevAdcValue = 0;
unsigned int display[3] = {0, 0, 0};
char select = 0;

//Timer1
//Prescaler 1:1; TMR1 Preload = 55536; Actual Interrupt Time : 2 ms
//Place/Copy this part in declaration section
void InitTimer1() {
    T1CON = 0x01;
    TMR1IF_bit = 0;
    TMR1H = 0xD8;
    TMR1L = 0xF0;
    TMR1IE_bit = 1;
    INTCON = 0xC0;
}

void Interrupt() {
    if(TMR1IF_bit) {
        //Enter your code here
        LATE = 0x0F;
        LATD = 0xFF;
        LATC = (LATC | 0xC0);

        switch(select) {
            case 0:
                  if(display[0] != mask[0]) {
                        LATD = display[0] >> 2;
                        LATC = (LATC & 0x3F) | ((display[0] & 0x03) << 6);
                        LATE = 0b1110;
                  }
                  break;
            case 1:
                  if((display[0] == mask[0]) && (display[1] == mask[0])) {
                  }
                  else {
                        LATD = display[1] >> 2;
                        LATC = (LATC & 0x3F) | ((display[1] & 0x03) << 6);
                        LATE = 0b1101;
                  }
                  break;
            case 2:
                  LATD = display[2] >> 2;
                  LATC = (LATC & 0x3F) | ((display[2] & 0x03) << 6);
                  LATE = 0b1011;
                  break;

        };

        if(++select == 3)select = 0;

        TMR1IF_bit = 0;
        TMR1H = 0xD8;
        TMR1L = 0xF0;
    }
}

void main() {

    CM1CON0 = 0x00;
    CM2CON0 = 0x00;

    SLRCON = 0x00;
   
    ADCON1 = 0x80;
    ADCON2 = 0b10110001;
   
    ANSELA = 0x01;
    ANSELB = 0x00;
    ANSELC = 0x00;
    ANSELD = 0x00;
    ANSELE = 0x00;

    TRISA = 0xC1;
    TRISB = 0x00;
    TRISC = 0x00;
    TRISD = 0x00;
    TRISE = 0x08;

    PORTA = 0x00;
    PORTB = 0x00;
    PORTC = 0x00;
    PORTD = 0x00;
    PORTE = 0x08;

    LATA = 0x00;
    LATB = 0x00;
    LATC = 0xC0;
    LATD = 0xFF;
    LATE = 0x0F;

    Delay_ms(200);

    InitTimer1();

    while(1) {

           adcValue = (unsigned long)ADC_Read(0) * 300 / 1024;
           Delay_ms(20);

           if(prevAdcValue != adcValue) {

                 if((adcValue >= 0) && (adcValue < 10)) {
                          display[0] = mask[0];
                          display[1] = mask[0];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }
                 else if((adcValue >= 10) && ((unsigned int)adcValue < 100)) {
                          display[0] = mask[0];
                          display[1] = mask[(unsigned int)adcValue / 10];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }
                 else if((adcValue >= 100) && (adcValue < 1000)) {
                          display[0] = mask[(unsigned int)adcValue / 100];
                          display[1] = mask[((unsigned int)adcValue / 10) % 10];
                          display[2] = mask[(unsigned int)adcValue % 10];
                 }

                 prevAdcValue = adcValue;
           }
    }
}
 

Thread Starter

Remembermyname

Joined Sep 6, 2015
91
This code is correct. Discard all previous codes. According to my code if adc input is 5V it will give adc result 299 and I can see the correct LEDs turning ON but there is flickering. Maybe it is a problem related to Proteus LED BARGRAPH model. Maybe the model is not designed for fast switching. Try this code in hardware with PIC18F46K22 circuit. Compile code for 20 MHz HS Oscillator.
299 should be correct as it represents 29.9 VDC. The original circuit's input, like this one was design to handle a max of 30 VDC and the 10 bits ADC correctly devided the 5 VDC from the divider circuit. The voltage divider will curb the high input to 5 VDC which is the maximum input the analog input can handle. I will have to search for PIC18F46K22 chip and obtain it. This is 44 pin chip. I haven't examined the code closely yet. But the outputs are 12 bits and may not work in the 8 bit PIC correct? Unless I misunderstand it.
 
Last edited:

jayanthd

Joined Jul 4, 2015
945
No, In my code I am converting 5V adc input to 300V. As I am using integer variable for adc input it will show 299.9 as 299. I can write the code for any other PIC18F also. My advice is it is better to use PIC18F device. PIC18F46K22 is a 40 pin device but I can write code for PIC18F26K22 which is a 28 pin device.

Do you want to display something like 29.9 ? That is do you need floating point value ? If yes then you need additional two LEDs and in adc read code you have to use

C:
adcValue = (double)ADC_Read(0) * 30.0 / 1024.0
and changes have to be made in the if() conditions also.
 

Attachments

Thread Starter

Remembermyname

Joined Sep 6, 2015
91
Correct. This was idea from the original seven segment that used floating point and had a maximum input of 30 volts. Under that SSD code, it was static (i.e. 20.0 vdc, 09.1 vdc, 02.5 vdc) but a moving floating point is a cool idea whereas two additional LED's sit as an 11th LED in the right row and the middle row and would activate if necessary.

I was uncertain if this is possible if the 16F1826 was capable of handling this type of code due to the 3 byte HEX being used in the code. I haven't examined the PIC46K22 as it is a much larger IC. I was contemplating the smaller SOIC 16F1826 but if it is not possible (8 bits vs 16 bits) then the QFN 18F46K22 isn't very much larger. The 18F26K22 is much smaller. I will need to learn how to correctly solder this IC.

Originally, I had aimed for the display digits to each be ~1-2 cm^2 and by using the 16F1826 DIP underneath but the 18F46K22 QFN is only 7 mm^2. The 26K22 is ~4mm^2. That's tiny and may have advantages however, require severely tight soldering skills. For the case of the prototype circuit, the DIP 18F46K22 or 26K22 will do as at that point in the design and build, size should not be determining factor but it's impractically huge for production device. Only proof of concept.
 
Last edited:

jayanthd

Joined Jul 4, 2015
945
11th LED in the right row and the middle row and would activate if necessary.
11th LED in the left most and middle displays. It will display 2.34, 23.4, 234

I will post the project made for 26K22. I will also post a code for PIC16F1826, If you have that device with you then make a quick test with the code I post. The code will be small and hence can be compiled with mikroC PRO PIC demo compiler. So, download and install that compiler.
 
Last edited:

Thread Starter

Remembermyname

Joined Sep 6, 2015
91
11th LED in the left most and middle displays. It will display 2.34, 23.4, 234
Understood.

I will post the project made for 26K22. I will also post a code for PIC16F1826, If you have that device with you then make a quick test with the code I post. The code will be small and hence can be compiled with mikroC PRO PIC demo compiler. So, download and install that compiler.
A PIC16F1826 and PIC18F26K22 sample are on the way from Microchip. I have a very large order of LED's coming in for the proto board and then some but it will take a couple of weeks for them to arrive. I did manage to find a Proteus install running on Windows virtual machine to try it out. (Sorry, I am not a Windows user). The virtual machine is quite a bit slow but the simulation looks very promising. I played with feeding different levels of DC to the input and the MCU reacts accordingly. The samples coming in are QFN. It'll be fun trying in circuit programming design as DIP versions are not much available. So the MCU's will be very tiny indeed! At first, I was worried the physical size of these larger DIP MCU's but are easy to work with for testing and protoyping. But I can go either direction.
 

dannyf

Joined Sep 13, 2015
2,197
The code flow is simple: adv the input and then display it. Implementation wise, you need to figure out if the display is static or dynamic. The conversion from adv values to voltage and then to display fonts or segmentation information is also easy: the former can be done via fixed or floating point math and the latter via a look up table.

a more fundamental issue is with the design: the 10 bit adc can output a max of 3 decimal digits, on a 10 digit display. After the first 2 - 3 digits, you get nothing but noise.
 

Thread Starter

Remembermyname

Joined Sep 6, 2015
91
Thank you for your input however, this is not for a 10 digit segmented display. This is for a 3 digit display. Each digit consisting of 10 individual LED's for each numeral 0-9 to operate an edge-lit numerik display set. This was explained in the thread previously.
 

jayanthd

Joined Jul 4, 2015
945
Hi

I will post a code for PIC18F26K22 tomorrow. It will be for 3 digits with two additional LEDs and for displaying Floating point values. You can manufacture them and easily use it for Edge Lit Displays. If you can use PIC18F46K22 then I will make a better version in which you can set the value of x in the below formula and make the system work for any desired three or four digit values.

Adc_result = ADC_Read(0) * x / 1024;

If x = 300 then 5V represents 300
If x is set as 600 then 5V adc input represents 600

You will need a few buttons, one to switch between run mode and set mode. In set mode you will need two buttons, one to increment and one to decrement the x value. After x is set and returned to run mode then x is stored in eeprom and read when system is restsrted and this x value is used for adc value conversion (scaling).
 
Top