Pages: [1]   Go Down
Author Topic: LED Display/clock, no output, no compilation errors  (Read 563 times)
0 Members and 1 Guest are viewing this topic.
Long Island, New York
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using a LTM-8647AHR display to tell the time in 12 hour format, with hours minutes and seconds. It's not lighting up any segments however. Hardware isn't an issue as far as I and another friend can tell. On the scope, I couldn't see any pulse, but it's an analog scope so not sure if I should've. Below is the code, the schematic, and above is a link to the datasheet download mirrors.



Uses a 317 for the 3.3V rail, and a 7805 for the 5 volt rail. Bypass caps on the input and output of both regulators. Both are fed by a 9 VDC 2 A Wall wart, and all display IC's are getting voltage to the supply pins.

Code:
#define SECS_CS    46
#define MINS_CS    44
#define HOURS_CS   42
#define SDATA      22
#define SCLK       30
#define PPS        26
#define DP1        0x10000000
#define DP2        0x20000000

void setup(void)
{
pinMode(SECS_CS,OUTPUT);
pinMode(MINS_CS,OUTPUT);
pinMode(HOURS_CS,OUTPUT);
pinMode(SDATA,OUTPUT);
pinMode(SCLK,OUTPUT);
pinMode(PPS,INPUT);
digitalWrite(SECS_CS,1);
digitalWrite(MINS_CS,1);
digitalWrite(HOURS_CS,1);
digitalWrite(SDATA,0);
digitalWrite(SCLK,0);
}

void loop()
{
unsigned char secs=0;
unsigned char mins=0;
unsigned char hours=12;
unsigned char ampm=0;
int i;
long seg;
long segments[]={
0x200FC03F,
0x200FC006,
0x200FC0DB,
0x200FC0CF,
0x200FC0E6,
0x200FC0ED,
0x200FC0FD,
0x200FC007,
0x200FC0FF,
0x200FC0E7,
0x2001803F,
0x20018006,
0x200180DB,
0x200180CF,
0x200180E6,
0x200180ED,
0x200180FD,
0x20018007,
0x200180FF,
0x200180E7,
0x2036C006,
0x2036C0DB,
0x2036C0CF,
0x2036C0E6,
0x2036C0ED,
0x2036C0FD,
0x2036C007,
0x2036C0FF,
0x2036C0E7,
0x2036C006,
0x2033C03F,
0x2033C006,
0x2033C0DB,
0x2033C0CF,
0x2033C0E6,
0x2033C0ED,
0x2033C0FD,
0x2033C007,
0x2033C0FF,
0x2033C0E7,
0x2039803F,
0x20398006,
0x203980DB,
0x203980CF,
0x203980E6,
0x203980ED,
0x203980FD,
0x20398007,
0x203980FF,
0x203980E7,
0x203B403F,
0x203B4006,
0x203B40DB,
0x203B40CF,
0x203B40E6,
0x203B40ED,
0x203B40FD,
0x203B4007,
0x203B40FF,
0x203B40E7
};

  {
/*  while(digitalRead(PPS)) ; */
  delay(999);
  if(++secs>59)
{
secs=0;
if(++mins>59)
{
mins=0;
if(++hours>12)
{
hours=1;
ampm^=1;
}
}
}
  seg=(ampm)?  segments[secs] : (segments[secs]&~(DP2));  //turn off dp2 if ampm==0 (AM)
  writeLED(seg,SECS_CS);
  writeLED(segments[mins],MINS_CS);
  writeLED(segments[hours],HOURS_CS);
  }
return(0); 
}

void writeLED(long segword, int cs)
{
int i;
 
digitalWrite(cs,0);     //assert chip select 
 
digitalWrite(SCLK,0);
digitalWrite(SDATA,1);  //start bit
digitalWrite(SCLK,1);
digitalWrite(SCLK,0);

for(i=1; i!=0; i<<=1)
  {
  if(segword&i) digitalWrite(SDATA,1);
  else digitalWrite(SDATA,0);
  digitalWrite(SCLK,1);
  digitalWrite(SCLK,0);
  }

digitalWrite(SDATA,0);
for(i=0;i<4;i++)
  {
  digitalWrite(SCLK,1);
  digitalWrite(SCLK,0);
  }
digitalWrite(cs,1);     //chip select off
 
return; 
}

 
Code used, no errors when compiled.

I'm just trying to get it to put out the time in hours, minutes, and seconds starting at 12:00:00 for now.

Thanks for any help that can be offered.

« Last Edit: January 23, 2013, 09:26:53 pm by Tezzers » Logged

Long Island, New York
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can't edit posts on this forum, heh.

line that's commented out

Code:
/*  while(digitalRead(PPS)) ; */
is going to be used to sync it up with a 1 Hz pulse from a binary clock, and is to be ignored for the moment.
Logged

Copenhagen, Denmark
Online Online
Edison Member
*
Karma: 25
Posts: 1133
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can't edit posts on this forum, heh.
Yes you can. Its hard to find the little edit icon though. Its in the post on the lower right
Logged

Copenhagen, Denmark
Online Online
Edison Member
*
Karma: 25
Posts: 1133
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's not lighting up any segments however. Hardware isn't an issue ...
Are you sure? Can you load a very simple program that just pulses out lots of 1's (lighting up everything), and after a while pulses out lots of 0's (turning everything off). Until you can do that there are two possible problems.

The hardware is wrong, somewhere.

You have not been able to pulse something out. Even with an analog scope you should see some pulses

Good hunting for the bug.

When above works we can start looking at the program
Logged

Long Island, New York
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sure? Can you load a very simple program that just pulses out lots of 1's (lighting up everything), and after a while pulses out lots of 0's (turning everything off). Until you can do that there are two possible problems.

I have no clue how to do so, I had a friend do the code for me, who's not available.
« Last Edit: January 22, 2013, 05:18:17 pm by Tezzers » Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
no compilation errors

No compilation errors means you are 1% closer to your goal of having a functioning device.
Logged

Long Island, New York
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Got it on a digital scope, and oddly the clock is tristating somehow. After a few pulses it goes into a slight curve and rests floating around 3V, but the data keeps on going. Any help with this one?
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 44
Posts: 2808
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I didn't read your code carefully but I did notice that there were no pull-ups on clock or data. About 4K7 for a start and if your wiring to the S/R's is long those values could drop to 1K with no problems.

I did however look at the sketch again and noticed this.. How would you display 12:15 AM?
The Time Library works well for this sort of thing, I use it for a GPS clock but the GPS example in the library doesn't work at all. A friend wrote a working GPS example for the Time Lib... take a look at the library. If you want the time gps sketch I can post it, PM me, I may not check this thread again.

