scrolling message display HELP!!!

Thread Starter

andrakis2

Joined Nov 13, 2008
8
Hi, I have this program I got From,
http://hobby_elec.piclist.com/e_pic6_2.htm

i have built the board after designing it and printing it and now i have a problem i made the multiplexer in backward so it scrolls the wrong way!!!

i belive this should be fixable at the code level so what i need is to know how to change the code below to make it scroll the opisite way.

here is the code i am using
Rich (BB code):
;************************************************* ******* ; ; The signboard control processing ; ; Author : Seiichi Inoue ;************************************************* ******* list p=pic16f84a include p16f84a.inc __config h'3ff2' ;**************** Label Definition ******************** lpcnt equ 0c ;Screen loop counter adr scrnidx equ 0d ;Screen data index adr w_save equ 0e ;W register save adr s_save equ 0f ;STATUS reg save adr scrnhd equ 10 ;Screen table head adr tm_cnt equ 20 ;Time adjust counter adr e_adr equ 21 ;EEPROM data adr e_check equ 22 ;EEPROM end check cnt adr s_loop equ 23 ;Screen data loop cnt adr s_index equ 24 ;Screen table index adr s_work equ 25 ;Screen data work area ;************************ ;* Time adjust * ;************************ ;This data decides a scroll speed. Basic rate is 26msec. tm_adj equ 0c ;Time adjust(26msec x 12) ;************************ ;* EEPROM data size * ;************************ ;If the data size is 30 bytes, then simply set d'30'. e_size equ d'32' ;EEPROM data size ;*************** EEPROM Data Definition *************** org h'2100' de b'11111111' de b'01111000' de b'10111111' de b'11011111' de b'10111111' de b'01111000' de b'11111111' de b'11111111' de b'11000011' de b'10111101' de b'01111110' de b'00000000' de b'11111111' de b'01110110' de b'01110110' de b'00000000' de b'11111111' de b'00000110' de b'01110110' de b'01110000' de b'11111111' de b'10000001' de b'01111110' de b'10000001' de b'11111111' de b'01111111' de b'01111111' de b'00000000' de b'11111111' de b'10011001' de b'01111110' de b'10000001' ;**************** Program Start *********************** org 0 ;Reset Vector goto init org 4 ;Interrupt Vector goto int ;**************** Initial Process ********************* org 5 init bsf STATUS,RP0 ;Change to Bank1 clrf TRISA ;Set PORTA to Output mode clrf TRISB ;Set PORTB to Output mode movlw h'07' ;TOCS=0,PSA=0,PS2/1/0=111 movwf OPTION_REG ;Set timer condition bcf STATUS,RP0 ;Change to Bank0 movlw h'00' ;Set timer value movwf TMR0 ;TMR0 = 0 (255 counts) movlw tm_adj ;Set time adjust value movwf tm_cnt ;Save time adjust clrf e_adr ;Clear EEPROM data adr movlw e_size ;Set EEPROM data size movwf e_check ;Save EEPROM end check movlw h'a0' ;GIE=1,TOIE=1 movwf INTCON ;Interruption enable ;************** Screen Load Process ******************* screen bsf INTCON,GIE ;Interrupt enable movlw d'16' ;Set loop count movwf lpcnt ;Save loop count movlw h'0f' ;Set screen index movwf scrnidx ;Save index bcf INTCON,GIE ;Interrupt disable scrnlp movlw h'ff' ;Set LED OFF data movwf PORTB ;Output Data movf scrnidx,w ;Set Position movwf PORTA ;Output Position movlw scrnhd ;Set Table head address addwf scrnidx,w ;Head + Index movwf FSR ;Set Table address movf INDF,w ;Read Data movwf PORTB ;Output Data decf scrnidx,f ;Index - 1 decfsz lpcnt,f ;Loop end ? goto scrnlp ;No. Next line goto screen ;Yes. Next screen ;************ Begin Interruption Process ************** int movwf w_save ;Save W register movf STATUS,w ;Read STATUS reg movwf s_save ;Save STATUS reg btfsc INTCON,T0IF ;Time out interruption ? goto timer_int ;Jump to Timer process goto init ;Reset(Illegal interrupt) ;************ END of Interruption Process ************** int_end movf s_save,w ;Read saved STATUS reg movwf STATUS ;Recover STATUS reg swapf w_save,f ;Read saved W register swapf w_save,w ;Recover W register retfie ;*********** Time-out interruption Process ************ timer_int bcf INTCON,T0IF ;Clear timer int flag movlw h'00' ;Set timer value movwf TMR0 ;TMR0 = 0 (255 counts) decfsz tm_cnt,f ;Time over ? goto int_end ;No. Retry movlw tm_adj ;Set time adjust value movwf tm_cnt ;Save time adjust ;************ Screen data shift Process *************** movlw d'15' ;Set loop count movwf s_loop ;Save loop count movlw scrnhd ;Set screen head adr movwf s_index ;Set screen adr loop incf s_index,w ;Inclement index movwf FSR ;Set read addres movf INDF,w ;Read data movwf s_work ;Save data movf s_index,w ;Read index movwf FSR ;Set write address movf s_work,w ;Recover data movwf INDF ;Write data incf s_index,f ;Inclement index decfsz s_loop,f ;All shifted ? goto loop ;No. Continue. ;i belive this is where the message moves ;************** New data write Process **************** movf s_index,w ;Read index movwf FSR ;Set write address movf e_adr,w ;Read EEPROM address movwf EEADR ;Set EEPROM address bsf STATUS,RP0 ;Change to Bank1 bsf EECON1,RD ;Start EEPROM reading bcf STATUS,RP0 ;Change to Bank0 movf EEDATA,w ;Read EEPROM data movwf INDF ;Write new data incf e_adr,f ;Inclement data address decfsz e_check,f ;End of EEPROM data ? goto int_end ;No. Return clrf e_adr ;Clear EEPROM data adr movlw e_size ;Set EEPROM data size movwf e_check ;Save EEPROM end check goto int_end ;Return ;************************************************* ******* ; END of signboard control processing ;************************************************* ******* end​
any help would be appreciated i am very new to this
 
Last edited by a moderator:

beenthere

Joined Apr 20, 2004
15,819
You have two choices here - get the multiplexer corrected or change the code.

You may have found the part of the code that does the scrolling. If you have identified it to that extent, why not do a bit of analysis and modify it to scroll in the other direction? Instead of INCrementing the address, DECrement it. Just change the start and finish values.

You get to learn something about programming that way.
 

Thread Starter

andrakis2

Joined Nov 13, 2008
8
i tried just changing the commands to dec but the display jumps once and stops that was the first thing i tried b4 i noticed that the chip was wrong i cannot change the chip as it gp in a printed board without cutting the tracks
 

hgmjr

Joined Jan 28, 2005
9,029
What happens if you complement the address written to the multiplexer while leaving the rest of the code the same?

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,029
For the message to come out correctly you may need to reverse the order of the message pattern at the same time.

hgmjr
 

Thread Starter

andrakis2

Joined Nov 13, 2008
8
as i said i am new to this i know how to change the message and speed i can guess a few things from the comments but that is it! Basicaly i am a newbie at programming i am good at electronics but that wont help much with the computer parts
 

Thread Starter

andrakis2

Joined Nov 13, 2008
8
i can make it look right if i turn it upside down.:) sorry for the bad grammer i actually access this site from my mobile phone
 

hgmjr

Joined Jan 28, 2005
9,029
Actually, what is so bad about mounting the board upsided down?

I expect that you are going to house it in a box of some sort.


If you change the pattern as I have indicated and then complement the 4-bit value that the PIC is feeding to the multiplexer, I think you will get the desired behaviour.

hgmjr

