XY Plotter - Wiring advice needed. CNC shield, 2 stepper motors, 1 solenoid - Page 1
Forum section: electronics / beginners

author: SteveB9999
author_rank: Newbie
timestamp: May 11, 2020, 09:29:38 am
content: As a beginner I would be very appreciative if someone could have a look at the attached wiring diagram and tell me if I have made a mistake, which is very likely as this is a relatively new hobby.Note: I haven't shown the limit switches in the diagram.Many thanks.SteveArduino UnoCNC Shield (Youmile CNC Shield V3.0 Expansion Board + Arduino UNO R3 Board+DRV8255 Stepper Motor Driver with Heatsink CNC Shield V3)2 Nema 17 stepper motors (data sheet attached)1 6V solenoid (Hechen solenoid electromagnet JF-0530B DC 6V 300mA)Relay module (ARCELI 6Pcs 5V One 1 Channel Relay Module Board Shield With Optocoupler Support High And Low Level Trigger Power Supply Module)Buck converter (Valefod LM2596 DC to DC High Efficiency Voltage Regulator 3.0-40V to 1.5-35V Buck Converter DIY Power Supply Step Down Module)

author: Ian.M
author_rank: Super Contributor
timestamp: May 11, 2020, 10:43:41 am
content: What does the solenoid do? Its datasheet says its only good for momentary operation:Quote from: DatasheetIts not suitable for direct drive of a non-latching pen up/down mechanism.Apart from that, I'd probably do away with the relay and buck converter and instead drive a low Vgs threshold N-MOSFET as a low side switch with a 50% duty cycle PWM, and wire the top end of the solonoid coil to +12V for an average 6V across the solonoid when the PWM output is active. If you cant PWM it because you are using an off-the-shelf sketch you aren't comfortable modifying, or because all PWM pins are already in use, you could use a NPN power Darlington on the low side to drive it with a 12R 1W wirewound resistor in series with its emitter to limit the solonoid current to slightly over 300mA even though its feed would still be from +12V. Another alternative would be to still use a low side MOSFET to control it, but keep the buck converter to power it at 6V. In all cases you need an anti-parallel diode (cathode positive) across the solonoid coil to control the back-EMF. If you want a faster release and aren't PWMing it, put a 22R resistor in series with the diode.You are going to need to supply the Arduino with either power on its Vin pin or with a well regulated current limited 5V supply on its +5V pin. Applying 12V to Vin is problematic because the on-board regulator is poorly heatsinked and many regulators on clone Arduinos have little or no safety margin operating at that voltage. Applying external 5V to +5V pin is problematic (and not officially recommended) because it bypasses all the on-board over-current protection so a shorted output has a far higher risk of destroying the Arduino. If other parts of the system need a 5V rail with a significant current capability, use an external 5V regulator for that, and a low current polyfuse between its output and the Arduino +5V pin. If I wasn't using absolute voltage analog sensors, I'd also fit a Schottky diode between the external 5V and the +5V pin, so that you can connect the USB to update the sketch without having to power up everything else. If you are using analog sensors powered from the Arduino +5V pin, its probably best to provide a supply of between 7.5V and 9V to Vin. A LM7808 regulator (+caps - see its datasheet) would do that nicely. Bolt it down to any large aluminum chassis member to give it a bit of heatsinking. Alternativelky if you need 6V for the solonoid, it may be worth setting the buck converter to 7.5V so it can feed Arduino Vin, then putting two 1N4001 (or other 1A silicon) diodes in series with the solonoid feed to drop that to near 6V. However you'll need to verify that operating the solonoid doesn't glitch the arduino supply and maybe crash it!N.B. many Chinese so-called 2A or 3A 'LM2596' buck modules have fake LM2596 chips that operate at a far lower switching frequency. As the magnetics and capacitors on low cost modules are typically marginal for 2A output even with a genuine chip, never expect these modules to be good for more than 0.5A. Also, don't trust them not to lose regulation - if the 'set voltage' pot goes bad the output will shoot up to the input voltage and destroy any load that can't tolerate the overvoltage. Its therefore a bad idea to use them to feed anything expensive that you cant afford to replace if the module goes bad, unless you add an over-voltage crowbar circuit to blow the input fuse (*MUST* fit one) if the output rises excessively.Also, what's the nominal voltage of your stepper motors? If you want to get decent acceleration, you need a significantly higher supply voltage and to rely on the driver's current limit to keep the motor within its ratings when holding a stationary position.

author: SteveB9999
author_rank: Newbie
timestamp: May 11, 2020, 10:58:43 am
content: Hi Ian,The solenoid is used to momentarily lift the pen off the paper. I can't be sure if it will be less than a few seconds though. I was also considering using a servo, but I thought that a solenoid would allow for faster operation.

author: Ian.M
author_rank: Super Contributor
timestamp: May 11, 2020, 11:07:56 am
content: A servo gives you far better control of the pen-down speed which is important to avoid blots or nib damage. While the solonoid could be made to work you'd need some sort of mechanical latching mechanism to hold the pen up, and either another solonoid to release the latch, or a sensor to detect pen up/down state if the latch toggles. You'd probably also need a pneumatic damper to control the pen down speed

author: SteveB9999
author_rank: Newbie
timestamp: May 11, 2020, 11:42:30 am
content: Sounds good! Servo it is then.If I understand the power suggestion, I should have the 12V power the steppers through the CNC shield. Can that also be wired in parallel with a voltage regulator to run the Arduino.Something like thishttps://www.amazon.co.uk/Ranking-MB102-Breadboard-Supply-Arduino/dp/B06XZ3RJ9T/ref=sr_1_16?dchild=1&keywords=arduino+5v+power+regulator&qid=1589196979&sr=8-16Or could I use the Buck convertor I already have and just set the voltage to 5V?Thanks so much for your help.Kind regards,Steve

author: Ian.M
author_rank: Super Contributor
timestamp: May 11, 2020, 12:13:53 pm
content: The same PSU can run everything, but as I said earlier, don't trust 'chinesium' 'LM2596' modules without a crowbar circuit! e.g. if vibration causes its voltage set preset to go intermittent it will probably dump 12V onto your 5V rail and destroy all the rest of the electronics. Also it would be barely adequate for just the servo supply if you want to do high speed servo movements. N.B. keeping the servo supply separate from the general 5V logic rail is advisable to prevent the servo glitching the Arduino supply and crashing it.You can use a single buck converter set approx 0.3V high then isolate the logic rail with a Schottky diode and a big reservoir cap down-stream of it to keep the logic 5V up while the servo is overloading the buck module on rapid movement. Its probably easier simply to have separate regulators.I wouldn't recommend the breadboard regulator you linked for this project - it cant handle a lot of power and its got no safety margin operating at 12V in. Another 'LM2596' module to feed Arduino Vin with 7.5V, or a LM7808 to feed it with 8V, or a LM7805 with two diodes in the common leg to lift its output voltage above 7V would be a far better idea. Because the Arduino's internal regulator can tolerate up to 12V in, (although it will go into thermal shutdown at high load currents if the dissipation due to high Vin is excessive), you don't need a crowbar circuit on the buck module output. If the other module is only powering the servo, and you put a 470R resistor in the servo control line, worst case: if its buck module blows you'll only loose the servo, so could probably omit overvoltage protection from that as well.TheDRV8825chips (I assume DRV8255 was a typo!) will PWM the stepper motor coils at 30KHz to maintain the preset maximum current, and if I'm reading the motor spec sheet correctly, that's 1.68A at an average voltage of 2.8V. That's an average wattage of 4.7W/coil. Assuming the drivers are only 70% efficient, they'll need worst case 2.25A from the PSU, but will need a couple of big decoupling caps on the 12V rail to supply the worst case 6.75A peak current. The caps need a total ripple current rating equal to the difference 4.5A. A 12V 3A PS would marginal due to the other loads, so go for a 4A one. Alternatively you could probably repurpose a used 19V laptop or netbook PSU - the buck converters or LM78xx regulator and the stepper drivers can all accept the higher voltage, but I'd recommend a 10V 3W Zener from Arduino Vin to ground to blow a fuse if its buck converter fails

author: SteveB9999
author_rank: Newbie
timestamp: May 11, 2020, 01:26:22 pm
content: Thanks Ian,I'll need time to digest all this info!I'll update my drawing and post it once I figure out everything. Bear in mind I am a complete novice to electronics, so I only half understand your advice.Once I have updated the drawing, I'll post it to see what you think.Thanks again,Regards,Steve

author: SteveB9999
author_rank: Newbie
timestamp: May 11, 2020, 01:50:13 pm
content: Here is the CNC shield, I think it has the capacitors you mentioned.https://ooznest.co.uk/product/arduino-cnc-shield/Steve

author: Ian.M
author_rank: Super Contributor
timestamp: May 11, 2020, 02:11:21 pm
content: Yep, that appears to have a decent amount of on-board decoupling. However an extra few thousand uF would make a major difference if you are right on the edge of what a particular PSU can handle. e.g. if you have 10000uF extra capacitance, it can supply 1A for 10ms with only 1V drop, so assuming a PSU with either fold-back or constant current limiting self-resetting overload protection, can allow brief demand surges considerably higher than its nominal maximum output current.Also 'chinesium' buck modules often don't have enough bulk decoupling so may benefit from additional caps on their input and possibly output.Incidentally, you can use LM78xx regulators in TO-220 packages without a PCB. Simply solder the required (minimum) decouling chips direct to the pins as close to the body as possible, solder hookup wire to the pins, heatshrink over the joints and bolt it down remembering that the exposed tab is connected to the center common (0V) pin.

