PDA

View Full Version : Scrolling thermo



fratello
- 6th September 2011, 14:46
Hi ! I made this schematic : http://solderslingers.com/cart/index.php?main_page=product_info&products_id=1 and work very fine ! So, since I am "0" in Atmel programming, I try to write my own program for PIC, using PBP (here am I to "1" level :) and example from this forum- Thanks to Mr.D.J.Welburn !
But...of course, I need help. Only 4 columns are lighting and the characters are ...strange, non-readable. It's some "moving" on my led matrix, but sure it's something wrong. I need help ! Thanks in advance !

@ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_ON
define osc 4
INTCON = 0
TRISA= %00000000
TRISB= %10000000
DQ var PortB.7
CMCON=7 ' Disable comparators


'************************************************* **************************************
eeprom 0, [%00111110,%01010001,%01001001,%01000101,%00111110] '0
eeprom 5, [%00000000,%01000010,%01111111,%01000000,%00000000] '1
eeprom 10,[%01000010,%01100001,%01010001,%01001001,%01000110] '2
eeprom 15,[%00100001,%01000001,%01000101,%01001011,%00110001] '3
eeprom 20,[%00011000,%00010100,%00010010,%01111111,%00010000] '4
eeprom 25,[%00100111,%01000101,%01000101,%01000101,%00111001] '5
eeprom 30,[%00111100,%01001010,%01001001,%01001001,%00110000] '6
eeprom 35,[%00000001,%01110001,%00001001,%00000101,%00000011] '7
eeprom 40,[%00110110,%01001001,%01001001,%01001001,%00110110] '8
eeprom 45,[%00000110,%01001001,%01001001,%00101001,%00011110] '9



counter var byte
scan var byte
scroll var byte
leddata var byte[36] 'Column Data for display 36 columns
temperature var Word 'reading from sensor
Sign var BIT
tempA var byte 'Stores First digit (High)
tempB var byte 'stores Second digit (Mid)
tempC var byte 'stores Third digit (low)

DS18B20_12bit CON %01111111

START:
CLEAR 'Clear all varibles

' Init Sensor 1
OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
OWOut DQ, 1, [$CC, $48] ' Start temperature conversion
OWOut DQ, 1, [$CC, $B8]
OWOut DQ, 1, [$CC, $BE]
Pause 50
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Pause 50

'leddata locations 0-7 are blank so that data scrolls onto display
'leddata locations 8-12 1st digit (leading digit)
'leddata location 13 blank column between digits
'leddata locations 14-18 2nd digit
'leddata location 19 blank column between digits
'leddata locations 20 & 21 Decimal Point
'leddata locations 23 - 27 3rd digit (last digit)
'leddata locations 28 blank column between digits
'leddata locations 29 - 34 Degrees C symbol
'leddata location 35 is a blank column at end to clear display as it scrolls

leddata [20] = %11000000 ' DECIMAL POINT
leddata [21] = %11000000

leddata [29] = %00000011 ' degrees c
leddata [30] = %00000011
leddata [31] = %00111000
leddata [32] = %01000100
leddata [33] = %01000100
leddata [34] = %01000100


OWOut DQ, 1, [$CC, $44]
OWOut DQ, 1, [$CC, $BE]
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Sign = temperature.15
temperature= ABS(temperature)
temperature=((temperature >> 4)*100) + ((temperature & $F) * 100 >> 4)
if sign then temperature= -temperature


tempA = temperature DIG 2
tempB = temperature DIG 1
tempC = temperature DIG 0

IF tempA = 0 THEN ' if 1st digit is 0 then skip so display dosnt display 09.5c
GOTO skipdigit ' it will display 9.5c instead
ENDIF
FOR counter = 0 TO 4
READ tempA*5+counter,leddata [counter+8] 'stores 1st digit in leddata locations 8,9,10,11,12
NEXT counter
skipdigit:
FOR counter = 0 TO 4
READ tempB*5+counter,leddata [counter+14] 'stores 2nd digit in leddata locations 14,15,16,17,18
NEXT
FOR counter = 0 TO 4
READ tempC*5+counter,leddata [counter+23] 'stores 3rd digit in leddata locations 23,24,25,26,27
NEXT





LOOP:
FOR scroll = 0 TO 35
FOR scan = 0 TO 15
PORTA = 1
FOR counter = 0 TO 7
PORTB = leddata [counter]
PAUSEUS 1500
PORTB = 0
PORTA = PORTA * 2
NEXT
NEXT
FOR counter = 0 TO 34
leddata [counter] = leddata [counter+1]
NEXT
NEXT
GOTO START
END

BobEdge
- 6th September 2011, 15:27
Hi,

Just ran a simulation in isis. First thing I notice is that porta.4 does not seem to be working. Don't know if that is just the simulator though.

Will take a closer look at your code :)

pedja089
- 6th September 2011, 17:42
Maybe pull up resistor is missing?

gadelhas
- 6th September 2011, 17:51
Hi;

In PIC16F628A the RA4 Pin is open drain, so you wll need a pull up resistor.

fratello
- 6th September 2011, 18:05
Working soft in simulation !!!

fratello
- 6th September 2011, 18:20
Mr.Arrati say : " PortA.4 is a Schmitt Trigger input and an open drain output. You will need an additional NPN transistor with a pull down resistor to make column 5 working.". So... can I use PortA.5 instead PortA.4 ? How ? Using "MCLR off" and ?!

gadelhas
- 6th September 2011, 18:41
Mr.Arrati say : " PortA.4 is a Schmitt Trigger input and an open drain output. You will need an additional NPN transistor with a pull down resistor to make column 5 working.". So... can I use PortA.5 instead PortA.4 ? How ? Using "MCLR off" and ?!

You can only use RA5 as Input with MCLR off

fratello
- 6th September 2011, 20:35
This is schematic who work fine in Proteus. In "real life" , despite modification of scroll timming (pause 500 to 5000 !), the led's are always ON !!! Any idea ?
Thanks !

gadelhas
- 6th September 2011, 21:01
Hi;

I cannot compile that source code. What is the "LOOP" for?? This is a reserved word, you cannot compile the code with this word on a label. And i'm always getting illegal opcode.

What are you using to compile? Mpasm? or PBP?

gadelhas
- 6th September 2011, 21:13
Got it;
Since I'm using MPASM needed to change the config line;



@ __config _INTOSC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _BODEN_OFF & _MCLRE_ON


Also like i said before needed to delete the "LOOP" label also, since its a reserved word.

mister_e
- 6th September 2011, 21:32
LOOP is a reserved word for new version of PBP (2.60 and latter if my memory serves me well) you can replace it with a REPEAT/UNTILL, WHILE/WEND loop.

