DocStein99:
I find the encoder counting to be working exceptionally good.
A reasonable thing to do at this point is post your working code so others have an opportunity to learn from what you have done.
DocStein99:
I find the encoder counting to be working exceptionally good.
A reasonable thing to do at this point is post your working code so others have an opportunity to learn from what you have done.
I could, after I can be sure it's working, but is not. I re-calculated since the hardware encoder is attached to the gearbox to deliver: 512ppm * 4=2048 quadrature signals. Then * 27 = 55296 signals per revolution. I put a sharpie-mark on a gear tooth aimed at the "HOME" position - now take notice to the mark back and fourth to find it's losing encoder counts again, when I increase the speed limit of the motor.
I'm using this PID library - that I do not understand yet what that is doing.
Simple hardware that decodes quadrature into up pulses on one pin, down pulses on the other pin. Just a 74HC74 dual D flip-flop.
Should be simpler to just count pulses than decode quadrature.
polymorph:
Should be simpler to just count pulses than decode quadrature.
Well maybe. but its not hard to do the quadrature with a little bit shuffling or table lookup,
and counting two sets of pulses needed two counters with hardware clock inputs.
I think I need to calculate the TIME the processor will take to count 1 detent move on this encoder. There are 55296 counts per revolution. This sketch DOES work - when I analog.write pulse output up to 64. I use a laser aimed at one tooth to test that the wheel will spin forward one revolution and reverse one revolution. Once I set the limit on the PID curve, above 108 - the forward and return becomes LOOSE, the tooth on the wheel passes the laser target. The encoder reads 55296 counts and the wheel is out of position.
I did not measure the speed of 1 revolution. To ESTIMATE, it is less than 1 second. Possibly 500 ms.
So, if I use the 74HC74 - all I need to do is 1 line of code on the two hardware interrupt pins to ++ or -- the encoder count. This would lighten up the load of calculating quadrature position cycles for each detent cycle. Ironically - I actually DO have 74HC74 in my box from 10 years ago, so I don't need to wait 3 weeks for the postman to fly from China for me.
I'm going to setup this hardware RPM / counter device I have to help me verify the number of pulses, and compare against the Arduino's count of captured signals.
Or a 4013, I think.
Ok, well tonight I hooked up an external counter - to compare it to the Arduino. Unfortunately this dumb "DELTA CTA4" can ONLY count 5k cps in quadrature counting mode. So that makes this device REALLY SLOW compared to the Arduino's counting, so I can't use this to compare the counts to. I can only get an accurate reading AFTER I set the maximum speed to "5" which is something like 2 seconds per rpm super granny slow.
I used the 7474 ic, and it worked right away. I set the maximum pulse-out @ 255, and I've got the full speed of this 12v motor accurately positioning, using that device. Thank you - that worked great! Took out all that overhead processing, just 2 lines of code in the interrupts and it works like a charm.
DocStein99:
I used the 7474 ic, and it worked right away. I set the maximum pulse-out @ 255, and I've got the full speed of this 12v motor accurately positioning, using that device. Thank you - that worked great! Took out all that overhead processing, just 2 lines of code in the interrupts and it works like a charm.
Hi @DocStein99
Could you share in more details what you did to get it to work, maybe share a schematic, code example and a picture?
/cheers
polymorph:
Simple hardware that decodes quadrature into up pulses on one pin, down pulses on the other pin. Just a 74HC74 dual D flip-flop.Radio Ham Technology : by Alastair GW0AJU - 49er digital vfo
...
However this decoding may lose/gain pulses during direction change. Or when the motor is stopped and shaking slightly. It may be problem for some applications.
tropicdome:
Hi @DocStein99
Could you share in more details what you did to get it to work, maybe share a schematic, code example and a picture?/cheers
I think the circuit was already on this thread. I will post what I have in my file


$6.90 + &c.
You can buy $7.00 I2C module, of course if you prefer. I think the 74HC74 components are about $.10 each, and less if you buy more than $1.00's worth. Both of them will require the same time and effort and time to learn and test for a novice.