Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:50 07 Jul 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 encoders (yet again)

Author Message
StoveMan
Regular Member

Joined: 29/03/2013
Location: United States
Posts: 51
Posted: 06:24pm 16 Dec 2016
Copy link to clipboard 
Print this post

Anyone know if a CFunction exists for tracking encoder to +1kkhz?
I have implemented many rotary encoders of the hand twirly type in MMBasic but regularly miss counts due to machine vibration (jitter) affecting the pulse stream. I am tracking the punch of a press brake (homemade) and assuring parallelism at the same time with incremental counts.
I switched to Terry Weeders (weedtech.com) serial DAQ board but it is $$ for just this functionality. I really like the way SPLATCO (aus) provides an on board quad peripheral as part of their microontroller line but their language is so clunky compared with MMBasic. They have a <clear> <set> <read> interface aimed at two pins declared as Quad Counters.
Does this fit Geoffs vision for an extension to core MMBasic functionality? The logic is easy to implement but closer access to the silicon is what I am after. the same pulse stream could be used to measure frequency as a high speed counter no?
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 06:42pm 16 Dec 2016
Copy link to clipboard 
Print this post

I have not seen a CFunction for this and I doubt that it would be possible.

I have looked at implementing the tracking of encoder outputs in the Micromite firmware but it was not easy, mainly due to the speed of the pulse train while the Micromite was still running a BASIC program. The other factor was that encoders always seem to be associated with the need for stepper outputs which are also hard to implement.

In the end I decided that it would be best to implement both stepper and encoder functionality in a dedicated microcontroller which talked I2C to the Micromite. Rather like a specific peripheral chip. Unfortunately, that is as far as I have got (ie, not far at all).

Geoff
Geoff Graham - http://geoffg.net
 
StoveMan
Regular Member

Joined: 29/03/2013
Location: United States
Posts: 51
Posted: 07:09pm 16 Dec 2016
Copy link to clipboard 
Print this post

I understand Geoff. Thank you.
Anyone have a theory on how SPLATCO.com implements Quadrature? Up until 2015 they were still using a Freescale 8 bit and still running a pseudo interpreter (virtual machine).
I have hundreds of their boards out there monitoring combustion. I really like their round robin multi-tasking too!
I'll continue with Terry's add-on boards. BTW he has serial stepper driver too; multidrop like I2C and no problem with transmission noise.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4036
Posted: 09:23pm 16 Dec 2016
Copy link to clipboard 
Print this post

If it's the EC1 etc I think it's a 32-bit ARM. Like the Teensy 3.1, which has h/w fl pt as well as 256KB flash, 64K RAM, 2K EEPROM and runs at 72MHz.

JohnEdited by JohnS 2016-12-18
 
bigfix
Senior Member

Joined: 20/02/2014
Location: Austria
Posts: 129
Posted: 11:16pm 16 Dec 2016
Copy link to clipboard 
Print this post

PoLabs is a european company which makes small affordable controllers -
They are used for Homeautomation CNC-Control etc...



I did not use them yet, but their users seem to be quite happy with them

They are quite versatile driving Steppers, reading encoders and many other type of sensors in realtime (CNC Machines do not tolerate lost pulses...)

You have a graphical programming environment - Poblocks
Either USB HID Interface or Ethernet & WEB Dashboard, Modbus TCP etc..

It should be possible to interface by I2C to the Micromite

Price is around 50 Euro

Pokey Ethernet Version

POblocks example

Features:
Ethernet 10/100 with DHCP client or fixed IP support
TCP connection with device
55 digital inputs with pull-up resistors
55 software controlled digital outputs
7 analog inputs (12-bit) with adjustable low-pass filtering support
Up to 26 encoder pair inputs (3 high-speed encoder inputs, 1 ultra high speed encoder input)
3-axis 25 kHz or 8-axis 125 kHz Pulse engine
Digital counters on specific digital input pins
Up to 16×8 matrix keyboard
Two 8×8 matrix LED display support
Up to 6 high-speed fully configurable PWM outputs support (25 MHz PWM timer)
HD44780-based character LCD support (up to 4×20 characters)
PoExtBus support for adding up to 10 external shift registers = 80 aditional outputs
PoNET devices support (48-key CNC keyboard, etc…)
Modbus TCP support (access to digital IO, analog inputs, encoders’ counters, digital counters values, PWM outputs, LCD display, LED matrix display, PoExtBus devices, matrix keyboard status)
Support for up to 10 sensors on I2C bus, up to 10 sensors on 1-wire bus and up to 7 analog sensors
Web interface with newly designed dashboard and I/O status display with multiple user accounts
Support for communication with devices on I2C and 1-wire buses
Support for Connection signal output
Intuitive and user-friendly software
Third-party support via communication DLL library and extensive protocol specification document that allows porting to other systems
Plugin for Mach3 and Mach4 software, PoKeys as 4-axis external motion controller or general purpose, highly cusomizable Human Machine Interface
PoBlocks graphical programming PLC software
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4036
Posted: 12:16am 17 Dec 2016
Copy link to clipboard 
Print this post

More performance :)

LPC1768 512K flash 64K RAM up to 100MHz
cpu can do USB OTG, CAN, Ethernet

JohnEdited by JohnS 2016-12-18
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 02:37pm 17 Dec 2016
Copy link to clipboard 
Print this post

Up/Dn count or SPI versions

If you go Up/Dn option, feed to two of MMs 300KHz counters and subtract one value from the other.

HCTL-2032

A PIC with QEI (quadrature encoder interface)

Supported by Great Cow BASIC, etc.

My favourite for machine-tool applications
If your encoder has complementary outputs (A, -A, B, -B, I, -I), this already has the line-receiver.
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 03:07pm 17 Dec 2016
Copy link to clipboard 
Print this post

Are you merely tracking or closing the loop on a hydraulic servo-proportional valve?

Check the data-sheet for PWM to +/-10v conversion
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 03:26pm 17 Dec 2016
Copy link to clipboard 
Print this post

Forgot to mention the Parallax Propeller. There are sofware objects in the "OBEX" (object exchange) for reading up to 16 encoders in a single one of the 8-available cogs (processors).

I rolled my own, using PropBASIC and am currently reading 4 encoders. Max frequency is ~2M quadrature counts/sec.Edited by Tinine 2016-12-19
 
StoveMan
Regular Member

Joined: 29/03/2013
Location: United States
Posts: 51
Posted: 08:41pm 21 Dec 2016
Copy link to clipboard 
Print this post

Thanks for all the replies!
@ Bigfix... Great stuff that PoKeys. I got engrossed with Gearotic from Art F. of Mach3 fame from your link. I ordered a cnc board to convert my mill from your heads-up. Thanks.
@ Tinine... I like the Prop idea but want to stay with the MM+ for SD card native support for bend table random access records and GUI pages; and because I am already invested in HW and SW.
I will probably stay with my Weedtech solution as it it's dead easy to add functionality to MM with these boards (just $$).
For those who haven't used the SPLATCO boards I love their idea of round robin multitasking. These are not fast boards but they get alot done by optimizing timing. They aim directly at embedded control with an interpreted layer. Could MMbasic be configured thus?

A "task" is just a block of code that executes when the main loop encounters a blocking expression (pause, wait, etc). A task will suspend and switch due to system timer, interrupt, or yield instruction. Although it is a simple time sharing architecture it allows efficient use of clock cycles to attend to lower priority loops; and is particularly effective when the instructions wont fit into an interrupt. They allow up to 32 of these tasks to be maintained in a stack. I have found that this obviates the need for a super long main loop with endless sub/function branches. Each "task' handles a ... well task ie GUI, serials, Maths, data logging, etc.
This functionality is what i miss most in MMBasic. A true RTOS is not going to happen in an interpreted layer. But if we are truly focusing the Mite on embedded control, and diverging from GWBasic; why sit and wait like nothing needs to be done?
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 10:29pm 21 Dec 2016
Copy link to clipboard 
Print this post

  StoveMan said  
@ Tinine... I like the Prop idea but want to stay with the MM+ for SD card native support for bend table random access records and GUI pages; and because I am already invested in HW and SW.


Oh, absolutely. I was suggesting the Prop as a peripheral device to the MM. Just as MMbasic needs hardware support for high-speed serial comms and counters.

The Micromite companion is similar.

  StoveMan said  
A "task" is just a block of code that executes when the main loop encounters a blocking expression (pause, wait, etc). A task will suspend and switch due to system timer, interrupt, or yield instruction. Although it is a simple time sharing architecture it allows efficient use of clock cycles to attend to lower priority loops; and is particularly effective when the instructions wont fit into an interrupt. They allow up to 32 of these tasks to be maintained in a stack. I have found that this obviates the need for a super long main loop with endless sub/function branches. Each "task' handles a ... well task ie GUI, serials, Maths, data logging, etc.
This functionality is what i miss most in MMBasic. A true RTOS is not going to happen in an interpreted layer. But if we are truly focusing the Mite on embedded control, and diverging from GWBasic; why sit and wait like nothing needs to be done?


This sounds like the scheduling/tasking that was recently implemented on the ByPic.
I think that the nearest you're gonna get in MMbasic is a state machine.

BTW, I'd forgotten about the Click module with the 7366.


 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 12:17am 22 Dec 2016
Copy link to clipboard 
Print this post

I build industrial control systems for a living and am currently working on my "ultimate process control system".

At this point, I have narrowed it down to the MM+, married to one or more Propellers (perfect for real-time).

My GUI is a "ruggedized" tablet that I have been using for the past four years which is programmed using Basic4Android (B4A). This is linked via BlueTooth.



 
StoveMan
Regular Member

Joined: 29/03/2013
Location: United States
Posts: 51
Posted: 05:49am 22 Dec 2016
Copy link to clipboard 
Print this post

@ Tinine. The micro click board might just work; thanks!

  Quote  My GUI is a "ruggedized" tablet that I have been using for the past four years which is programmed using Basic4Android (B4A). This is linked via BlueTooth.

I remember your HMI idea from another post. I did one over serial a while back and was wondering how you implemented yours?
Is the android the slave?
How do you handle bad transmission/disconnect? Is there an echo or verification for the master?
Can the master run autonomously without an expected response; IOW do we fail safe?

These were things I ran into. The comms protocol became cumbersome and ate up valuable cycles. I ended up with a modbus type packet system; wishing I'd chosen an OTS system.
Anyway I am intrigued by your idea as some type of SCADA is usually desired in a micro project.
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 10:31am 22 Dec 2016
Copy link to clipboard 
Print this post

  StoveMan said   @ Tinine. The micro click board might just work; thanks!

Incredible performance spec when you consider that most standard industrial incremental encoders are limited to 500KHz. Would've been nice if they'd daisy-chained 3 or 4 devices on the same board.


  StoveMan said  I remember your HMI idea from another post. I did one over serial a while back and was wondering how you implemented yours?
Is the android the slave?
How do you handle bad transmission/disconnect? Is there an echo or verification for the master?
Can the master run autonomously without an expected response; IOW do we fail safe?


Yes, the microcontroller is autonomous. The Android device serves as a data-in/out portal. The tablet can be carried out-of-range and brought back without problems. The display simply stops updating the axis positions, I/O status, etc. and resumes updating accordingly. Exactly the same as a BT headset would.

I use a checksum to ensure tablet-to-controller data integrity.

Should the tablet ever fail (not happened yet), all that needs to happen with the replacement is to set it up with the same email addy and pair the BT. The app (APK) will appear in the Inbox. A fresh tablet can be fully functional within 15mins of unpacking.

Surelock prevents unauthorized personnel doing something they shouldn't.

Fault finding:
Most HMIs indicate such things as sensor status but in the event of a fault, the troubleshooter is faced with the problem of the sensor being located where he can't see the HMI while manually triggering the suspect device. Thanks to the portability of the wireless HMI, it can be quickly detached from its pedestal and carried to the area of interest. All electrical and hydraulic circuit schematics are also stored on the tablet and can be searched, zoomed and scrolled.

My focus is on the shortest possible MTTR (mean-time-to-repair) and all-too-often, a piece of critical production machinery is dead-in-the-water due to a failed HMI or lost documentation.

I'm sure you can relate



 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 02:42am 26 Feb 2017
Copy link to clipboard 
Print this post

  StoveMan said   @ Tinine. The micro click board might just work; thanks!


I just received one of these for my E-100, plus a BT Click module. Hopefully get to test these this week.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025