Long Island, New York
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« 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. #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
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #1 on: January 22, 2013, 04:44:55 pm » |
Can't edit posts on this forum, heh. line that's commented out /* 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
Offline
God Member
Karma: 18
Posts: 841
Have you testrun your PDE file today?
|
 |
« Reply #2 on: January 22, 2013, 04:48:45 pm » |
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
Offline
God Member
Karma: 18
Posts: 841
Have you testrun your PDE file today?
|
 |
« Reply #3 on: January 22, 2013, 04:53:19 pm » |
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
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #4 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.
|
|
|
|
« Last Edit: January 22, 2013, 05:18:17 pm by Tezzers »
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #5 on: January 22, 2013, 05:28:26 pm » |
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
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #6 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?
|
|
|
|
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 31
Posts: 2311
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #7 on: January 23, 2013, 08:43:32 pm » |
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.
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
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
UK
Offline
Tesla Member
Karma: 89
Posts: 6391
-
|
 |
« Reply #8 on: January 23, 2013, 09:12:59 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()
Also suggest you consider making that fixed data const and also consider moving it to progmem to free up RAM.
|
|
|
|
|
Logged
|
|
|
|
|
Long Island, New York
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #9 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.
|
|
|
|
|
Logged
|
|
|
|
|
Long Island, New York
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #10 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. 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
Tesla Member
Karma: 89
Posts: 6391
-
|
 |
« Reply #11 on: January 23, 2013, 09:35:04 pm » |
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
|
|
|
|
|
Long Island, New York
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #12 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. #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
Tesla Member
Karma: 89
Posts: 6391
-
|
 |
« Reply #13 on: January 24, 2013, 09:19:10 am » |
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
|
|
|
|
|
|