. .
Page 12 of 23 FirstFirst ... 2101112131422 ... LastLast
  1. #111
    Quote Originally Posted by Doddy View Post
    Interested to see how this goes. Glad to hear you're bit-banging, though as the 328 is inline with the axis pulses to the stepper drivers it has to keep up at all time (not just homing) and I'd be curious if you can hold the signalling whilst I2Cing the display - interesting challenge.

    I did realise after writing that the optos were for homing switches/reflection into the DDCS, so, yeah, will be fine - I'll withdraw that.
    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, Joe
    Last edited by devmonkey; 10-06-2020 at 08:23 AM.

  2. The Following User Says Thank You to devmonkey For This Useful Post:


  3. #112
    Quote Originally Posted by devmonkey View Post
    Hi Doddy,
    write your own crude framebuffer and I2C non-bocking state machine
    "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.

  4. #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.

  5. The Following User Says Thank You to devmonkey For This Useful Post:


  6. #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.

  7. #115
    Quote Originally Posted by Doddy View Post
    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.
    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.

  8. #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.

    Click image for larger version. 

Name:	hantek10_2.png 
Views:	120 
Size:	24.3 KB 
ID:	28337

  9. #117
    You're not going to get better than that!

  10. #118
    AndyUK's Avatar
    Lives in Southampton, United Kingdom. Last Activity: 2 Weeks Ago Has been a member for 6-7 years. Has a total post count of 469. Received thanks 100 times, giving thanks to others 43 times. Referred 1 members to the community.
    Quote Originally Posted by devmonkey View Post
    after a lot of messing about I just stuck the logic in a lookup table and deleted all my code ;-)
    Hahaha love it. Sometimes 'ugly' solutions are just the best.

  11. #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.

    Click image for larger version. 

Name:	IMG_20200613_133845.jpg 
Views:	136 
Size:	322.6 KB 
ID:	28364
    Last edited by devmonkey; 13-06-2020 at 01:47 PM.

  12. #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.

Page 12 of 23 FirstFirst ... 2101112131422 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. BUILD LOG: 8x4 router build. Steel base & Aluminium gantry gantry
    By D-man in forum DIY Router Build Logs
    Replies: 57
    Last Post: 13-12-2019, 10:43 AM
  2. BUILD LOG: Design stage - All steel - 1200x750x110 - aluminium capable (hopefully)
    By oliv49 in forum DIY Router Build Logs
    Replies: 3
    Last Post: 08-06-2018, 01:18 PM
  3. welding steel base or just getting aluminium extrusion
    By reefy86 in forum Gantry/Router Machines & Building
    Replies: 200
    Last Post: 15-01-2018, 08:55 AM
  4. BUILD LOG: Steel Frame, Aluminium Hybrid Design Thread
    By f1sy in forum DIY Router Build Logs
    Replies: 0
    Last Post: 23-02-2016, 10:04 AM
  5. Steel vs Aluminium
    By gavztheouch in forum Metalwork Discussion
    Replies: 4
    Last Post: 26-05-2014, 10:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •