Shop OBEX P1 Docs P2 Docs Learn Events
Pulse counter — Parallax Forums

Pulse counter

fma38fma38 Posts: 42
edited 2007-05-31 22:10 in BASIC Stamp
Hi,

The astronomic head I plan to turn into a pano head uses DC motors and encoders. Unfortunatly, these encoders are very primitive, and only provide one signal, not two in quadrature. This is not really a problem, as I know when I'm going forward or backward.

The problem is to count these pulses while driving the motor (using PID). I think I will have to use an external circuit. Do you know search circuit? Ideally, it will have 2 inputs (I have 2 motors to drive), and will use serial communication. I don't know what is the maximum frequency of the encoder pulses (I will measure it), but I guess that 16bits will be enough for the counter, and let enough time to the BS2 to compute its PID before the counter overrun (between two iterations).

Thanks for any pointer.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Fr

Comments

  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-05-31 17:12
    PWMPAL has counter inputs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • fma38fma38 Posts: 42
    edited 2007-05-31 18:11
    That's an idea... I could use it to also drive the motors... But I guess I need to add a H-bridge, like the SN754410. Do you have any schematics for such application?

    Another point: I need to drive 2 motors (in both directions), and read 2 encoders. Is it possible to only use 1 PWMPAL?

    BTW, I can't find the exact schematic of all pins...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fr
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-05-31 19:40
    It looks like a PWMPAL has 4 counters, AND 4 motor control outputs, all of which can be used at the same time. Yes, you'll need an H-Bridge, and I believe a 'Direction' control signal which can come from the BS2.
  • fma38fma38 Posts: 42
    edited 2007-05-31 21:15
    Reading the SN754410, I found that it is possible to use the 4 half-bridges to drive 2 motors in both directions; I guess I just need to put one output to the ground, while using the other one as PWM. For the other direction, I just need to switch outputs usage: the first becomes the PWM output, and the second is set to the ground.

    Well, seems to be a good solution! Thanks for your help.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fr
  • LSBLSB Posts: 175
    edited 2007-05-31 21:55
    Clarification on the SN754410-- One half bride goes to each motor leed; one motor on the right, one on the left. Each half-bridge has an associated signal pin so, setting one pin high, one low is one direction. Switch pin output signals to reverse direction. Both pins high is brake, both low is coast. If you can do without coast and brake, use an inverter chip and save the stamp outputs. The enable pin is where the PWM output goes into the SN754410 (PWM enables and disables the motor very fast without affecting polarity of the bridges.
  • fma38fma38 Posts: 42
    edited 2007-05-31 22:10
    I guess I have to connect 1 PWM output of the PWMPAL to 2 signal pins of the 754410?

    It seems that Pololu does not use it that way; they use 4 PWM output to drive the 4 signal pins; enable pins are always high. It meens that one leed of the motor is at either 0 or VMot, and the other one quickly switch from 0 to VMot. So, the motor is powered by VMot, or there is short circuit (brake or coast). Don't know if it is better than powered and opened...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fr
Sign In or Register to comment.