Problem with 12F629, servo and EEPROM


Results 1 to 14 of 14

Threaded View

  1. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Default

    Hi, Atom

    Those lines Have Passed the MPSIM Test ...

    Code:
    @ DEVICE pic12F629, INTRC_OSC_NOCLKOUT ; Using Internal Clock, no clock out
    @ DEVICE pic12F629, WDT_ON ; Enable Watch dog timer
    @ DEVICE pic12F629, PWRT_ON ; Enable Power-up timer
    @ DEVICE pic12F629, MCLR_OFF ; Disable MCLR pin 
    @ DEVICE pic12F629, BOD_ON ; Enable Brown-out detect
    @ DEVICE pic12F629, CPD_OFF ; EEPROM Protect
    @ DEVICE pic12F629, PROTECT_OFF ; Code Protect off
    
    '@ __CONFIG _INTRC_OSC_NOCLKOUT &  _WDT_ON & _PWRTE_ON & _BODEN_ON & _MCLRE_OFF
    
    DEFINE OSCCAL_1K 1
    DEFINE BUTTON_PAUSE 20
    
    GPIO	= %00000000
    TRISIO 	= %11111110
    
    INTCON.6=0 ' Disable all unmasked Interrupts
    INTCON.7=0 ' Disable Global Interrupts
    CMCON = 7 ' Disable analog comparator
    
    ServoOut 	var GPIO.0
    SetLimitSw 	var GPIO.1
    PotIn 		var GPIO.2
    MinSw 		var GPIO.4
    MaxSw 		var GPIO.5
    
    Delay		var Byte
    
    Posit 		var Byte
    MinPosit 	var Byte
    MaxPosit 	var Byte
    
    'load starting min and max positions at program time
    data @ 0,100 
    data @ 2,250 
    
    '************************************************* ***************
    low Servoout
    
    'read in stored min and max limits
    
    read 0, MinPosit
    read 2, MaxPosit
    
    Start:
    
    gosub GetServoPosition
    
    Low 	servoout
    pulsout servoout, posit
    
    
    
    Delay = 0
    BUTTON setlimitsw, 0, 255, 0, Delay, 1, Start
    
    	Delay = 0
    	BUTTON minsw, 1, 255, 0, Delay, 1, MinL		'20 ms
    	Delay = 0
    	BUTTON maxsw, 1, 255, 0, Delay, 1, MaxL		' 20 ms
    	
    	pause 20					' no button pushed
    	Goto Start					
    	
    MinL:
    	IF maxsw = 1 THEN Start		'1 Button pushed at a Time !!!
    	
    	IF Posit <> MinPosit THEN
    	
    		MinPosit = Posit
    		write 0, MinPosit						'10 ms
    	
    	ENDIF
    	
    goto start
    
    MaxL:
    	
    	IF minsw = 1 THEN Start		'1 Button pushed at a Time !!!
    	
    	IF Posit <> Maxposit THEN
    	
    		MaxPosit = Posit
    		write 2, MaxPosit						' 10 ms
    		
    	ENDIF
    
    goto start
    
    '************************************************* ***************
    GetServoPosition:
    
    high potin
    pause 1
    rctime potin, 1, Posit 'at 4 mhz, returns 3 - 123 :: 1.23 ms max
    
    'adjust posit to get values between 75 and 250
    posit = posit + 75 + (posit / 2)
    
    'now limit posit to 100 - 250 (1 ms - 2.5 ms)
    
    if posit < 100 then posit = 100
    if posit > 250 then posit = 250
    
    if setlimitsw = 0 then 'apply limits
    
    	if Posit < MinPosit then Posit = MinPosit
    	if Posit > MaxPosit then Posit = MaxPosit
    	
    endif 
    
    return 
    
    '************************************************* ***************
    
    End
    Try those lines ... should work !!!

    Alain
    Last edited by Acetronics2; - 29th February 2008 at 19:32.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03:17
  2. Writing to a table.
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th December 2005, 16:20
  3. Servo Recording
    By kenpo in forum General
    Replies: 3
    Last Post: - 2nd September 2005, 16:03

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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