Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:50 31 May 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Quadrature multichannel decoder for PicoMite using PIO

     Page 4 of 5    
Author Message
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7646
Posted: 10:06am 29 May 2025
Copy link to clipboard 
Print this post

Circular buffer?

When we were working with PLCs the first rule was to run everything as slow as we needed to in able to see exactly what's happening. Timing isn't critical at that stage. You can take the delays out of it later. :)  No, things like displays may not work, but you'd see the bytes being sent to them even if they weren't connected.

At one point I had a PLC programmed to "look like" six diesel generator sets. The panel under test was wired back to that and you could simulate mains-failure starting, generator synchronising, breaker control and various engine faults. It was quite some thing!
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4943
Posted: 07:26pm 29 May 2025
Copy link to clipboard 
Print this post

Controlling 4 steppers real time: use arduino uno and grbl to drive the 4 SHerLine controllers.

That may not be top noch, but it does the real time stuff very reliable. And you simply send it coordinate strings. That would be my take on it.

If you send the coordinate strings from a pc (grbl player)  at start of tje project, or from a CMM2 ( write it yourself) is up to you.
The pico can be used as feedback reading encoders, and you can decide in your CMM2 program to use it or not.

Volhout
PicomiteVGA PETSCII ROBOTS
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7646
Posted: 09:16pm 29 May 2025
Copy link to clipboard 
Print this post

"ar...", "ard...". Are you allowed to use that word here? Go wash your mouth out!

;)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1245
Posted: 09:57pm 29 May 2025
Copy link to clipboard 
Print this post

That's why I recommended FluidNC. Claims to be an improved GRBL controller. Easier setup, etc.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2482
Posted: 10:03pm 29 May 2025
Copy link to clipboard 
Print this post

Some though bubbles.
1) As you have encoders for exact feedback you don't need to know how many pulses are being sent.
Use PWM with PID to slow when nearing the target.

2) If the PWM response time to commands is too slow, control it with a DOUT and diode AND gate. The DOUT can then rapidly cut off the pulses.

If necessary cut off the pulses (with the DOUT) just before reaching the target and creep the last bit by toggling the DOUT.
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1245
Posted: 10:03pm 29 May 2025
Copy link to clipboard 
Print this post

@Volhout
This is why I requested PIO pulse/direction. There are those who would like to use these GRBL controllers but with their existing closed loop servo systems.
Here, the PicoMite becomes the converter  
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1245
Posted: 10:18pm 29 May 2025
Copy link to clipboard 
Print this post

@Phil99

I don't know much about steppers but PWM with stepper motors?

PID on the PicoMite can easily handle 4 axes @ the typical 1ms loop rate and the encoder counting rate is faster than many dedicated motion systems.

We have some serious motion control capability here.

Closed loop servo is FAR superior to the hit-and-hope stepper stuff.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2482
Posted: 10:29pm 29 May 2025
Copy link to clipboard 
Print this post

I was thinking about @allie's Sherline units driving the steppers.
They just need pulse and direction inputs.
As encoders are fitted to the motors this way they can be treated as servo motors. Just send a stream of pulses until the PID slows and stops it. If the PWM command is too slow use the faster PIN(x)=0 command to override it via an AND gate.
Edited 2025-05-30 08:45 by phil99
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1245
Posted: 10:49pm 29 May 2025
Copy link to clipboard 
Print this post

Ah, interesting. Need to mull that one over  
 
allie
Regular Member

Joined: 06/10/2018
Location: Canada
Posts: 59
Posted: 10:54pm 29 May 2025
Copy link to clipboard 
Print this post

  PhenixRising said  How about a quick rundown of what the goal is...maybe I missed it.

The way I interpret it is that a single PicoMite would suffice.


May be a single PicoMite would be all I need. I'm new to all these microcontrollers. So I'm checking out different ways. The reason I chose the CMM2's were to store the stepper motors 1000th hand wheel counts and save the counts to an SD card. The SHERLINE  Controllers are stand alone programmable units. For me the SHERLINE Controllers can be programmed in 1" and 1000th of an inch to the inch limit of the tables allowable movement. The SHERLINE Controllers can be programmed with up to 40 steps (moves) in each of the two program memory's. But there is no SD card or USB stick port that you can use to save these moves. That is why I want the CMM2 to get these moves from the encoders. Because in a month or two if I want to make the same part I'll put the SD card into the CMM2 and the CMM2 can send the step and direction signals to the SHERLINE controllers to make the part. I needed the PicoMites state machines to get the readouts from the encoders. Last year someone on the back shed told me that the CMM2 would not be fast enough to count the encoders and that I should use the PicoMite to count.
This is why I'm doing this.
Thanks for your input.

Regards Allie
 
allie
Regular Member

Joined: 06/10/2018
Location: Canada
Posts: 59
Posted: 11:03pm 29 May 2025
Copy link to clipboard 
Print this post

  Volhout said  Allie probably wants to use the SHERLINE units because he has them.

Volhout


Yes I want to use the SHERLINE units and the CMM2 units because I have them.
Thanks for all of your input.

Regards Allie
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2482
Posted: 01:55am 30 May 2025
Copy link to clipboard 
Print this post

If you are only recording the encoders while using the hand wheels maybe the speed is low enough for the CMM2.
I think PhenixRising is thinking in terms of the blinding speeds that he uses.

As a test connect a multimeter to one encoder output and read the frequency as you turn the hand wheel at the highest rate you are likely to use. That will provide a reference point to work toward.

If the frequency is a bit high but isn't way too high just going slower may get it in range.

If that is acceptable during a Sherline recording session the PORT Function can record all 8 outputs (2 per encoder) by recording a timestamp and the PORT value each time a PORT bit changes.

To play back the recording instead of driving the Sherlines directly disconnect the encoders and connect 8 CMM2 outputs (they can be the same pins that were used for recording) to the Sherline encoder inputs. Put the Sherlines in recording mode.
Use the PORT Command to send the reconstructed encoder signals from the recording to the Sherlines.

Now the Sherlines can make the parts without the CMM2.
.
Edited 2025-05-30 11:58 by phil99
 
dddns
Guru

Joined: 20/09/2024
Location: Germany
Posts: 412
Posted: 05:32am 30 May 2025
Copy link to clipboard 
Print this post

With NEMA23 size the fun stops. Has anybody seen and heard when it's used in a mill and a crash occurs? That feels as bad as a car crash.. How long would it take to get a self made 4 axis real time controller programmed, that it'll be as stable as GRBL or Fluid?
To use CMM2 or PicoMite as a front-end is an interesting thought from my point of view.
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1245
Posted: 05:34am 30 May 2025
Copy link to clipboard 
Print this post

Hi Phil99, Allie.

It's not an encoder frequency problem, it's quadrature decode. The Picomite's PIO provides a 32bit position value. It's unsigned so we need to handle rollover.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2482
Posted: 07:17am 30 May 2025
Copy link to clipboard 
Print this post

I don't propose to use PIO. Not even to count the pulses at all, just record the Port state and timer to a file when any bit in the Port changes.

This file can later be replayed sending the Port data (at the recorded intervals) to the inputs of the Sherlines so they can record the session as if the data was coming from the handwheels. the Sherlines do all the work. The CMM2 is just an 8 track tape deck, recording a programming session and playing it back.

The stepper and encoder are 1000 counts / inch driven by hand so I think the pulse rate wont be too high.

I have done some experiments on a PicoMite 2040 @ 378MHz and it appears to be able to record to a file on A: the port value and timer with intervals less than 0.5mS. That amounts to 2"/S.
.
Edited 2025-05-30 17:38 by phil99
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1245
Posted: 07:29am 30 May 2025
Copy link to clipboard 
Print this post

But the encoder generates two channels of pulses, A & B that are 90 degrees out of phase. Without decode, they'll only count in one direction whereas the axes need to constantly move plus/minus.

Am I on the wrong track?
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1245
Posted: 07:45am 30 May 2025
Copy link to clipboard 
Print this post

I'm thinking that you might be expecting the encoder output to be pulse & direction, like a stepper motor?
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2482
Posted: 07:46am 30 May 2025
Copy link to clipboard 
Print this post

There is no need to decode. The Port is 8 bits wide, 2 bits per encoder and 4 Sherlines.
The state of the Port is recorded when any bit changes, along with a time stamp.

On replay the those timestamps reconstruct the encoder phases as the 8 bits are sent back to the Port at each recorded interval.

  Quote  I'm thinking that you might be expecting the encoder output to be pulse & direction, like a stepper motor?
No the Sherlines do the decoding.
When the Sherlines are in Record mode they are taking what they think is the encoder outputs (which it was in the original recording session) and they convert that to steps and direction and save in their own memory.
Edited 2025-05-30 17:52 by phil99
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1245
Posted: 08:03am 30 May 2025
Copy link to clipboard 
Print this post

I dare someone to request that Pete (or is it Gerry now?) to enable the CMM2 quadrature counters  

Pretty sure it has them.
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1245
Posted: 08:07am 30 May 2025
Copy link to clipboard 
Print this post

Allie, are you aware of GRBLGRU

With a GRBL controller, you can develop your part on the simulator and then send it to the controller.

The developer is a super nice guy and will even create a model of your machine if one of his existing models doesn't fit.
 
     Page 4 of 5    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025