kpap
New member
Hi all, first post here. My congratulations to Paul for his excellent products!
Have made some Teensy projects in the past, but this is the first time that I think I might have to dig deep in some hardware specifics. I'm planning on using Teensy 3.1 on a small PID controller for 3 servo motors. I have made the first tests with a Teensy 3 I have and they are very promising, although I think I already have some issues with needed interrupt priorities.
So, here are the project details as well as the first questions.
This is a project for driving servos for cnc machines. I'm going to get 3 step and 3 direction signals from a PC's parallel port or from any other source (fpga cards that generate step and direction signals are common place in cnc projects). Teensy will count the step signals and together with the direction signals will know the target position of the motor's encoder. Teensy will also read the servos' quadrature encoders A and B signals (another total of 6 signals) and calculate the PID output for the motors for 3 PWMs.
I have succesfully made a simple PID loop that runs every 1 ms using IntervalTimer and checked on my oscilloscope for the function's timing which i see is excellent. I have also tied the encoder signals to an Encoder object and saw that it counts correctly. I'm also driving one motor using a PWM output. So far so good, except that I think I'm having trouble when I attach an interrupt to a pin so that I can count the step pulses. I run some tests this morning and I get a very strange behaviour from the PID output which I *think* is caused by a delay that the PID function does to the step counting function. I read in another post that all interrupts get the same default priority at first. Is this correct?
My first question will be if you think it will be feasible to have this kind of timing that I need for everything to run smooth with 3 motors in some relatively high step frequencies (say 200KHz, I don't know how far I can get and what level of programming I will need). Maybe I should use external counter ICs for this job? Second question is how I change the priority for an interrupt I defined with attachInterrupt, or the IntervalTimer priority.
Thanks in advance,
Kostas
Have made some Teensy projects in the past, but this is the first time that I think I might have to dig deep in some hardware specifics. I'm planning on using Teensy 3.1 on a small PID controller for 3 servo motors. I have made the first tests with a Teensy 3 I have and they are very promising, although I think I already have some issues with needed interrupt priorities.
So, here are the project details as well as the first questions.
This is a project for driving servos for cnc machines. I'm going to get 3 step and 3 direction signals from a PC's parallel port or from any other source (fpga cards that generate step and direction signals are common place in cnc projects). Teensy will count the step signals and together with the direction signals will know the target position of the motor's encoder. Teensy will also read the servos' quadrature encoders A and B signals (another total of 6 signals) and calculate the PID output for the motors for 3 PWMs.
I have succesfully made a simple PID loop that runs every 1 ms using IntervalTimer and checked on my oscilloscope for the function's timing which i see is excellent. I have also tied the encoder signals to an Encoder object and saw that it counts correctly. I'm also driving one motor using a PWM output. So far so good, except that I think I'm having trouble when I attach an interrupt to a pin so that I can count the step pulses. I run some tests this morning and I get a very strange behaviour from the PID output which I *think* is caused by a delay that the PID function does to the step counting function. I read in another post that all interrupts get the same default priority at first. Is this correct?
My first question will be if you think it will be feasible to have this kind of timing that I need for everything to run smooth with 3 motors in some relatively high step frequencies (say 200KHz, I don't know how far I can get and what level of programming I will need). Maybe I should use external counter ICs for this job? Second question is how I change the priority for an interrupt I defined with attachInterrupt, or the IntervalTimer priority.
Thanks in advance,
Kostas