Shop OBEX P1 Docs P2 Docs Learn Events
DMX Control of Stepper — Parallax Forums

DMX Control of Stepper

DynamoBenDynamoBen Posts: 366
edited 2008-10-13 03:21 in General Discussion
I'm trying to build a new Halloween prop. The goal is to have DMX control of 1 bipolar stepper, 1 phase-angle dimmer, and one servo from one SX.
·
I'm using the DMX code from this thread:
http://forums.parallax.com/showthread.php?p=724440
·
…and stepper code from this thread:
http://forums.parallax.com/showthread.php?p=607883
·
While each work well individually when I merge them together neither works, thoughts?·

Comments

  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-09-18 06:28
    You may not have enough bandwidth in the ISR for the stepper control -- consider adding it as a state in the foreground part of the program.
  • DynamoBenDynamoBen Posts: 366
    edited 2008-09-18 15:44
    I will give that a try. I guess the bigger questions is am I asking too much of the SX (stepper, servo, dimmer, and DMX)? I know I could pull this off with a prop but I wanted to keep the cost per prop down.
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-09-18 17:55
    I think it can be done with the SX, it's just a matter of careful coding. Forum member PJV has shown that the SX is capable of amazing things for those that want to learn to code it.

    Post Edited (JonnyMac) : 9/18/2008 6:01:18 PM GMT
  • DynamoBenDynamoBen Posts: 366
    edited 2008-10-10 04:12
    I have had some level of success but I've run into all kinds of odd issues. On a few occasions I've gotten my code to work perfectly, two seconds later I reprogram the SX and now the code appears to "dead end." I move the stepper code into a sub and it starts to work again, disconnect power, return later and the code appears to be non-functional again. Everything looks correct in the code, so I'm at a loss for the source of my issues.

    If I didn't know any better I would think this was a hardware issue not code. The last time I saw something similar during a project I added a 10uF cap to the 5V rail and things began to work properly.

    Any thoughts or similar expirences? (I'm using the SX development board /w breadboard)
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-10-10 06:44
    Why don't you post a schematic and your code -- that would make analysis from this end easier.
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2008-10-10 08:52
    The problems you describe may also be caused by some non-initialized registers where the code expects certain values. Thus it can depend on the random contents in sich registers on power-up if your code works or not.

    Nevertheless - as JonnyMac suggested - the code and the schematic would make it less guessy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • DynamoBenDynamoBen Posts: 366
    edited 2008-10-10 14:54
    I will post a schematic·tonight, for now here is the code.

    Thanks for the help so far.

    Post Edited (DynamoBen) : 10/10/2008 3:02:52 PM GMT
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-10-10 16:16
    Can you describe what you want the program to do? I can see that you're using some of my DMX code, but you're also using dimmer code in it that doesn't seem to need to be there. If this project is just for controlling a stepper, tell me how you want it to behave and I'll give it a crack. I happen to need to do some stepper coding, anyway, and this might be fun.
  • DynamoBenDynamoBen Posts: 366
    edited 2008-10-10 16:27
    I guess some context would help...

    This code is going to controll a halloween prop. The stepper is designed to raise/lower the prop and the phase angle dimmer will illuminate it. There is a section of the code that has not been added which controls two servos·for pan and tilt on the prop.

    So the dimmer, stepper, and servor·code will co-exist and they will all control one prop via DMX.

    Make sense?
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-10-10 17:25
    It does now. I think you may end up with some trouble with servo stuff. I have cleaned up your program and have the lamp dimmer and stepper code in place -- with enhancements that should make it more efficient (removed the // operator -- this generates a lot of code). I once wrote some DMX stepper code but never tested it. I will find that and add it in to see if it works (you'll have to do the test.)
  • DynamoBenDynamoBen Posts: 366
    edited 2008-10-10 17:33
    Thanks for your help, I'm still learning the SX but like it so far. The servo code is a "nice to have" as long as the other two work well.
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-10-10 19:06
    Give this version a try. Everything compiles fine but I don't have the hardware to test it on. Since servos don't like being ignored I added a "no DMX" timer that will refresh them to default values if the DMX signal is lost (this also stops the stepper). You'll notice that I added code that allows you to define a range for the stepper (using channel #2) for forward, stop, and reverse -- this is easy to update.

    Let me know if this works; if it does I will blow out the servo stuff to eight channels for a DMX servo controller.

    Post Edited (JonnyMac) : 10/10/2008 8:23:30 PM GMT
  • DynamoBenDynamoBen Posts: 366
    edited 2008-10-10 23:53
    The code appears to work as you designed it. However in my application I need the stepper to be positioned by the DMX value not spin freely in a given direction. I updated the code and am seeing another issue. If I slowly increase the DMX value from 0 to 255 the stepper travels the full 255 steps. If however I quickly move from 0 to 255 the motor only moves ~170 steps and·appears to be moving·slower.
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-10-11 00:50
    Hmmm.... I wonder if you're having some kind of wrap-around/wrap-under issue with the stpPos variable. Ideally, you'd like a "home" input for the stepper position; it seems like now you're starting with it being at position zero for start-up and going from there. Maybe you need to protect the Step_Forward and Step_Reverse subroutines when the stpPos value would cause roll-over or roll-under:

    SUB Step_Forward
      IF stpPos < 255 THEN
        INC stpPos
        INC stpIdx
        stpidx = stpIdx & %11                       ' keep 0..3
        READ Coils + stpIdx, __PARAM1
        RC = RC & %1111_0000                        ' clear old coil
        RC = RC | __PARAM1                          ' output new coild
      ENDIF
      ENDSUB
    
    '--------------------------------------------------------------------------
    
    SUB Step_Reverse
      IF stpPos > 0 THEN
        DEC stpPos
        DEC stpIdx
        stpidx = stpIdx & %11
        READ Coils + stpIdx, __PARAM1
        RC = RC & %1111_0000
        RC = RC | __PARAM1
      ENDIF
      ENDSUB
    


    Do the servos work?
  • DynamoBenDynamoBen Posts: 366
    edited 2008-10-11 01:43
    No joy for the stepper or servos.

    Stepper still has the same symptoms. I went back to the original code you posted noticed something else. When the If...then statements are in place the stepper spin at 1/2 the speed than if you remove the statements. I also altered the Step_Reverse value to 169 and 170 in both cases the motor just stopped.

    As far as the servos when I hooked them up they turned all the way to the right and the application began to "stutter" and not function. When I unplugged the servo things went back to "normal."

    There is something really bizarre with the stepper code and DMX, I'm not sure what it is?

    Post Edited (DynamoBen) : 10/12/2008 11:48:21 PM GMT
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2008-10-12 23:54
    Is there enough power available for the system? With what you described for the servos you make me think that the power draw with the stepper and servos is too much.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.

    www.brilldea.com·- Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto fo SunSPOT, BitScope
    www.sxmicro.com - a blog·exploring the SX micro
    www.tdswieter.com
  • DynamoBenDynamoBen Posts: 366
    edited 2008-10-13 01:12
    Power isn't a concern. The steppers are fed with a 15V supply, 5V is coming from by bench supply. I did drop in some LEDs in place of the stepper and eliminated the 15V supply, problems persisted.
  • CapdiamontCapdiamont Posts: 218
    edited 2008-10-13 03:12
    How many amps for the power supply?
  • DynamoBenDynamoBen Posts: 366
    edited 2008-10-13 03:21
    15V/15A and 5V/3A

    I wasn't as clear as I could have been with the servo problem. The stutter begins when I start transmitting DMX.

    Post Edited (DynamoBen) : 10/13/2008 3:51:51 AM GMT
Sign In or Register to comment.