PID -Hardware needed for a software fix

New Home Forum Mostly Printed CNC – MPCNC Hardware Development – MPCNC PID -Hardware needed for a software fix

This topic contains 463 replies, has 28 voices, and was last updated by  John 3 months, 2 weeks ago.

Viewing 30 posts - 391 through 420 (of 464 total)
  • Author
    Posts
  • #64766

    Tim W
    Participant

    Shoot Todd, you already have the dimmer right, no need to buy another? Sorry brain fart on that one.

    Tim, 0-5, as far as I know all arduinos are the same.

    Just wanted to be sure you rent using the heater or something i don’t have Thanks it will make it very easy for everyone 🙂  love this system

    1 user thanked author for this post.
    #64896

    Tom Cole
    Participant

    Two things:  what are you guys using as a pot and can I get a basic wiring diagram?

    Got the board soldered and the nano programmed and I’m ready to start wiring.  I “think” I have it figured out, but would rather be sure.

    I’m not using the 660 anymore so I’m going to start with that, then moving it to the 611.

    #64902

    Ryan
    Keymaster

    No potentiometer, Speed is controlled through Gcode only for now. Working on the LCD code soon.

    I can’t find a full wiring diagram for some reason but, https://www.robotshop.com/letsmakerobots/hooking-qrd1114-line-sensor, is how I wired the sensor.

    #64903

    Ryan
    Keymaster

    I can sort out any issues you have just ask. I swear I had a wiring diagram somewhere.

    #64937

    Tom Cole
    Participant

    So, based on the attached diagram and tracing the resistors on the PCB, wiring from the “Sensor” connector on the PCB (beginning at pin beside the “+” and going left) is #1 sensor power, #3 emitter power, #4 emitter ground, #2 sensor out/ground.

    And the long legs of both the emitter and sensor are +.

    The photo vs the schematic on that page is correct but tricky because the emitter side in the photo is flipped from the schematic.  Wonder why they did that?  Best to go by the long legs for identification.

     

    Attachments:
    #64945

    Tom Cole
    Participant

    On the PCB, “Control Board” Pins reading from + to the LEFT are: Power, Ground, Ground, PWM in, and Run (aka enable).

    And the “Dimmer” Pins reading from + to the RIGHT are: Power, PWM out, and Ground.

    Correct?

    Last question: where does the extra 1k resistor go?

    #65071

    Ryan
    Keymaster

    The sensor has a pin 1 marked with a dot on the plastic.

    The extra 1k is in case we should be using it to pull down the enable pin.

    pcb

    And the “Dimmer” Pins reading from + to the RIGHT are: Power, PWM out, and Ground.

    yes

    On the PCB, “Control Board” Pins reading from + to the LEFT are: Power, Ground, Ground, PWM in, and Run (aka enable).

    I think so, I am not sure about the last two double check the pin numbers against the PID sketch. The center pin is not a ground it is open in case we want to use that extra pin for something later on (turns out it is already used on the Rambo…bummer)

    Attachments:
    #65094

    Tom Cole
    Participant

    double check the pin numbers against the PID sketch

    That is where I looked for the Arduino pinout, then I looked at the PCB to see what pin led where.

    Presently I’m figuring out what changes I have to make to Grbl.  Things are coming together.

    #65095

    Ryan
    Keymaster

    Presently I’m figuring out what changes I have to make to Grbl.

    You shouldn’t have to make any other than know where those two pins are.

    #66105

    Jeff Lawrence
    Participant

    Do you still plan on adding the anti-chatter logic to vary the speed some, or did the direction change along the way to a pure speed control circuit?

    (or is the chatter control handled by the CAM?)

    #66107

    Jeffeb3
    Participant

    It would be tough to control from CAM, since some commands have very long trajectories.

    I think the plan is to have it do the oscillations in the arduino nano, but it’s not terribly clear the best way to turn it on or off without a screen. Also, Ryan and I haven’t really coded anything yet for that.

    #66145

    Jeff Lawrence
    Participant

    Looking at the source video in the original post – he seems to vary the RPMs by about 10% continuously around the target setting and only engages it when chatter control is needed.

    Could you accomplish this with a tweak to the code so that each time the nano gets a speed control request from the control board that it actually begins a process of speed request – 10% climbing to the requested speed and then back down to request -10%?

    So Rambo says 20k, arduino starts at 18k climbs to 20k, decreases back down to 18k – repeat until next speed request change comes in.

    Kind of the opposite of all the PID control worked in the code but i guess you could use the PID to handle the individual speed requests.

    Then you have the question of how to engage – either always on or driven by end user input or some sort of chatter detection.  I wonder if it wouldn’t be easier to just leave it always on, or leverage some sort of vibration sensor on the spindle.

    Anyway more than anything was just interested to see if the goal had changed – all the PID work seemed somewhat contrary to the starting goal of the original post and I wasn’t seeing any button or external control in the board to allow this to be engaged via the user.

    #66149

    Ryan
    Keymaster

    I hope to get back to this soon. I have been running mine to make sure everything works as it should. All kinds of ideas have come with it’s actual use…including needing a screen (the code is in there just not for controls).

    #66177

    Ryan U
    Participant

    Got it all wired up this weekend and was testing\updating the configs and changing some invert configs to get it turning on and off with M3\M5 properly.

    Not sure what happened but now it only runs full power and doesn’t shut off even when disconnected from the nano control.

    New Triac?  If so, whats the best place to source (mouser, digikey?). looks like a Bt139-600, anything special?

     

    #66183

    Jeffeb3
    Participant

    Not sure what happened but now it only runs full power and doesn’t shut off even when disconnected from the nano control.

    Disconnected might be floating at high voltage. Can you connect the signal to ground (with the nano off)?

    #66184

    Ryan U
    Participant

    I tried connecting the PWM pin to GND but still get full speed on when plugging in the dimmer.

    #66196

    Ryan U
    Participant

    Does the dimmer have any type of snubbing circuit for the inductive load of the router? or do we need to add a metal oxide varistor or some type of snubbing circuit to prevent the high voltage when the motor is switched off?

    #66199

    Ryan
    Keymaster

    Does the dimmer have any type of snubbing circuit for the inductive load of the router?

    Yes

    #66201

    Ryan
    Keymaster

    If so, whats the best place to source (mouser, digikey?). looks like a Bt139-600, anything special?

    Either of those stores will work, if that is all you need. I have a couple here, if you have anything else you need from my store I can drop one in your order.

     

    I believe the snubber is the two large components right above the blue terminals.

    #66262

    Ryan U
    Participant

    Thanks. For now I ordered some BT139-600E’s from Digi key  and another dimmer board.  Can’t hurt to have a spare(if replacing the Triac fixes the old one).  Not sure what happened.

    I did read on the kinda board it has the snubbing circuit for Triac protection.

     

    #66776

    Ryan U
    Participant

    Got it working tonight.  Had to add a jumper from the Vin pin to the +5v pin on the nano board which tripped me up a bit(since I’m pulling power from the EXT2 pin which is 5v).  It would work fine when connected for debug to my laptop and then would glitch out during higher PWM when not connected.   The dimmer boards lists 5v or 3.3v so didn’t want to connect to 12v.

    Also adjusted the code a bit to move rpm value calc into the ISR so it’s only storing an int vs a long which could potentially change in the middle of a read operation outside an ISR if an interrupt occurs mid-read.

    Also changed the method to read the PWM input from Marlin to just use a pulseIn command and disabled the Pid when the enable pin is low.

    Additionally added a 10K between GND & D5 on the nano for the pull-down.

    Nice to have control now for speed and thru software.  Thanks for the design!

    #66780

    Jeffeb3
    Participant

    Had to add a jumper from the Vin pin to the +5v pin on the nano board which tripped me up a bit(since I’m pulling power from the EXT2 pin which is 5v).

    If you’re powering the nano via 5V, then don’t connect Vin. You’re shorting across the vregulator on the nano, and if you get something a little more off from 5V, then that regulator will let go of it’s magic smoke.

    Also adjusted the code a bit to move rpm value calc into the ISR so it’s only storing an int vs a long which could potentially change in the middle of a read operation outside an ISR if an interrupt occurs mid-read.

    I have been meaning to work on this, and I would instead add ATOMIC_BLOCK on the read outside the interrupt. Your way is good too though.

    Also changed the method to read the PWM input from Marlin to just use a pulseIn command

    What’s the reasoning for that? I though pulsein was slow (waiting for the whole pulse) especially if it’s not actually connected to a pulse signal.

    disabled the Pid when the enable pin is low.

    Good, it should be disabled whenever it isn’t controlling the output.

    Do you know github? Can you try to share your edits?

    #66788

    Ryan
    Keymaster

    Looks like I am going to be learning even more about programming…

    #66797

    Ryan U
    Participant

    If you’re powering the nano via 5V, then don’t connect Vin. You’re shorting across the vregulator on the nano, and if you get something a little more off from 5V, then that regulator will let go of it’s magic smoke.

    Ok, The dimmer specs mention 5v or 3.3v so was concerned on plugging in anything higher.  Are you using 12v from the power brick for the nano, sensor, and dimmer board?

    What’s the reasoning for that? I though pulsein was slow (waiting for the whole pulse) especially if it’s not actually connected to a pulse signal.

    Was more concerned at the time about multiple interrupts and this allowed me to only have the Spindle sensor on interrupts.  I only had it do pulseIn when the spindle enable pin was high so it never took too long.  I have since changed back to use the interrupt method though now that everything is working.

    I changed so the range of the PWM out and PID could use a higher range instead of 0-255.  I have it using a 0-4095 range so its not taking away resolution coming from Marlin with 0-2024.   I did add a disable of interrupts during the new analogwrite16 command since an interrupt could mess with it.

     

    Do you know github? Can you try to share your edits?

    I created a fork under the current version under rsullmann. I haven’t used github much so if there is something else I need to do let me know.   I renamed things quite a bit as I was going thru things for my understanding.

    1 user thanked author for this post.
    #66799

    Ryan U
    Participant

    I also posted a case if anyone is interested.  Its been updated a few times after printing and assembly.

    Nothing special but figure once I integrate an LCD, potentiometer, and switch I can change the cover easily.  I included some holes on top and bottom for venting but haven’t taken temps during extended testing yet so take that into consideration when using.

    https://www.thingiverse.com/thing:3034861.

     

     

     

    #66823

    Jeffeb3
    Participant

    Ok, The dimmer specs mention 5v or 3.3v so was concerned on plugging in anything higher.  Are you using 12v from the power brick for the nano, sensor, and dimmer board?

    On the nano, Vin powers an onboard regulator, which creates 5V. IIRC, the regulator is spec’d at 5-15V. You could power the nano with 5-15V on Vin or just 5V on the 5V pin (which is what happens when you connect USB). The output pins (and its PWM) are 5V regardless of if you’re using Vin or 5V. The power to the dinmer is seperate. I’m not sure how Ryan has it on his board, is that what you’re using? The sensor should be at 5V. Powering everything at 5V should be fine.

    The danger with shorting Vin to 5V is if the input is 6V somehow, then the nano 5V reg. Will try to make the 5V pin 5V, and it will move a lot of current to do it. I think there is a small range around 5V where a diode is going to stop that, but I don’t know what it is.

    #66824

    Ryan U
    Participant

    I’m not sure how Ryan has it on his board, is that what you’re using?

    Yes, I’m using Ryan’s board.  Vin is tied to dimmer and sensor power and the input from the control board(Rambo in my case).  I removed the male header terminal for Vin from the Nano and tied Vin on Ryan’s board to +5v for now.

    Everything seems to be working well.

    #66825

    Jeffeb3
    Participant

    Ok. The vin was only powering the regulator then, and if it didn’t work without jumping to 5V, then your regulator is probably already toast. At any rate, the way you’ve done it is fine.

    #66984

    JJWHarris
    Participant

    How would this work with an 8-20 pole motor? More precise or less precise with more poles?

    #66985

    Ryan
    Keymaster

    That must be above my pay grade, or it is really expensive. I have no idea what it is but I bet that is going to be a whole new rabbit hole…

Viewing 30 posts - 391 through 420 (of 464 total)

You must be logged in to reply to this topic.