CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Code how to drive 40-Segment LED Bar Display Board

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

Code how to drive 40-Segment LED Bar Display Board
PostPosted: Thu Sep 13, 2007 2:37 pm     Reply with quote

Can someone help me to drive this board (see link below)

Is it possible to drive it with SPI commands?
Please give me a simple example
Lets say the first led on the second led bar must lit

http://www.sure-electronics.net/mcu,display/DE-DP011.pdf


Last edited by The Puma on Sun Sep 16, 2007 4:06 am; edited 1 time in total
kevcon



Joined: 21 Feb 2007
Posts: 142
Location: Michigan, USA

View user's profile Send private message

PostPosted: Thu Sep 13, 2007 2:51 pm     Reply with quote

Dude,

there is PIC code right in the datasheet what more do you need?
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Sep 13, 2007 3:21 pm     Reply with quote

What must i change to use it with CCS-C

Quote:
void SEG_Shift3(void)
{
unsigned char i;
position++;
for(i = 0;i < (40-position); i++)
{
DATA = 1;
CLK = 0;
CLK = 1;
}
for(i = 0;i < position; i++)
{
DATA = 0;
CLK = 0;
CLK = 1;
}
if(position>40)position=0;
[/code]
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Fri Sep 14, 2007 3:35 am     Reply with quote

Hello,

here is just an example, there are some other way to adapting.
Code:

#define Fuc_key  PIN_B3
#define DIMM     PIN_B2

#define CLKpin   PIN_B1
#define DATApin  PIN_B0

int position ;

void SEG_Shift3(void) {
 unsigned char i;
 
  position++;
  for(i = 0;i < (40-position); i++) {
    output_high(DATA) ;
    output_low(CLK);
    output_high(CLK);
  }
  for(i = 0;i < position; i++) {
    output_low(DATA) ;
    output_low(CLK);
    output_high(CLK);
  }
  if(position>40)position=0;
}


An other way:
Code:

#define Fuc_key  PIN_B3
#define DIMM     PIN_B2

#define CLKpin   PIN_B1
#define DATApin  PIN_B0

#define DATA(x) output_bit(DATApin, x)
#define CLK(x) output_bit(CLKpin, x)

int position ;

void SEG_Shift3(void) {
 unsigned char i;
 
 position++;
  for(i = 0;i < (40-position); i++) {
    DATA(1) ;
    CLK(0);
    CLK(1);
  }
  for(i = 0;i < position; i++) {
    DATA(0) ;
    CLK(0);
    CLK(1);
  }
  if(position>40)position=0;
}


dro.
_________________
in médio virtus
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Sep 14, 2007 6:48 am     Reply with quote

Ok, thx i will play with it
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Sep 15, 2007 2:08 pm     Reply with quote

Ok, i have it working
This lit up the leds from right to left
then it clears the leds

But i need the following routine:
let say i must lit the led no 8
Can i made a routine the swith a led (on or off) whrn i give a ledno as parameter ( 1...40)

Please can someone help me


Quote:

for(i=0;i<40;i++) {

output_high(DE_DP011_DATA);
delay_ms(100);
output_low(DE_DP011_CLK);
delay_us(50);
output_high(DE_DP011_CLK);
delay_us(50);
}

for(i=0;i<40;i++) {
output_low(DE_DP011_DATA);
delay_ms(100);
output_low(DE_DP011_CLK);
delay_us(50);
output_high(DE_DP011_CLK);
delay_us(50);
}

}
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Sep 16, 2007 3:32 am     Reply with quote

The hardware is the following:
It has 4 x led matrix ( 10 leds/bar) controlled by 5 x 74HC164
My question is now, how can i switch led 15 on?
There must be an easer method to do that than below

Code:

DE_DP011_send_byte(0);
DE_DP011_send_byte(0);
DE_DP011_send_byte(0);
DE_DP011_send_byte(64);
DE_DP011_send_byte(0);

Now must i send 5 times the send_byte procedure with the correct value
Can i made a procedure and gives as parameter the ledno that will lit


Another nice program where it to display the value of the ADC(PIC) to the ledbar.

In steps of 1024(5volts)/40(leds) = 26
a value below 26 most lit no led, a value >26 and <52 must lit led1 and so on

The source sofar is the this:

Code:
#include <18F4620.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOBROWNOUT,NOPUT,NOLVP,DEBUG,NOSTVREN,NOPROTECT

#include <de_dp011.h>
   
void main() {
   DE_DP011_init();
      
   while(TRUE) {
      DE_DP011_send_byte(0);
      DE_DP011_send_byte(0);
      DE_DP011_send_byte(0);
      DE_DP011_send_byte(0);
      DE_DP011_send_byte(1);
      delay_ms(1000);
   }
}

Code:
#ifndef DE_DP011_SELECT

#define DE_DP011_SELECT  PIN_C0
#define DE_DP011_CLK     PIN_C3
#define DE_DP011_DATA    PIN_C5

#endif

void DE_DP011_init() {
   output_high(DE_DP011_SELECT);
}

void DE_DP011_send_byte(BYTE data) {
   BYTE i;
      
   for(i=0;i<8;i++) {
      if((data&0x80)==0)
         output_low(DE_DP011_DATA);
      else
         output_high(DE_DP011_DATA);
   shift_left(&data,1,0);
   output_high(DE_DP011_CLK);
   output_low(DE_DP011_CLK);
   }
}
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Sep 19, 2007 9:47 am     Reply with quote

Can nobody can help me or give me a hint to do that?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group