Quote
if(++hours>12)
         {
         hours=1;  // shouldn't this be 0 ?
         ampm^=1;
[/color]
Bob
« Last Edit: January 23, 2013, 09:03:33 pm by Docedison » Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11170
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You have defined main() so your definition will be used instead of the Arduino default. Your implementation of main() doesn't call setup() so you are not initialising any of your pins.

Unless you have a particular reason not to use the standard Arduino main() I suggest you restructure your code as follows:

  • Take the variable declarations from main() and make them global
  • Create a function void loop()
  • Take the code out of the while(1) loop and put them inside the new function loop
  • Throw away the now-empty remains of main()

Also suggest you consider making that fixed data const and also consider moving it to progmem to free up RAM.


Logged

I only provide help via the forum - please do not contact me for private consultancy.

Long Island, New York
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You have defined main() so your definition will be used instead of the Arduino default. Your implementation of main() doesn't call setup() so you are not initialising any of your pins.

Unless you have a particular reason not to use the standard Arduino main() I suggest you restructure your code as follows:

  • Take the variable declarations from main() and make them global
  • Create a function void loop()
  • Take the code out of the while(1) loop and put them inside the new function loop
  • Throw away the now-empty remains of main()


I changed that in the code late last night but forgot to update it, sorry. That was done before I got to the DSO.
Logged

Long Island, New York
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I did however look at the sketch again and noticed this.. How would you display 12:15 AM?
The Time Library works well for this sort of thing, I use it for a GPS clock but the GPS example in the library doesn't work at all. A friend wrote a working GPS example for the Time Lib... take a look at the library. If you want the time gps sketch I can post it, PM me, I may not check this thread again.


The way it's set up it should work. For the moment I just want it to increment roughly at 1 second intervals.


Quote
if(++hours>12)
         {
         hours=1;  // shouldn't this be 0 ?
         ampm^=1;


It should be 1. It's a 12 hour format, starting at 1 and ending at 12.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11170
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I changed that in the code late last night but forgot to update it, sorry. That was done before I got to the DSO.

Will you post your actual code now, please? Your amended code in the first post is obviously not it. To avoid confusion/doubt I suggest you put it in a new post and not by amending the previous post.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Long Island, New York
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Will you post your actual code now, please? Your amended code in the first post is obviously not it. To avoid confusion/doubt I suggest you put it in a new post and not by amending the previous post.

Sure.

Code:
#define SECS_CS    46
#define MINS_CS    44
#define HOURS_CS   42
#define SDATA      22
#define SCLK       30
#define PPS        26
#define DP1        0x10000000
#define DP2        0x20000000

void setup(void)
{
pinMode(SECS_CS,OUTPUT);
pinMode(MINS_CS,OUTPUT);
pinMode(HOURS_CS,OUTPUT);
pinMode(SDATA,OUTPUT);
pinMode(SCLK,OUTPUT);
pinMode(PPS,INPUT);
digitalWrite(SECS_CS,1);
digitalWrite(MINS_CS,1);
digitalWrite(HOURS_CS,1);
digitalWrite(SDATA,0);
digitalWrite(SCLK,0);
}

void loop()
{
unsigned char secs=0;
unsigned char mins=0;
unsigned char hours=12;
unsigned char ampm=0;
int i;
long seg;
long segments[]={
0x200FC03F,
0x200FC006,
0x200FC0DB,
0x200FC0CF,
0x200FC0E6,
0x200FC0ED,
0x200FC0FD,
0x200FC007,
0x200FC0FF,
0x200FC0E7,
0x2001803F,
0x20018006,
0x200180DB,
0x200180CF,
0x200180E6,
0x200180ED,
0x200180FD,
0x20018007,
0x200180FF,
0x200180E7,
0x2036C006,
0x2036C0DB,
0x2036C0CF,
0x2036C0E6,
0x2036C0ED,
0x2036C0FD,
0x2036C007,
0x2036C0FF,
0x2036C0E7,
0x2036C006,
0x2033C03F,
0x2033C006,
0x2033C0DB,
0x2033C0CF,
0x2033C0E6,
0x2033C0ED,
0x2033C0FD,
0x2033C007,
0x2033C0FF,
0x2033C0E7,
0x2039803F,
0x20398006,
0x203980DB,
0x203980CF,
0x203980E6,
0x203980ED,
0x203980FD,
0x20398007,
0x203980FF,
0x203980E7,
0x203B403F,
0x203B4006,
0x203B40DB,
0x203B40CF,
0x203B40E6,
0x203B40ED,
0x203B40FD,
0x203B4007,
0x203B40FF,
0x203B40E7
};

  {
/*  while(digitalRead(PPS)) ; */
  delay(999);
  if(++secs>59)
{
secs=0;
if(++mins>59)
{
mins=0;
if(++hours>12)
{
hours=1;
ampm^=1;
}
}
}
  seg=(ampm)?  segments[secs] : (segments[secs]&~(DP2));  //turn off dp2 if ampm==0 (AM)
  writeLED(seg,SECS_CS);
  writeLED(segments[mins],MINS_CS);
  writeLED(segments[hours],HOURS_CS);
  }
}

void writeLED(long segword, int cs)
{
int i;
 
digitalWrite(cs,0);     //assert chip select 
 
digitalWrite(SCLK,0);
digitalWrite(SDATA,1);  //start bit
digitalWrite(SCLK,1);
digitalWrite(SCLK,0);

for(i=1; i!=0; i<<=1)
  {
  if(segword&i) digitalWrite(SDATA,1);
  else digitalWrite(SDATA,0);
  digitalWrite(SCLK,1);
  digitalWrite(SCLK,0);
  }

digitalWrite(SDATA,0);
for(i=0;i<4;i++)
  {
  digitalWrite(SCLK,1);
  digitalWrite(SCLK,0);
  }
digitalWrite(cs,1);     //chip select off
 
return; 
}

Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11170
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In Arduino, int is a sixteen bit type. In writeLED() you're only shifting out twenty bits rather than the thirty six bits that the display controller is expecting. To shift out all thirty six bits, you would need to make i an unsigned long.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: