Welcome! Log In Create A New Profile

Advanced

Including Quadrature Encoder - PID positioning of DC motors into Teacup_Firmware

Posted by unix_guru 
I've been working for a while to get my Teensy 3.1 based controller board to manage four Quadrature Encoders, and provide PID position control for four DC motors.

This was completed a month or so ago, and I've since downloaded, and finally successfully compiled and installed Teacup_firmware on the Teensy.

My Quadrature decoder routines use two separate methods, Hardware flextimer modules run X/Y axis, and hardware interrupts for two Z axis decoders. Thought being that movement of the Z-Axis is less critical to path planning.

All decoder routines are interrupt driven, and run autonomous of anything else on the processor. They simply provide global variables for the current exact position and direction of each axis.

The DC motor PIDs today use the metro timing library and a version of the arduino PID library, and also run autonomous of anything else on the processor. Fill a global variable with the next target position, and it goes there. What is missing currently is the velocity profiling to have smooth X/Y path control.

So.. long story short, I'm looking for a method to use the functionality of Teacup_firmware to control my servos as if they were steppers.
in other words, the macros that are in teacup to WRITE direction and step, I wish to replace with macros that assign +1 or -1 to an axis direction variable. (ie: XAXIS_DIR=-1) then when a STEP command is issued, that macro would ADD the axis direction variable to the axis target position value (ie: XAXIS_TARGET += XAXIS_DIR) . If DIR was negative, the addition would result in decrementing the target position.

The axis position PID would then update it's position based on this in real time.
And yes, at some point, I would expect to use dda_clock() to control timing of the PIDs.

Am I way off track here? Is there an easier way to integrate? In my mind, I simply need to include my two files and their headers.
Encoders are interrupt driven, and feed global variables.
Motors read global variables and use interrupts to sync position.
two macros need to be replaced per axis. One for WRITE Direction one for WRITE Step.

Thoughts? Guidance please...

Edited 1 time(s). Last edit at 03/23/2015 08:34AM by unix_guru.
Ok... I can hear you laughing at how naive I am....

That said, I'm working through the X-axis pin remapping and macro replacements etc... Hope to have X-Axis running later tonight.

Cheers.
If i understand u it´s "Fantastic".

Seems you solved it, but mey u want to take a look Misan work in [forums.reprap.org]

Sorry if not.

I´m not english.
Yes, Miguel Sanchez (MISAN) and I have been talking for quite a while now. He is doing some incredible work!

He recently developed a two dc-motor controller on one arduino with Step/DIR control!
Sorry, only registered users may post in this forum.

Click here to login