Author Topic: Simple Electronic Switch Mod  (Read 16359 times)

Offline l0rdnic0

  • 2%
  • Acidmods Alumni
  • E = MC² Mad Scientist
  • *
  • Posts: 1836
  • Post quality +8/-0
  • Gender: Male
  • TeamCYBER

Simple Electronic Switch Mod
« on: March 23, 2008, 11:16:11 PM »
Here is an Electronic switch that I have installed in a PSP Slim. This can be installed in any console and be programmed to turn on and off as many mods as you have. The nice thing about this is that it is set to any button you wish and does not interfere with that buttons original functions. To use the button all you need to do is hold it down for .5 of one second.



Keep in mind that is has been configured to turn on and off only one mod, but could be expanded to acomidate many more. Also I'm not a ASM coder so my code is not as clean as I would like but it does what its suposed to.

the modes are as follow

Mode 1:
hold button down for .5 second turns MOD one on.

Mode 2:
Hold button down for .5 second turns Mod one off .

;Software License Agreement                                         
;                                                                   
;The software supplied herewith by L0rdnic0           
;Incorporated (the "Company") is intended and supplied to you, the 
;Company’s customer. The software is owned by the Company and/or its supplier,
;and is protected under applicable copyright laws. All rights are   
;reserved. Any use in violation of the foregoing restrictions may   
;subject the user to criminal sanctions under applicable laws, as   
;well as to civil liability for the breach of the terms and         
;conditions of this license.                                       
;                                                                   
;THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, 
;WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED 
;TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A       
;PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ACIDMODS.COM SHALL NOT, 
;IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR         
;CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.       
;****************************************************************************
;File Name:   l0rdnic0.asm
;Author:   L0rdNiC0   
;Date:     24 March 2008
;Version:   1.01   
;Description:   Single pole, single throw switch (Can be moddified to include other functions)
;
;******************************************************************************
;Notes:
;******************************************************************************
;   Each button push toggles the Switch.
;   Origional code snipits taken from works by W.R.Brown Date: 2 December 2002
;                             
;
;******************************************************************************

   list      p=12F675       ; list directive to define processor
   #include <p12f675.inc>    ; processor specific variable definitions

   __CONFIG  _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _CPD_OFF

; '__CONFIG' directive is used to embed configuration word within .asm file.
; The labels following the directive are located in the respective .inc file.
; See data sheet for additional information on configuration word settings.

;******************************************************************************
;Defines
;******************************************************************************

#define Bank0      0x00
#define   Bank1      0x80
#define SWITCH      GPIO,3
#define D0_1Tris   B'11001111'
#define D0On      B'00010000'
#define D0Off      B'00000000'
#define D1On      B'00100000'
#define D1Off      B'00000000'
#define LEDOn      GPIO,4
#define OneSecond   D'276'   ; number of Timer0 overflows in 1 sec
              ; when Fosc = 4MHz and prescale = 1:4
#define ChangeMode   Flags,0   ; request to change the debounce mode                                  


