Is this the correct way to reverse the count direction?
myEnc.setInitConfig();
myEnc.init();
//myEnc.write(initvalue); // just because
Serial.printf("\nUsing HW encoder\n");
//myEnc.printConfig(&myEnc.EncConfig)...
More fundamental question, how do I invoke void QuadEncoder::printConfig(enc_config_t *config)?
QuadEncoder myEnc(1, A, B, 0, IDX); // HW spindle encoder
myEnc.setInitConfig();
myEnc.init();
myEnc.write(16384*4);
myEnc.printConfig(&config); //...
Hmm, these encoders behave differently and making things hard to compare. The SW encoder counts position from t=0. The HW encoder is doing something different. My experiment is to have 10 revs forward, and 11 revs backwards. With an ideal...
With the trials I have been doing, (USB Serial off during acquisition) it seems that the HW encoder never seems to lose or gain counts, but the SW encoder may be +/- 1. Usually get 0 or +1. Basically these results are inconclusive, not sure if...
Decent idea, but hard for me to implement. I'd need to procure timing pulleys, source a new belt and machine a new mounting plate. Previously I printed a plate to hold the motor and encoder. It wasn't rigid enough and I got more counts. My...
Good point. My arch nemesis SerialUSB. That bit of code (SerialUSB) is poorly behaved. I'm waiting for my FTDI cable to arrive, to dump that to the curb.
I'll try that. Edit: Gained a count. Initial 16384, Final 16385.
Post #29 is 10 cycles of 10 revs forward, then 10 revs back. That's +/-1 count.
I tried 10 cycles of 15 revs forward then 15 cycles back, and got 16386 counts with the SW encoder. HW encoder is always 16384. Well the thing is, if I repeat the...
Seems that the SW encoder has lost a count.
Using SW encoder
Initial position = 16384
Number of revolutions before reversal = 10
Pulse Repetition Interval = 180 microseconds
Full steps per revolution = 200
Micro-steps/full step = 4
Repetitions of...
Ok, here's a version with both encoders. But one needs to compile the option, one vs the other. Just comment out the #define HW 1 or #undef HW statement. Luni's encoder behaves a lot different, and I can't explain why right now. I get zero...
So I rewrote my code. Primarily to make it explicit what was happening. I seem to not get any errors. However, I changed a bunch of things, including the stepper driver code. To make myself feel that I haven't pulled the wool over my own...
Good point. That fact got past me. Sometimes it's not quite that neat, but this time it was either 8199 or 8200.
I'll try that. Maybe today will bring fresh new insights! Is there a way on quad encoder to get an interrupt on the index...
Good idea.
The whole premise of using a stepper is that it is a discrete device, and angular errors don't accumulate. It may be true on an aggregate level, but it seems that on an arbitrary start point I'm not getting to the count I expect...
I have no idea at this point. One full step would correspond to 4096 counts/rev / ( 200 steps/rev) = 20.48 counts/step. One micro-step is 1/4 of that, or 5.12 counts.
I observe ~6 counts, which perhaps coincidentally(?) is about 1/4 step (1...
I'm just as puzzled as you are. I'm doing something similar and seeing bizarre stuff. My driver is set up to do 4 microsteps/step. The NEMA17 stepper is 200 full steps per revolution. I have connected a 1024 PPR rotary encoder to the stepper...
@PaulStoffregen Setting up a new MacMini M4 for my shop computer. Getting the same error as the first post. I didn't need to add Rosetta (that I remember) for my M3 MacBook Pro. Is Rosetta still needed? Downloaded the 64 bit image of Arduino...
Here is a modified version with an IntervalTimer configured for 10 kHz. The timer handler reads the encoder, computes the delta since the previous read, and updates a running sum. The number of interrupts and the running sum of encoder counts are...
Yes. Would be instructive to see how that's done.
Down in the shop, all the timing indications show "things are fine", but the syncing is most definitely erratic. Sync every once in a while is not good enough. So I'd like somehow to...
I added a 4" diameter disk, about 1/2" thick, coaxial with the bore of the timing pulley. Was good enough to drive the resonance from about 1200 RPM to over 2200 RPM, which was good enough for my application. (Max spindle speed on my lathe is...
Me too.;)
Mid-band resonance sounded like there was gravel in my gearbox, it really sounded terrible, like things were irreparably broken. In my case, I pushed mid-band resonance to a higher frequency by increasing the inertial load on the...
EncSim has a typo? in one of it's whatevers. Methods?
tachsim.setContinuousMode( true ); <=== won't compile. Compiler suggests setContinousMode
tachsim.setContinousMode( true ); will compile
Steppers behave funky, even with some load. I have seen this on my electronic lead screw on my lathe. I'm using 4 microsteps/step. The even microsteps are different in size than the odd. That's just how the stepper driver is. I can't do...
I need to return to this. I can try this code on a spare Teensy4.1 with a screw terminal test board. I'm trying to rule out whether EncoderTool on my ELS project is slipping counts. It's going to be a bear to shoehorn in. Not sure if the...
The program below is one that I wrote to test both EncSim and QuadEncoder. The encoder simulation uses pins 0,1,2 (outputs), and those must be looped to pins 3,4,5 (inputs) for QuadEncoder. The simulated encoder is set to 1200 PPR by default, and...
Trying to understand whether this library is suitable for what I have in mind. Simple questions, I hope.
Does quad encoder count on every edge of A and B? Or really only on a single edge of A? From reading the source files it wasn't clear to...
Yes, and yes.
Not really. I don't know the spindle RPM, it is computed from the encoder counts in a time interval, and the spindle RPM can depend on lathe motor load, or the whim of an operator. For all I know, the RPM is wowing, but my...
I'm sampling multiple things, angular position, aka the spindle, and linear position in Z. When the lead screw clutch is engaged the Z position has to follow exactly the spindle angular position. Yes, I'm taking advantage of the Z carriage...
Thanks for the suggestions. Will try to make something workable from it. Obviously will require a lot more planning than my previous ad hoc methodology. I'll have to think long and hard about what the bounds are for data or state transitions...
If I can't output to USB, then how do I log a "reasonable" amount of data? If I can only log at acoustic coupler rates (an exageration, but) and I'm running a system at 27 KHz, am I not running blind? How do I know I went from one state to...
Yes. The decision is dependent on the settings made by the operator, different feed rates or threads change the timing.
I did experiments in the beginning to ensure the algorithm could run up to 5000 RPM. My lathe (more importantly, my lathe...
At the moment, I can't see how to integrate the Bresenham algorithm, which is an integral part of what I need to do. Just knowing the count isn't good enough... I need to generate stepper pulses at exactly the right time, every time. Also have...
Yes. It is executed in integer math, very fast.
Not quite. I use every state change as a count, to determine when to step the motor. So I get a resolution of 4096 counts in a single rotation of the spindle.
Knowing where I am does help if...
I came to the same conclusion. I can't use USB communication if I'm doing something with interrupts with critical timing.
Understand that you've gone too far to change now, but this can be done with quadrature counting in hardware. Instead of...
To sort of answer the original question - I have managed to send a sustained 32 Mbits/s to the teensy over ethernet using the asyncTCP library, in testing I could push it up to around 50 without issues. This is receiving rather than sending so a...
I reviewed QuadEncoder again. Can't use it as is, as it breaks my entire software architecture. But I still will look at it to see if there's a non complex method to adapt it's use. At the moment, I'm having a tough time disconnecting from my...
Thanks for your helpful response. It gives me an idea of what to expect, at least for receive. I've done both ends of a client server in C long ago, lots of ACK'ing etc.
I could change things, sometimes that HAS to happen.
I know all about clough42, I was going to implement his system during the pandemic. But the TI control boards were unavailable for over 12 months due to supply chain disruptions, After...
uint32_t status, cyccnt=ARM_DWT_CYCCNT;
do {
USB1_USBCMD |= USB_USBCMD_ATDTW;
status = USB1_ENDPTSTATUS;
} while (!(USB1_USBCMD & USB_USBCMD_ATDTW) && (ARM_DWT_CYCCNT - cyccnt < 2400));
The way I...
Well, one place is usb.c, another is usb_serial.c I am running 1.58.1.
In usb.c there is
static void schedule_transfer(endpoint_t *endpoint, uint32_t epmask, transfer_t *transfer)
{
// when we stop at 6, why is the last transfer missing...
If QuadEncoder was 64 bit, and it allowed me to execute the Bresenham algorithm inside it, that would be great. 64 bits will never overflow in my lifetime, 32 bit, will in under a day. It's hard (for me) to debug unsigned arithmetic errors...
As I recall USB is fastest. But in usb.c and associated files, there is considerable amount of blocking, with ISR's globally blocked. I cannot have my ISR's blocked or I lose control of a machine. I may be interpreting things incorrectly, but...
I have a data logging problem, but it's really a debugging problem. I'm trying to find unexpected behavior (which I get every few days) and log a lot of data to find the problem. USB isn't so great for this, as there's a bit of blocking, at...