mister_e
- 6th September 2011, 21:38
This is schematic who work fine in Proteus. In "real life" , despite modification of scroll timming (pause 500 to 5000 !), the led's are always ON !!! Any idea ?
Thanks !
Are they FULL ON or dimmed? I feel they will be dimmed, it's a kind of ghost ;) probably you'll need to add some delay after you turn them off, after the PORTB=0 line

Turn some LED ON, wait a little bit, turn them OFF, wait a little, do it again.

fratello
- 7th September 2011, 08:56
I will try this code today, later...

....
LOOPing:
FOR scroll = 0 TO 35
FOR scan = 0 TO 15
PORTb = 1
porta=1
FOR counter = 0 TO 7
PORTA = leddata [counter]
PAUSE 10
PORTb = PORTb * 2
NEXT
NEXT
FOR counter = 0 TO 34
leddata [counter] = leddata [counter+1]
NEXT
NEXT
GOTO START
END

I find another ...mistake (?) : line 2 do not appear on matrix ! What a hell it's going ?!

fratello
- 8th September 2011, 14:04
Tens of variants and no result ! Nobody has a clue ?

Sphere
- 8th September 2011, 18:59
You might have to play with your FOSC setting to enable I/O mode on RA6&RA7.

Sphere.

fratello
- 8th September 2011, 20:18
With schematic from post #8 :

; working variant ; anode to portB, catode to portA
@ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_off
define osc 4
INTCON = 0
TRISA = %00000000
TRISB = %10000000
CMCON = 7 ' Disable comparators

DQ var PortB.7

'************************************************* **************************************
eeprom 0, [%10100001,%01111010,%01110110,%01101110,%10100001] '0
eeprom 5, [%11111111,%01111101,%00000000,%01111111,%11111111] '1
eeprom 10,[%01111101,%00111110,%01101110,%01110110,%01111001] '2
eeprom 15,[%10111101,%01111110,%01110110,%01110110,%10101001] '3
eeprom 20,[%11100111,%11101011,%11101101,%00000000,%11101111] '4
eeprom 25,[%10111000,%01111010,%01111010,%01111010,%10100110] '5
eeprom 30,[%10100001,%01110110,%01110110,%01110110,%10101101] '6
eeprom 35,[%11111110,%00001110,%11110110,%11111010,%11111100] '7
eeprom 40,[%10001001,%01110110,%01110110,%01110110,%10001001] '8
eeprom 45,[%11111001,%01110110,%01110110,%01110110,%10001001] '9

counter var byte
scan var byte
scroll var byte
leddata var byte[36] 'Column Data for display 36 columns
temperature var Word 'reading from sensor
Sign var BIT
tempA var byte 'Stores First digit (High)
tempB var byte 'stores Second digit (Mid)
tempC var byte 'stores Third digit (low)
n var byte

DS18B20_12bit CON %01111111

START:
CLEAR 'Clear all varibles

' Init Sensor 1
OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
OWOut DQ, 1, [$CC, $48] ' Start temperature conversion
OWOut DQ, 1, [$CC, $B8]
OWOut DQ, 1, [$CC, $BE]
Pause 50
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Pause 50


for n=0 to 7
leddata [n] = %11111111
next n

leddata [13] = %11111111
leddata [19] = %11111111
leddata [20] = %00111111 ' DECIMAL POINT
leddata [21] = %00111111
leddata [22] = %11111111
leddata [28] = %11111111


leddata [29] = %11111100 ' degrees c
leddata [30] = %11111100
leddata [31] = %11100011
leddata [32] = %10111101
leddata [33] = %10111101
leddata [34] = %10111101
leddata [35] = %11111111

OWOut DQ, 1, [$CC, $44]
OWOut DQ, 1, [$CC, $BE]
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Sign = temperature.15
temperature= ABS(temperature)
temperature=((temperature >> 4)*100) + ((temperature & $F) * 100 >> 4)
if sign then temperature= -temperature

tempA = temperature DIG 3
tempB = temperature DIG 2
tempC = temperature DIG 1

IF tempA = 0 THEN
for counter = 0 to 4
leddata [counter+8] = %11111111
next ' if 1st digit is 0 then skip so display dosnt display 09.5c
GOTO skipdigit ' it will display 9.5c instead
ENDIF
FOR counter = 0 TO 4
READ tempA*5+counter,leddata [counter+8] 'stores 1st digit in leddata locations 8,9,10,11,12
NEXT counter

skipdigit:
FOR counter = 0 TO 4
READ tempB*5+counter,leddata [counter+14] 'stores 2nd digit in leddata locations 14,15,16,17,18
NEXT
FOR counter = 0 TO 4
READ tempC*5+counter,leddata [counter+23] 'stores 3rd digit in leddata locations 23,24,25,26,27
NEXT

LOOPing:
FOR scroll = 0 TO 35
FOR scan = 0 TO 35
PORTb = 1
FOR counter = 0 TO 7
PORTa = leddata [counter]
PAUSE 1
PORTb = PORTb * 2
NEXT
NEXT
FOR counter = 0 TO 34
leddata [counter] = leddata [counter+1]
NEXT
NEXT
GOTO START
END
Maybe I put here tomorrow link to video (Y...tube).

fratello
- 9th September 2011, 18:15
How I promise...
http://www.youtube.com/watch?v=L_mR6FxYSYY
Note : The pullup resistor on RA4 it's 4k7.

mackrackit
- 10th September 2011, 02:17
Very nice!!!

fratello,
This will make a great project for the wiki.

fratello
- 10th September 2011, 17:10
Thanks :) !
I need one advice : the leds are not fully OFF when it's nothing to scroll... I try to add "pause" in different places of code, but without results...Please, I need help for one code 100% good ! Thanks in advance !

fratello
- 11th September 2011, 18:43
Last version of code :

; working variant ; anode to portB, catode to portA
; 11 september 2011
; SCROLLING THERMOMETER
; By NICULESCU DAN


@ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_off
define osc 4
INTCON = 0
TRISA = %00000000
TRISB = %10000000
CMCON = 7 ' Disable comparators
DQ var PortB.7

'************************************************* **************************************
eeprom 0, [%10100001,%01111010,%01110110,%01101110,%10100001] '0
eeprom 5, [%11111111,%01111101,%00000000,%01111111,%11111111] '1
eeprom 10,[%01111101,%00111110,%01101110,%01110110,%01111001] '2
eeprom 15,[%10111101,%01111110,%01110110,%01110110,%10101001] '3
eeprom 20,[%11100111,%11101011,%11101101,%00000000,%11101111] '4
eeprom 25,[%10111000,%01111010,%01111010,%01111010,%10100110] '5
eeprom 30,[%10100001,%01110110,%01110110,%01110110,%10101101] '6
eeprom 35,[%11111110,%00001110,%11110110,%11111010,%11111100] '7
eeprom 40,[%10001001,%01110110,%01110110,%01110110,%10001001] '8
eeprom 45,[%11111001,%01110110,%01110110,%01110110,%10001001] '9

counter var byte
scan var byte
scroll var byte
leddata var byte[36] 'Column Data for display 36 columns
temperature var Word 'reading from sensor
Sign var BIT
tempA var byte 'Stores First digit (High)
tempB var byte 'stores Second digit (Mid)
tempC var byte 'stores Third digit (low)
n var byte

DS18B20_12bit CON %01111111

START:
CLEAR 'Clear all varibles
porta = 1
portb = 0
pause 100
' Init Sensor 1
OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
OWOut DQ, 1, [$CC, $48] ' Start temperature conversion
OWOut DQ, 1, [$CC, $B8]
OWOut DQ, 1, [$CC, $BE]
Pause 50
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Pause 50


for n=0 to 7
leddata [n] = %11111111
next n

leddata [13] = %11111111
leddata [19] = %11111111
leddata [20] = %00111111 ' DECIMAL POINT
leddata [21] = %00111111
leddata [22] = %11111111
leddata [28] = %11111111


leddata [29] = %11111100 ' degrees c
leddata [30] = %11111100
leddata [31] = %11100011
leddata [32] = %10111101
leddata [33] = %10111101
leddata [34] = %10111101
leddata [35] = %11111111

OWOut DQ, 1, [$CC, $44]
OWOut DQ, 1, [$CC, $BE]
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Sign = temperature.15
temperature= ABS(temperature)
temperature=((temperature >> 4)*100) + ((temperature & $F) * 100 >> 4)
if sign then temperature= -temperature
temperature=2340
tempA = temperature DIG 3
tempB = temperature DIG 2
tempC = temperature DIG 1

if tempA = 0 then
FOR counter = 0 TO 4
leddata [counter+8] = %11111111
next
else
for counter = 0 to 4
READ tempA*5+counter,leddata [counter+8] 'stores 1st digit in leddata locations 8,9,10,11,12
NEXT
endif
FOR counter = 0 TO 4
READ tempB*5+counter,leddata [counter+14] 'stores 2nd digit in leddata locations 14,15,16,17,18
NEXT

FOR counter = 0 TO 4
READ tempC*5+counter,leddata [counter+23] 'stores 3rd digit in leddata locations 23,24,25,26,27
NEXT

;LOOPing:
FOR scroll = 0 TO 35
FOR scan = 0 TO 6
PORTb = 1
FOR counter = 0 TO 7
PORTa = leddata [counter]
pAUSE 1
PORTb = PORTb * 2
NEXT
NEXT
FOR counter = 0 TO 34
leddata [counter] = leddata [counter+1]
NEXT
NEXT
GOTO START
END

Work fine... but, in transition, some LEDs (not all) of first column on left are a little dimmed ! I don't know what else I can do :( ...

fratello
- 13th September 2011, 19:06
I did it ! Full led on, full led off. Enjoy !