author: SteveB9999
author_rank: Newbie
timestamp: May 11, 2020, 02:27:19 pm
content: I don't see the LM7808 regulator in Fritzing app at the moment.What do you think of this updated drawing (see attached) using the 6V servo instead of the solenoid?I think I might have put the Schottky diode in wrong??ThanksSteve

author: Ian.M
author_rank: Super Contributor
timestamp: May 11, 2020, 03:18:34 pm
content: You'll find a 7805 regulator in the fritzing bin 'SparkFun-PowerIC'. As all TO-220 package 78xx series regulators from all manufacturers have the same pinout, you can use it for any of them, but for documentation purposes it would be advisable to edit it to create a new part, and set the correct voltage and part number.Otherwise it looks OK so far, but you don't actually need an anti-parallel diode on the buck output across the servo power pins. I haven't checked if your chosen servo pin conflicts with anything on the CNC shield.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 11, 2020, 03:25:14 pm
content: Quote from: Ian.M on May 11, 2020, 12:13:53 pmProbably but be very conscious that you will get very spooky behaviour if the motors cause the voltage to dip to the point the controller starts to brown out. I would advise a separate PSU for the controller until you have proven you can combine them.

author: SteveB9999
author_rank: Newbie
timestamp: May 11, 2020, 03:33:41 pm
content: I just tested the servo running through the Buck convertor with some success!I supplied the buck convertor with a 12V 800mA power. Before connecting the servo red and black wires, I used my multi-meter to adjust the convertor down to 6V.Then I connected the servo red, black to the output of the convertor, the white wire to analog output pin on the Arduino and also connected the black to ground on the Arduino. I hope this was correct.I'm very pleased that it worked. For this experiment, the Arduino was powered by USB to my PC. I do have several small 5V power supplies I can use if this is best.The next test is to power the CNC shield with the same 12V power. Do I just run a parallel red and black, or do I need something in between. Forgive me, but I am a complete novice.Thanks again.Steve

author: Ian.M
author_rank: Super Contributor
timestamp: May 11, 2020, 04:19:38 pm
content: Simply wire the CNC shield and the buck converter power (and ground) supply connections in parallel. You could join them at the power supply, or daisy chain them, joining them at the CNC shield.Unless I've misunderstood the CNC shield, the Arduino is currently running on USB power. If you want to run it standalone you need to feed power to its Vin. An alternative to the various regulator options discussed above would be to use a string of six silicon diodes in series to drop enough voltage to get Vin below 8V under load. A standalone implementation would need a display, some controls and a SD card. With no Z axis stepper, you can (just) free up enough pins to do that, including a servo output, if you use an I2C display, and a resistor/button ladder on A3 (CNC coolant enable) for the extra controls required. Before going down that road, do check that a ATmega328P based Arduino has enough memory for the application, + all the extra libraries required, as you may be forced into using an Arduino Mega2560 just for the much larger memory, with its extra pins being a bonus.

author: SteveB9999
author_rank: Newbie
timestamp: May 11, 2020, 04:28:18 pm
content: Thanks Ian,I will most likely always have it connected to my laptop running GRBL or something like that, which I think means I don't need to worry about the Arduino UNO not having enough memory for the drawing data (gcode?).I do actually have an Arduino Mega, but to be honest, now that this seems to work, I'd like to figure out how to use GRBL, or maybe write my own code.I will run the DC12V to both the CNC shield and the Buck convertor, and if I understand you correctly, I don't need a diode or anything.Thanks so much for your help.Steve

author: Ian.M
author_rank: Super Contributor
timestamp: May 11, 2020, 04:42:48 pm
content: Sounds good. With no USB power the Arduino will drag down all the pins that control the CNC shield. That *should* be OK, but if the enable signal to the board is active low, you should probably rig up some sort of external power feed for the Arduino, and make the sketch disable the steppers if its been N minutes with no data, so it doesn't sit there gently cooking the motors if the PC is off but the 12V PSU is still powered.Traditionally, most pen plotters 'talked'HP-GL(Hewlett-Packard Graphics Language), so you may wish to look into emulating that rather than G code. However that very much depends on if your preferred vector graphics applications have a HPGL output driver.For added fun you could try to figure out a pen changer so you can do multi-colour plots!