Shop OBEX P1 Docs P2 Docs Learn Events
PWM Current Control using BS2sx — Parallax Forums

PWM Current Control using BS2sx

Carlos FormigalCarlos Formigal Posts: 2
edited 2006-07-06 18:18 in BASIC Stamp
Hello Guys,

I have been working with stepper motor to control my milling machine. I'm considering to build a Stepper motor controller using the Basic Stamp. The motor that I need to control needs to be powered by 5 Amp and because the torque varies with speed the current must be set constant. One way to do this is to PWM the current that drives the 4 trannsistores that control each motor phase ( the motor are unipolar with 4 phase).

The question that I would like to address to this forum is:

It is possible to send at the same time a PWM signal to two ports of the B2sx and how could this be made?

I need to power up to phase at the same time by PWM.

With regards to everyone.

Carlos

Comments

  • T ChapT Chap Posts: 4,217
    edited 2006-07-06 08:21
    You could consider an alternative, although not to discourage the Stamp use: Let the current chop itself, thus self regulating at a fixed current regardless of speed. To do this, you would have a shunt on the low side off the mosfets on the Hbridge. A sensor on the shunt would output a relative voltage to a comparator, which has a trim pot(or fixed value reference) voltage that is set at the max current rating of the motor. When the current reaches x, the current sense opamp puts out x volts to the comparator, the compartor turns on and disables the highside voltage via a logic circuit(SR latch) that is being clocked by a 20k or so signal to the Set input. In other words, the Clock is constantly "turning on" the latch at its Set input. When the current rises to the threshold you determine with a pot, the comparator turns off the latch via its Reset input. The Clock turns it right back on however, so it really is going into a form of PWM if you will, as oscillation between ON, and too much current=reset latch= OFF, back and forth. PWM can be regulated as well and even could track the speed for a logrithmic curve to achieve the best speed/torque.

    If the speed with the Stamp isn't sufficient for the option as you described, you could surely use the Propeller with two(or more) cogs outputting pulses as needed. The Propeller could have a pot as well determining the PWM duty cycle, and/or rate.

    For info on the chopper circuit, this link is a great read:

    http://pheatt.emporia.edu/projects/stepper/currentcontrol.pdf
  • Carlos FormigalCarlos Formigal Posts: 2
    edited 2006-07-06 17:43
    Hi,

    Thanks for the reply. I'm really considering to use the Stamp, but seems that I can not PWM two ports at the same time. Another alternative is to use a PIC, but the Stamp capabilities to be easily programmed is blinding me. The Stamp would be use also to integrate a RPM counter in the milling or in the lathe.

    The circuit that you suggest is the traditional one. I was considering in develop a PC program where I could tune the motor performance, much alike the circuit that is the the http:\\www.hobbycnc.hu. In this way the circuit would not be motor dependent.

    With regards,

    Carlos
  • T ChapT Chap Posts: 4,217
    edited 2006-07-06 18:18
    If you are looking at this as a one-off, then depending on the speed you need, you could use two stamps maybe. For that matter, the SX can be programmed "relatively" easy for basic commands as well, and you could get several SX chips that would handle the speed requirement, all for less than a s stamp, if $ is a concern. That is your closeset bet if you want to use Pbasic and the Stamp can't handle the situation.

    A Visual Basic app could be easily put togerther that could monitor RPM, output a PWM(speed/duty cycle factor etc) to the SX's. There is a download and simulator for the SX language called SX/b that you could look at and get a feel for the similarities in programming.
Sign In or Register to comment.