; SCROLLING THERMOMETER
; FINAL VERSION
; By NICULESCU DAN
; SEPTEMBER, 13, 2011
;
; .oooO
; ( ) Oooo.
; \ ( ( )
; \_) ) /
; (_/
;

@ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_off
define osc 4
INTCON = 0
TRISA = %00000000 ' CATODES TO PORTA
TRISB = %10000000 ' ANODES TO PORTB
CMCON = 7
DQ var PortB.7

'************************************************* **************************************
eeprom 0, [%10100001,%01111010,%01110110,%01101110,%10100001] '0
eeprom 5, [%11111111,%01111101,%00000000,%01111111,%11111111] '1
eeprom 10,[%01111101,%00111110,%01101110,%01110110,%01111001] '2
eeprom 15,[%10111101,%01111110,%01110110,%01110110,%10101001] '3
eeprom 20,[%11100111,%11101011,%11101101,%00000000,%11101111] '4
eeprom 25,[%10111000,%01111010,%01111010,%01111010,%10100110] '5
eeprom 30,[%10100001,%01110110,%01110110,%01110110,%10101101] '6
eeprom 35,[%11111110,%00001110,%11110110,%11111010,%11111100] '7
eeprom 40,[%10001001,%01110110,%01110110,%01110110,%10001001] '8
eeprom 45,[%11111001,%01110110,%01110110,%01110110,%10001001] '9

counter var byte
scan var byte
scroll var byte
leddata var byte[36] 'Column Data for display 36 columns
temperature var Word 'reading from sensor
Sign var BIT
tempA var byte 'Stores First digit (High)
tempB var byte 'stores Second digit (Mid)
tempC var byte 'stores Third digit (low)
n var byte

DS18B20_12bit CON %01111111

START:
CLEAR
' Init Sensor
OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
OWOut DQ, 1, [$CC, $48]
OWOut DQ, 1, [$CC, $B8]
OWOut DQ, 1, [$CC, $BE]
Pause 50
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Pause 50

OWOut DQ, 1, [$CC, $44]
OWOut DQ, 1, [$CC, $BE]
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Sign = temperature.15
temperature= ABS(temperature)
temperature=((temperature >> 4)*100) + ((temperature & $F) * 100 >> 4)
if sign then temperature= -temperature
; temperature=2340 ; UNCOMMENT FOR DISPLAY TEST

tempA = temperature DIG 3
tempB = temperature DIG 2
tempC = temperature DIG 1

if tempA = 0 then
FOR counter = 0 TO 4
leddata [counter+8] = %11111111
next
else
for counter = 0 to 4
READ tempA*5+counter,leddata [counter+8] 'stores 1st digit in leddata locations 8,9,10,11,12
NEXT
endif
FOR counter = 0 TO 4
READ tempB*5+counter,leddata [counter+14] 'stores 2nd digit in leddata locations 14,15,16,17,18
NEXT

FOR counter = 0 TO 4
READ tempC*5+counter,leddata [counter+23] 'stores 3rd digit in leddata locations 23,24,25,26,27
NEXT




for n=0 to 7
leddata [n] = %11111111
next n
leddata [13] = %11111111
leddata [19] = %11111111
leddata [20] = %00111111 ' DECIMAL POINT
leddata [21] = %00111111
leddata [22] = %11111111
leddata [28] = %11111111

leddata [29] = %11111100 ' degrees c
leddata [30] = %11111100
leddata [31] = %11100011
leddata [32] = %10111101
leddata [33] = %10111101
leddata [34] = %10111101
leddata [35] = %11111111

LOOPing:
FOR scroll = 0 TO 35
FOR scan = 0 TO 10
PORTA=%11111111
PAUSE 1
PORTb = 1
FOR counter = 0 TO 7
PORTa = leddata [counter]
pAUSE 1
PORTb = PORTb * 2
NEXT
NEXT
FOR counter = 0 TO 34
leddata [counter] = leddata [counter+1]
NEXT
NEXT
GOTO START
END

fratello
- 13th September 2011, 19:24
Thanks to Mr.Wellyboot : http://www.picbasic.co.uk/forum/showthread.php?t=10834&highlight=matrix .

wellyboot
- 29th September 2011, 12:28
sorry, just saw your private message....looks like you got it going!

nice one!

fratello
- 16th October 2011, 08:47
Mr.Wellyboot : Need advice on using RTC DS1307 AND DS18B20 sensor ! How reading/displaying both (temperature and time) ? Please help ! Can I use same (two) pins to driven leds and reading DS1307 ? Any help it's wellcome . Thanks in advance !

wellyboot
- 16th October 2011, 20:42
Im not sure you can use the I2C pins to also connect to your leds, as from my experience the bus can be quite fussy

fratello
- 16th October 2011, 22:07
Thanks for replay! I can give up at 1x1 line/column for DS1307...but how displaying time & temperature?

fratello
- 17th October 2011, 19:44
I made this schematic and I re-write the code for using DS1307. But ...
Time it's scrolling "00:00" , without any changes... Please HELP !

; test for scroll - clock - thermometer
; using DS1307 & DS18B20
;

@ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_OFF
define osc 4
INTCON = 0
TRISA = %00100000 ' CATODES TO PORTA
TRISB = %10000001 ' ANODES TO PORTB
CMCON = 7
DQ var PortB.7

SDA Var PORTA.5 ' DS1307 SDA pin #5
SCL Var PORTB.0 ' DS1307 SCL pin #6

DEFINE I2C_SLOW 1 ;without this nothing work !
DEFINE I2C_HOLD 1 ;without this nothing work !
DEFINE I2C_SCLOUT 1 ;without this nothing work !

'************************************************* **************************************
eeprom 0, [%10100001,%01111010,%01110110,%01101110,%10100001] '0
eeprom 5, [%11111111,%01111101,%00000000,%01111111,%11111111] '1
eeprom 10,[%01111101,%00111110,%01101110,%01110110,%01111001] '2
eeprom 15,[%10111101,%01111110,%01110110,%01110110,%10101001] '3
eeprom 20,[%11100111,%11101011,%11101101,%00000000,%11101111] '4
eeprom 25,[%10111000,%01111010,%01111010,%01111010,%10100110] '5
eeprom 30,[%10100001,%01110110,%01110110,%01110110,%10101101] '6
eeprom 35,[%11111110,%00001110,%11110110,%11111010,%11111100] '7
eeprom 40,[%10001001,%01110110,%01110110,%01110110,%10001001] '8
eeprom 45,[%11111001,%01110110,%01110110,%01110110,%10001001] '9

counter var byte
scan var byte
scroll var byte
leddata var byte[75] 'Column Data for display 70 columns
temperature var Word 'reading from sensor
Sign var BIT
tempA var byte 'Stores First digit (High)
tempB var byte 'stores Second digit (Mid)
tempC var byte 'stores Third digit (low)
n var byte

DB Var BYTE[8] ' Data byte array
RTCSec Var DB[0] ' alias individual bytes in array
RTCMin Var DB[1]
RTCHour Var DB[2]
RTCDay Var DB[3]
RTCDate Var DB[4]
RTCMonth Var DB[5]
RTCYear Var DB[6]
RTCCtrl Var DB[7]

oraa var byte
orab var byte
minutea var byte
minuteb var byte
ttime var word

DS18B20_12bit CON %01111111
gosub write_1307

START:
CLEAR
gosub read_1307
' Init Sensor
OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
OWOut DQ, 1, [$CC, $48]
OWOut DQ, 1, [$CC, $B8]
OWOut DQ, 1, [$CC, $BE]
Pause 50
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Pause 50

OWOut DQ, 1, [$CC, $44]
OWOut DQ, 1, [$CC, $BE]
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Sign = temperature.15
temperature= ABS(temperature)
temperature=((temperature >> 4)*100) + ((temperature & $F) * 100 >> 4)
if sign then temperature= -temperature
; temperature=2340 ; UNCOMMENT FOR DISPLAY TEST

tempA = temperature DIG 3
tempB = temperature DIG 2
tempC = temperature DIG 1

; ttime = 2345 ; just for test
; oraa = ttime dig 3
; orab = ttime dig 2
; minutea = ttime dig 1
; minuteb = ttime dig 0

oraa = ((RTCHour>>4)& $01) ; ?????????????????????????
orab = (RTCHour & $0f) ; ?????????????????????????
minutea = ((RTCMin>>4)& $0f) ; ?????????????????????????
minuteb = (RTCMin & $0f) ; ?????????????????????????


if tempA = 0 then
FOR counter = 0 TO 4
leddata [counter+8] = %11111111
next
else
for counter = 0 to 4
READ tempA*5+counter,leddata [counter+8] 'stores 1st digit in leddata locations 8,9,10,11,12
NEXT
endif
FOR counter = 0 TO 4
READ tempB*5+counter,leddata [counter+14] 'stores 2nd digit in leddata locations 14,15,16,17,18
NEXT

FOR counter = 0 TO 4
READ tempC*5+counter,leddata [counter+23] 'stores 3rd digit in leddata locations 23,24,25,26,27
NEXT


FOR counter = 0 TO 4
READ oraa*5+counter,leddata [counter+41]
NEXT

FOR counter = 0 TO 4
READ orab*5+counter,leddata [counter+47]
NEXT



FOR counter = 0 TO 4
READ minutea*5+counter,leddata [counter+57] 'stores minut digit in leddata locations 41,42,43,44,45
NEXT

FOR counter = 0 TO 4
READ minuteb*5+counter,leddata [counter+63] 'stores minut digit in leddata locations 41,42,43,44,45
NEXT

;================================================= ================================================== =======
'leddata locations 0-7 are blank so that data scrolls onto display
'leddata locations 8-12 1st digit (leading digit)
'leddata location 13 blank column between digits
'leddata locations 14-18 2nd digit
'leddata location 19 blank column between digits
'leddata locations 20 & 21 Decimal Point
'leddata locations 23 - 27 3rd digit (last digit)
'leddata locations 28 blank column between digits
'leddata locations 29 - 34 Degrees C symbol
'leddata location 35 is a blank column at end to clear display as it scrolls
;================================================= ================================================== =======

for n=0 to 7
leddata [n] = %11111111
next n
leddata [13] = %11111111
leddata [19] = %11111111
leddata [20] = %00111111 ' DECIMAL POINT
leddata [21] = %00111111
leddata [22] = %11111111
leddata [28] = %11111111
leddata [29] = %11111100 ' degrees c
leddata [30] = %11111100
leddata [31] = %11100011
leddata [32] = %10111101
leddata [33] = %10111101
leddata [34] = %10111101
leddata [35] = %11111111
leddata [36] = %11111111
leddata [37] = %11111111
leddata [38] = %11111111
leddata [39] = %11111111
leddata [40] = %11111111
leddata [46] = %11111111
leddata [52] = %11111111
leddata [53] = %11111111
leddata [54] = %10111011
leddata [55] = %11111111
leddata [56] = %11111111
leddata [62] = %11111111
leddata [68] = %11111111
leddata [69] = %11111111
leddata [70] = %11111111
leddata [71] = %11111111
leddata [72] = %11111111
leddata [73] = %11111111
leddata [74] = %11111111
leddata [75] = %11111111
LOOPing:
FOR scroll = 0 TO 70
FOR scan = 0 TO 10
PORTA=%11111111
PAUSE 1
PORTb = 1
FOR counter = 0 TO 7
PORTa = leddata [counter]
PAUSE 1
PORTb = PORTb * 2
NEXT
NEXT
FOR counter = 0 TO 70
leddata [counter] = leddata [counter+1]
NEXT
NEXT
GOTO START

Write_1307:
' Set time & date to 11:59:00, Day 2, Date:Month:Year 30:08:2007
I2CWRITE SDA,SCL,$D0,$00,[$00,$59,$51,$02,$30,$08,$27,$90] ' Write to DS1307
pause 10
RETURN

read_1307: ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
I2CREAD SDA,SCL,$D1,$00,[STR DB\8] ' Read 8 bytes from DS1307
return

end

fratello
- 18th October 2011, 07:26
I try with this variant of code

read_1307: ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
I2CREAD SDA,SCL,$D1,$00,[STR DB\8] ' Read 8 bytes from DS1307
pause 50
If RTCHour.6=1 then ' Work-Out 12 or 24 hour Display for Hours
CounterA=(RTCHour>>4)&$01
else
CounterA=(RTCHour>>4)&$03
endif

CounterA=CounterA*10+(RTCHour&$0F)
If RTCHour.6=1 then ' Display Hours appropriately for 12 or 24 hour Mode
oraa = CounterA
else
oraa = CounterA Dig 1 : orab = CounterA Dig 0
endif

minutea =(RTCMin>>4)&$0F : minuteb = RTCMin&$0F
return
but still "00:00" time I have :( ...

fratello
- 18th October 2011, 07:40
I made this change

read_1307: ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
I2CRead SDA,SCL,$D1,$00,[ RTCSec,RTCMin,RTCHour,RTCDay,RTCDay,RTCMonth,RTCYe ar,RTCCtrl]
and now the time is "20:20" ! The clock still don't run ...

gadelhas
- 18th October 2011, 12:41
You must put a crystal on the DS1307 ( 32.768Khz)

fratello
- 18th October 2011, 13:00
Thanks...but Proteus dont need him. The clock works fine...just the scroll don't look the "real" time ; it's stuck on "20:20"
I try many variants, without results. I can't find the way to store real clock in my variables : oraa,orab,minutea & minuteb :( ...

cncmachineguy
- 18th October 2011, 17:53
I dont think you can have SDA connected to MCLR.

fratello
- 19th October 2011, 11:55
Thanks cncmachineguy ! Indeed MCLR cannot be SDA.
Working variant, but just 5 columns :( ....

; Working variant for scroll - clock - thermometer
; using DS1307 & DS18B20
;

@ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_OFF
define osc 4
INTCON = 0
TRISA = 000000 ' CATODES TO PORTA
TRISB = 000000 ' ANODES TO PORTB
CMCON = 7
DQ var PortB.7

SDA Var PORTB.6 ' DS1307 SDA pin #5
SCL Var PORTB.5 ' DS1307 SCL pin #6

'************************************************* **************************************
eeprom 0, [100001,111010,110110,101110,100001] '0
eeprom 5, [111111,111101,000000,111111,111111] '1
eeprom 10,[111101,111110,101110,110110,111001] '2
eeprom 15,[111101,111110,110110,110110,101001] '3
eeprom 20,[100111,101011,101101,000000,101111] '4
eeprom 25,[111000,111010,111010,111010,100110] '5
eeprom 30,[100001,110110,110110,110110,101101] '6
eeprom 35,[111110,001110,110110,111010,111100] '7
eeprom 40,[001001,110110,110110,110110,001001] '8
eeprom 45,[111001,110110,110110,110110,001001] '9

counter var byte
scan var byte
scroll var byte
leddata var byte[75] 'Column Data for display 70 columns
temperature var Word 'reading from sensor
Sign var BIT
tempA var byte 'Stores First digit (High)
tempB var byte 'stores Second digit (Mid)
tempC var byte 'stores Third digit (low)
n var byte

DB Var BYTE[8] ' Data byte array
RTCSec Var DB[0] ' alias individual bytes in array
RTCMin Var DB[1]
RTCHour Var DB[2]
RTCDay Var DB[3]
RTCDate Var DB[4]
RTCMonth Var DB[5]
RTCYear Var DB[6]
RTCCtrl Var DB[7]
ore var word
minute var word
oraa var byte
orab var byte
minutea var byte
minuteb var byte


DS18B20_12bit CON 111111

gosub write_1307


START:
CLEAR
' Init Sensor
OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
OWOut DQ, 1, [$CC, $48]
OWOut DQ, 1, [$CC, $B8]
OWOut DQ, 1, [$CC, $BE]
Pause 50
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Pause 50

OWOut DQ, 1, [$CC, $44]
OWOut DQ, 1, [$CC, $BE]
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Sign = temperature.15
temperature= ABS(temperature)
temperature=((temperature >> 4)*100) + ((temperature & $F) * 100 >> 4)
if sign then temperature= -temperature

tempA = temperature DIG 3
tempB = temperature DIG 2
tempC = temperature DIG 1

if tempA = 0 then
FOR counter = 0 TO 4
leddata [counter+8] = 111111
next
else
for counter = 0 to 4
READ tempA*5+counter,leddata [counter+8] 'stores 1st digit in leddata locations 8,9,10,11,12
NEXT
endif
FOR counter = 0 TO 4
READ tempB*5+counter,leddata [counter+14] 'stores 2nd digit in leddata locations 14,15,16,17,18
NEXT

FOR counter = 0 TO 4
READ tempC*5+counter,leddata [counter+23] 'stores 3rd digit in leddata locations 23,24,25,26,27
NEXT


gosub read_1307
oraa = ore dig 1
orab = ore dig 0
minutea = minute dig 1
minuteb = minute dig 0

FOR counter = 0 TO 4
READ oraa*5+counter,leddata [counter+41] 'stores hours digit 1 in leddata locations
NEXT


FOR counter = 0 TO 4
READ orab*5+counter,leddata [counter+47] 'stores hours digit 0 in leddata locations
NEXT



FOR counter = 0 TO 4
READ minutea*5+counter,leddata [counter+57] 'stores minutes digit 1 in leddata locations
NEXT

FOR counter = 0 TO 4
READ minuteb*5+counter,leddata [counter+63] 'stores minutes digit 0 in leddata locations
NEXT

;================================================= ================================================== =======
'leddata locations 0-7 are blank so that data scrolls onto display
'leddata locations 8-12 1st digit (leading digit)
'leddata location 13 blank column between digits
'leddata locations 14-18 2nd digit
'leddata location 19 blank column between digits
'leddata locations 20 & 21 Decimal Point
'leddata locations 23 - 27 3rd digit (last digit)
'leddata locations 28 blank column between digits
'leddata locations 29 - 34 Degrees C symbol
'leddata location 35 is a blank column at end to clear display as it scrolls
'e.t.c.
;================================================= ================================================== =======

for n=0 to 7
leddata [n] = 111111
next n
leddata [13] = 111111
leddata [19] = 111111
leddata [20] = 111111 ' DECIMAL POINT
leddata [21] = 111111
leddata [22] = 111111
leddata [28] = 111111
leddata [29] = 111100 ' degrees c
leddata [30] = 111100
leddata [31] = 100011
leddata [32] = 111101
leddata [33] = 111101
leddata [34] = 111101
leddata [35] = 111111
leddata [36] = 111111
leddata [37] = 111111
leddata [38] = 111111
leddata [39] = 111111
leddata [40] = 111111
leddata [46] = 111111
leddata [52] = 111111
leddata [53] = 111111
leddata [54] = 111011
leddata [55] = 111111
leddata [56] = 111111
leddata [62] = 111111
leddata [68] = 111111
leddata [69] = 111111
leddata [70] = 111111
leddata [71] = 111111
leddata [72] = 111111
leddata [73] = 111111
leddata [74] = 111111
leddata [75] = 111111

LOOPing:
FOR scroll = 0 TO 70
FOR scan = 0 TO 10
PORTA=111111
PAUSE 1
PORTb = 1
FOR counter = 0 TO 7
PORTa = leddata [counter]
PAUSE 1
PORTb = PORTb * 2
NEXT
NEXT
FOR counter = 0 TO 70
leddata [counter] = leddata [counter+1]
NEXT
NEXT
GOTO START

Write_1307:
I2CWRITE SDA,SCL,$D0,$00,[$59,$30,$9,$7,$14,$2,$10,$90] ' Write to DS1307
pause 10
RETURN

read_1307: ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
I2CREAD SDA,SCL,$D1,$00,[STR DB\8] ' Read 8 bytes from DS1307
ore = (db[2] & $F )+((db[2]>>4)*10) ' Hex to Dec hour
minute = (db[1] & $F )+((db[1]>>4)*10) ' Hex to Dec minutes
RETURN

end


I think I will "upgrade" to 16F886 or 16F57 (more I/O pins) ...

fratello
- 19th October 2011, 17:50
I found in my boxes one piece of PIC16F877A. So, because this have a lot of I/O, I try to migrate the code.
But...of course, I have problems ! What's up now ?

@ DEVICE pic16F877A, intOSC_osc_noclkout, WDT_ON, PWRT_ON, BOD_ON, MCLR_OFF
DEFINE OSC 4

OPTION_REG.7 = 0
ADCON0 = %110000000
ADCON1 = %000000111
CMCON=7
CVRCON=0

PORTA = %00000001 'Set all INPUTS to 0 except RA0 = DQ
TRISA = %00000001 'Set PORTA RA0-RA5
PORTB = %00000000 'Set all outputs to 0 (off)
TRISB = %00000000 'Set PORTB to all output
PORTC = %00000000 'Set all outputs to 0 (off)
TRISC = %00000000 'Set PORTC to all output

DQ var PortA.0

SDA Var PORTC.4 ' DS1307 SDA pin #5
SCL Var PORTC.3 ' DS1307 SCL pin #6

'************************************************* **************************************
eeprom 0, [%10100001,%01111010,%01110110,%01101110,%10100001] '0
eeprom 5, [%11111111,%01111101,%00000000,%01111111,%11111111] '1
eeprom 10,[%01111101,%00111110,%01101110,%01110110,%01111001] '2
eeprom 15,[%10111101,%01111110,%01110110,%01110110,%10101001] '3
eeprom 20,[%11100111,%11101011,%11101101,%00000000,%11101111] '4
eeprom 25,[%10111000,%01111010,%01111010,%01111010,%10100110] '5
eeprom 30,[%10100001,%01110110,%01110110,%01110110,%10101101] '6
eeprom 35,[%11111110,%00001110,%11110110,%11111010,%11111100] '7
eeprom 40,[%10001001,%01110110,%01110110,%01110110,%10001001] '8
eeprom 45,[%11111001,%01110110,%01110110,%01110110,%10001001] '9

counter var byte
scan var byte
scroll var byte
leddata var byte[75] 'Column Data for display 75 columns
temperature var Word 'reading from sensor
Sign var BIT
tempA var byte 'Stores First digit (High)
tempB var byte 'stores Second digit (Mid)
tempC var byte 'stores Third digit (low)
n var byte

RTCSec Var byte ' alias individual bytes in array
RTCMin Var byte
RTCHour Var byte
RTCDay Var byte
RTCDate Var byte
RTCMonth Var byte
RTCYear Var byte
RTCCtrl Var byte

oraa var byte
orab var byte
minutea var byte
minuteb var byte


DS18B20_12bit CON %01111111
gosub write_1307

START:
CLEAR
' Init Sensor
OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
OWOut DQ, 1, [$CC, $48]
OWOut DQ, 1, [$CC, $B8]
OWOut DQ, 1, [$CC, $BE]
Pause 50
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Pause 50

OWOut DQ, 1, [$CC, $44]
OWOut DQ, 1, [$CC, $BE]
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Sign = temperature.15
temperature= ABS(temperature)
temperature=((temperature >> 4)*100) + ((temperature & $F) * 100 >> 4)
if sign then temperature= -temperature
; temperature=2340 ; UNCOMMENT FOR DISPLAY TEST

tempA = temperature DIG 3
tempB = temperature DIG 2
tempC = temperature DIG 1


gosub read_1307

if tempA = 0 then
FOR counter = 0 TO 4
leddata [counter+8] = %11111111
next
else
for counter = 0 to 4
READ tempA*5+counter,leddata [counter+8] 'stores 1st digit in leddata locations 8,9,10,11,12
NEXT
endif
FOR counter = 0 TO 4
READ tempB*5+counter,leddata [counter+14] 'stores 2nd digit in leddata locations 14,15,16,17,18
NEXT

FOR counter = 0 TO 4
READ tempC*5+counter,leddata [counter+23] 'stores 3rd digit in leddata locations 23,24,25,26,27
NEXT


FOR counter = 0 TO 4
READ oraa*5+counter,leddata [counter+41]
NEXT

FOR counter = 0 TO 4
READ orab*5+counter,leddata [counter+47]
NEXT



FOR counter = 0 TO 4
READ minutea*5+counter,leddata [counter+57] 'stores minut digit in leddata locations 41,42,43,44,45
NEXT

FOR counter = 0 TO 4
READ minuteb*5+counter,leddata [counter+63] 'stores minut digit in leddata locations 41,42,43,44,45
NEXT

;================================================= ================================================== =======
'leddata locations 0-7 are blank so that data scrolls onto display
'leddata locations 8-12 1st digit (leading digit)
'leddata location 13 blank column between digits
'leddata locations 14-18 2nd digit
'leddata location 19 blank column between digits
'leddata locations 20 & 21 Decimal Point
'leddata locations 23 - 27 3rd digit (last digit)
'leddata locations 28 blank column between digits
'leddata locations 29 - 34 Degrees C symbol
'leddata location 35 is a blank column at end to clear display as it scrolls
;================================================= ================================================== =======

for n=0 to 7
leddata [n] = %11111111
next n
leddata [13] = %11111111
leddata [19] = %11111111
leddata [20] = %00111111 ' DECIMAL POINT
leddata [21] = %00111111
leddata [22] = %11111111
leddata [28] = %11111111
leddata [29] = %11111100 ' degrees c
leddata [30] = %11111100
leddata [31] = %11100011
leddata [32] = %10111101
leddata [33] = %10111101
leddata [34] = %10111101
leddata [35] = %11111111
leddata [36] = %11111111
leddata [37] = %11111111
leddata [38] = %11111111
leddata [39] = %11111111
leddata [40] = %11111111
leddata [46] = %11111111
leddata [52] = %11111111
leddata [53] = %11111111
leddata [54] = %10111011
leddata [55] = %11111111
leddata [56] = %11111111
leddata [62] = %11111111
leddata [68] = %11111111
leddata [69] = %11111111
leddata [70] = %11111111
leddata [71] = %11111111
leddata [72] = %11111111
leddata [73] = %11111111
leddata [74] = %11111111
leddata [75] = %11111111

LOOPing:
FOR scroll = 0 TO 70
FOR scan = 0 TO 10
PORTA=%11111111
PAUSE 1
PORTb = 1
FOR counter = 0 TO 7
PORTa = leddata [counter]
PAUSE 1
PORTb = PORTb * 2
NEXT
NEXT
FOR counter = 0 TO 70
leddata [counter] = leddata [counter+1]
NEXT
NEXT
GOTO START

Write_1307:
I2CWRITE SDA,SCL,$D0,$00,[$00,$55,$15,$2,$6,$7,$4,$90] ' Write to DS1307
pause 10
RETURN

read_1307: ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
I2CRead SDA,SCL,$D0,$00,[ RTCSec,RTCMin,RTCHour,RTCDay,RTCDate,RTCMonth,RTCY ear,RTCCtrl]
RETURN

END

And I've got many errors :

FATAL ERROR: Too many errors. (21)
ERROR Line 4: Redefiniton of LABEL OPTION_REG. (16F877A.bas)
ERROR Line 5: Redefiniton of LABEL ADCON0. (16F877A.bas)
ERROR Line 6: Redefiniton of LABEL ADCON1. (16F877A.bas)
ERROR Line 7: Redefiniton of LABEL CMCON. (16F877A.bas)
ERROR Line 8: Redefiniton of LABEL CVRCON. (16F877A.bas)
ERROR Line 10: Redefiniton of LABEL PORTA. (16F877A.bas)
ERROR Line 11: Redefiniton of LABEL TRISA. (16F877A.bas)
ERROR Line 12: Redefiniton of LABEL PORTB. (16F877A.bas)
ERROR Line 13: Redefiniton of LABEL TRISB. (16F877A.bas)
ERROR Line 14: Redefiniton of LABEL PORTC. (16F877A.bas)
ERROR Line 15: Redefiniton of LABEL TRISC. (16F877A.bas)
ERROR Line 17: Redefinition of VAR. (16F877A.bas)
ERROR Line 19: Redefinition of VAR. (16F877A.bas)
ERROR Line 20: Redefinition of VAR. (16F877A.bas)
ERROR Line 34: Redefinition of VAR. (16F877A.bas)
ERROR Line 35: Redefinition of VAR. (16F877A.bas)
ERROR Line 36: Redefinition of VAR. (16F877A.bas)
ERROR Line 179: Redefiniton of LABEL PORTA. (16F877A.bas)
ERROR Line 181: Redefiniton of LABEL PORTB. (16F877A.bas)
ERROR Line 183: Redefiniton of LABEL PORTA. (16F877A.bas)
ERROR Line 185: Redefiniton of LABEL PORTB. (16F877A.bas)


Please, help ! Thanks !

mackrackit
- 19th October 2011, 18:22
DATA sheets are your friend.
Please read the chips DATA sheet and make it happy :)


intOSC_osc_noclkout

First problem

fratello
- 19th October 2011, 18:38
I allready check this :
"@ DEVICE pic16F877A, XT_OSC, LVP_OFF, WDT_ON, PWRT_ON, BOD_ON, MCLR_OFF"
Of course, the messages it's still there ...

mackrackit
- 19th October 2011, 18:47
What do you want the ADC to do? Did you adjust for the new part?
Did you select the correct chip in the compiler?

fratello
- 19th October 2011, 19:43
I am so DUMB !!! The file I wrote and I try to compile has the name "16F877A.bas" ! So idiot !!!
Works fine...now ! Thank You all ! Sorry for my stupidity :( .

'************************************************* ***************
'* Name : test scroll-clock-thermometer-16F877A
'************************************************* ***************
@ DEVICE pic16F877A, XT_OSC, WDT_ON, PWRT_ON, BOD_ON
DEFINE OSC 4

OPTION_REG.7 = 0
ADCON1 = 7
CMCON=7

PORTA = %00000001 'Set all INPUTS to 0 except RA0 = DQ
TRISA = %00000001 'Set PORTA RA0-RA5
PORTB = %00000000 'Set all outputs to 0 (off)
TRISB = %00000000 'Set PORTB to all output
PORTC = %00000000 'Set all outputs to 0 (off)
TRISC = %00000000 'Set PORTC to all output
PORTD = %00000000
TRISD = %00000000
DQ var PortA.0

SDA Var PORTC.1 ' DS1307 SDA pin #5
SCL Var PORTC.0 ' DS1307 SCL pin #6
...etc...

mackrackit
- 19th October 2011, 20:05
$_hit happens...
Do not be so hard on yourself.

fratello
- 20th October 2011, 16:56
Still need help...I try to write code for setting clock ; I use parts from the great code of Melanie's (Thanks !). In Proteus I see what happens but... In real-life I need to display each digit of clock-time ; if set hour I need to see, first tens hour digit, then hour digit, tens minutes, minutes.
How can I display on this matrix static number ? Please, give me a clue !

cncmachineguy
- 20th October 2011, 19:24
Do you mean how do you display 4 digits on an 8x8 display without scrolling? That I don't think you can do and still be able to read it.

Maybe I just don't understand the question :(

fratello
- 20th October 2011, 19:49
Sorry for my poor english...
So, If set tens hour : on matrix appears (without scrolling) tens hour digit only.
If set hour : on matrix appears (without scrolling) hour digit only.
etc, etc.
Otherwise I can't setting the clock, because I don't see what happens ...

fratello
- 21st October 2011, 14:33
I DID IT !
Full working (:)) version of scroll-thermo-clock, using PIC16F877A. With buttons for setting hours/minutes !
Enjoy !

LE : The answer on my previous question:

portb=0
portd=0
pause 1
FOR counter = 0 TO 4
READ oraa*5+counter,leddata [counter]
NEXT
PORTB=%11111111
PORTD = 1
FOR counter = 0 TO 4
PORTB = leddata [counter]
PORTD = PORTD * 2
leddata [counter] = leddata [counter+1]
NEXT

cncmachineguy
- 21st October 2011, 15:19
Awesome!!!!!!!!

fratello
- 21st October 2011, 19:53
Bug of setting hours (23-->0) solved :

' Decrement Units Hours
' ---------------
If CounterC=1 then
if setdechour=2 then
IF SetHour=0 THEN
SetHour= 3
else
SetHour=SetHour-1
Endif
else
if sethour=0 then
sethour=9
else
sethour=sethour-1
endif
endif
endif
and

' Increment Units Hours
' ---------------
If CounterC=1 then
if SetDecHour=2 then
if SetHour=3 then
SetHour=0
else
SetHour=SetHour+1
endif
else
if SetHour=9 then
SetHour=0
else
SetHour=SetHour+1
endif
Endif
endif

This is it ! Best regards !

fratello
- 21st October 2011, 20:05
Just connect RD7 to matrix and having 8 columns instead 7 :). No software update required.6076

fratello
- 22nd October 2011, 19:51
Soft update : if hour < 10 then not show first 0.

if oraa = 0 then
FOR counter = 0 TO 4
leddata [counter+41] = %11111111
next
else
FOR counter = 0 TO 4
READ oraa*5+counter,leddata [counter+41] 'stores tens hours digit in leddata locations
NEXT
endif

wellyboot
- 22nd October 2011, 23:16
I use 4k7 pullup resistors on the I2C bus, as i read somewhere that its a bit fussy with 10K....dont know how true this is

fratello
- 26th October 2011, 19:07
Now I intend to use two 5x7 led matrix, since some ports of PIC (16F877A) are free...
Please, I need help : how can making scroll in this case ?
Note : PortB are lines (7) ; PortC are columns from 0 to 7 ; PortD are columns from 8 to 15.

fratello
- 26th October 2011, 20:09
I found a way...but I think it's not the BETTER way :(.

'
' Display RTC & temp.
' -----------
LOOPing:
FOR scroll = 0 TO 70
FOR scan = 0 TO 7
PORTB=%11111111
PAUSE 1
PORTc = 1
PORTd = 1
FOR counter = 0 TO 15
PORTB = leddata [counter]
pause 1
if counter > 7 then
PORTD = PORTD * 2
else
portc = portc * 2
endif
NEXT
NEXT
FOR counter = 0 TO 70
leddata [counter] = leddata [counter+1]
NEXT
NEXT

LED's on column 7 (PortD 0) are, sometimes, on ... What @##%$@ is this ?

mackrackit
- 27th October 2011, 01:14
Thanks for making this an article!
http://www.picbasic.co.uk/forum/content.php?r=449-Scrolling-thermometer

fratello
- 29th October 2011, 17:41
My first working variant of scroll-thermo-clock : http://www.youtube.com/watch?v=Zkv4EbElOCg
Used : 16F877A, DS1307, home-made LED's matrix (7x7) and DS18B20 (missing in video, don't have anyone :( ).
Different code from previous example (because of my custom matrix). Enjoy !

mackrackit
- 1st November 2011, 23:41
There was a problem with the web site when the article was first published. It appears to be fixed now.

Thanks Dan for re-posting the article.

http://www.picbasic.co.uk/forum/content.php?r=449-Scrolling-thermometer

krish69
- 14th December 2012, 17:39
Just connect RD7 to matrix and having 8 columns instead 7 :). No software update required.6076

what are the values of X1 and X2,?

fratello
- 14th December 2012, 22:49
X1=32768 KHz (see app note for DS1307) ; X2=4MHz (see second line of program file).

krish69
- 25th December 2012, 03:09
thanks lot for the fast reply n giving all instructions to build this without hiding..
by the way ur final video shows 0.0 c because missing of thermo saensor??
can u upload a new video with full functionality..?
reg
krish69