OLD PATTERN

Rich (BB code):
;*************** EEPROM Data Definition ***************
org h'2100'
de b'11111111'
de b'00011100'
de b'11111101'
de b'11111011'
de b'11111101'
de b'01111000'
de b'11111111'
de b'11111111'
de b'11000011'
de b'10111101'
de b'01111110'
de b'00000000'
de b'11111111'
de b'01110110'
de b'01110110'
de b'00000000'
de b'11111111'
de b'00000110'
de b'01110110'
de b'01110000'
de b'11111111'
de b'10000001'
de b'01111110'
de b'10000001'
de b'11111111'
de b'01111111'
de b'01111111'
de b'00000000'
de b'11111111'
de b'10011001'
de b'01111110'
de b'10000001'
NEW PATTERN

Rich (BB code):
org h'2100'
de b'10000001'
de b'01111110'
de b'10011001'
de b'11111111'
de b'00000000'
de b'11111110'
de b'11111110'
de b'11111111'
de b'10000001'
de b'01111110'
de b'10000001'
de b'11111111'
de b'00001110'
de b'01101110'
de b'01100000'
de b'11111111'
de b'00000000'
de b'01110110'
de b'01110110'
de b'11111111'
de b'00000000'
de b'01111110'
de b'10111101'
de b'11000011'
de b'11111111'
de b'11111111'
de b'00011110'
de b'11111101'
de b'11111011'
de b'11111101'
de b'00011110'
de b'11111111'
;****************
 
Last edited:

hgmjr

