Searching \ for '[SX] Problems with WKPND_B' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/devices.htm?key=sx
Search entire site for: 'Problems with WKPND_B'.

Exact match. Not showing close matches.
PICList Thread
'[SX] Problems with WKPND_B'
2009\07\11@212511 by RS_Jimn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, RS_Jim wrote:

I have been working on a Tacometer project for a while now and seem to have hit the wall.  I am running the Tac under an interupt along with a counter timer that I use to measure the lapse time between passes of the tac stripe on an optical sensor.  I am currently using an external comparitor just to give me an absolutly clean tac pulse.  This has been confirmed by scope. Here is the interupt code:


' =========================================================================
'
'   File......  interupt_inc_a.SXB
'   Purpose... INterupts for tac Project.
'   Author....  Jim Meek
'   E-mail....  
'   Started...
'   Updated...June 3. 2009 to include tac skip function.
'   Updated....June 14, 2009 to use edge detection for tac
' =========================================================================

' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
' Runs tacometer accelerometer pwm under intrupts

' -------------------------------------------------------------------------
' INTERRUPT
' -------------------------------------------------------------------------
ISR_Start:


ASM


Bank Timing                    
 mov w, #230   ; for it - 234_000
 'mov w,#100   ;for int=100,000
' mov w, #10   ;for int = 10,000
 dec usec                      
 snz                          
   mov usec,w   ;reload microsec timer
 snz                          
'   SETB AccRun   'tells the Accelerameter to colllect data
' Snz
inc Msec                      ;every millisec

mov w, #10                   ;was 10
 mov w, MSec-w                 ;Z if MSec = 10
 snz                          
   clr Msec
 SNZ
   SETB  Trigger                  
 snz                          
   inc Hsec                    ';every 1/100 sec for 1 sec
mov W,#$06
 ADD Hsec,W
 SB DC
 Sub Hsec,w

 mov w, #$A0   'Hex equivalant of 100                  
 mov w, HSec-w                 ;Z if HSec = 100
 snz                          
   clr Hsec                    
 snz                          
   inc sec                    ; every  sec
  mov W,#$06
 ADD sec,W
 SB DC
 Sub sec,w
 
mov w, #$60                    
 mov w, Sec,-w                 ; Z if Sec = 60
 snz                          
 clr sec
 clrb  Trigger     'BANK 0
ENDASM
ASM
   BANK  txSerial                              ' (1)
   TEST  txCount                               ' (1)   transmitting now?
   JZ    TX_Buffer                             ' (2/4) if txCount = 0, no
   DEC   txDivide                              ' (1)   update bit timer
   JNZ   TX_Done                               ' (2/4) time for new bit?
   MOV   txDivide, #Baud1x0                    ' (2)   yes, reload timer
   STC                                         ' (1)   set for stop bit
   RR    txHi     ' (1)   rotate TX char buf
   RR    txLo                                  ' (1)
   DEC   txCount                               ' (1)   update the bit count
   MOVB  TX, txLo.6                            ' (4)   output the bit
   JMP   TX_Done                               ' (3)
TX_Buffer:
   TEST  txBufCnt                              ' (1)   anything in buffer?
   JZ    TX_Done                               ' (2/4) exit if empty
   MOV   W, #txBuf                             ' (2)   point to buffer tail
   ADD   W, txTail                             ' (1)
   MOV   FSR, W                                ' (1)
   MOV   txHi, IND                             ' (2)   move byte to TX reg
   CLR   txLo                                  ' (1)   clear for start bit
   MOV   txCount, #10                          ' (2)   start + 8 + 1 stop
   INC   txTail                                ' (1)   update tail pointer
   CLRB  txTail.3                              ' (1)   keep 0..7
   DEC   txBufCnt                              ' (1)   update buffer count
TX_Done:
'    BANK  __DEFAULT                             ' (1)
 ENDASM
'Tachometer:
ASM
BANK timing
jb TInhib,Tacexit  ' Tinhib  prevents  loading time values from 2 diffenent periods
Mode WKPNDB
CLR W
MOV !RB,W
AND W,#%0001_0000
SNZ     'jmp if no bit
jmp TacExit
inc TacTmp_lsb 'test how often we get a hit every revolution.
SNZ
inc TacTmp_msb
mov tac0_lsb,tac1_lsb  'save previous pass
mov tac0_msb,tac1_msb
mov tac1_lsb,Tac2_lsb  'save last pass
mov tac1_msb,Tac2_msb
Mov tac2_lsb,TacTime_lsb
Mov Tac2_msb,TacTime_msb
mov TacTime_lsb,hsec  'store current time
mov TacTime_MSB,SEC
SETB tDone

