Electronic Circuits and Projects Forum



Questions on upgrading my Project

« First 1234 Last »
  1. #21
    ljcox ljcox is offline
    Yes, you can do what you like with the programme.

    Have you tried to simulate it in MPLAB?

    Yes, I was intending to suggest that you start a new thread in the Microprocessor section as more people with PIC expertise will see it there & be able to help you.

    EDIT.
    Do you have the 16F84 data sheet?

    If so, the config word is on page 21 (I have the DS35007A version)
    0
    Last edited by ljcox; 8th March 2012 at 03:31 AM. Reason: extra info
    Len

  2. Thread Starter #22
    Sloetyme Sloetyme is offline
    Quote Originally Posted by ljcox View Post
    Yes, you can do what you like with the programme.

    Have you tried to simulate it in MPLAB?

    Yes, I was intending to suggest that you start a new thread in the Microprocessor section as more people with PIC expertise will see it there & be able to help you.
    I haven't put it into MPLAB but will be doing so tomorrow. Then I will study it and follow up in a new thread in the desired section with any questions and as for now i'm gonna leave this thread alone.
    Thanks for the response.

    Response to EDIT:
    Yes I do and will look at that.
    0
    Last edited by Sloetyme; 8th March 2012 at 03:40 AM. Reason: Response to EDIT

  3. #23
    ljcox ljcox is offline
    After some thought about the PIC programme, I have made some minor changes to the circuit in order to make the programme simpler.
    Attached Images
    0
    Len

  4. #24
    ljcox ljcox is offline
    Tom,
    Here is another simple programme that you may find of interest.

    I wrote it some years ago for a friend who wanted a device that would switch a fan on for 1, 2, 3 or 4 hours - as set by a rotary switch.

    The PIC is driven by a 32.768 kHz crystal. Therefore the PIC is operating at 8192 instructions per second.

    The basic timing is done by TMR0. The prescaler is set to 256. So TMR0 is being incremented every 256/8192 = 31.25 ms.

    TMR0 is loaded with the complement of the value required and it counts up. The overflow flag is set when it goes from FF to 00.

    When the programme detects the overflow flag, it counts the event & and reloads TMR0.

    So for a delay of 4 seconds, TMR0 is loaded with the complement of 128 (128 = 4/0.03125).

    Code :
    ;Programme function - Operate a relay & release it after 1, 2, 3 or 4 hours.
    ;The timing is set by a rotary switch. Switch changes are detected by the 
    ; RB change interrupt function & cause the timer to restart from 0.
    ;Oscillator frequency = 32.768 kHz, Instruction rate = 32768/4 = 8192 Hz.
    ;TMR0 prescale = 256, so the frequency input to the TMR0 is 8192/256 = 32 Hz.
    ;If TMR0 is set to the complement of 16 (decimal) then it will overflow after
    ; approx 16/32 = 0.5 seconds.  
    ;If TMR0 is set to the complement of 128, it will overflow after 128/32 = 4 sec.
     
                  LIST   P=PIC16F84,	F=INHX8M
                include "p16f84.inc"
                 __CONFIG 0x3FF0	;32.768 kHz Crystal Oscillator, WDT off, Power up reset on
     
    porta	equ	05	;input/output pins RA0 ~ RA4
    portb	equ	06	;input/output pins RB0 ~ RB7
     
    cblock 0x10				
    	count1	;minutes counter (4 sec increments)
    	count2	;hours counter (60 sec increments)
    	temp
    endc
     
    #define relay	portb, 0	;relay connected to RB0
     
    #define	tmr0_of	INTCON, 2	;TMR0 overflow flag
    #define	sw_ch	INTCON, 0	;switch change (RB change flag)
     
    	ORG	0x00		;set programme counter to 0
     
    	call	init
     
    	bsf		relay		;operate relay
     
    restart 		;Starts from here after a switch change is detected
    	bcf		sw_ch		;clear RB change flag
     
    	call	delay_500m		;call 0.5 second delay to allow switch contacts to settle
     
    	movlw	d'240'		;4 hour
     
    	btfsc	portb, 4	;is rb4 high?
    	movlw	d'60'		;1 hour
     
    	btfsc	portb, 5	;is rb5 high?
    	movlw	d'120'		;2 hour
     
    	btfsc	portb, 6	;is rb6 high?
    	movlw	d'180'		;3 hour
     
    	movwf	count2		;count2 = 60, 120, 180 or 240
    ;the code below uses count1 & count2 to determine the relay on time.
     
    loopb
    	movlw	d'15'		
    	movwf	count1		;4 sec * 15 = 1 minute
     
    loopa
    	call	delay_4s
     
    	btfsc	sw_ch		;has a switch changed?
    	goto	restart		;yes - restart to determine the new time setting
     
    	decfsz	count1		;decrement count1 by 1, skip if 0
    	goto	loopa		;count1 is not 0, so repeat
     
    	decfsz	count2		;count1 is 0 , so decrement count2
    	goto	loopb		;count2 is not 0, so repeat
     
    	bcf		relay		;count2 is 0, so release relay
     
    	sleep	;PIC goes into low power mode & does nothing
    	NOP
     
    ;sub routines
     
    delay_4s
    	movlw	d'127'		;4 second delay @ 32.768 kHz
    	goto 	$+2
     
    delay_500m
    	movlw	d'15'		;0.5 second delay @ 32.768 kHz
    	movwf	temp		
    	comf	temp, w
    	movwf	TMR0
    	bcf		tmr0_of
     
    	btfsc	sw_ch		;has a switch changed?
    	return				;yes - exit loop
     
    	btfss	tmr0_of		;await TMR0 overflow
    	goto	$-1
    	return
     
    init
    	bsf		STATUS, 5	;selects BANK 1
     
    	clrf	TRISA		;make RA0:4 outputs
     
    	movlw	b'01110000'	
    	movwf	TRISB       ;RB0:3,7 outputs  RB4:6 inputs
     
    	movlw	b'10000111'	;sets prescaler to 256, internal clock
    	movwf	OPTION_REG	
     
    	bcf		STATUS,5	;selects bank 0
     
    	clrf	INTCON
    	clrf	porta		;clears porta
    	clrf	portb		;clears portb
     
    	bsf		INTCON, 3	;RB change enable
    	bsf		INTCON, 5	;TMR0 overflow enable
    	return
     
    	end
    0
    Len

  5. Thread Starter #25
    Sloetyme Sloetyme is offline

    Questions on upgrading my Project**UPDATE**

    Thanks to the directions of ljcox I have been able to now see how I am going to tackle my project here.

    As discussed earlier in this thread, I had some questions about how to drive my 15 cathode columns and sink my 7 anode rows for my 15x7 moving display. My original source(talkingelectronics.com) has things different than the parts I have. They used leds and I wanted to use the mis-ordered 5x7 display modules I have.

    Well I'm working on this slowly and surely as my brain will allow...lol.

    This may be hard to understand but links to my sources and pics and video and asm's will hope to help you.

    Like I said its gonna take some time for me to get the whole picture, but, i'm working on it and starting with 4x4 first.

    Thanks and comments and questions are invited.

    sources:

    http://www.electro-tech-online.com/c...LTP2157AKx.pdf

    http://thevaportrail.com/pr/01_Crossbar/crossbar.html

    http://talkingelectronics.com/projec...Display-1.html

    ((((MY VIDEO)))) http://www.youtube.com/watch?v=5A0rk...qpNKvxfCRY8%3D
    Attached Images
    Attached Files
    0

  6. #26
    ljcox ljcox is offline
    Very good.

    Now I can see what it does.

    There is a lot in the .asm files that I have not used or knew was possible, eg. Macros & if functions.
    0
    Len

  7. Thread Starter #27
    Sloetyme Sloetyme is offline
    Quote Originally Posted by ljcox View Post
    Very good.

    Now I can see what it does.

    There is a lot in the .asm files that I have not used or knew was possible, eg. Macros & if functions.
    Thank you Len.

    I am studying them now, they are something new to my self too.

    Talk later

    Tom
    0
    Last edited by Sloetyme; 20th March 2012 at 04:06 AM. Reason: Spell check correction

  8. Thread Starter #28
    Sloetyme Sloetyme is offline

    Question to the "UPDATE"

    Hi,

    I noticed that there is still some current running through the rows and maybe the columns so I increased the inline resistors from 1K0 to 2K0 and still see real faint flicker when leds are not supposed to be on.

    Anyone know what may be a solution to this? You may have to watch ((((MY VIDEO)))) from post #25 to understand.

    PS. attachment below of the schematic below.
    Attached Images
    0
    Last edited by Sloetyme; 20th March 2012 at 04:39 AM. Reason: Add info

  9. #29
    alec_t alec_t is offline
    Anyone know what may be a solution to this?
    Try adding a respective resistor (say 10 x the base resistor value) between base and emitter of each transistor, to ensure turn-off.
    0
    My circuit designs should be regarded as experimental. Although they work in simulation, their component values may need altering or additional components may occasionally be necessary when the circuit is built. Due safety precautions should be taken with any circuit involving mains voltage or electrostatic-sensitive components.
    Alec's First Law:-
    Every problem has a solution (given the right information and resources).

  10. #30
    ljcox ljcox is offline
    Quote Originally Posted by alec_t View Post
    Try adding a respective resistor (say 10 x the base resistor value) between base and emitter of each transistor, to ensure turn-off.
    That should not be necessary since the PIC outputs switch between V+ & Gnd.

    I study your circuit further & post later.
    0
    Len

« First 1234 Last »
Tags
Similar Threads
Thread Starter Forum Replies Last Post
Questions regarding my rather ambitious project ACF2802 General Electronics Chat 13 3rd August 2009, 03:17 PM
i'm new here, and i have questions about my first electronic project 3dfreakout General Electronics Chat 11 1st December 2008, 01:29 PM
Senoir Design Project Questions? excetara2 Electronic Projects Design/Ideas/Reviews 1 15th October 2008, 08:44 AM
Questions leading to small project (Laser Vortex) Norritt Electronic Projects Design/Ideas/Reviews 0 17th October 2007, 05:48 PM
NEWBIE PROJECT QUESTIONS?????? NEED ELECTRONICS HELP ShiftPointShaun Electronic Projects Design/Ideas/Reviews 3 12th June 2004, 03:58 AM
Electronic Circuits  |  Learning Electronics

Join our community with over 100,000 Members! It's free, easy and when you're logged in you have many more features! Click to register.
Page Time: 0.12376 seconds      Memory: 7,780 KB      Queries: 17      Templates: 0