Joined Jan 28, 2005
9,029
Rich (BB code):
;********************************************** ; ; The signboard control processing ; ; Author : Seiichi Inoue ;********************************************** list p=pic16f84a include p16f84a.inc __config h'3ff2' ;************* Label Definition ******************** lpcnt equ 0c ;Screen loop counter adr scrnidx equ 0d ;Screen data index adr w_save equ 0e ;W register save adr s_save equ 0f ;STATUS reg save adr scrnhd equ 10 ;Screen table head adr tm_cnt equ 20 ;Time adjust counter adr e_adr equ 21 ;EEPROM data adr e_check equ 22 ;EEPROM end check cnt adr s_loop equ 23 ;Screen data loop cnt adr s_index equ 24 ;Screen table index adr s_work equ 25 ;Screen data work area ;************************ ;* Time adjust * ;************************ ;This data decides a scroll speed. Basic rate is 26msec. tm_adj equ 0c ;Time adjust(26msec x 12) ;************************ ;* EEPROM data size * ;************************ ;If the data size is 30 bytes, then simply set d'30'. e_size equ d'32' ;EEPROM data size ;*************** EEPROM Data Definition *************** org h'2100' de b'11111111' de b'01111000' de b'10111111' de b'11011111' de b'10111111' de b'01111000' de b'11111111' de b'11111111' de b'11000011' de b'10111101' de b'01111110' de b'00000000' de b'11111111' de b'01110110' de b'01110110' de b'00000000' de b'11111111' de b'00000110' de b'01110110' de b'01110000' de b'11111111' de b'10000001' de b'01111110' de b'10000001' de b'11111111' de b'01111111' de b'01111111' de b'00000000' de b'11111111' de b'10011001' de b'01111110' de b'10000001' ;**************** Program Start *********************** org 0 ;Reset Vector goto init org 4 ;Interrupt Vector goto int ;**************** Initial Process ***************** org 5 init bsf STATUS,RP0 ;Change to Bank1 clrf TRISA ;Set PORTA to Output mode clrf TRISB ;Set PORTB to Output mode movlw h'07' ;TOCS=0,PSA=0,PS2/1/0=111 movwf OPTION_REG ;Set timer condition bcf STATUS,RP0 ;Change to Bank0 movlw h'00' ;Set timer value movwf TMR0 ;TMR0 = 0 (255 counts) movlw tm_adj ;Set time adjust value movwf tm_cnt ;Save time adjust clrf e_adr ;Clear EEPROM data adr movlw e_size ;Set EEPROM data size movwf e_check ;Save EEPROM end check movlw h'a0' ;GIE=1,TOIE=1 movwf INTCON ;Interruption enable ;************** Screen Load Process ************* screen bsf INTCON,GIE ;Interrupt enable movlw d'16' ;Set loop count movwf lpcnt ;Save loop count movlw h'0f' ;Set screen index movwf scrnidx ;Save index bcf INTCON,GIE ;Interrupt disable scrnlp movlw h'ff' ;Set LED OFF data movwf PORTB ;Output Data movf scrnidx,w ;Set Position movwf PORTA ;Output Position movlw scrnhd ;Set Table head address addwf scrnidx,w ;Head + Index movwf FSR ;Set Table address movf INDF,w ;Read Data movwf PORTB ;Output Data decf scrnidx,f ;Index - 1 decfsz lpcnt,f ;Loop end ? goto scrnlp ;No. Next line goto screen ;Yes. Next screen ;********** Begin Interruption Process ************** int movwf w_save ;Save W register movf STATUS,w ;Read STATUS reg movwf s_save ;Save STATUS reg btfsc INTCON,T0IF ;Time out interruption ? goto timer_int ;Jump to Timer process goto init ;Reset(Illegal interrupt) ;********* END of Interruption Process ************** int_end movf s_save,w ;Read saved STATUS reg movwf STATUS ;Recover STATUS reg swapf w_save,f ;Read saved W register swapf w_save,w ;Recover W register retfie ;*********** Time-out interruption Process ************ timer_int bcf INTCON,T0IF ;Clear timer int flag movlw h'00' ;Set timer value movwf TMR0 ;TMR0 = 0 (255 counts) decfsz tm_cnt,f ;Time over ? goto int_end ;No. Retry movlw tm_adj ;Set time adjust value movwf tm_cnt ;Save time adjust ;********** Screen data shift Process *************** movlw d'15' ;Set loop count movwf s_loop ;Save loop count movlw scrnhd ;Set screen head adr movwf s_index ;Set screen adr loop incf s_index,w ;Inclement index movwf FSR ;Set read addres movf INDF,w ;Read data movwf s_work ;Save data movf s_index,w ;Read index movwf FSR ;Set write address movf s_work,w ;Recover data movwf INDF ;Write data incf s_index,f ;Inclement index decfsz s_loop,f ;All shifted ? goto loop ;No. Continue. ;i believe this is where the message moves ;************New data write Process**************** movf s_index,w ;Read index movwf FSR ;Set write address movf e_adr,w ;Read EEPROM address movwf EEADR ;Set EEPROM address bsf STATUS,RP0 ;Change to Bank1 bsf EECON1,RD ;Start EEPROM reading bcf STATUS,RP0 ;Change to Bank0 movf EEDATA,w ;Read EEPROM data movwf INDF ;Write new data incf e_adr,f ;Inclement data address decfsz e_check,f ;End of EEPROM data ? goto int_end ;No. Return clrf e_adr ;Clear EEPROM data adr movlw e_size ;Set EEPROM data size movwf e_check ;Save EEPROM end check goto int_end ;Return ;***************************************************** ; END of signboard control processing ;****************************************************** end​
I cleaned up the code to see if that would make it clearer to those with more experience in the PIC programming than I.

hgmjr
 
Last edited:

hgmjr

Joined Jan 28, 2005
9,029
The code insert contains the added line highlighted in RED. This line does nothing more than invert the 4-bit value right before it is written to PORTA. The only other change that is likely to be needed is the pattern table for the message will need to be mirrored.

As far as I can tell, all of the heavy lifting is being performed by the Timer 0 Interrupt Service Routine. There is only one place where PORTA is being updated. By inverting the value written to PORTA, the net effect should be a change in the direction that the display is scrolling. If this works as I expect then you may want to add a bit more code so that you can change the direction of scrolling at will by assigning an unused pin to select the scroll direction.

hgmjr

Rich (BB code):
;********************************************** ; ; The signboard control processing ; ; Author : Seiichi Inoue ;********************************************** list p=pic16f84a include p16f84a.inc __config h'3ff2' ;************* Label Definition ******************** lpcnt equ 0c ;Screen loop counter adr scrnidx equ 0d ;Screen data index adr w_save equ 0e ;W register save adr s_save equ 0f ;STATUS reg save adr scrnhd equ 10 ;Screen table head adr tm_cnt equ 20 ;Time adjust counter adr e_adr equ 21 ;EEPROM data adr e_check equ 22 ;EEPROM end check cnt adr s_loop equ 23 ;Screen data loop cnt adr s_index equ 24 ;Screen table index adr s_work equ 25 ;Screen data work area ;************************ ;* Time adjust * ;************************ ;This data decides a scroll speed. Basic rate is 26msec. tm_adj equ 0c ;Time adjust(26msec x 12) ;************************ ;* EEPROM data size * ;************************ ;If the data size is 30 bytes, then simply set d'30'. e_size equ d'32' ;EEPROM data size ;*************** EEPROM Data Definition *************** org h'2100' de b'11111111' de b'01111000' de b'10111111' de b'11011111' de b'10111111' de b'01111000' de b'11111111' de b'11111111' de b'11000011' de b'10111101' de b'01111110' de b'00000000' de b'11111111' de b'01110110' de b'01110110' de b'00000000' de b'11111111' de b'00000110' de b'01110110' de b'01110000' de b'11111111' de b'10000001' de b'01111110' de b'10000001' de b'11111111' de b'01111111' de b'01111111' de b'00000000' de b'11111111' de b'10011001' de b'01111110' de b'10000001' ;**************** Program Start *********************** org 0 ;Reset Vector goto init org 4 ;Interrupt Vector goto int ;**************** Initial Process ***************** org 5 init bsf STATUS,RP0 ;Change to Bank1 clrf TRISA ;Set PORTA to Output mode clrf TRISB ;Set PORTB to Output mode movlw h'07' ;TOCS=0,PSA=0,PS2/1/0=111 movwf OPTION_REG ;Set timer condition bcf STATUS,RP0 ;Change to Bank0 movlw h'00' ;Set timer value movwf TMR0 ;TMR0 = 0 (255 counts) movlw tm_adj ;Set time adjust value movwf tm_cnt ;Save time adjust clrf e_adr ;Clear EEPROM data adr movlw e_size ;Set EEPROM data size movwf e_check ;Save EEPROM end check movlw h'a0' ;GIE=1,TOIE=1 movwf INTCON ;Interruption enable ;************** Screen Load Process ************* screen bsf INTCON,GIE ;Interrupt enable movlw d'16' ;Set loop count movwf lpcnt ;Save loop count movlw h'0f' ;Set screen index movwf scrnidx ;Save index bcf INTCON,GIE ;Interrupt disable scrnlp movlw h'ff' ;Set LED OFF data movwf PORTB ;Output Data movf scrnidx,w ;Set Position xorlw h'ff' ;Invert all of the bits of column address ; just prior to outputing the value to PORTA???? movwf PORTA ;Output Position movlw scrnhd ;Set Table head address addwf scrnidx,w ;Head + Index movwf FSR ;Set Table address movf INDF,w ;Read Data movwf PORTB ;Output Data decf scrnidx,f ;Index - 1 decfsz lpcnt,f ;Loop end ? goto scrnlp ;No. Next line goto screen ;Yes. Next screen ;********** Begin Interruption Process ************** int movwf w_save ;Save W register movf STATUS,w ;Read STATUS reg movwf s_save ;Save STATUS reg btfsc INTCON,T0IF ;Time out interruption ? goto timer_int ;Jump to Timer process goto init ;Reset(Illegal interrupt) ;********* END of Interruption Process ************** int_end movf s_save,w ;Read saved STATUS reg movwf STATUS ;Recover STATUS reg swapf w_save,f ;Read saved W register swapf w_save,w ;Recover W register retfie ;*********** Time-out interruption Process ************ timer_int bcf INTCON,T0IF ;Clear timer int flag movlw h'00' ;Set timer value movwf TMR0 ;TMR0 = 0 (255 counts) decfsz tm_cnt,f ;Time over ? goto int_end ;No. Retry movlw tm_adj ;Set time adjust value movwf tm_cnt ;Save time adjust ;********** Screen data shift Process *************** movlw d'15' ;Set loop count movwf s_loop ;Save loop count movlw scrnhd ;Set screen head adr movwf s_index ;Set screen adr loop incf s_index,w ;Inclement index movwf FSR ;Set read addres movf INDF,w ;Read data movwf s_work ;Save data movf s_index,w ;Read index movwf FSR ;Set write address movf s_work,w ;Recover data movwf INDF ;Write data incf s_index,f ;Inclement index decfsz s_loop,f ;All shifted ? goto loop ;No. Continue. ;i believe this is where the message moves ;************New data write Process**************** movf s_index,w ;Read index movwf FSR ;Set write address movf e_adr,w ;Read EEPROM address movwf EEADR ;Set EEPROM address bsf STATUS,RP0 ;Change to Bank1 bsf EECON1,RD ;Start EEPROM reading bcf STATUS,RP0 ;Change to Bank0 movf EEDATA,w ;Read EEPROM data movwf INDF ;Write new data incf e_adr,f ;Inclement data address decfsz e_check,f ;End of EEPROM data ? goto int_end ;No. Return clrf e_adr ;Clear EEPROM data adr movlw e_size ;Set EEPROM data size movwf e_check ;Save EEPROM end check goto int_end ;Return ;***************************************************** ; END of signboard control processing ;****************************************************** end​
 
