Continuing My Project

I was looking at the control_diy and noticed this piece of code:

RCCh0 con P0 ;RC Remote Left Stick Up/Down (THRO) RCCh1 con P1 ;RC Remote Right Stick Up/Down (AILE) RCCh2 con P2 ;RC Remote Right Stick Left/Right (ELEV) RCCh3 con P3 ;RC Remote Left Stick Left/Right (RUDD) RCCh4 con P4 ;RC Remote Left Slider (GEAR) RCCh5 con P5 ;RC Remote Right Slider (AUX1) RCCh6 con P6 ;RC Remote Buttons (AUX2)

i’m still not sure what are those pins used for, they are only used here :

[code]InitController:
; Make sure all 7 pins are marked for input…
input RCCh0
input RCCh1
input RCCh2
input RCCh3
input RCCh4
input RCCh5
input RCCh6

fNoTransmitter = 0 ; assume we have a transmitter.
fLostTransmitter = 0

ControlMode = WalkMode
return[/code]

other than that there isn’t anything about them.

Edit: I just finished running through the code … i’m stumped :neutral_face: , i couldn’t find whats going on wrong . it’d be helpful if someone could try this code and send a feedback.

Sorry, as I mentioned, for the most part I am not doing much with Baps…

But from what you posted, it looks more like it is from a 7 channel RC receiver version of the software. Actually it is probably from DIY remote control code we did before some of us converted our remote controls to use XBees instead of the RC transmitter. Mine has not worked with RC for several years now. That version of the code measured the pulse widths. Not sure without looking more if it used simple pulsein like commands, or if it used by assembly langage code. Since you mentioned, they were only referenced in the input statements, I am almost sure assembly language, where I directly manipulate the registers or the like.

As I mentioned in previous post, you are probably better off using a more recent version of the code base. Also need to use different version of the input code as I am quite sure you are not setup with one of these RC receivers… Could be wrong :slight_smile:

you are right, the code segment where the input pulses are received is coded in assembly :

[code];[Pulsein7] Read in all 7 servo values in one pass.
Pulsein7:
; Make sure all 7 IOs are set to input.
PMR5 = 0 ; all IO lines are general IO
PCR5 = 0 ; All are input (may want to leave bit 7 alone…

; Ok now lets transisiton to assembly language. 
; 

; bMask = 0x7f ; set a mask of which bits we are needing…
; ; Mask could be 0xFE for pins 1-7, need to make array 8 not 7
mov.b #0x7f, r1l ; Ok R1l will be our mask for outstanding IO port bytes.

; wait until none of the IO lines are high... 

; while PDR5 & bMask
; ;
; wend
mov.l #250000,er2 ;(4) - setup timeout counter
_PI7_WAIT_FOR_ALL_LOW:
mov.b @PDR5:8, r0l
and.b r1l, r0l ; see if any of the IO bits is still on…
beq _PI7_WAIT_FOR_NEXT_IO_TO_GO_HIGH:8 ; all zero go to wait for one to go high…
dec.l #1,er2 ;(2)
bne _PI7_WAIT_FOR_ALL_LOW:8 ; an IO pin is high and we have not timed out, keep looping until none are high
; We timed out waiting for all inputs to be low, so error out…
bra _P17_RETURN_STATUS:16 ; will return status that all timed out…

; while bMask

_PI7_WAIT_FOR_NEXT_IO_TO_GO_HIGH:
mov.l #250000,er2 ;(4) - setup timeout counter

_PI7_WAIT_FOR_NEXT_IO_TO_GO_HIGH2:
; we still need some 1 or more of the pulses…
; while (PDR5 & bMask) = 0 ; waiting for a pulse to go high.
mov.b @PDR5:8, r0l ;(4)
and.b r1l, r0l ;(*2) see if any of the IO bits is still on…
bne _P17_IO_WENT_HIGH:8 ;(*4) One went high so go process
dec.l #1,er2 ;(2)
bne _PI7_WAIT_FOR_NEXT_IO_TO_GO_HIGH2:8 ; (4) Not a timeout go try again.
; we timed out…
bra _P17_RETURN_STATUS:16 ; will return status of what timed out…

; wend
; iPin = ???; TBD: convert which bit is high to IO line number 0-6
; see which bit is on in the mask
ASM {
_P17_IO_WENT_HIGH:
xor.w r2,r2 ;(*2)
xor.b r0h, r0h ;(*2)
mov.l #AWPULSESIN,er3 ;(*6)
_P17_WHICH_BIT_LOOP:
shlr.b r0l ;(@2)
bcs _P17_WHICH_BIT_LOOP_DONE:8 ;(@4)
inc.b r0h ;(@2)
inc.l #2, er3 ;(@2) - point to the next place in the array.
add.w #18,r2 ;(@4) - we do 18 clocks for each pass through this loop
bra _P17_WHICH_BIT_LOOP:8 ;(@4)
_P17_WHICH_BIT_LOOP_DONE:
; bMaskBit = 1 << iPin ; get the mask for which pin…
xor.b r1h,r1h ;(*2)
bset.b r0h,r1h ;(*2) ok we have the mask
bclr.b r0h,r1l ;(*2) and clear it from our global mask of ones we are waiting for
}
; = (22) - count so far of clocks after went high

; iPinLoopCnt = 0 ; This may be replaced with time calculations…
; while (PDR5 & bMaskBit)
; iPinLoopCnt = iPinLoopCnt + 1 ; how long until it goes low again
; wend
_P17_WAIT_FOR_IO_GO_BACK_LOW:
mov.b @PDR5:8, r0l ;(#4)
and.b r1h, r0l ;(#2)
beq _P17_IO_WENT_BACK_LOW:8 ;(#4)
add.w #18,r2 ;(#4) - number of cyles per loop
bcc _P17_WAIT_FOR_IO_GO_BACK_LOW:8 ;(#4)

; we had a timeout return the status.
bset.b r0h, r1l ; turn back on the bit we were waiting for…
bra _P17_RETURN_STATUS:8 ;

_P17_IO_WENT_BACK_LOW:
; need to calculate the pulse width in ms… need to divide calculated clocks by 16
add.w #22,r2 ; (4) ; need to add the rest of the overhead(*-1 loop above) in…
shlr.w r2 ; (2)
shlr.w r2 ; (2)
shlr.w r2 ; (2)
shlr.w r2 ; (2) / 16 (for clock speed)

; aPulses(iPin) = iPinLoopCnt ; convert loop count to pulse width…
mov.w r2,@er3 ; Save away the value

; bMask = bMask & ~bMaskBit ; turn off waiting for this one…
or r1l,r1l ; (2) see if we are done or not
; wend
bne _PI7_WAIT_FOR_NEXT_IO_TO_GO_HIGH:16 ;(6)our mask has not gone to zero so wait for the next one.

_P17_RETURN_STATUS:
mov.b r1l,@BPULSETIMEOUT
; finally transisition back to basic and return.
return
;--------------------------------------------------------------------[/code]

I couldn’t understand one bit of that code, i only know c and basic x). I’ll see if i can get my hands on a ps2 version of the code, thanks for your input . stay tuned for more updates :smiley:

I just found pheonix_control_ps2.bas file in the projext folder, i loaded it instead of the diy file and the problem was solved :slight_smile:. Unfortunately i have to go now so i’ll have to test the code later, Thank you all for your inputs :smiley: