![]() |
Forum Index : Microcontroller and PC projects : Quadrature encoders (yet again)
Author | Message | ||||
StoveMan Regular Member ![]() Joined: 29/03/2013 Location: United StatesPosts: 51 |
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: AustraliaPosts: 3282 |
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 StatesPosts: 51 |
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 KingdomPosts: 4036 |
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. John |
||||
bigfix Senior Member ![]() Joined: 20/02/2014 Location: AustriaPosts: 129 |
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 KingdomPosts: 4036 |
More performance :) LPC1768 512K flash 64K RAM up to 100MHz cpu can do USB OTG, CAN, Ethernet John |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
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 KingdomPosts: 1646 |
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 KingdomPosts: 1646 |
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. |
||||
StoveMan Regular Member ![]() Joined: 29/03/2013 Location: United StatesPosts: 51 |
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 KingdomPosts: 1646 |
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. 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 KingdomPosts: 1646 |
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 StatesPosts: 51 |
@ Tinine. The micro click board might just work; thanks! 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 KingdomPosts: 1646 |
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. 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 KingdomPosts: 1646 |
I just received one of these for my E-100, plus a BT Click module. Hopefully get to test these this week. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |