[CCC DEV] PWM MOTOR CONTROL

Michael Pirrone-Brusse pirronm at allegheny.edu
Sat Aug 7 04:25:16 BST 2010


Hey Laurence,
    So, this is a bit exciting for me as I wasn't really sure the use-cases
of the pwm(..) and servo(..) protocols when I wrote them, so.. ::rubs hands
together::

    Just by glancing at your code I can't say if what you're doing is
exactly right for motor control -- I've only tested pwm on fading LEDs, and
servos. No motors handy -- but you're really close to (what I'm guessing)
you want.
    The one big thing you're doing that you *shouldn't* need to
(emphasized because, well... yeah) is the whole byte.tick PROC. The pwm PROC
actually just sets a few registers on the ATmega that tells it to constantly
pulse the pin given at the frequency given, and then it should keep pulsing
until the board looses power. By telling it to pulse at 255 as quickly as
possible, you shouldn't actually be changing the behavior of the PWM. The
CHAN BYTE pwm(..) takes is for changing the pulse width as your program
runs.

    I think we were planning on putting these online pretty soon anyway, but
if you'd like, I could share the OccamDocs (JavaDoc style, html
documentation for Occam code) for the plumbing libraries. I'm not sure how
much they would help, but you'd certainly help me figure that out. XD

    Let us know how things go,
        -Drew Pirrone-Brusse

On Fri, Aug 6, 2010 at 7:52 PM, Laurence Laycock <rencio7 at gmail.com> wrote:

> Hi guys...yeah I've been twiddling around...and I've figured out how to get
> pwm motor control - well I don't think it probably is the best way to do it
> but here is an example of a section of the code : -
>
> *PROC main ()*
> *  CHAN SIGNAL s1:*
> *  CHAN SIGNAL s2:*
> *  CHAN BYTE b1:*
> *  CHAN BYTE b2:*
> *  PAR*
> *    heartbeat ()*
> *    pinSetup ()*
> *    goForward()*
> *    byte.tick (255, b1!)     *
> *    pwm (enablePin, b1?)*
> *    byte.tick (50, b2!)*
> *    pwm (enablePin2, b2?)*
> *
> *
> *
> *
> goForward() just tells the motor pins on the h bridge to go high or low.
> byte.tick is in plumbing module here is the code: -
>
> *PROC byte.tick (VAL BYTE input.value, CHAN BYTE out!)*
> *  WHILE TRUE*
> *    SEQ*
> *      out ! input.value*
> *:*
>
> The first value is the byte that will be sent to pwm through a channel
> defined in the second.
> I hope you like it as I am quite new to coding - I would like to know if
> there is a better way to do this....
> I really want to control my robot and get wheel encoders to work
> (eventually) in concurrency.
>
> Please advise
>
> Laurence (:
>
> _______________________________________________
> developers mailing list
> developers at concurrency.cc
> http://unhosting.org/mailman/listinfo/developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.concurrency.cc/pipermail/developers/attachments/20100806/813fd7cf/attachment.htm>


More information about the developers mailing list