Results 1 to 9 of 9

Thread: Custom M1 firmwire for low battery protect with high IGN line

  1. #1
    Maximum Bitrate
    Join Date
    May 2003
    Location
    UK
    Posts
    581

    Custom M1 firmwire for low battery protect with high IGN line

    Like many of you I have found the M1-ATX's low battery protection feature ONLY works if the ignition line is low ( ie if PC was supposed to turn off but hasn't or it's been in standby for a week too many )
    I would like this to be monitored even when the PC is on - if it's playing music at an outdoor party, or i've forgotten to turn my IGN-ON manual switch off when updating music over the WLAN

    The source is avaliable here:

    http://www.epiacenter.com/downloads/itatx2.zip




    I need somebody more expert on PIC programming than me to check over my proposed addition...

    here is the voltage check ( I think ) which is from the init_wait subroutine ( off state )

    Code:
    call	read_adc	;read ADC channel 0
              sublw	VSW12	;compare with threshold
    	btfsc	STATUS,C	;low bat: clear counter
    My proposal is to add these lines to the on state loop which i think is "onstate1"


    Any PIC experts have any input here?




    EDIT - some more usefull information:


    VSW12 is the analog input for battery voltage - which seems to have another value attached which is the required shutdown voltage

    The ‘equ’ instruction simply means something equals something else. It is not an instruction for the PIC, but for the assembler. With this instruction we can assign a name to a register address location, or in programming terms assign a constant. Let us set up some constants for our program, then you will see how much easier to read the program is.

    Code:
    shut4	call	read_adc	;read ADC channel 0
              sublw	VSW12	;compare with threshold
    	btfss	STATUS,C	;ok bat: clear counter
    	  goto	shut0
    	movlw LEDCNTLOW
    	movwf ledcounter
    	decfsz	cntr3l,f	;LOWOFF countdown
    	  goto	shut1
    	decfsz	cntr3h,f
    	  goto	shut1
    	goto	reset2	;do hard power off
    ^ this looks like the subroutine that performs the actual hardOFF on low battery





    The BTFSC instruction means ‘Do a bit test on the register and bit we specify. If it is a 0, then we skip the next instruction’.


    sublw is a subtract command
    www.digital-car.co.uk - The UK CarPC Forum

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    1,736
    I had a quick look at the code, must say its a little bit strange the way its written.

    Anyway...

    Do you want to do a hard off or a proper shutdown on low battery?

    The on state is actually the loop from here >>>

    Code:
    onstate	
    	call	check_alternate_swith ; check if we need to restart the motherboard because of a J8 usage during OFFDELAY
    	call	read_sw	;set OFFDELAY counter
    	call	offtabl
    	movwf	cntr1l
    	call	offtabh
    	movwf	cntr1h
    
    onstate1	call	on200	;on state process
    	btfsc	PORTA,1	;ignition on ?
    	  goto	onstate	;yes: reset timer
    	movlw	1h
    	movwf	ignition_was_off ; set the flag because we have an ignition_off event
    	movfw	cntr1l	;counter 0 ?
    	iorwf	cntr1h,w
    	btfsc	STATUS,Z
    	  goto	onstate1	;yes: ignore ignition
    	decfsz	cntr1l,f	;count down
    	  goto	onstate1
    	decfsz	cntr1h,f
    	  goto	onstate1
    While the PC is on the IGN is monitored, it keep looping constantly reading some tables for some reason. Once the IGN goes off a timer is started making sure the IGN wasnt just a glitch or a quick off/on situation.


    This code from above check the timers value >>>

    Code:
    	decfsz	cntr1l,f	;count down
    	  goto	onstate1
    	decfsz	cntr1h,f
    	  goto	onstate1
    Once the timer is exhausted the "decfsz cntr1h,f" skip the "goto onstate1" leaving the loop and starting the shutdown process.

    What you want to do is add a LOWBAT check and make it jump to the proper shutdown routine.

    Code:
    	call	read_adc			;read ADC channel 0
    	sublw	VSW12				;compare with threshold
    	btfsc	STATUS,C			;low bat: do a shutdown, else just continue as normal
    	goto	DOAPROPERSHUTDOWN	;
    The code above will check for LOWBAT and do a shutdown, else it will continue as normal.


    I cant be to sure if my advice is 100% correct as the code is abit hard to follow. A little bit of trial and error wont hurt.

    Thats it, hope that helps.

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    1,736
    Quote Originally Posted by Jamez_Warner
    EDIT - some more usefull information:
    Hehe, if they needed those extra info on equ and btfsc how can you expect them to even understand the rest of the code?

  4. #4
    Maximum Bitrate Danceheaven's Avatar
    Join Date
    May 2002
    Location
    Essex, UK'er
    Posts
    664
    Quote Originally Posted by Chris31
    Hehe, if they needed those extra info on equ and btfsc how can you expect them to even understand the rest of the code?
    James is just attempting to look intelligent with hes limited knowledge aint ya buddy
    Co Develper of A.I.M.E.E Automotive Intelligent Multimedia Entertainment Engine
    www.aimee.cc

  5. #5
    Maximum Bitrate
    Join Date
    May 2003
    Location
    UK
    Posts
    581
    i never pretended to be a PIC expert !
    www.digital-car.co.uk - The UK CarPC Forum

  6. #6
    Maximum Bitrate Danceheaven's Avatar
    Join Date
    May 2002
    Location
    Essex, UK'er
    Posts
    664
    Quote Originally Posted by Jamez_Warner
    i never pretended to be a PIC expert !

    No but i did!
    Co Develper of A.I.M.E.E Automotive Intelligent Multimedia Entertainment Engine
    www.aimee.cc

  7. #7
    Registered User
    Join Date
    May 2003
    Posts
    1,736
    Someone asked for help, he got the help...wonder if he even notice it?



    Ehh, so did it work then?

  8. #8
    Maximum Bitrate
    Join Date
    May 2003
    Location
    UK
    Posts
    581
    thanks chris - sorry I did not respond

    I'm still checking it - I need to send elsewhere to have it programmed so must get it right first time
    where did you suggest the code was added - in "onstate" ?

    James
    www.digital-car.co.uk - The UK CarPC Forum

  9. #9
    MySQL Error Scouse Monkey's Avatar
    Join Date
    Mar 2004
    Location
    Bristol
    Posts
    9,727
    Quote Originally Posted by Chris31
    I had a quick look at the code, must say its a little bit strange the way its written.

    Anyway...

    Do you want to do a hard off or a proper shutdown on low battery?

    The on state is actually the loop from here >>>

    Code:
    onstate	
    	call	check_alternate_swith ; check if we need to restart the motherboard because of a J8 usage during OFFDELAY
    	call	read_sw	;set OFFDELAY counter
    	call	offtabl
    	movwf	cntr1l
    	call	offtabh
    	movwf	cntr1h
    
    onstate1	call	on200	;on state process
    	btfsc	PORTA,1	;ignition on ?
    	  goto	onstate	;yes: reset timer
    	movlw	1h
    	movwf	ignition_was_off ; set the flag because we have an ignition_off event
    	movfw	cntr1l	;counter 0 ?
    	iorwf	cntr1h,w
    	btfsc	STATUS,Z
    	  goto	onstate1	;yes: ignore ignition
    	decfsz	cntr1l,f	;count down
    	  goto	onstate1
    	decfsz	cntr1h,f
    	  goto	onstate1
    While the PC is on the IGN is monitored, it keep looping constantly reading some tables for some reason. Once the IGN goes off a timer is started making sure the IGN wasnt just a glitch or a quick off/on situation.


    This code from above check the timers value >>>

    Code:
    	decfsz	cntr1l,f	;count down
    	  goto	onstate1
    	decfsz	cntr1h,f
    	  goto	onstate1
    Once the timer is exhausted the "decfsz cntr1h,f" skip the "goto onstate1" leaving the loop and starting the shutdown process.

    What you want to do is add a LOWBAT check and make it jump to the proper shutdown routine.

    Code:
    	call	read_adc			;read ADC channel 0
    	sublw	VSW12				;compare with threshold
    	btfsc	STATUS,C			;low bat: do a shutdown, else just continue as normal
    	goto	DOAPROPERSHUTDOWN	;
    The code above will check for LOWBAT and do a shutdown, else it will continue as normal.


    I cant be to sure if my advice is 100% correct as the code is abit hard to follow. A little bit of trial and error wont hurt.

    Thats it, hope that helps.
    Wow chris31, looks like you have put a lot of effort into that!

Similar Threads

  1. MPJA - MECI ASTEC DC-DC Converter
    By Luc in forum General Hardware Discussion
    Replies: 39
    Last Post: 11-22-2004, 10:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •