Shop OBEX P1 Docs P2 Docs Learn Events
Help with MSR1 and Position Controller — Parallax Forums

Help with MSR1 and Position Controller

daveedavee Posts: 35
edited 2010-08-13 13:42 in Propeller 1
I have the motor kit with Position Controller, 2 HB25s and an MSR1 board.

If I make the MSR1 board talk directly to the HB25s, things pretty much work as expected (you can almost drive straight except for the inherent issues that PWM present)

When I try to use the position encoders, I get random oscillations on one or both motors

I am using the MoMoCtrl.spin code from Steve Norris as he used in his roboStool project
and a very simple test program, nut as far as I can tell, The encoders are oblivious to the commands being sent it them. They don't respond at all now. I'm wondering if there is something I'm doing wrong or if I just got a couple of bad encoders.

Do the HB24s blink when they talk?


Wiring:

Pin 7 is three wire cable to right encoder. left encoder is daisy chained off the right
Both motors have yellow going to M1 on HB25
Both motors have Blue going to M2 on HB25
Data cable on right encoder connected to right HB25
Data cable on left encoder connected to left HB25
right encoder ID set to 1 (both jumper installed)
left encoder ID set to 2 (right jumper remove)
all cables between MSR1, both encoders, and the HB25 are three conductor female/female cables.
MSR1 is configured as it came from the factory

Anyone got any clues?




========================== Test program follows
CON
'
' Constants
'

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

' Pins
Pin_Drive = 7

' Move Directions
Mov_Halt = 0
Mov_Fwd = 1
Mov_Rev = 2
Mov_SpinCW = 3
Mov_SpinCCW = 4

' Function return codes
Ret_None = 0
Ret_Complete = 1
Ret_Canceled = 2

VAR
'
' Variables
'

long m_CurrentSpeed
long m_CurrentDir

long m_Rolling

OBJ
Drive : "MoMoCtrl"

PUB Init
' Initialize drive/position system (uses 1 cog)
Drive.Start(Pin_Drive)
'Drive.emergencyhalt
Drive.SetSpeed(Drive#AllWheels, 12)
Drive.GoDistance(0, 1000)




DAT

===================================================



{{ MoMoCtrl.spin }}

' ==============================================================================
'
' File...... MoMoCtrl.spin
' Purpose... Support functions for the Parallax Motor Mount & Wheel Kit
' Author.... (C) 2008 Steven R. Norris - See end of file for terms of use
' E-mail.... steve@norrislabs.com
' Started... 07/02/2008
' Updated...
'
' ==============================================================================

'
' Program Description
'
{{
This is a collection of support functions for the Parallax Motor Mount
and Wheel Kit/Position Controller using HB-25 motor controllers.
Start must be called first with the pin number of the serial line.
}}


'
' Revision History
'
{{
0827a - This is the first version
}}


CON
'
' Constants
'

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

' Drive/Position controller commands
QPOS = $08 'Query Position
QSPD = $10 'Query Speed
CHFA = $18 'Check for Arrival
TRVL = $20 'Travel Number of Positions
CLRP = $28 'Clear Position
SREV = $30 'Set Orientation as Reversed
STXD = $38 'Set TX Delay
SMAX = $40 'Set Speed Maximum
SSRR = $48 'Set Speed Ramp Rate

' Wheels
AllWheels = 0
RightWheel = 1 'ID of the right side Position Controller
LeftWheel = 2 'ID of the left side Position Controller



VAR
'
' Variables
'

long m_Init


OBJ

DriveCom : "FullDuplexSerial"


PUB Start(PinDrive)

DriveCom.Start(PinDrive, PinDrive, 4, 19200)
Pause_ms(250)
ResetDrive

' Reverse the sensor on the right
DriveCom.tx(SREV + RightWheel)

m_Init := true


PUB Stop

DriveCom.Stop


PUB GoDistance(Wheel, Distance)

if m_Init
DriveCom.tx(TRVL + Wheel)
DriveCom.tx(Distance.byte[1])
DriveCom.tx(Distance.byte[0])


PUB SetSpeed(Wheel, Speed)

if m_Init
DriveCom.tx(SMAX + Wheel)
DriveCom.tx(Speed.byte[1])
DriveCom.tx(Speed.byte[0])


PUB SpinCW(Degrees) | dist

dist := Degrees / 6
SetSpeed(AllWheels, 5)
GoDistance(LeftWheel, dist)
GoDistance(RightWheel, -dist)


PUB SpinCCW(Degrees) | dist

dist := Degrees / 6
SetSpeed(AllWheels, 5)
GoDistance(RightWheel, dist)
GoDistance(LeftWheel, -dist)


PUB Halt

GoDistance(AllWheels, 0)
Pause_ms(500)
' WaitArrived(RightWheel)


PUB EmergencyHalt

if m_Init
DriveCom.tx(CLRP + RightWheel)
DriveCom.tx(CLRP + LeftWheel)


PUB WaitArrived(Wheel)

repeat while HasArrived(Wheel, 1) == false
Pause_ms(10)


PUB HasArrived(Wheel, Tolerance) : yesno | data

if m_Init
DriveCom.rxflush

DriveCom.tx(CHFA + Wheel)
DriveCom.tx(Tolerance)

' Receive what was just sent
' TX and RX are the same pin
DriveCom.rx
DriveCom.rx

if DriveCom.rx == $FF
yesno := true
else
yesno := false
else
yesno := true


PUB ResetDrive

if m_Init
repeat 3
DriveCom.tx(CLRP + RightWheel)
DriveCom.tx(CLRP + LeftWheel)
Pause_ms(100)


PRI Pause_ms(msDelay)
waitcnt(cnt + ((clkfreq / 1000) * msDelay))


DAT
{<end of object code>}

{{
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ TERMS OF USE: MIT License │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │
│files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │
│modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│
│is furnished to do so, subject to the following conditions: │
│ │
│The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│
│ │
│THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │
│WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │
│COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │
│ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
}}
Sign In or Register to comment.