Last edited:

SimoN15

Joined Dec 19, 2010
5
Actually, what is so bad about mounting the board upsided down?

I expect that you are going to house it in a box of some sort.


If you change the pattern as I have indicated and then complement the 4-bit value that the PIC is feeding to the multiplexer, I think you will get the desired behaviour.

hgmjr

OLD PATTERN

Rich (BB code):
;*************** EEPROM Data Definition ***************
org h'2100'
de b'11111111'
de b'00011100'
de b'11111101'
de b'11111011'
de b'11111101'
de b'01111000'
de b'11111111'
de b'11111111'
de b'11000011'
de b'10111101'
de b'01111110'
de b'00000000'
de b'11111111'
de b'01110110'
de b'01110110'
de b'00000000'
de b'11111111'
de b'00000110'
de b'01110110'
de b'01110000'
de b'11111111'
de b'10000001'
de b'01111110'
de b'10000001'
de b'11111111'
de b'01111111'
de b'01111111'
de b'00000000'
de b'11111111'
de b'10011001'
de b'01111110'
de b'10000001'
NEW PATTERN

Rich (BB code):
org h'2100'
de b'10000001'
de b'01111110'
de b'10011001'
de b'11111111'
de b'00000000'
de b'11111110'
de b'11111110'
de b'11111111'
de b'10000001'
de b'01111110'
de b'10000001'
de b'11111111'
de b'00001110'
de b'01101110'
de b'01100000'
de b'11111111'
de b'00000000'
de b'01110110'
de b'01110110'
de b'11111111'
de b'00000000'
de b'01111110'
de b'10111101'
de b'11000011'
de b'11111111'
de b'11111111'
de b'00011110'
de b'11111101'
de b'11111011'
de b'11111101'
de b'00011110'
de b'11111111'
;****************
where did you get the old code pattern? based on the original code pattern, there was a slight difference between of them.
 
Top