-
10-06-2020 #111
Hi Doddy,
So it turns out if you ditch the standard I2C/TWI wire.h library and display driver, crack open the 328p datasheet, write your own crude framebuffer and I2C non-bocking state machine that operates directly on the TWI registers you can tick the state machine at a 2-3us per tick penalty. Will put it on the scope and see if this is sufficient.
Main loop becomes:
1. Mirror stepper/home signals with squaring logic.
2. Update framebuffer if needed (using a 5x7 font this is 5 memory reads/writes per character)
3. Tick I2C state machine.
I could remove the framebuffer to make it a bit faster if required, this will effectively amortise the font copy part at one byte/I2C tick.
Cheers, JoeLast edited by devmonkey; 10-06-2020 at 08:23 AM.
-
The Following User Says Thank You to devmonkey For This Useful Post:
-
10-06-2020 #112
"Crude"?, I prefer to think of this as "fit-for-purpose".
You know as well as I do the 328 is just one of a thousand different micro controllers that pollute the oceans and the Arduinio packaging is just a convenient way of throwing that chip into an accessible form for stupidly low cost - makes them a sensible solution for even the most simple of problems. There's no reason to use the Arduino libraries unless you're concerned about cross-platform compatibility or speed/ease of development (sacrificing code base, efficiency and real-time performance). I think you'd agree programming at the register level (I gave up at the instruction level many decades ago - I prefer to have a compiler at least) adds a level of complexity and care, but if that floats-your-boat (and it does, me) then hack away to your hearts content. At least you can be confident that you know exactly that the uC is behaving exactly as you want it to.
-
10-06-2020 #113
So I've just scoped the DDCS. An axis setup as per my machine, 1610 screw, 16x ustepping -> 320 steps/mm, max speed 10000mm/min.
As expected step frequency is ~53kHz, half period of 9.375us. Nyquist/Shannon tell us that this needs to be sampled at a minimum of 2f, i.e. 106kHz for perfect reconstruction. Puts an upper bound on my mirror code latency of ~9us, so to be safe say 5us. This is 80 cpu cycles, will it fit?? Should do, got to wire it in and test.
DDCS defaults set dir 7000ns (7us) ahead of step therefore code running at 5us will always see this. EM806 only requires 2.5us but configuring DDCS to deliver this will risk breaking the contract woth EM806.
-
The Following User Says Thank You to devmonkey For This Useful Post:
-
10-06-2020 #114
Interrupt on change of state? Your time-sensitive processing is in the discrete control and not the I2C if you're using the TWI registers.
-
10-06-2020 #115
Yes it is possible you can register for toggle interrupts on any of the IO pins, trouble is my code is written in arduino/cpp at the moment, this means there is a stack to park so there is some overhead from servicing the interrupt. If the current polling approach takes too long will have a look.
-
10-06-2020 #116
So here is a baseline, the basic axis mirroring with auto squaring, but without I2C. Lag is 600ns after a lot of messing about I just stuck the logic in a lookup table and deleted all my code ;-) Yellow trace is step output from DDCS running at 10000mm/min, blue trace is the arduino step output, lag is shown in 'dt' bottom right.
-
11-06-2020 #117
You're not going to get better than that!
-
11-06-2020 #118
-
13-06-2020 #119
My dual motor homing / squaring board is now working with the DDCS. Video clip below. DDCS was told to 'home' the X axis:
1. Each motor stops when its respective home switch is activated,
2. Once both home switches are activated the board signals home to the DDCS,
3. DDCS now backs X away from home searching for switch release,
4. If one motor's home releases before the other this motor is stopped until both home switches are released,
5. Once both home switches are released the board clears home back the the DDCS and DDCS zero's X co-ordinate,
6. DDC now moves X a pre-configured distance away from home.
This logic only activates when a home switch is hit and the machine is travelling towards home. If travelling away from home either switch hit signals the DDCS (i.e. it behaves as a limit switch).
The only downside of this is that in normal operation driving the machine past home in the X- direction requires both switches to activate before limit- is signalled. This is not a problem unless one of the switches has fallen off.
Last edited by devmonkey; 13-06-2020 at 01:47 PM.
-
13-06-2020 #120
Call me stupid, but what exactly do you adjust to make the gantry square once the whole sequence has finished? What is the purpose of step 4? Do you have separate cotrol of the two X distances in 6?
An optimist says the glass is half full, a pessimist says the glass is half empty, an engineer says you're using the wrong sized glass.
Thread Information
Users Browsing this Thread
There are currently 5 users browsing this thread. (0 members and 5 guests)
Similar Threads
-
BUILD LOG: 8x4 router build. Steel base & Aluminium gantry gantry
By D-man in forum DIY Router Build LogsReplies: 57Last Post: 13-12-2019, 10:43 AM -
BUILD LOG: Design stage - All steel - 1200x750x110 - aluminium capable (hopefully)
By oliv49 in forum DIY Router Build LogsReplies: 3Last Post: 08-06-2018, 01:18 PM -
welding steel base or just getting aluminium extrusion
By reefy86 in forum Gantry/Router Machines & BuildingReplies: 200Last Post: 15-01-2018, 08:55 AM -
BUILD LOG: Steel Frame, Aluminium Hybrid Design Thread
By f1sy in forum DIY Router Build LogsReplies: 0Last Post: 23-02-2016, 10:04 AM -
Steel vs Aluminium
By gavztheouch in forum Metalwork DiscussionReplies: 4Last Post: 26-05-2014, 10:11 PM
Bookmarks