Re: [Emc-users] Encoder HAL programming.

2020-05-27 Thread N
> > I actually saw a youtube video where someone was using this chip.  I
> > believe he said it was like $28, and you'd still need something to read/run
> >
> 
> I buy them for about $3 each
> ebay.com/itm/1PC-STM32F103C8T6-ARM-STM32
> 
> 
> You can do this with no Meas card by going with USB, i2c or SPI directly
> back to the Raspberry Pi.
> 
> You can buy something like this for $28 too.   They typically have bigger
> versions of STM32 on them but for controlling two servo motors with a PID
> loop the cheaper part is enough.

Have inververter card with a STM32 on it, did however not solder it yet.


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-26 Thread Chris Albertson
On Mon, May 25, 2020 at 9:02 AM R C  wrote:

> I actually saw a youtube video where someone was using this chip.  I
> believe he said it was like $28, and you'd still need something to read/run
>

I buy them for about $3 each
ebay.com/itm/1PC-STM32F103C8T6-ARM-STM32


You can do this with no Meas card by going with USB, i2c or SPI directly
back to the Raspberry Pi.

You can buy something like this for $28 too.   They typically have bigger
versions of STM32 on them but for controlling two servo motors with a PID
loop the cheaper part is enough.

>
> --

Chris Albertson
Redondo Beach, California

___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread R C

never done anything with those, and have a few RPIs lying around

On 5/25/20 1:27 PM, andy pugh wrote:

On Mon, 25 May 2020 at 20:15, R C  wrote:


I am actually trying to see how much I can push it by using a rpi for
that, that's about the same price.

An Arduino is possibly a better choice. You can get Nanos for about £5.




___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread andy pugh
On Mon, 25 May 2020 at 20:15, R C  wrote:

> I am actually trying to see how much I can push it by using a rpi for
> that, that's about the same price.

An Arduino is possibly a better choice. You can get Nanos for about £5.

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread John
Yes but it is another level of development. 

Sent from John's iPhone 4S

On 2020-05-25, at 12:07 PM, Jon Elson  wrote:

> On 05/25/2020 11:01 AM, R C wrote:
>> In the video I posted earlier (it's a year old)... the guy using that chip 
>> says it cost  him $40,  he showed it on line for about $28.
>> 
>> (and that's just for the LS7366R by itself.)
> This just doesn't make sense anymore.  You can take a bottom of the line FPGA 
> and put 4, 8 or maybe even dozens of quadrature counters in it, with digital 
> filtering, latch on index and other features. The Spartan 3A chips I use are 
> just over $10 each.
> 
> Jon
> 
> 
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread R C
that's what I thought too, it's pretty expensive. (probably low 
production runs etc., obsolete?).



I am actually trying to see how much I can push it by using a rpi for 
that, that's about the same price.



Ron


On 5/25/20 1:07 PM, Jon Elson wrote:

On 05/25/2020 11:01 AM, R C wrote:
In the video I posted earlier (it's a year old)... the guy using that 
chip says it cost  him $40,  he showed it on line for about $28.


(and that's just for the LS7366R by itself.)


This just doesn't make sense anymore.  You can take a bottom of the 
line FPGA and put 4, 8 or maybe even dozens of quadrature counters in 
it, with digital filtering, latch on index and other features. The 
Spartan 3A chips I use are just over $10 each.


Jon


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread Jon Elson

On 05/25/2020 11:01 AM, R C wrote:
In the video I posted earlier (it's a year old)... the guy 
using that chip says it cost  him $40,  he showed it on 
line for about $28.


(and that's just for the LS7366R by itself.)


This just doesn't make sense anymore.  You can take a bottom 
of the line FPGA and put 4, 8 or maybe even dozens of 
quadrature counters in it, with digital filtering, latch on 
index and other features. The Spartan 3A chips I use are 
just over $10 each.


Jon


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread John Dammeyer
> -Original Message-
> From: andy pugh [mailto:bodge...@gmail.com]
> On Mon, 25 May 2020 at 10:42, Chris Albertson  
> wrote:
> 
> > Ideally you have just one thin cable going from controller to the machine.
> >  If you like those chips just glue on on each encoder and turn then encoder
> > into a serial interfaced device.  Or use a serial buss so 6 encoders can
> > share one cable.
> 
> There are elements of this to the STMBL servo drive, in that it uses
> the STM32 to count encoder (and resolver and SSI) encoders then
> reports back to LinuxCNC using the Mesa smart-serial protocol.
> This is a neat choice, as Smart-Serial is self-configuring. Plug in
> the device and all the appropriate HAL pins appear as if by magic.
> 
> Smart-serial is still one cable per node, though. It's a star topology.
> 
> But if it will work for you, then the smart-serial STMBL code for
> STM32 is there on the STMBL Github.
> 

There are two options for distributed.  Either CAN bus or EtherCAT.   For 
closed loop motor control CAN bus just isn't fast enough although the new 
CAN-FD has possibilities.  EtherCAT is seeing more use in industry.  All those 
solutions are generally more expensive than LinuxMESA for a 
home/small_shop/hobby system.

And that you can get full 3 or 4 Axis CNC systems with LCD displays from China 
for under $300US for basic CNC operations (internally they have 32 bit ARM 
processors I believe) the reality is one has to now look at the market.

The days of replacing the FANUC or whatever industrial controller on the 
surplus mill with only a PC c/w parallel port are over. For those systems I'm 
seeing either MACH4 with Ethernet type Smooth Stepper or LinuxMESA.Most 
users of Linux do not recommend LinuxCNC with a parallel port.  Some users are 
experimenting quite successfully with Raspberry Pi LinuxMESA.

And the BeagleBone with MachineKit is somewhat dead because MachineKit itself 
is somewhat dead end.

Certainly Andy is right.  The STM32 as used on our STMBL drives is a good 
solution for motor control and what Rene and company have done with the STMBL 
drive is really quite good.  

I happen to have the Microchip ICD-4 for programming and debugging code.  And 
lots of other Microchip stuff so I am pulled in that direction rather than text 
based make files and terminal interfaces for all debugging.  And it's where my 
work is.  My clients refuse to use Linux for development so it's a no brainer 
that I'm using MPLAB-X etc.

Meanwhile, I've still not completely figured out how LinuxCNC decides how 
far/fast it should move the Z axis based on the items read back from the 
quadrature encoder.  Or how starting G95 will, I'm told, result in the Z axis 
tracking the spindle as it's rocked back and forth by hand.

John Dammeyer







___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread John Dammeyer

> > be a good idea.  There are also devices from the same manufacturer
> > that can change quadrature into up/down pulses streams to use regular
> > counters inside the Pi.
> 
> But quadrature has one huge advantage over regular counters, you get both
> speed AND  direction from every edge that goes by.
> > John
> >
Gene, 
The small devices take quadrature and change it into pulse/dir or count up  and 
count down signals.  So if you have a processor that has 32 bit counters but 
doesn't have QEI modules those chips can do that for you.  Both speed and 
direction.

For example the PIC32MX795 I've ported my ELS project to doesn't have a QEI 
module. But does have some counters.  From the data sheet overview.

Timers/Output Compare/Input Capture
• Five General Purpose Timers:
- Five 16-bit and up to two 32-bit Timers/Counters
• Five Output Compare (OC) modules
• Five Input Capture (IC) modules
• Real-Time Clock and Calendar (RTCC) module

So for a standalone controller that has CAN bus, Ethernet and USB but needs QEI 
the smaller translation chip is one option.   
Or alternatively:
https://www.microchip.com/wwwproducts/en/PIC32MK1024MCF100

Is PIC32 with up to 4 CAN us channels, 6 QEI, 2 USB but no Ethernet.  This 
device can also do PWM and is designed for closed loop motor control.  

And it's always possible to add an external Ethernet controller like this one 
for EtherCAT
https://www.microchip.com/wwwproducts/en/LAN9252

or 
https://www.microchip.com/wwwproducts/en/ENC424J600

for just simple 10/100 Mbps Ethernet.

John




___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread R C
interesting, so how easy would it be to use a board/device like this in 
linux-cnc?


if those are just a few $$$  it would be fun to mess with.

On 5/25/20 3:39 AM, Chris Albertson wrote:

Yes, you can buy a hardware Quadrature chip.  But any modern
microcontroller like the STM32 will have hardware quadrature decoders.
The larger versions of the chip will have multiple quadrature decoders.
The chip will also have SPI.   These things cost under $1 or about $3 if
you want it on PCB ready to use.   If you buy the chip you need to design a
PCB.   I buy the microcontroller already on a PCB and in a usable form for
$3.

I like to place these not on some kind of large PCB near the main processor
but rather near the sensor.  This reduces the bulk of wire.   You can stick
the littlle computers where ever they are needed and then  snake one
(say) CANbus
cable around to connect each of them to power and data.

If you try to build a cape that does everything you find that you can't.
By "everything" I mean works with a PC, with a Pi4 and with a BBB and
connects steppers and servos and VFDs and linear scales. It is best to
just put a CAN bus or whatever on the main computer and nothing else.
  This is 100% "future proof" because every part can be swapped out.

These little boards have become by "go to" universal interface board.  They
cost $3 and have hardware pulse, PWM and quadrature support in hardware and
can talk over SPI I2C or USB.  They are small and cheap enough that you can
place them where ever they are needed.
ebay.com/itm/STM32F103C8T6...
<https://www.ebay.com/itm/STM32F103C8T6-ARM-STM32-Minimum-System-Development-Board-Module-For-Arduino-HOT/372276039369?epid=23002532325=item56ad618ec9:g:VjoAAOSwkRJazxC6>

THe other design option is to use an FPGA.  That is what Mesa does and they
can put any reasonable number of counters and generaters in one FPGA but
then you have to route a ton of wires all back to that one chip.

Ideally you have just one thin cable going from controller to the machine.
  If you like those chips just glue on on each encoder and turn then encoder
into a serial interfaced device.  Or use a serial buss so 6 encoders can
share one cable.



On Mon, May 25, 2020 at 12:38 AM John Dammeyer 
wrote:


BTW,  Check out
https://lsicsi.com/datasheets/LS7366R.pdf
This device is interfaced via SPI and has a 32 bit quadrature counter
module.  If you go in the direction of Raspberry Pi with LinuxCNC a device
like this can provide the spindle information.  So if someone was thinking
of building a CNC cape for a Pi a device like this would be a good idea.
There are also devices from the same manufacturer that can change
quadrature into up/down pulses streams to use regular counters inside the
Pi.

John



-Original Message-
From: R C [mailto:cjv...@gmail.com]
Sent: May-24-20 6:01 PM
To: linuxcnc-users-list
Subject: Re: [Emc-users] Encoder HAL programming.


On 5/24/20 6:29 PM, andy pugh wrote:

On Mon, 25 May 2020 at 00:17, R C  wrote:


I have been following this thread.  I wrote some code that runs on an
RPI that can read a quadrature encoder, I have a few of them, with
different resolutions.

Is this something different to the normal LinuxCNC software encoder
that reads GPIO?
Is there some dedicated encoder counter hardware on the Pi?


Oh I am not running linux cnc on an rpi, I run it on a server "class"
machine.�� I was just curious about how these encoders work, and why
they didn't

work that well with my linux-cnc setup using a db25 BOB with the 2
benchtops I have.


So I decided to use an RPI (because it is easy to use GPIO pins to read
signals) and write some code to read these� encoder signals.



So I guess my answer is yes,� it is different from, what linux-cnc
running on a pi does (I would be surprised if it was similar)


I setup an RPI, hooked up a 2 line LCD display to it to display rpms,
wrote some interrupt driven code that reads the encoder and displays it
on the LCD. The idea is, I want

to try and see if I can read the encoder and then send signals back to
linux-cnc that it 'could handle".


So I have a 60ppr encoder,� 60 has a lot of dividers.� 2, 3, 4, 5, 6,
10, and 12� So if I can "transfer" a pulse with a consistent delay
exactly when the actual n-th pulse

comes in, I could turn a 60ppr� encoder into a 30, 20, 15, 12, 10, 6 or
5 ppr encoder by just skipping pulses,� while raising some GPIO pins,
that I connect to the BOB, when

I read a different set of GPIO pins directly from the encoder.



But as I said earlier,� I don't know a lot about the linux-cnc's
internals, and HAL, but it is something I am playing with to see if it
could work.


Ron



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users



___
Emc-users mailing list
Emc-users@lists.sourcefor

Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread R C
In the video I posted earlier (it's a year old)...  the guy using that 
chip says it cost  him $40,  he showed it on line for about $28.


(and that's just for the LS7366R by itself.)


https://www.youtube.com/watch?v=RLCPKa9SoF0

On 5/25/20 2:31 AM, Gene Heskett wrote:

On Monday 25 May 2020 03:35:05 John Dammeyer wrote:


BTW,  Check out
https://lsicsi.com/datasheets/LS7366R.pdf

Is cute, but the only thing it can do better than a mesa 7i90, is work at
5 volts. Both are s32 counters, but the mesa needs >3.3 volt
protections. What is its per unit cost?

And its the protections that run the price of a complete 7i90 solution
out of sight. But you also get a total of 72 i/o lines so you generally
can do a complete system for a multiaxis machine on just one of them.


This device is interfaced via SPI and has a 32 bit quadrature counter
module.  If you go in the direction of Raspberry Pi with LinuxCNC a
device like this can provide the spindle information.  So if someone
was thinking of building a CNC cape for a Pi a device like this would
be a good idea.  There are also devices from the same manufacturer
that can change quadrature into up/down pulses streams to use regular
counters inside the Pi.

But quadrature has one huge advantage over regular counters, you get both
speed AND  direction from every edge that goes by.

John


-Original Message-
From: R C [mailto:cjv...@gmail.com]
Sent: May-24-20 6:01 PM
To: linuxcnc-users-list
Subject: Re: [Emc-users] Encoder HAL programming.

On 5/24/20 6:29 PM, andy pugh wrote:

On Mon, 25 May 2020 at 00:17, R C  wrote:

I have been following this thread.  I wrote some code that runs
on an RPI that can read a quadrature encoder, I have a few of
them, with different resolutions.

Is this something different to the normal LinuxCNC software
encoder that reads GPIO?
Is there some dedicated encoder counter hardware on the Pi?

Oh I am not running linux cnc on an rpi, I run it on a server
"class" machine.�� I was just curious about how these encoders work,
and why they didn't

work that well with my linux-cnc setup using a db25 BOB with the 2
benchtops I have.


So I decided to use an RPI (because it is easy to use GPIO pins to
read signals) and write some code to read these� encoder signals.



So I guess my answer is yes,� it is different from, what linux-cnc
running on a pi does (I would be surprised if it was similar)


I setup an RPI, hooked up a 2 line LCD display to it to display
rpms, wrote some interrupt driven code that reads the encoder and
displays it on the LCD. The idea is, I want

to try and see if I can read the encoder and then send signals back
to linux-cnc that it 'could handle".


So I have a 60ppr encoder,� 60 has a lot of dividers.� 2, 3, 4, 5,
6, 10, and 12� So if I can "transfer" a pulse with a consistent
delay exactly when the actual n-th pulse

comes in, I could turn a 60ppr� encoder into a 30, 20, 15, 12, 10, 6
or 5 ppr encoder by just skipping pulses,� while raising some GPIO
pins, that I connect to the BOB, when

I read a different set of GPIO pins directly from the encoder.



But as I said earlier,� I don't know a lot about the linux-cnc's
internals, and HAL, but it is something I am playing with to see if
it could work.


Ron



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Cheers, Gene Heskett



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread R C
I actually saw a youtube video where someone was using this chip.  I 
believe he said it was like $28, and you'd still need something to read/run


it with. (also,  not running linux cnc on the pi,  the little raspberry 
pi project has nothing to do with my linux cnc machine, I just did that 
to read


the quadrature encoder.


Here's the video I found a while back: 
https://www.youtube.com/watch?v=RLCPKa9SoF0



Ron

On 5/25/20 1:35 AM, John Dammeyer wrote:

BTW,  Check out
https://lsicsi.com/datasheets/LS7366R.pdf
This device is interfaced via SPI and has a 32 bit quadrature counter module.  
If you go in the direction of Raspberry Pi with LinuxCNC a device like this can 
provide the spindle information.  So if someone was thinking of building a CNC 
cape for a Pi a device like this would be a good idea.  There are also devices 
from the same manufacturer that can change quadrature into up/down pulses 
streams to use regular counters inside the Pi.

John



-Original Message-
From: R C [mailto:cjv...@gmail.com]
Sent: May-24-20 6:01 PM
To: linuxcnc-users-list
Subject: Re: [Emc-users] Encoder HAL programming.


On 5/24/20 6:29 PM, andy pugh wrote:

On Mon, 25 May 2020 at 00:17, R C  wrote:


I have been following this thread.  I wrote some code that runs on an
RPI that can read a quadrature encoder, I have a few of them, with
different resolutions.

Is this something different to the normal LinuxCNC software encoder
that reads GPIO?
Is there some dedicated encoder counter hardware on the Pi?


Oh I am not running linux cnc on an rpi, I run it on a server "class"
machine.�� I was just curious about how these encoders work, and why
they didn't

work that well with my linux-cnc setup using a db25 BOB with the 2
benchtops I have.


So I decided to use an RPI (because it is easy to use GPIO pins to read
signals) and write some code to read these� encoder signals.



So I guess my answer is yes,� it is different from, what linux-cnc
running on a pi does (I would be surprised if it was similar)


I setup an RPI, hooked up a 2 line LCD display to it to display rpms,
wrote some interrupt driven code that reads the encoder and displays it
on the LCD. The idea is, I want

to try and see if I can read the encoder and then send signals back to
linux-cnc that it 'could handle".


So I have a 60ppr encoder,� 60 has a lot of dividers.� 2, 3, 4, 5, 6,
10, and 12� So if I can "transfer" a pulse with a consistent delay
exactly when the actual n-th pulse

comes in, I could turn a 60ppr� encoder into a 30, 20, 15, 12, 10, 6 or
5 ppr encoder by just skipping pulses,� while raising some GPIO pins,
that I connect to the BOB, when

I read a different set of GPIO pins directly from the encoder.



But as I said earlier,� I don't know a lot about the linux-cnc's
internals, and HAL, but it is something I am playing with to see if it
could work.


Ron



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread Gene Heskett
On Monday 25 May 2020 06:50:16 andy pugh wrote:

> On Mon, 25 May 2020 at 10:42, Chris Albertson 
 wrote:
> > Ideally you have just one thin cable going from controller to the
> > machine. If you like those chips just glue on on each encoder and
> > turn then encoder into a serial interfaced device.  Or use a serial
> > buss so 6 encoders can share one cable.
>
> There are elements of this to the STMBL servo drive, in that it uses
> the STM32 to count encoder (and resolver and SSI) encoders then
> reports back to LinuxCNC using the Mesa smart-serial protocol.
> This is a neat choice, as Smart-Serial is self-configuring. Plug in
> the device and all the appropriate HAL pins appear as if by magic.
>
> Smart-serial is still one cable per node, though. It's a star
> topology.

When using that as I am with a 5i25-7i76 pairing, I assume each device 
then occupies a pair of conductors back to the hosting card? I've seen 
hints of a 2nd SS channel in the firmwares for the 5i25 where two 
daughtercards were involved but so far I am using a common bob on the p2 
plug and haven't run out of i/o. Yet...

How then does one go about expanding that to 4, or even 6 channels?

> But if it will work for you, then the smart-serial STMBL code for
> STM32 is there on the STMBL Github.

Thank you Andy.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page 


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread andy pugh
On Mon, 25 May 2020 at 10:42, Chris Albertson  wrote:

> Ideally you have just one thin cable going from controller to the machine.
>  If you like those chips just glue on on each encoder and turn then encoder
> into a serial interfaced device.  Or use a serial buss so 6 encoders can
> share one cable.

There are elements of this to the STMBL servo drive, in that it uses
the STM32 to count encoder (and resolver and SSI) encoders then
reports back to LinuxCNC using the Mesa smart-serial protocol.
This is a neat choice, as Smart-Serial is self-configuring. Plug in
the device and all the appropriate HAL pins appear as if by magic.

Smart-serial is still one cable per node, though. It's a star topology.

But if it will work for you, then the smart-serial STMBL code for
STM32 is there on the STMBL Github.

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread Chris Albertson
Yes, you can buy a hardware Quadrature chip.  But any modern
microcontroller like the STM32 will have hardware quadrature decoders.
The larger versions of the chip will have multiple quadrature decoders.
The chip will also have SPI.   These things cost under $1 or about $3 if
you want it on PCB ready to use.   If you buy the chip you need to design a
PCB.   I buy the microcontroller already on a PCB and in a usable form for
$3.

I like to place these not on some kind of large PCB near the main processor
but rather near the sensor.  This reduces the bulk of wire.   You can stick
the littlle computers where ever they are needed and then  snake one
(say) CANbus
cable around to connect each of them to power and data.

If you try to build a cape that does everything you find that you can't.
By "everything" I mean works with a PC, with a Pi4 and with a BBB and
connects steppers and servos and VFDs and linear scales. It is best to
just put a CAN bus or whatever on the main computer and nothing else.
 This is 100% "future proof" because every part can be swapped out.

These little boards have become by "go to" universal interface board.  They
cost $3 and have hardware pulse, PWM and quadrature support in hardware and
can talk over SPI I2C or USB.  They are small and cheap enough that you can
place them where ever they are needed.
ebay.com/itm/STM32F103C8T6...
<https://www.ebay.com/itm/STM32F103C8T6-ARM-STM32-Minimum-System-Development-Board-Module-For-Arduino-HOT/372276039369?epid=23002532325=item56ad618ec9:g:VjoAAOSwkRJazxC6>

THe other design option is to use an FPGA.  That is what Mesa does and they
can put any reasonable number of counters and generaters in one FPGA but
then you have to route a ton of wires all back to that one chip.

Ideally you have just one thin cable going from controller to the machine.
 If you like those chips just glue on on each encoder and turn then encoder
into a serial interfaced device.  Or use a serial buss so 6 encoders can
share one cable.



On Mon, May 25, 2020 at 12:38 AM John Dammeyer 
wrote:

> BTW,  Check out
> https://lsicsi.com/datasheets/LS7366R.pdf
> This device is interfaced via SPI and has a 32 bit quadrature counter
> module.  If you go in the direction of Raspberry Pi with LinuxCNC a device
> like this can provide the spindle information.  So if someone was thinking
> of building a CNC cape for a Pi a device like this would be a good idea.
> There are also devices from the same manufacturer that can change
> quadrature into up/down pulses streams to use regular counters inside the
> Pi.
>
> John
>
>
> > -Original Message-
> > From: R C [mailto:cjv...@gmail.com]
> > Sent: May-24-20 6:01 PM
> > To: linuxcnc-users-list
> > Subject: Re: [Emc-users] Encoder HAL programming.
> >
> >
> > On 5/24/20 6:29 PM, andy pugh wrote:
> > > On Mon, 25 May 2020 at 00:17, R C  wrote:
> > >
> > >> I have been following this thread.  I wrote some code that runs on an
> > >> RPI that can read a quadrature encoder, I have a few of them, with
> > >> different resolutions.
> > > Is this something different to the normal LinuxCNC software encoder
> > > that reads GPIO?
> > > Is there some dedicated encoder counter hardware on the Pi?
> > >
> >
> > Oh I am not running linux cnc on an rpi, I run it on a server "class"
> > machine.�� I was just curious about how these encoders work, and why
> > they didn't
> >
> > work that well with my linux-cnc setup using a db25 BOB with the 2
> > benchtops I have.
> >
> >
> > So I decided to use an RPI (because it is easy to use GPIO pins to read
> > signals) and write some code to read these� encoder signals.
> >
> >
> >
> > So I guess my answer is yes,� it is different from, what linux-cnc
> > running on a pi does (I would be surprised if it was similar)
> >
> >
> > I setup an RPI, hooked up a 2 line LCD display to it to display rpms,
> > wrote some interrupt driven code that reads the encoder and displays it
> > on the LCD. The idea is, I want
> >
> > to try and see if I can read the encoder and then send signals back to
> > linux-cnc that it 'could handle".
> >
> >
> > So I have a 60ppr encoder,� 60 has a lot of dividers.� 2, 3, 4, 5, 6,
> > 10, and 12� So if I can "transfer" a pulse with a consistent delay
> > exactly when the actual n-th pulse
> >
> > comes in, I could turn a 60ppr� encoder into a 30, 20, 15, 12, 10, 6 or
> > 5 ppr encoder by just skipping pulses,� while raising some GPIO pins,
> > that I connect to the BOB, when
> >
> > I read a different set of GPIO pins directly from the en

Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread Gene Heskett
On Monday 25 May 2020 03:35:05 John Dammeyer wrote:

> BTW,  Check out
> https://lsicsi.com/datasheets/LS7366R.pdf
> This device is interfaced via SPI and has a 32 bit quadrature counter
> module.  If you go in the direction of Raspberry Pi with LinuxCNC a
> device like this can provide the spindle information.  So if someone
> was thinking of building a CNC cape for a Pi a device like this would
> be a good idea.  There are also devices from the same manufacturer
> that can change quadrature into up/down pulses streams to use regular
> counters inside the Pi.
>
> John
>
> > -Original Message-
> > From: R C [mailto:cjv...@gmail.com]
> > Sent: May-24-20 6:01 PM
> > To: linuxcnc-users-list
> > Subject: Re: [Emc-users] Encoder HAL programming.
> >
> > On 5/24/20 6:29 PM, andy pugh wrote:
> > > On Mon, 25 May 2020 at 00:17, R C  wrote:
> > >> I have been following this thread.  I wrote some code that runs
> > >> on an RPI that can read a quadrature encoder, I have a few of
> > >> them, with different resolutions.
> > >
> > > Is this something different to the normal LinuxCNC software
> > > encoder that reads GPIO?
> > > Is there some dedicated encoder counter hardware on the Pi?
> >
> > Oh I am not running linux cnc on an rpi, I run it on a server
> > "class" machine.�� I was just curious about how these encoders work,
> > and why they didn't
> >
> > work that well with my linux-cnc setup using a db25 BOB with the 2
> > benchtops I have.
> >
> >
> > So I decided to use an RPI (because it is easy to use GPIO pins to
> > read signals) and write some code to read these� encoder signals.
> >
> >
> >
> > So I guess my answer is yes,� it is different from, what linux-cnc
> > running on a pi does (I would be surprised if it was similar)
> >
> >
> > I setup an RPI, hooked up a 2 line LCD display to it to display
> > rpms, wrote some interrupt driven code that reads the encoder and
> > displays it on the LCD. The idea is, I want
> >
> > to try and see if I can read the encoder and then send signals back
> > to linux-cnc that it 'could handle".
> >
> >
> > So I have a 60ppr encoder,� 60 has a lot of dividers.� 2, 3, 4, 5,
> > 6, 10, and 12� So if I can "transfer" a pulse with a consistent
> > delay exactly when the actual n-th pulse
> >
> > comes in, I could turn a 60ppr� encoder into a 30, 20, 15, 12, 10, 6
> > or 5 ppr encoder by just skipping pulses,� while raising some GPIO
> > pins, that I connect to the BOB, when
> >
> > I read a different set of GPIO pins directly from the encoder.
> >
> >
> >
> > But as I said earlier,� I don't know a lot about the linux-cnc's
> > internals, and HAL, but it is something I am playing with to see if
> > it could work.
> >
> >
> > Ron
> >
> >
> >
> > ___
> > Emc-users mailing list
> > Emc-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/emc-users
>
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users


Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page <http://geneslinuxbox.net:6309/gene>


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-25 Thread John Dammeyer
BTW,  Check out 
https://lsicsi.com/datasheets/LS7366R.pdf
This device is interfaced via SPI and has a 32 bit quadrature counter module.  
If you go in the direction of Raspberry Pi with LinuxCNC a device like this can 
provide the spindle information.  So if someone was thinking of building a CNC 
cape for a Pi a device like this would be a good idea.  There are also devices 
from the same manufacturer that can change quadrature into up/down pulses 
streams to use regular counters inside the Pi.

John


> -Original Message-
> From: R C [mailto:cjv...@gmail.com]
> Sent: May-24-20 6:01 PM
> To: linuxcnc-users-list
> Subject: Re: [Emc-users] Encoder HAL programming.
> 
> 
> On 5/24/20 6:29 PM, andy pugh wrote:
> > On Mon, 25 May 2020 at 00:17, R C  wrote:
> >
> >> I have been following this thread.  I wrote some code that runs on an
> >> RPI that can read a quadrature encoder, I have a few of them, with
> >> different resolutions.
> > Is this something different to the normal LinuxCNC software encoder
> > that reads GPIO?
> > Is there some dedicated encoder counter hardware on the Pi?
> >
> 
> Oh I am not running linux cnc on an rpi, I run it on a server "class"
> machine.�� I was just curious about how these encoders work, and why
> they didn't
> 
> work that well with my linux-cnc setup using a db25 BOB with the 2
> benchtops I have.
> 
> 
> So I decided to use an RPI (because it is easy to use GPIO pins to read
> signals) and write some code to read these� encoder signals.
> 
> 
> 
> So I guess my answer is yes,� it is different from, what linux-cnc
> running on a pi does (I would be surprised if it was similar)
> 
> 
> I setup an RPI, hooked up a 2 line LCD display to it to display rpms,
> wrote some interrupt driven code that reads the encoder and displays it
> on the LCD. The idea is, I want
> 
> to try and see if I can read the encoder and then send signals back to
> linux-cnc that it 'could handle".
> 
> 
> So I have a 60ppr encoder,� 60 has a lot of dividers.� 2, 3, 4, 5, 6,
> 10, and 12� So if I can "transfer" a pulse with a consistent delay
> exactly when the actual n-th pulse
> 
> comes in, I could turn a 60ppr� encoder into a 30, 20, 15, 12, 10, 6 or
> 5 ppr encoder by just skipping pulses,� while raising some GPIO pins,
> that I connect to the BOB, when
> 
> I read a different set of GPIO pins directly from the encoder.
> 
> 
> 
> But as I said earlier,� I don't know a lot about the linux-cnc's
> internals, and HAL, but it is something I am playing with to see if it
> could work.
> 
> 
> Ron
> 
> 
> 
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread John Dammeyer
> 
> On Mon, 25 May 2020 at 00:17, R C  wrote:
> 
> > I have been following this thread.  I wrote some code that runs on an
> > RPI that can read a quadrature encoder, I have a few of them, with
> > different resolutions.
> 
> Is this something different to the normal LinuxCNC software encoder
> that reads GPIO?
> Is there some dedicated encoder counter hardware on the Pi?
> 
> --

The Pi doesn’t have QEI hardware.  In fact the PIC32 I've ported my ELS code to 
doesn't have a QEI so it too is limited to whatever BASE rate that could set 
up.  With the PIC32 it can be much higher than 50uS.

In the old days, when the biggest processor available for embedded systems was 
the 16 bit MC68000 most stuff was done with 8 bit micro's and external 
hardware.   One system I designed for measuring rig heave on drilling platforms 
tracked encoders on a cable attached to the ocean floor and to the drill ship.  
The other was on the cable that held the drill string.

As the tide or ocean swell lifted the boat the encoder reported how much the 
ship moved upwards and signaled the servo on the drill string cable to lower 
the drill string by a corresponding amount.  This kept the same load on the 
drill bit a few thousand feet down.  Otherwise it could pick up and slam down 
damaging the cutter.

Since we didn't have the fancy Digital Signal Processors we used LSI Computer 
Systems LS7066 and  LS7266R devices.  They had an bit parallel bus interface to 
two 24 bit quadrature counters.   At something equivalent to the LinuxCNC base 
rate the code would read the counters.

Now that's all done with programmable logic inside FPGA devices and the 
counters are larger.   With a 10MHz clock rate they can even debounce edges if 
need be.  Access to these is done on some products with SPI bus also running 10 
MBPS which the Raspberry Pi can do very easily.That math works out like 
this:  32 bits is requested with say a command and an address byte for a total 
of 6 bytes transferred(48 bits).   So READ from ADDRESS X for 4 bytes 
incrementing the address after each read requires 4.8 micro-seconds.

Now let's do the math on the other side.  A spindle turning 6000 RPM with a 
2500 line encoder generates 10,000 edges per rev at a rate of 1MHz or one edge 
every 1 microsecond.That means roughly 4 or  5 edges will be counted every 
4.8 microseconds.   But you'd use the BASE thread running 50uS to actually get 
this data and probably use it in the SERVO thread once every 1mS.

What do you get then at 50 uS?  Theoretically 50 edges at 6000 RPM.  That's 50 
out 10,000 or 1.8 degrees.  Drop the RPM by 10 to 600 RPM and you'd now get 5 
pulses every 50 uS or 0.18 degrees.What does all that mean?

Well, if tapping 20 TPI (0.05" pitch) at 600 RPM that 0.18 degrees works out to 
0.25" every 50 uS.  So if you are threading or tapping at 600 RPM then 
every 50uS the Z axis has to move 0.25".  My mill has a 4TPI screw turned 
1:3 with a Gecko driven stepper motor.  That's 6000 steps per 0.25" or 
0.41667" per step.   So really the Z axis will only get a step pulse every 
2 BASE Periods or so.

Back to the original question then.  Can the Pi do this?  As Andy has said, 
unless you have a RTOS of sort running on the Pi you can't get a deterministic 
50uS BASE Thread or for that matter even a SERVO thread.  And then getting 
smooth motion linked to the spindle can be difficult. 

So if your encoder is limited to 100 PPR and you have an accurate 50uS BASE 
thread period then you can count encoder pulses.  Otherwise it's easiest, and 
best just to use hardware.  

John Dammeyer





___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread Gene Heskett
On Sunday 24 May 2020 20:29:28 andy pugh wrote:

> On Mon, 25 May 2020 at 00:17, R C  wrote:
> > I have been following this thread.  I wrote some code that runs on
> > an RPI that can read a quadrature encoder, I have a few of them,
> > with different resolutions.
>
> Is this something different to the normal LinuxCNC software encoder
> that reads GPIO?
> Is there some dedicated encoder counter hardware on the Pi?

No. I expect the linuxcnc software would work within its limits.  But I 
am useing a 7i90HD which is programmed to run over SPI, and does it 
quite well. IOW, I still have a normal network available on mine.  The 
7i90 has 4 hardware encoders available in the file I have loaded into 
mine, using 3, one for the spindle and 2 for jog dials on the Sheldon.  
So I can drive it by hand or as cnc.

While here, I'll relay that the buildbots pi4b has not been building well 
for a day or 4, something about insane headers when I tried it here.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page 


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread andy pugh
On Mon, 25 May 2020 at 02:03, R C  wrote:

> So I decided to use an RPI (because it is easy to use GPIO pins to read
> signals) and write some code to read these  encoder signals.

It's pretty easy to read GPIO with LinuxCNC, and at least as easily as
with a Pi.

Now, an Arduino with dedicated quadrature hardware counters might make
sense, but the Pi can't do anything that LinuxCNC can't do,

_How_ are you reading the encoder on the Pi? If it is not in the
context of a realtime thread then it might be _fast_ but it won't be
accurate.

I have read encoders at impressive speed inside Excel VBA. It works
great except that every few seconds, it doesn't. Because the OS finds
something better to do.
If your Pi isn't running something realtime-patched (like, for
example, LinuxCNC and the preempt-rt kernel) then it might count fast,
but it wont count accurate.


-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread Dan Henderson
As Gene pointed out, the typical Chinese BOB for sell uses optocouplers on
the input/outputs. The reason this is done is to prevent damage to the
mothership should a short or another nasty occur on the far end of the
connection. I’ve not tried his suggestion of bypassing them, but I have
tried three different BOB variations  and each provided the same results
with my encoder.

On Sun, May 24, 2020 at 7:32 PM andy pugh  wrote:

> On Mon, 25 May 2020 at 00:17, R C  wrote:
>
> > I have been following this thread.  I wrote some code that runs on an
> > RPI that can read a quadrature encoder, I have a few of them, with
> > different resolutions.
>
> Is this something different to the normal LinuxCNC software encoder
> that reads GPIO?
> Is there some dedicated encoder counter hardware on the Pi?
>
> --
> atp
> "A motorcycle is a bicycle with a pandemonium attachment and is
> designed for the especial use of mechanical geniuses, daredevils and
> lunatics."
> — George Fitch, Atlanta Constitution Newspaper, 1912
>
>
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
>

___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread R C


On 5/24/20 6:29 PM, andy pugh wrote:

On Mon, 25 May 2020 at 00:17, R C  wrote:


I have been following this thread.  I wrote some code that runs on an
RPI that can read a quadrature encoder, I have a few of them, with
different resolutions.

Is this something different to the normal LinuxCNC software encoder
that reads GPIO?
Is there some dedicated encoder counter hardware on the Pi?



Oh I am not running linux cnc on an rpi, I run it on a server "class" 
machine.   I was just curious about how these encoders work, and why 
they didn't


work that well with my linux-cnc setup using a db25 BOB with the 2 
benchtops I have.



So I decided to use an RPI (because it is easy to use GPIO pins to read 
signals) and write some code to read these  encoder signals.




So I guess my answer is yes,  it is different from, what linux-cnc 
running on a pi does (I would be surprised if it was similar)



I setup an RPI, hooked up a 2 line LCD display to it to display rpms, 
wrote some interrupt driven code that reads the encoder and displays it 
on the LCD. The idea is, I want


to try and see if I can read the encoder and then send signals back to 
linux-cnc that it 'could handle".



So I have a 60ppr encoder,  60 has a lot of dividers.  2, 3, 4, 5, 6, 
10, and 12  So if I can "transfer" a pulse with a consistent delay 
exactly when the actual n-th pulse


comes in, I could turn a 60ppr  encoder into a 30, 20, 15, 12, 10, 6 or 
5 ppr encoder by just skipping pulses,  while raising some GPIO pins, 
that I connect to the BOB, when


I read a different set of GPIO pins directly from the encoder.



But as I said earlier,  I don't know a lot about the linux-cnc's 
internals, and HAL, but it is something I am playing with to see if it 
could work.



Ron



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread andy pugh
On Mon, 25 May 2020 at 00:17, R C  wrote:

> I have been following this thread.  I wrote some code that runs on an
> RPI that can read a quadrature encoder, I have a few of them, with
> different resolutions.

Is this something different to the normal LinuxCNC software encoder
that reads GPIO?
Is there some dedicated encoder counter hardware on the Pi?

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread Gene Heskett
On Sunday 24 May 2020 19:15:22 R C wrote:

> Hello,
>
>
> I have been following this thread.  I wrote some code that runs on an
> RPI that can read a quadrature encoder, I have a few of them, with
> different resolutions.
>
> I also have a few encoders that came with some stepper motors I got my
> hands on, still have to play with those to see what it is they exactly
> do.
>
>
> I saw this thread about "HAL programming", I don't know much about
> linux-cnc/HAL, if anything, but is there some "general" interface so
> one could 'feed' linux cnc
>
> data from an encoder?
>
>
> I started  playing/messing with these things, because it seems that
> linux-cnc has a hard time keeping up with these encoders and there's
> not a whole lot I could find

Most of that hard time is in the bob's, You can't buy one that is all ttl 
and therefore fast enough to keep up with a decent fine grained encoder 
on a spindle that might peak at 3k rpms.  So if using a $20 bob, it 
comes with opto's on its inputs. You can throw lots a money at it, or 
rip out the opto's.  I am a CET, so tracing the card and ripping out the 
opto's is my choice as all it costs me is the time. cnc4pc used to have 
a fancy bob (C1G rev-4, not rev-3) that worked well, but with all its 
bells and whistles it was 80 bucks. Now I "fix" the SainSmart bob. They 
at least give you visible input status even when fixed.


> about how to make a spindle encoder work with linux cnc
>
>
> Ron
>
> On 5/24/20 3:41 PM, John Dammeyer wrote:
> > The
> > http://linuxcnc.org/docs/html/examples/spindle.html#_spindle_feedbac
> >k document lists this example code with a footnote on the use of
> > encoder.3
> >
> > "In this example, we will assume that some encoders have already
> > been issued to axes/joints 0, 1, and 2. So the next encoder
> > available for us to attach to the spindle would be number 3. Your
> > situation may differ."
> >
> > The document isn't clear to me on this.  If I do not have encoders
> > issued for axes/joints 0,1,2 then can the spindle use encoer.0?  Or
> > are those numbers reserved for the existing axis anyway?  Which I
> > guess doesn't make sense because then there would also have to be
> > encoders for axis a,b & c and the spindle would start at 6.  I've
> > probably answered my own question.
> >
> > But if the spindle encoder is declared in the hal file first, as
> > encoder.0, does that make x,y & z then encoder.1, encoder.2 and
> > encoder.3?
> >
> > Or by default if encoders are used with x,y  are they then by
> > default 0,1 & 2?  And even if declared in the hal file in a
> > different order must be allocated as 0, 1 & 2?
> >
> > Enquiring minds need to know.
> > Thanks
> > John
> >
> >
> > # add the encoder to HAL and attach it to threads.
> > loadrt encoder num_chan=1
> > addf encoder.update-counters base-thread
> > addf encoder.capture-position servo-thread
> >
> > # set the HAL encoder to 100 pulses per revolution.
> > setp encoder.3.position-scale 100
> >
> > # set the HAL encoder to non-quadrature simple counting using A
> > only. setp encoder.3.counter-mode true
> >
> > # connect the HAL encoder outputs to LinuxCNC.
> > net spindle-position encoder.3.position => motion.spindle-revs
> > net spindle-velocity encoder.3.velocity => motion.spindle-speed-in
> > net spindle-index-enable encoder.3.index-enable <=>
> > motion.spindle-index-enable
> >
> > # connect the HAL encoder inputs to the real encoder.
> > net spindle-phase-a encoder.3.phase-A <= parport.0.pin-10-in
> > net spindle-phase-b encoder.3.phase-B
> > net spindle-index encoder.3.phase-Z <= parport.0.pin-11-in
> >
> >
> >
> >
> >
> > ___
> > Emc-users mailing list
> > Emc-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/emc-users
>
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users


Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page 


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread John Dammeyer
Hi Ron,


> -Original Message-
> From: R C [mailto:cjv...@gmail.com]
> Sent: May-24-20 4:15 PM
> To: emc-users@lists.sourceforge.net
> Subject: Re: [Emc-users] Encoder HAL programming.
> 
> Hello,
> 
> 
> I have been following this thread.� I wrote some code that runs on an
> RPI that can read a quadrature encoder, I have a few of them, with
> different resolutions.
> 
> I also have a few encoders that came with some stepper motors I got my
> hands on, still have to play with those to see what it is they exactly do.
> 
> 
> I saw this thread about "HAL programming", I don't know much about
> linux-cnc/HAL, if anything, but is there some "general" interface so one
> could 'feed' linux cnc
> 
> data from an encoder?
> 
> 
> I started� playing/messing with these things, because it seems that
> linux-cnc has a hard time keeping up with these encoders and there's not
> a whole lot I could find
> 
> about how to make a spindle encoder work with linux cnc

Just use this link and start at the beginning of the document.  
http://linuxcnc.org/docs/html/examples/spindle.html#_spindle_feedback

The examples are for the parallel port and are limited to about 100 PPR.  
That's because if the base thread is 50,000 ns (20kHz) then to detect the 
rising edges the encoder speed must not exceed half that.  

So imagine you have a 1000 line encoder on the spindle.  If you are only 
looking for speed then max is 10,000 Hz.  Divided by 100PPR and you get 10 RPS. 
 Multiply by 60 to get minute and it's 600 RPM.   So you can't detect spindle 
speed faster than 600 RPM.  And with tolerances probably 500 RPM is a better 
top end.

With the 100 PPR you can see 5000 RPM.

Now switch over to an Ethernet based board like the MESA 7i92H and the counting 
is done in hardware.  I'm pretty sure you can track quadrature with that and a 
2500 line encoder or 10,000 edges per rev.  A spindle turning 6000 RPM would 
create a pulse streak of 250kHz. Not a problem for the MESA hardware AFAIK.

A BeagleBone Black PRU interfacing to the hardware QEI would perform with that 
hi res encoder too.  But then you'd be running machinekit.  That hardware 
support isn't available on a Raspberry Pi.  So for your Pi purchase a MESA 
board.  

Best to post the question as to which version of LinuxCNC runs on a Pi3 or Pi4 
and which MESA Ethernet board works with that.
John
> 
> 
> Ron
> 



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread Dan Henderson
I put  a CUI ATM-103 encoder on my spindle motor. I’m using a parallel port
card and a BOB to interface my steppers and spindle. The spindle uses PWM
pulses and I’m able to receive the encoder inputs directly in to LCNC via
the BOB. With the encoder set to 100 PPR, it would lose count of the rpm
above 1200. I changed the PPR to 48 and am now able to track rpm from the
encoder up to around 2400. LCNC has a hard time counting the pulses in
software. Many use a hardware counter built in to the Mesa Variety of
interface cards.  For me, I really only need the feedback for rigid tapping
which is well within the rpm range I can achieve with tracking.

On Sun, May 24, 2020 at 6:17 PM R C  wrote:

> Hello,
>
>
> I have been following this thread.  I wrote some code that runs on an
> RPI that can read a quadrature encoder, I have a few of them, with
> different resolutions.
>
> I also have a few encoders that came with some stepper motors I got my
> hands on, still have to play with those to see what it is they exactly do.
>
>
> I saw this thread about "HAL programming", I don't know much about
> linux-cnc/HAL, if anything, but is there some "general" interface so one
> could 'feed' linux cnc
>
> data from an encoder?
>
>
> I started  playing/messing with these things, because it seems that
> linux-cnc has a hard time keeping up with these encoders and there's not
> a whole lot I could find
>
> about how to make a spindle encoder work with linux cnc
>
>
> Ron
>
>
> On 5/24/20 3:41 PM, John Dammeyer wrote:
> > The
> > http://linuxcnc.org/docs/html/examples/spindle.html#_spindle_feedback
> > document lists this example code with a footnote on the use of encoder.3
> >
> > "In this example, we will assume that some encoders have already been
> issued to axes/joints 0, 1, and 2. So the next encoder available for us to
> attach to the spindle would be number 3. Your situation may differ."
> >
> > The document isn't clear to me on this.  If I do not have encoders
> issued for axes/joints 0,1,2 then can the spindle use encoer.0?  Or are
> those numbers reserved for the existing axis anyway?  Which I guess doesn't
> make sense because then there would also have to be encoders for axis a,b &
> c and the spindle would start at 6.  I've probably answered my own question.
> >
> > But if the spindle encoder is declared in the hal file first, as
> encoder.0, does that make x,y & z then encoder.1, encoder.2 and encoder.3?
> >
> > Or by default if encoders are used with x,y  are they then by default
> 0,1 & 2?  And even if declared in the hal file in a different order must be
> allocated as 0, 1 & 2?
> >
> > Enquiring minds need to know.
> > Thanks
> > John
> >
> >
> > # add the encoder to HAL and attach it to threads.
> > loadrt encoder num_chan=1
> > addf encoder.update-counters base-thread
> > addf encoder.capture-position servo-thread
> >
> > # set the HAL encoder to 100 pulses per revolution.
> > setp encoder.3.position-scale 100
> >
> > # set the HAL encoder to non-quadrature simple counting using A only.
> > setp encoder.3.counter-mode true
> >
> > # connect the HAL encoder outputs to LinuxCNC.
> > net spindle-position encoder.3.position => motion.spindle-revs
> > net spindle-velocity encoder.3.velocity => motion.spindle-speed-in
> > net spindle-index-enable encoder.3.index-enable <=>
> motion.spindle-index-enable
> >
> > # connect the HAL encoder inputs to the real encoder.
> > net spindle-phase-a encoder.3.phase-A <= parport.0.pin-10-in
> > net spindle-phase-b encoder.3.phase-B
> > net spindle-index encoder.3.phase-Z <= parport.0.pin-11-in
> >
> >
> >
> >
> >
> > ___
> > Emc-users mailing list
> > Emc-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/emc-users
>
>
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
>

___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread R C

Hello,


I have been following this thread.  I wrote some code that runs on an 
RPI that can read a quadrature encoder, I have a few of them, with 
different resolutions.


I also have a few encoders that came with some stepper motors I got my 
hands on, still have to play with those to see what it is they exactly do.



I saw this thread about "HAL programming", I don't know much about 
linux-cnc/HAL, if anything, but is there some "general" interface so one 
could 'feed' linux cnc


data from an encoder?


I started  playing/messing with these things, because it seems that 
linux-cnc has a hard time keeping up with these encoders and there's not 
a whole lot I could find


about how to make a spindle encoder work with linux cnc


Ron


On 5/24/20 3:41 PM, John Dammeyer wrote:

The
http://linuxcnc.org/docs/html/examples/spindle.html#_spindle_feedback
document lists this example code with a footnote on the use of encoder.3

"In this example, we will assume that some encoders have already been issued to 
axes/joints 0, 1, and 2. So the next encoder available for us to attach to the spindle 
would be number 3. Your situation may differ."

The document isn't clear to me on this.  If I do not have encoders issued for 
axes/joints 0,1,2 then can the spindle use encoer.0?  Or are those numbers reserved 
for the existing axis anyway?  Which I guess doesn't make sense because then there 
would also have to be encoders for axis a,b & c and the spindle would start at 
6.  I've probably answered my own question.

But if the spindle encoder is declared in the hal file first, as encoder.0, does 
that make x,y & z then encoder.1, encoder.2 and encoder.3?

Or by default if encoders are used with x,y  are they then by default 0,1 & 2?  
And even if declared in the hal file in a different order must be allocated as 0, 1 & 2?

Enquiring minds need to know.
Thanks
John


# add the encoder to HAL and attach it to threads.
loadrt encoder num_chan=1
addf encoder.update-counters base-thread
addf encoder.capture-position servo-thread

# set the HAL encoder to 100 pulses per revolution.
setp encoder.3.position-scale 100

# set the HAL encoder to non-quadrature simple counting using A only.
setp encoder.3.counter-mode true

# connect the HAL encoder outputs to LinuxCNC.
net spindle-position encoder.3.position => motion.spindle-revs
net spindle-velocity encoder.3.velocity => motion.spindle-speed-in
net spindle-index-enable encoder.3.index-enable <=> motion.spindle-index-enable

# connect the HAL encoder inputs to the real encoder.
net spindle-phase-a encoder.3.phase-A <= parport.0.pin-10-in
net spindle-phase-b encoder.3.phase-B
net spindle-index encoder.3.phase-Z <= parport.0.pin-11-in





___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread Gene Heskett
On Sunday 24 May 2020 17:41:33 John Dammeyer wrote:

> The
> http://linuxcnc.org/docs/html/examples/spindle.html#_spindle_feedback
> document lists this example code with a footnote on the use of
> encoder.3
>
> "In this example, we will assume that some encoders have already been
> issued to axes/joints 0, 1, and 2. So the next encoder available for
> us to attach to the spindle would be number 3. Your situation may
> differ. "
>
> The document isn't clear to me on this.  If I do not have encoders
> issued for axes/joints 0,1,2 then can the spindle use encoer.0?  Or
> are those numbers reserved for the existing axis anyway?  Which I
> guess doesn't make sense because then there would also have to be
> encoders for axis a,b & c and the spindle would start at 6.  I've
> probably answered my own question.
>
> But if the spindle encoder is declared in the hal file first, as
> encoder.0, does that make x,y & z then encoder.1, encoder.2 and
> encoder.3?

You can AFIAK, use them in any order in the hal file.
Same with steppers, or pwm-gen's, the hal file can assign them in any 
order.

Mesa may demand no missing numbers to work correctly, but I doubt it.

> Or by default if encoders are used with x,y  are they then by
> default 0,1 & 2?  And even if declared in the hal file in a different
> order must be allocated as 0, 1 & 2?

"Default use order" is generally up to the coder writing the hal file. 
Totally arbitrary order IOW.

> Enquiring minds need to know.
> Thanks
> John
>
>
> # add the encoder to HAL and attach it to threads.
> loadrt encoder num_chan=1
> addf encoder.update-counters base-thread
> addf encoder.capture-position servo-thread
>
> # set the HAL encoder to 100 pulses per revolution.
> setp encoder.3.position-scale 100
>
> # set the HAL encoder to non-quadrature simple counting using A only.
> setp encoder.3.counter-mode true
>
> # connect the HAL encoder outputs to LinuxCNC.
> net spindle-position encoder.3.position => motion.spindle-revs
> net spindle-velocity encoder.3.velocity => motion.spindle-speed-in
> net spindle-index-enable encoder.3.index-enable <=>
> motion.spindle-index-enable
>
> # connect the HAL encoder inputs to the real encoder.
> net spindle-phase-a encoder.3.phase-A <= parport.0.pin-10-in
> net spindle-phase-b encoder.3.phase-B
> net spindle-index encoder.3.phase-Z <= parport.0.pin-11-in
>
>
>
>
>
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users


Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page 


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread andy pugh
On Sun, 24 May 2020 at 22:44, John Dammeyer  wrote:

> But if the spindle encoder is declared in the hal file first, as encoder.0, 
> does that make x,y & z then encoder.1, encoder.2 and encoder.3?

It's HAL. You can connect any encoder to any axis and control it with
any stepgen or pwmgen. There is no requirement that the numbering be
consistent.

(For example on my lathe the X axis is revolver 0, Z is resolver 1 and
the spindle is Resolver 4. (for convenience)


--
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Encoder HAL programming.

2020-05-24 Thread Peter C. Wallace

On Sun, 24 May 2020, John Dammeyer wrote:


Date: Sun, 24 May 2020 21:41:33 + (UTC)
From: John Dammeyer 
Reply-To: "Enhanced Machine Controller (EMC)"

To: "'Enhanced Machine Controller (EMC)'" 
Subject: [Emc-users] Encoder HAL programming.

The
http://linuxcnc.org/docs/html/examples/spindle.html#_spindle_feedback
document lists this example code with a footnote on the use of encoder.3

"In this example, we will assume that some encoders have already been issued 
to axes/joints 0, 1, and 2. So the next encoder available for us to attach to 
the spindle would be number 3. Your situation may differ. "


The document isn't clear to me on this.  If I do not have encoders issued for 
axes/joints 0,1,2 then can the spindle use encoer.0?  Or are those numbers 
reserved for the existing axis anyway?  Which I guess doesn't make sense 
because then there would also have to be encoders for axis a,b & c and the 
spindle would start at 6.  I've probably answered my own question.


But if the spindle encoder is declared in the hal file first, as encoder.0, 
does that make x,y & z then encoder.1, encoder.2 and encoder.3?


Or by default if encoders are used with x,y  are they then by default 0,1 & 
2?  And even if declared in the hal file in a different order must be 
allocated as 0, 1 & 2?


Enquiring minds need to know.
Thanks
John


Encoder numbering (like most hardware including stepgens/pwmgens etc) is 
_entirely arbitrary_


When instantiated, they are often instantiated by count so you get  0 .. N-1 
range.



Peter Wallace
Mesa ELectronics


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users