TacExit:
ENDASM
'  BANK 0    'reset bank if ending ISR
ISR_Exit:
BANK 0
 RETURNINT ' {cycles}                                

The program code looks like this:

Start:
ASM
MODE WKEDB
MOV W,#%11101110
MOV !RB,W
MODE WKPNDB
CLR W
MOV !RB,W
' MODE  CMP
' MOV !rb,#CompEn
ENDASM
 PLP_A = %0000_0000
 PLP_B = %0000_0000
PLP_C = %0000_0000
TX = 1
DELAY_MS 5
Main:
LCD_CCHAR CC0
TX_Byte LCDCls
Delay_MS 250
TX_BYTE LCDBlON
TX_BYTE POS1
TX_STR pPwmWId
TX_BYTE POS3
TX_STR pTacResult

pwmwid = $15
tmpW1 = 0
BANK @ MTRARRAY
\SETB motorOn
Put @m1Speed,15
BANK __DEFAULT
DELAY_MS 2000
\clrb Tdone do while pwmwid < $100
tmpW1 = 0
do while tmpw1 = 0
   tmpW1 = TAC_RESULT
loop
TacResult = tmpW1
TX_BYTE POS2
PRINT_HEX_STR pwmwid
TX_BYTE POS4
PRINT_HEX_STR TacResult
TX_BYTE POS5
BANK @Timing
__wParam12 = TimeWord
PRINT_HEX_STR __wparam12
TX_BYTE POS7
BANK @Timing
__wparam12 = TacTmp
PRINT_HEX_STR __wparam12
TacTmp = 0
BANK __default
 tmpW2 = 5
 pwmwid = BCD_Word_ADD pwmwid,tmpW2
BANK @ MTRARRAY
m1Speed = m1speed + 5
BANK __default
Delay_MS 2000
Loop
put @ m1speed,0
TX_Byte LCDCls
Delay_MS 250
TX_BYTE LCDBlON
TX_BYTE POS1
TX_STR pPwmWId
TX_BYTE POS3
TX_STR pTacResult
DELAY_MS 250
goto main

sub print hex encapsulates the HEX_str comand and sends it a numeric sting printing command

FUNC TAC_RESULT
 
__wparam12 =0
\ SB Tdone
\ jmp txit
\ SETB TInhib  'prevent interupt during this measurement
Bank @timing
__wparam34 = Tac2
__wparam12 = TacTime
if Tac2 > TacTime Then
  __wparam12 = __wparam12 + $6000   'sec rolled over
Endif
\clrb TInhib 'interupt wont hurt now.

' __wparam12 = tacTime  - Tac2
__wparam12 = BCD_WORD_SUB __wparam12,__wparam34
' Tac0 = Tac1  'handled in isr
' Tac1 = Tac2
' Tac2 = TacTime
\clrb TDone  'wait for new info

Txit:

'Txit1:
Bank 0
tmpW1 = __wparam12
RETURN tmpW1
I put the increment of TacTmp in the ISR just to see how many times the tac was being updated between passes of the main program.  The time between pulses from the tac are between 500 and 1100 MS.  The readout I am getting on the lcd display usually reads 1. When the motor is turning its slowest I may get .11 seconds where I should get over a second.  Any Ideas why the tac is updating more often than once per revolution?

Compiled under 2.00.26 assembled using new SX IDE 3.0
ANy and all ideas are invited.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=367347
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\07\12@052323 by peterverkaikn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote:

In this section
mov w, #10                   ;was 10
 mov w, MSec-w                 ;Z if MSec = 10
 snz                          
   clr Msec
 SNZ

you use clr Msec, but CLR FR sets the Z flag, so the following SNZ does
not work.

Change it to:

mov w, #10                   ;was 10
 mov w, MSec-w                 ;Z if MSec = 10
 snz                          
   mov Msec,w    ;clear Msec
 SNZ regards peter
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=367347#m367402
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\07\13@171119 by RS_Jimn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, RS_Jim wrote:

Never figured out why WKNDB was causing TAC readigs every pass so I rewrote the ISR to use a state machine. It works now as I had expected!  Still would like to know why WKND_B would not work in this application.
RS_JIM
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=367347#m367784
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

More... (looser matching)
- Last day of these posts
- In 2009 , 2010 only
- Today
- New search...