Shop OBEX P1 Docs P2 Docs Learn Events
Just want to make sure this code doesn't fry my board before i try it — Parallax Forums

Just want to make sure this code doesn't fry my board before i try it

noobmunchernoobmuncher Posts: 124
edited 2009-12-26 20:05 in Propeller 1
I just pulled apart a Christmas present of pass which is an old "RAD Robot" I have. I am using a SN754410 Quad Half H-Bridge IC www.sparkfun.com/commerce/product_info.php?products_id=315 to power the opening and closing of the arms and the leaning forward and backwards of the torso. So I have it wired up to my propeller education kit via the pin layout described here www.hobbyengineering.com/appHBridge1A.html however I am really afraid of frying it with the code I have. I have hooked this up on the BS2 before and it worked fine, but with that I just told two of the 4 signal pins to send HIGH commands and the others to have LOW and then just changed it. With the propeller I am a bit confused by the dira and the outa commands. I just need pins 27 and 25 to receive HIGH while 24 and 26 LOW and conversely.

If some one can help with this very simple problem that would be great, I am just afraid of having something get fried ha ha.

Thanks!

Comments

  • Clock LoopClock Loop Posts: 2,069
    edited 2009-12-26 06:11
    The chip you mention has recommended operating conditions of at least 4.5v.
  • noobmunchernoobmuncher Posts: 124
    edited 2009-12-26 06:28
    I thought the datasheet said that it's minimum HIGH was 2.5 or am I totally mistaken? Can this be remedied?
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-12-26 06:47
    Hello noobmuncher,

    as you didn't attached your code I can only say a little

    DIRA is to set the DIRection of an IO-Pin

      DIRA[noparse][[/noparse] 0 ] := 0 'set IO-PIN Number 0 as input
      DIRA[noparse][[/noparse] 0 ] := 1 'set IO-PIN Number 0 as output
    
      DIRA[noparse][[/noparse] 27 ] := 0 'set IO-PIN Number 27 as input
      DIRA[noparse][[/noparse] 27 ] := 1 'set IO-PIN Number 27 as output
    
    



    OUTA is for setting the IO-pins voltage

      OUTA[noparse][[/noparse] 27 ] := 0 'set voltage on IO-Pin number 27 to 0.0V 
      OUTA[noparse][[/noparse] 27 ] := 1 'set voltage on IO-Pin number 27 to 3.3V 
    
    



    I enjoyed porting the BS2-example-code to SPIN

    {BS2-Code:
    MotorID VAR Byte        ' Current Motor ID
    }
    'ported to SPIN
    'see lines with PUB MotorBrake(MotorID), PUB MotorReverse(MotorID) etc. 
    
    CON
    {BS2-code:
    Motor1  CON 1           ' Motor 1 control on stamp pins 1, 3 and 5
                            ' SN754410 pins 1 (1,2EN), 2 (1A) and 7 (2A)
    Motor2  CON 2           ' Motor 2 control on stamp pins 2, 4 and 6
                            ' SN754410 pins 9 (3,4EN), 10 (3A) and 15 (4A)
    }
    'ported to SPIN:
    CON
      Motor1 = 1
      Motor2 = 2
    
      LOW    = 0
      HIGH   = 1
    
    {BS2_code:  
    Loop:
      DEBUG CR, "s"
      MotorID = Motor1
      GOSUB MotorBrake
      MotorID = Motor2
      GOSUB MotorBrake
      PAUSE 1000
    
    ....
      DEBUG "R"
      MotorID = Motor1
      GOSUB MotorReverse
      MotorID = Motor2
      GOSUB MotorReverse
      PAUSE 1000
    
      GOTO Loop
    }
    'ported to SPIN
    
    PUB Main
      DIRA[noparse][[/noparse] Motor1 + 0 ] := 1 'setup IO-Pins as outputs
      DIRA[noparse][[/noparse] Motor1 + 2 ] := 1
      DIRA[noparse][[/noparse] Motor1 + 4 ] := 1
      
      DIRA[noparse][[/noparse] Motor2 + 0 ] := 1
      DIRA[noparse][[/noparse] Motor2 + 2 ] := 1
      DIRA[noparse][[/noparse] Motor2 + 4 ] := 1
      
      repeat
        MotorBrake(Motor1)
        MotorBrake(Motor2)
        WaitCnt(ClkFreq + cnt) 'wait for one second
        
        MotorCoast(Motor1)
        MotorCoast(Motor2)
        WaitCnt(ClkFreq + cnt) 'wait for one second
        
        MotorForward(Motor1)
        MotorForward(Motor2)
        WaitCnt(ClkFreq + cnt) 'wait for one second
        
        MotorReverse(Motor1)
        MotorReverse(Motor2)
        WaitCnt(ClkFreq + cnt) 'wait for one second
        'the INDENTION defines what belongs to the repeat-loop
        'no "end of loop statement required even NOT defined in SPIN
    
    
    {BS2-Code:    
    MotorCoast:
      LOW  MotorID
      HIGH MotorID + 2
      HIGH MotorID + 4
      RETURN
    }
    'ported to SPIN
    PUB MotorCoast(MotorID)
      OUTA[noparse][[/noparse] MotorID + 0 ] := LOW   
      OUTA[noparse][[/noparse] MotorID + 2 ] := HIGH   
      OUTA[noparse][[/noparse] MotorID + 4 ] := HIGH   
    
    
    
    
    {BS2-Code:    
    MotorBrake:
      HIGH MotorID
      LOW  MotorID + 2
      LOW  MotorID + 4
      RETURN
    }
    'ported to SPIN
    PUB MotorBrake(MotorID)
      OUTA[noparse][[/noparse] MotorID + 0 ] := HIGH   
      OUTA[noparse][[/noparse] MotorID + 2 ] := LOW   
      OUTA[noparse][[/noparse] MotorID + 4 ] := LOW   
    
    
    
    
    {BS2-Code:    
    MotorForward:
      HIGH MotorID
      HIGH MotorID + 2
      LOW  MotorID + 4
      RETURN
    }
    'ported to SPIN
    PUB MotorForward(MotorID)
      OUTA[noparse][[/noparse] MotorID + 0 ] := HIGH   
      OUTA[noparse][[/noparse] MotorID + 2 ] := HIGH   
      OUTA[noparse][[/noparse] MotorID + 4 ] := LOW   
    
    
    
    
    {BS2-Code:    
    MotorReverse:
      HIGH MotorID
      LOW  MotorID + 2
      HIGH MotorID + 4
      RETURN  
    }
    'ported to SPIN
    PUB MotorReverse(MotorID) 
      OUTA[noparse][[/noparse] MotorID + 0 ] := HIGH   
      OUTA[noparse][[/noparse] MotorID + 2 ] := LOW   
      OUTA[noparse][[/noparse] MotorID + 4 ] := HIGH   
    
    



    best regards

    Stefan
  • noobmunchernoobmuncher Posts: 124
    edited 2009-12-26 06:49
    Now I am not usre if my wiring is correct, I will list it below and if someone can take a look at it and at the hobby engineering link www.hobbyengineering.com/appHBridge1A.html and let me know what i am doing wrong i would appreciate it.
    Pin (of the SN754410) :
    1: Vdd
    2:P27
    3: Motor 1 A
    4: Vss
    5: Vss
    6: Motor 1 B
    7: P26
    8: Negative terminal on the battery
    9: Vdd
    10: P25
    11:Motor 2 A
    12: Vss
    13: Vss
    14:Motor 2 B
    15: P24
    16:Positive terminal on the battery

    and the code (among many, that i have now tested) is

    PUB LedsOn
    repeat
    dira[noparse][[/noparse]24..27] := %1111
    outa[noparse][[/noparse]24..27] := %0101
    waitcnt(clkfreq + cnt)
    outa[noparse][[/noparse]24..27] := %1010
    waitcnt(clkfreq + cnt)

    Thank you so much, Happy Holidays!
  • noobmunchernoobmuncher Posts: 124
    edited 2009-12-26 06:57
    Wow thanks alot stefan! I will give it a try, I think the problem was I didn't have the EN set to anything, it was just going to Vdd. Where in your code can I change the variables to use the pins 27-24 and 20 and 19 though? I see this here:
    Stefan said...
    Motor1 CON 1 ' Motor 1 control on stamp pins 1, 3 and 5
    ' SN754410 pins 1 (1,2EN), 2 (1A) and 7 (2A)
    Motor2 CON 2 ' Motor 2 control on stamp pins 2, 4 and 6
    ' SN754410 pins 9 (3,4EN), 10 (3A) and 15 (4A)
    but I am sorry I am not sure where this is defined in the program.

    Thanks again
  • noobmunchernoobmuncher Posts: 124
    edited 2009-12-26 07:01
    Never mind I think I figured it out now, slick programing by the way. smile.gif
  • noobmunchernoobmuncher Posts: 124
    edited 2009-12-26 07:13
    So i rewired it to work with your code, however the program didn't seem to do anything. Any idea whats wrong?
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-12-26 12:03
    Hi,

    Clock Loop mentioned that the SN754410-chip needs a SUPPLY-voltage of minimum 4.5V
    so supplying it with 3.3V is too low

    The IO-Pins start with zero not with 1

    To do more analysing you have to provide a schematic of how you wired EVERYTHING
    This means connections from Prop to SN754410 and SN754410 with the motor
    With ALL pins numbered and named.

    best regards

    Stefan
  • noobmunchernoobmuncher Posts: 124
    edited 2009-12-26 20:05
    Okay thank you, will do as soon as I get a chance.
Sign In or Register to comment.