Serial LED displays

Thread Starter

takao21203

Joined Apr 28, 2012
3,702
They are ready to use now, nearly two years after the PCBs were made.

XC8 is used now both for the displays, and to send the serial data.

Since a 16f54 is used, each time the data is sent, the display goes off for 20 msecs. This is because of the DRT (Device reset timer).

A 16f716 could be used which is pin compatible.

The code to send the serial data is shown.
It is also possible to use the hardware serial port!
However, 20 milliseconds delay is neccessary each time as long as 16f54 is used.

Having the displays available now means a simplification for many circuits. Never to wire 7seg. displays again!

I made it working using assembler, but it was so complicated, I did not want to use them myself. As well, external components were neccessary. Not anymore! Only 3 wires are required.

Rich (BB code):
#include <xc.h>         /* XC8 General Include File */

#include "system.h"        /* System funct/params, like osc/peripheral config */
#include "user.h"          /* User funct/params, such as InitApp */

#define clk LATAbits.LATA0
#define dat LATAbits.LATA1
#define reset LATCbits.LATC1
#define delay 0

unsigned int tmr0;

void send_ser(unsigned char ser_dat)
{unsigned char i;

if(ser_dat&0x01)dat=1; else dat=0;
clk=1;i=delay;while(i--);clk=0;

if(ser_dat&0x02)dat=1; else dat=0;
clk=1;i=delay;while(i--);clk=0;

if(ser_dat&0x04)dat=1; else dat=0;
clk=1;i=delay;while(i--);clk=0;

if(ser_dat&0x08)dat=1; else dat=0;
clk=1;i=delay;while(i--);clk=0;

if(ser_dat&0x10)dat=1; else dat=0;
clk=1;i=delay;while(i--);clk=0;

}

void init_ser()
{unsigned int i;
  clk=0;
  dat=0;
  reset=0;
  reset=1;
  i=200;while(i--);
}

void interrupt isr(void)
{
    if(TMR0IF)
    {
    TMR0IF=0; /* Clear Interrupt Flag 1 */

    tmr0++;
    if(tmr0>20)
    {
     LATC=0;
     LATA=0;
     TRISA=0b11111100;
     TRISC=0b11110101;
     tmr0=0;
     init_ser();
     send_ser(1);
     send_ser(2);
     send_ser(3);
     send_ser(4);

     TRISA=0xff;
     TRISC=0b11110111;
    }}
}

    void main(void)
{
   
    InitApp();

    GIE=1;
    TMR0IE=1;

    while(1){}

}
Note the display PCB is on the bottom of the LED 7seg module. The green PCB is only used for testing (16f1503).

The switches are neccessary for FLASH programming since the header is shared, as well the pins are used to transmit the serial data. Later in a real circuit, no switches are needed.

The displays will be available soon for sale. Time to make a profit of $1 or $2 after years and spending 1000s on components.
 

Attachments

Thread Starter

takao21203

Joined Apr 28, 2012
3,702
The code for the displays as well.

Rich (BB code):
#include <xc.h>         /* XC8 General Include File */
#include "system.h"      
#include "user.h"          /* User funct/params, such as InitApp */

const unsigned char ph_PORTA[]={2,2,0,2};
const unsigned char ph_PORTB[]={0x81,0x41,0xc1,0xc0};

const unsigned char dig_PORTA[]={0xd,0x1,0x9,0x9,0x5,0xc,0xc,0x9,\
                                 0xd,0xd,0xd,0x4,0xc,0x1,0xc,0xc,\
                                 0x0,0x5,0x4};

const unsigned char dig_PORTB[]={0x16,0x10,0x26,0x34,\
                                 0x30,0x34,0x36,0x30,\
                                 0x36,0x34,0x32,0x36,\
                                 0x06,0x36,0x26,0x22,\
                                 0x20,0x32,0x06};

unsigned char v_digit0,v_digit1,v_digit2,v_digit3;
unsigned char v_phase,v_refresh,v_PORTA,v_PORTB;
unsigned char v_digit_data;

#define clk PORTBbits.RB7
#define data PORTBbits.RB6

void get_serial()
{
    v_digit_data=0;
    while(!clk);if(data)v_digit_data|=1;
    while(clk);
    while(!clk);if(data)v_digit_data|=2;
    while(clk);
    while(!clk);if(data)v_digit_data|=4;
    while(clk);
    while(!clk);if(data)v_digit_data|=8;
    while(clk);
    while(!clk);if(data)v_digit_data|=10;
    while(clk);
}
void main(void)
{
    TRISA= 0xff;
    TRISB= 0xff;
    v_phase=0;
    v_refresh=0;
    
    get_serial();
    v_digit0=v_digit_data&0x0f;
    get_serial();
    v_digit1=v_digit_data&0xf;
    get_serial();
    v_digit2=v_digit_data&0xf;
    get_serial();
    v_digit3=v_digit_data&0xf;

    /* Initialize I/O and Peripherals for application */
    PORTA=0;
    PORTB=0;
    TRISB=0;TRISA=0;
    OPTION=4;

    while(1)
    {
        if((TMR0>0x80)&&(v_refresh==0))
        {
         v_refresh=0x77;
         if(v_phase==0)v_digit_data=v_digit0;
         if(v_phase==1)v_digit_data=v_digit1;
         if(v_phase==2)v_digit_data=v_digit2;
         if(v_phase==3)v_digit_data=v_digit3;
         v_PORTA=ph_PORTA[v_phase]|dig_PORTA[v_digit_data];
         v_PORTB=ph_PORTB[v_phase]|dig_PORTB[v_digit_data];
         PORTA=v_PORTA;PORTB=v_PORTB;
         v_phase++;if(v_phase==4)v_phase=0;
        }else v_refresh=0x00;
    }

}
Since it is not really sophisticated technology, and I wrote it in an hour.

