Shop OBEX P1 Docs P2 Docs Learn Events
Motor Mind B Enchanced Help — Parallax Forums

Motor Mind B Enchanced Help

CarnibusCarnibus Posts: 4
edited 2008-08-15 17:20 in Propeller 1
I've been having some trouble getting the MMBe to work with the propeller. As far as I know everything is hooked up right. I even tried hooking it up to my BS2, which worked. I'm not using any resistors or anything, should I be?

There was no MMBe object in the object exchange so I tried using the FullDuplexSerial object to replicate the BS2 example as follows:

'Output 15
'Input 14
CON
TM = 14
FM = 15
OBJ
FDS : "FullDuplexSerial"
PUB Main
FDS.start(TM, FM, 3, 2400)
FDS.tx($55) 'Sync
FDS.tx($03) 'SETDC
FDS.tx($DD) 'SETDC value

I contacted tech support and they told me to start with a mode value of 3.

Any help would be appreciated, I am completely stumped.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-13 23:09
    One of the things you have to be careful about with FDS in test programs is that it's buffered. Your program may need to wait for the data to be transmitted before quitting (or running off the end of the main program). A simple wait (WAITCNT) of 1/10 of a second should work at 2400 Baud.

    I think the proper mode value is zero, not 3. Try it. If you're expecting replies from the MMB, you'll need a pullup resistor on the TM lead. Best to use a 1K to 3.3K resistor between the Propeller pin and +3.3V. I wouldn't use the 1K pullup to +5V as recommended in the MMB documentation. It'll work, but it's better to tie it to +3.3V or use a higher value in tying it to +5V.

    Post Edited (Mike Green) : 8/13/2008 11:22:07 PM GMT
  • CarnibusCarnibus Posts: 4
    edited 2008-08-14 00:35
    Would waitcnt really be an issue if that was my whole program?
    Also, I'm using the commands without a reply (actually, TM is disconnected right now too)

    When I used the MMBe with my bs2 I saw the green led light up immediately, with the propeller I never see it light up no matter how long I wait.
  • AleksAleks Posts: 52
    edited 2008-08-15 17:20
    I actually use that exact motor controller with the Propeller in my workplace for a product we sell, and the key factor we always look for when starting it up is to make sure that that light does come on. Here's the library I've been using, i lazily called it MMBE.spin, and it works fine at 40 MHz clock speed. (10 MHz external oscillator, 4x PLL). It isn't well commented, but I'm more than willing to help explain what i can.

    CON
    
      sync = $55
      stop = $00
      reverse = $01
      setdc = $03
      thestatus = $05
      count = $06
      readcounter = $0B
      readfirm = $0E
    
    
    
    
    VAR
    
      long  sin, sout, inverted, bitTime, started, rxOkay, txOkay, status, speed   
    
    
    
    
    OBJ
    
      serial : "simple_serial"                              ' bit-bang serial driver
    
      
    PUB start(txPin, rxPin, baud)
    
      
      if lookdown(rxPin : 0..31)                            ' qualify rx pin
        sin := rxPin                                        ' save it
        rxOkay := started := true                           ' set flags
    
      if lookdown(txPin : 0..31)                            ' qualify tx pin
        sout := txPin                                       ' save it   
        txOkay := started := true                           ' set flags 
    
      if started
        serial.start(sin, sout, baud)
      return started
    
    PUB set(power)               'to set the DC value to the motor (range 0 - 255)
    
      if started
          serial.tx(sync)
          serial.tx(setdc)
          serial.tx(power)
          return true
      else
        return false
    
    PUB motorstop                'to stop the motor
      if started
        serial.tx(sync)
        serial.tx(stop)
        return true
      else
        return false
    
    PUB motorrev                'to reverse the motor direction
      if started
        serial.tx(sync)
        serial.tx(reverse)
        return true
      else
        return false
    
    PUB getstatus                  'to retrieve the status byte
      if started
        serial.tx(sync)
        serial.tx(thestatus)
        return serial.rx
      else
        return 0
    
    PUB getspeed                   'to extract the speed byte
      if started
        serial.tx(sync)
        serial.tx(thestatus)
        status := serial.rx
        return serial.rx
      else
        return 0
           
    PUB ismoving                     'to check the movement status of the motor
      if started
        serial.tx(sync)
        serial.tx(thestatus)
        status := serial.rx
        if speed := serial.rx
          return true
        else
          return false
      else
        return false
    
    



    Now I've never had any issues at all with this, but i can't guarantee due to the fact that I haven't really tested every circumstance (ie other PLL modes, or input frequencies). Let me know how things work for you. Hopefully it'll be of some help

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ~Some men see things as they are and ask "why?"
    I dream of things that never were and ask "why not?"~
Sign In or Register to comment.