Shop OBEX P1 Docs P2 Docs Learn Events
need help with BS2 functions — Parallax Forums

need help with BS2 functions

stargazer2050stargazer2050 Posts: 89
edited 2012-11-16 12:50 in Propeller 1
quickstart
BS2 functions
Radio Control receiver

trying to read the pulsein:
NEED to know what IO PIN to put it on?
What the word 'STATE' indicates????
ETC.

con
  ' SHIFTIN Constants
  MSBPRE   = 0
  LSBPRE   = 1
  MSBPOST  = 2
  LSBPOST  = 3
  OnClock  = 4   ' Used for I2C
  
  ' SHIFTOUT Constants
  LSBFIRST = 0
  MSBFIRST = 1
  ' SEROUT/SERIN Constants
  NInv     = 1
  Inv      = 0
  cntMin     = 400      ' Minimum waitcnt value to prevent lock-up
  DEBUG_BAUD = 9600     ' DEBUG Serial speed - maximum!
  DEBUG_MODE = 1        ' Non-Inverted
  SCL = 28
  SDA = 29
     #1, HOME, #8, BKSP, TAB, LF, CLREOL, CLRDN, CR, #16, CLS      ' PST formmatting control
OBJ
  BS2  : "BS2_Functions"    ' Create BS2 Objectterm
  term : "FullDuplexSerial"
  
VAR
  long s, ms, us,Last_Freq,Last_FreqB
  Byte DataIn[50],DEBUG_PIN,DEBUGIN_PIN  
  word  RCvar
PUB Start
    'dira[0] := 0
  s := clkfreq               ' Clock cycles for 1 s
  ms := clkfreq / 1_000        ' Clock cycles for 1 ms
  us := clkfreq / 1_000_000    ' Clock cycles for 1 us 
  Last_Freq := 0              ' Holds last setting for FREQOUT_SET
    
    BS2.start (31,30)        ' Initialize BS2 Object timing, Rx and Tx pins for DEBUG
    repeat
     RCvar := BS2.PULSIN(0,state???)   'MyVariable := BS2.PULSIN(pin,state)
     term.dec(HOME)
     term.tx(CLS)      
     term.str(string("RCvar"))
     term.tx(CR)  
     term.dec(RCvar)
     WaitCnt(ClkFreq / 2 + Cnt)

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-11-15 15:38
    trying to read the pulsein:
    NEED to know what IO PIN to put it on?
    What the word 'STATE' indicates????
    Can't help you with the pin, you should know where you connected the external circuitry. As for state, that's simply whether you want to measure a high(1) or a low(0) pulse. If you look at the code, the former sets up a LOGIC A counter (enabled when pinA == 1) the latter LOGIC !A (enabled when pinA == 0).
  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-15 16:15
    To clarify ... The Propeller's I/O pins are all identical in functionality. I/O pins 28 & 29 are used for the boot EEPROM and that somewhat limits what you can connect to them. I/O pins 30 & 31 are used for the (optional) serial connection to a PC for downloading programs and debugging, but all of these special use I/O pins are not used after the user program starts and could be used for other functions although it's easier to just leave them for their special functions. For example, if you want to add other I2C devices, you can use I/O pins 28 & 29 for that, things like an analog to digital converter or other EEPROMs.
  • stargazer2050stargazer2050 Posts: 89
    edited 2012-11-16 04:53
    Hi,
    Tnx kuroneko, ok understand state better, ill use a one i guess
    On where to put pin, i meant where to address it in this bs2 function library, i have it on pin zero.

    Hi mike, congrats on 20k responses!
    To explain, since i drive you nuts so much lately, im a retired wedding photographer with some programming background in excel application basic. I have almost every parallax sensor running after starting my new hobby 8 months ago

    Since im limited in this knowledge, im looking for a semi turn key method for getting the radio control variables to show up using fullduplexserial.

    Im struggling with this way, radioloop.spin and pvh_autopilot, which outputs to a tv which doesnt fit in with me monitoring everything with full duplex.

    Hope it all makes more sense now.

    Tnx, eddie

    .
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-11-16 07:48
    Since im limited in this knowledge, im looking for a semi turn key method for getting the radio control variables to show up using fullduplexserial.
    Eddie,

    How many RC channels do you want to monitor?

    The pulsein method is pretty slow if you're trying to capture a bunch of channels.

    I'm sure I have some code that does what you want with up to six channels. I'll try to find it.
  • stargazer2050stargazer2050 Posts: 89
    edited 2012-11-16 09:20
    Hi duane,

    6 channels
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-11-16 12:50
    Hi duane,

    6 channels

    I posted my modified (and now tested) object here.

    I'm not the author of most of it (and not of the hard parts). I just made the object usable with any of the Prop's I/O pins.
Sign In or Register to comment.