However you need to build a new data table for each different display, and also the data table depends on the PCB layout.

It is only shown to give you an idea.

It does not just work on any display or PCB.

For the schematic, well all display pins are connected to PIC I/O bits. The serial port is on RB6/RB7.
 

Markd77

Joined Sep 7, 2009
2,806
You could poll the serial pins in the display loop and avoid the extra wire needed for reset. You might have to reduce the rate the serial data is sent, but as it would also get rid of the 20ms device reset timer it would probably be faster overall.
You could do the same but with asynchronous serial and then only one pin would be required.
 

Thread Starter

takao21203

Joined Apr 28, 2012
3,702
You could poll the serial pins in the display loop and avoid the extra wire needed for reset. You might have to reduce the rate the serial data is sent, but as it would also get rid of the 20ms device reset timer it would probably be faster overall.
You could do the same but with asynchronous serial and then only one pin would be required.
yes I have done it that way before- resulting in a lengthy source code.

All pins are used so it must be multiplexed with the LED display.
It is possible, but a lot of effort, and requires extra components as well.

It is also complicated on the sender side, needs one extra line to wait for a transition.

Or it would conflict with the LED display data.

The PIC16f54 does not have a hardware serial port.

The 16f716 does have an interrupt on port change, so it could be done with two pins.

Still more complicated since the master must care for the transition.

It is a good solution in terms of simplicity and short source code.
The display goes off during the update, but not really annoying.

I will have an STM8 circuit ready soon with upto 24 I/O, and hardware serial port. Chips arrived here today.

Think of a radiation counter. It is not used very often, and the display going off for a short moment every second is totally acceptable. Applications like that.

If you want a high-grade display, use a LCD or TFT.

The refresh frequency I have programmed is good as well. It is not true actually, but it looks as if all segments are having even brightness. Technically they don't. That was a big annoyance, far more than the display going off a little during update.
 

Thread Starter

takao21203

Joined Apr 28, 2012
3,702
The displays actually open a range of new possibilities.

Much smaller controllers like for instance a 16f1503 can be used.

I added 3 LDRs and 2 pushbuttons.

4 digits are totally enough to display the mode, and the 10bit value directly.

Character LCDs are much larger, need a certain voltage for the bias (not so easy to work from a depleted coin cell), and the software interface is complicated to setup.

The code for the serial LED display is very easy to use.
The voltage range is really less than 2v to full 5V.
Only 3 wires.

My own productivity is much increased.

Sadly it took me about 2 years to have the idea simply to reset the display each time, then to transmit the data. And also the complicated assembler code made me not wanting to use them at all.

Next I want to make my radiation counter working...

I had the display mounted already, but then gave up to search for the schematic how to add the resistors, and how to wire it, and also to adapt the assembler to C. So it was just sitting there, uncompleted as it is.

One for sure- assembler is almost banned from my work.

I strongly recommend not to use it at all, if any possible.
 

Attachments

MrChips

Joined Oct 2, 2009
30,824
Why not go to the ultimate solution. Serial LED or LCD displays with backlighting, interfaced with one addressable control line, power and ground.

 

Thread Starter

takao21203

Joined Apr 28, 2012
3,702
Why not go to the ultimate solution. Serial LED or LCD displays with backlighting, interfaced with one addressable control line, power and ground.

Every government funded research and university needs 20 of these.

Then the manual gets lost and/or the cable, so despite the high price, nobody can or actually is using them.
 

Thread Starter

takao21203

Joined Apr 28, 2012
3,702
When I went to college the gear had an utilization rate of not even 1%.

We also had a PLC class with very old and klunky units floating around everywhere. Actually they were never even just powered up.

So they could use cardboard imitations.

What are these? Serial display units? What are they good for? When was the data they were produced? Where are they used?
 

MrChips

Joined Oct 2, 2009
30,824
It doesn't matter what they are used for. I am showing an example of multiple displays that are interfaced via a single wire to the controller board.
 

Thread Starter

takao21203

Joined Apr 28, 2012
3,702
It doesn't matter what they are used for. I am showing an example of multiple displays that are interfaced via a single wire to the controller board.
OK. Small TFTs also have SPI. And they need additional control signals as well. Also only cost 6 dollar, and can display a number of lines and even graphics.

However they need a regulated power supply, about 3 volts. If the battery becomes depleted, you need to step up, or the display will go off.

Big advantage of LED 7seg. They will go down to 1.5V really. Need no regulation.

The units you show rather raise question for the enclosure. You could step on these probably.
 

Thread Starter

takao21203

Joined Apr 28, 2012
3,702
Programmed the firmware for 3-digit displays today.
http://pic.hitechworld.org/serial_led.html

After writing such tables quite many times, it only takes an hour to create the data for a new display. Common Anodes for these.

Finalized the dual LCD PCB today- also soon will be produced. 2x PIC 16f59, and 1000uH coils for low frequency (to save battery power).
 

Attachments

Thread Starter

takao21203

Joined Apr 28, 2012
3,702
The 16f59 LCD boards arrived here.

Same technology. 2x 16f59 controllers.

Quite expensive, cost me about 8 dollar each.

On ebay for $15.98 or best offer.
It takes a while to assemble them, and the firmware + documentation also is a lot of work.

Differently to Hitachi standard LCD modules, these work from 3V button cells, and contrast does not drop off if the battery runs out more and more.

I have actually no idea how many uA or mA they use, or what is the MCU frequency. Much lower here for the LCD to save power.
 

Attachments

Top