Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: LED Display/clock, no output, no compilation errors on: January 23, 2013, 10:04:57 pm
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; 
}

2  Using Arduino / Programming Questions / Re: LED Display/clock, no output, no compilation errors on: January 23, 2013, 09:34:17 pm

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.
3  Using Arduino / Programming Questions / Re: LED Display/clock, no output, no compilation errors on: January 23, 2013, 09:28:43 pm
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.
4  Using Arduino / Programming Questions / Re: LED Display/clock, no output, no compilation errors on: January 23, 2013, 08:32:20 pm
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?
5  Using Arduino / Programming Questions / Re: LED Display/clock, no output, no compilation errors on: January 22, 2013, 05:08:18 pm
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.
6  Using Arduino / Programming Questions / Re: LED Display/clock, no output, no compilation errors on: January 22, 2013, 04:44:55 pm
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.
7  Using Arduino / Programming Questions / LED Display/clock, no output, no compilation errors on: January 22, 2013, 04:37:39 pm
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.

Pages: [1]