Shop OBEX P1 Docs P2 Docs Learn Events
DC Motor with encoder — Parallax Forums

DC Motor with encoder

todddrumtodddrum Posts: 1
edited 2014-08-14 09:26 in Robotics
I am a teacher that has been using the basic stamp bobot but want to move my students to a propeller based home brew robot programmed in C. We got several 12 volt dc motors that have built in encoders. We have gotten the motors to run with a L298 motor controller but would like some help controlling the speed and distance with the encoders. The problem is that we are all fairly new to propeller c. I have not been able to find sample code in c so we can start dissecting sample code and adjusting it to our purposes. If anyone could help it would be greatly appreciated.

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2014-08-14 08:50
    Hi and welcome to the forum.

    I've done a fair amount with the Propeller and C, but I haven't tackled PWM using C. So I had hoped someone else would respond.

    What I would probably do is get a PASM PWM driver from the OBEX (link in the nav bar) and port it and the Spin example to C. There's a tool called spin2cpp which can help, although the code it generates sometimes needs cleaning up.
  • Hal AlbachHal Albach Posts: 747
    edited 2014-08-14 09:26
    While in SimpleIDE click on HELP, then Simple Library Reference, then under Utility (near the top) click on simpletools.h, scroll down to Timed IO and you will find three PWM functions, pwm_start, pwm_set, and pwm_stop. Click on each one for a more detail description. There is or was a tutorial for this but I can't locate it right now. The functions are very easy to use, for me they work like a charm.
Sign In or Register to comment.