{{ RemoteNomad.spin }} ' ============================================================================== ' ' File...... RemoteNomad.spin ' Purpose... Remote control application for the Nomad ' Author.... (C) 2006 Steven R. Norris -- All Rights Reserved ' E-mail.... norris56@comcast.net ' Started... 11/27/2006 ' Updated... 11/28/2006 ' ' ============================================================================== ' ------------------------------------------------------------------------------ ' Program Description ' ------------------------------------------------------------------------------ {{ This is a simple remote control application for the Nomad. It uses the GaitNomad object for leg sequencing. It uses a Parallax RF Receiver to receive characters from a remote keyboard. The protocol is simple. The keyboard sends a "!" and then the character pressed. The RF Receiver connects to the Propeller through a 10K resistor to the pin designated by the constant Pin_LinkRx. This applications uses a total of 4 Cogs. One for this code, one for the GaitNomad, one for the serial comm to the Parallax Servo Controller, and one for the serial comm to the RF Receiver. }} ' ------------------------------------------------------------------------------ ' Revision History ' ------------------------------------------------------------------------------ {{ 0648a - This is the first version }} CON ' ------------------------------------------------------------------------------ ' Constants ' ------------------------------------------------------------------------------ _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 Pin_LinkRx = 23 GaitStop = -1 GaitWalk = 0 GaitCW = 1 GaitCCW = 2 VAR ' ------------------------------------------------------------------------------ ' Variables ' ------------------------------------------------------------------------------ byte m_Gait byte m_Speed byte m_Direction OBJ Gait : "GaitNomad" ' This is the Nomad Gait object Link : "FullDuplexSerial" ' Serial communications from the RF receiver PUB Main | char, valid ' ------------------------------------------------------------------------------ ' Main ' ------------------------------------------------------------------------------ ' Start the Gait object in its own Cog Gait.Start(22) ' Start the serial communications for the RF receiver Link.Start(Pin_LinkRx, -1, 1, 9600) ' Wait a bit Pause_ms(1000) ' Home the legs Gait.Home(1) ' Defaults m_Gait := GaitStop m_Speed := 1 m_Direction := 0 repeat valid := FALSE char := Link.rx if char == "!" char := Link.rxtime(10) case char "1": m_Gait := GaitWalk m_Direction := 5 valid := TRUE "2": m_Gait := GaitWalk m_Direction := 0 valid := TRUE "3": m_Gait := GaitWalk m_Direction := 1 valid := TRUE "4": m_Gait := GaitWalk m_Direction := 4 valid := TRUE "5": m_Gait := GaitWalk m_Direction := 3 valid := TRUE "6": m_Gait := GaitWalk m_Direction := 2 valid := TRUE "7": m_Gait := GaitCCW m_Direction := 0 valid := TRUE "9": m_Gait := GaitCW m_Direction := 0 valid := TRUE "A": m_Speed := 0 valid := TRUE "B": m_Speed := 1 valid := TRUE "C": m_Speed := 2 valid := TRUE "D": m_Speed := 3 valid := TRUE "*": m_Gait := GaitStop Gait.Halt "#": m_Gait := GaitStop Gait.Home(2) if valid Gait.SetGait(m_Gait, m_Direction, m_Speed, -1) PRI Pause_ms(msDelay) waitcnt(cnt + ((clkfreq / 1000) * msDelay))