;******************************************************************************
;General Purpose Registers (GPR's)
;******************************************************************************

   cblock   0x20
   FilterCount      ; debounce filter counter
   OneSecH         ; one second timer high byte
   OneSecL         ; one second timer low byte
   Flags         ; LED flags
   CountH         ; debounce counter - MS Byte
   CountL         ; debounce counter - LS Byte
   endc

;******************************************************************************
;Reset Vector
;******************************************************************************
   ORG     0x000            ; processor reset vector
   nop         ; required by in circuit debugger 
   goto    Init            ; go to beginning of program

;******************************************************************************
;Interrupt Vector     
;******************************************************************************
   ORG   0x004
   return         ; interrupt trap - returns without re-enabling
;******************************************************************************
;Initialization
;******************************************************************************
Init
   ;call    0x3FF      ; retrieve factory calibration value
                  ; comment instruction if using simulator, ICD2, or ICE2000
   BANKSEL   Bank1      ; BANK1
   movwf   OSCCAL          ; update register with factory cal value
   movlw   D0_1Tris   ; set direction so LEDs D0 & D1 are outputs
   movwf   TRISIO      ; all others are inputs (high-z)
   movlw   B'11010001'   ; Timer0 internal clock, 1:4 prescale
   movwf   OPTION_REG   ; set option register for Timer0 functions
   clrf   ANSEL      ; configure A/D I/O as digital
   banksel   Bank0      ; change back to PORT memory bank
   movlw   CM2 | CM1 | CM0 ; configure comparator inputs as digital I/O
   movwf   CMCON      ;
   clrf   Flags      ; set initial LED state as off
   clrf   FilterCount   ; set initial filter count
   call   ToggleLED   ; light initial LED

;******************************************************************************
;Main
;******************************************************************************
Main
TimerLoop
   btfss   INTCON,T0IF   ; wait for Timer0 overflow
   goto   TimerLoop   ;
   
   bcf   INTCON,T0IF   ; clear Timer0 overflow flag
   call   TestSwitch   ; test switch once every millisecond
   btfsc   ChangeMode   ; request to change debounce mode? We return here
   goto   InitMain1   ; yes - initialize and run brute force mode
   goto   Main

;******************************************************************************
;Subroutines & Functions
;******************************************************************************
;******************************************************************************
;TestSwitch - Test switch state and take action when filter count saturates
;******************************************************************************
TestSwitch
   btfss   SWITCH      ; test for switch closure
   goto   SwitchClosed

SwitchOpen
; When switch is open - decrement count if not already saturated
   movf   FilterCount,f   ; move affects zero flag
   btfsc   STATUS,Z   ; test filter count for zero
   return          ; count saturated - return to Main
      

   decfsz   FilterCount,f   ; decrement filter count
   return          ; not zero - return to Main      

   return          ; return to Main
   
SwitchClosed
; When switch is closed - increment count if not already saturated
   btfsc   FilterCount,4   ; 16 count saturation if bit 4 is high
   goto   TestHold   ; already saturated - test button hold

      
   incf   FilterCount,f   ; count up when switch is closed
   btfss   FilterCount,4   ; 16 count saturation when bit 4 goes high
   return          ; return to Main
      
   call   Reset1Second   ; reload 1 second timer count

   return          ; return to monitor loop

ResetAndTest
   bcf   INTCON,T0IF   ; reset Timer0 overflow flag

TestHold
; Increment negative 1 second counter and switch modes if it goes to zero

   incfsz   OneSecL,f   ; 16 bit increment ls byte
   return          ; return on no overflow
   incfsz   OneSecH,f   ; 16 bit increment ms byte
   return          ; return on no overflow

; one second of button holding has elapsed when both ls and ms bytes overflow      

   bsf   ChangeMode   ; button held for one second - change mode This is where the chmod happens
    call ToggleLED
   return
      

;******************************************************************************
;Reset1Second - Set 1 second counter to full count
;******************************************************************************
Reset1Second

   movlw   HIGH (-OneSecond & 0xFFFF)   ; most significant bits of
            ; negative count
   movwf   OneSecH      ; set ms register
   movlw   LOW -OneSecond   ; least significant bits of negative count
   movwf   OneSecL      ; set ls register
   return          ; return to calling routine


;******************************************************************************
;Main1 - Init Switching Debounce
;******************************************************************************
InitMain1
   btfsc   SWITCH      ; wait in loop until SWITCH closure is sensed
   goto   InitMain1      ; SWITCH closure grounds input pin
      
   call   SwitchDebounce   ; wait for switch to release and settle
   btfss   ChangeMode   ; test if button held for 1 second
   goto    Main


InitMain0      
   bcf      ChangeMode   ; clear mode change flag
   clrf   FilterCount   ; set initial filter count
   goto   Main      ; change to Mode0

;******************************************************************************
;ToggleLED - Toggles D0 on and off
;******************************************************************************
ToggleLED
   btfss   LEDOn      ; test flag of present LED condition
   goto   TurnLedOn   ; the LED is presently off - go turn it on
   
TurnLedOff
   bcf   LEDOn      ; clear flag to indicate LED is off
   movlw   D0Off      ; data for all LED outputs low
   movwf   GPIO      ; send data to GPIO port
   return         ; return to calling routine
   
TurnLedOn
   bsf   LEDOn      ; set flag to indicate LED is on
   movlw   D0On      ; data to forward bias LED0 and reverse bias LED1
   movwf   GPIO      ; send data to GPIO port
   return         ; return to calling routine

;******************************************************************************
;SwitchDebounce - Waits for switch to release and settle
;******************************************************************************
SwitchDebounce
#define TenMSH       D'20'
#define TenMSL      D'99'

   movlw   TenMSH      ; set outer timer loop count
   movwf   CountH      ; outer loop overhead is 2 instructions

;========== outer loop [TenMSH * 5 instruction cycles*(Inner loop time)] ======
SD10
   movlw   TenMSL      ; set inner timer loop
   movwf   CountL
;----------------- inner loop (TenMSL * 5 instruction cycles) -----------------
SD20
   btfss   SWITCH      ; test SWITCH input
   goto   SwitchDebounce   ; SWITCH was low - reset timer
   
   decfsz   CountL,f   ; inner loop countdown
   goto   SD20      ; test SWITCH while counting

;-------------------------------- inner loop ----------------------------------
   
   decfsz   CountH,f   ; outer loop countdown
   goto   SD10      ; reset inner loop after each outer loop count

;================================ outer loop ==================================

   return         ; full countdown and no bounces achieved - exit
   
   END         ; directive 'end of program'



« Last Edit: March 24, 2008, 12:24:10 AM by l0rdnic0 »


L0rdNiC0 Pioneering Mods on the PSP Slim :taunt:
Sound Mod, Button LED Mod, Security Mod, Dual NUB, Mode Select Switch + More

Offline Skullmaster

  • God Of Cars
  • Acidmods Alumni
  • E = MC² Mad Scientist
  • *
  • Posts: 1520
  • Post quality +1/-0
  • Gender: Male
  • Admin Force, Co-Owner Wanna-be
    • Acidmods
Re: Simple Electronic Switch Mod
« Reply #1 on: March 23, 2008, 11:24:27 PM »
Very nice nico! Lots of hard coding into this one, lol!

Offline robin1989

  • Site Owner - Site Maintenance & development
  • Administrator
  • Mad Bomber
  • *
  • Posts: 6272
  • Post quality +21/-0
  • Gender: Male
  • Site owner
    • Acidmods
Re: Simple Electronic Switch Mod
« Reply #2 on: March 24, 2008, 03:20:26 AM »
very nice

i am not responsible for what i do or my advice


Get the iPhone 4s from Three using Quidco and recieve £109 cashback

TheG4mer

  • Guest
Re: Simple Electronic Switch Mod
« Reply #3 on: March 24, 2008, 09:59:39 AM »
 Nico what is this coded in,Basic.C# ect ect.
« Last Edit: March 25, 2008, 04:58:15 AM by robin1989 »

Offline budgray19

  • Acidmods Alumni
  • E = MC² Mad Scientist
  • *
  • Posts: 2134
  • Post quality +1/-0
  • Gender: Male
  • OH NO MY CHITTY CHICKEN, NOO NOT MY CHITTY BEEF
Re: Simple Electronic Switch Mod
« Reply #4 on: March 24, 2008, 12:01:14 PM »
good job nico
« Last Edit: March 25, 2008, 04:58:41 AM by robin1989 »


Offline zbblanton

  • Acid Modder
  • *
  • Posts: 979
  • Post quality +5/-0
  • Gender: Male
    • My modding site
Re: Simple Electronic Switch Mod
« Reply #5 on: March 24, 2008, 01:18:02 PM »
ill probably have a code something like this in basic pro in a few  days (if u dont care nico)

Offline RATCHET

  • Motor Mouth
  • *
  • Posts: 76
  • Post quality +0/-0
  • Gender: Male
Re: Simple Electronic Switch Mod
« Reply #6 on: March 24, 2008, 05:05:46 PM »
ware we download it?

Offline robin1989

  • Site Owner - Site Maintenance & development
  • Administrator
  • Mad Bomber
  • *
  • Posts: 6272
  • Post quality +21/-0
  • Gender: Male
  • Site owner
    • Acidmods
Re: Simple Electronic Switch Mod
« Reply #7 on: March 24, 2008, 05:10:17 PM »
thats the code in the first topic you copy and paste that into your programmer i think

i am not responsible for what i do or my advice


Get the iPhone 4s from Three using Quidco and recieve £109 cashback

Offline RATCHET

  • Motor Mouth
  • *
  • Posts: 76
  • Post quality +0/-0
  • Gender: Male
Re: Simple Electronic Switch Mod
« Reply #8 on: March 24, 2008, 06:31:03 PM »
ware do i get that?

Offline robin1989

  • Site Owner - Site Maintenance & development
  • Administrator
  • Mad Bomber
  • *
  • Posts: 6272
  • Post quality +21/-0
  • Gender: Male
  • Site owner
    • Acidmods
Re: Simple Electronic Switch Mod
« Reply #9 on: March 25, 2008, 04:47:00 AM »
if you look in the first post the quoted text is the code whick you copy and paste into your programing software (like pic basic pro) then flash it to the pic chip using a programer which can be bought from imagesco.com

i am not responsible for what i do or my advice


Get the iPhone 4s from Three using Quidco and recieve £109 cashback

Offline RATCHET

  • Motor Mouth
  • *
  • Posts: 76
  • Post quality +0/-0
  • Gender: Male
Re: Simple Electronic Switch Mod
« Reply #10 on: March 25, 2008, 02:48:02 PM »
oh i need sum chip for the program man thats money right there i guess i aint gonna be doing this mod

Offline zbblanton

  • Acid Modder
  • *
  • Posts: 979
  • Post quality +5/-0
  • Gender: Male
    • My modding site
Re: Simple Electronic Switch Mod
« Reply #11 on: March 25, 2008, 02:50:38 PM »
what, there like a doaller a pic

Offline psphacksntips

  • ♪♪♪ Tone deff ♪♪♪
  • *
  • Posts: 69
  • Post quality +0/-0
  • Gender: Male
  • PSPHACKSNTIPS| From originality to insanity....
    • For PSP hacks n tips visit us @ PSPHACKSNTIPS
Re: Simple Electronic Switch Mod
« Reply #12 on: March 25, 2008, 09:22:14 PM »
nice coding
======================
PSPHACKSNTIPS
| From originality to insanity|
======================

Offline Demonbrn

  • Chief squatting Hard
  • *
  • Posts: 14
  • Post quality +0/-0
  • Gender: Male
Re: Simple Electronic Switch Mod
« Reply #13 on: May 18, 2008, 03:10:41 PM »
Can you use any 8-pin PIC microcontroller, or does it have to be specific?

Offline rojs

  • Guppy
  • *
  • Posts: 4
  • Post quality +0/-0
  • Gender: Male
    • MyMitsuPh
Re: Simple Electronic Switch Mod
« Reply #14 on: July 01, 2008, 06:44:17 PM »
That is one cool mod sir.  :clap:

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.5 © 2008-2012, SimplePortal