Hi everybody, I would love if some of you could help me with a huge doubt on how to connect a Solenoid to my cnc shield.
I have a 12 V/ 2A solenoid and I want to control it with my arduino UNO.
Gonna use 2 0.4 A steppers (not working at the same time) and that's why I got a CNC shield.
But I don't know where to connect the solenoid and how. I got this diagram to connect my solenoid but I don't know how it works, what is the diode and the transistor (TIP) for? then how can I connect it to my cnc shield? what pins can I use?
Here is how the CNC shield V3 pins are mapped to the Uno.
So, for example, you could connect the base of the transistor (ARDUINO_DIGITAL_OUT) to the Abort pin of the CNC shield and the ground of your circuit (ARDUINO_GND) to black header pin next to the Abort pin. Then in your code make the A0 (pin 14) an OUTPUTand control the solenoid with digitalWrite().
The diode is called a flyback diode and it dissipates the high reverse voltage that is generated by the solenoid when the solenoid turns off. Without the diode the transistor would be destroyed by the high voltage spike.
When you digitalWrite a LOW on the base of the transistor the transistor is cut-off and no current can flow through the solenoid. When you digitalWrite a HIGH to the base of transistor, the transistor conducts and allows current to flow through the solenoid so that it will activate.
I see, thank you for your help. I have some other questions about what you typed. You said I could connect the base of the thansistor to the abort pin, but the abord pin according to the image, isn't an analog input instead of an output? besides, is it neccesary to be analog instead of digital? or can I use other pins instead?
My last question is, where do I connect the solenoid power V+ and GND of the diagram that I uploaded before? I made this image and I want to know if it's right if I connect the solenoid power in the same voltage input (dual blue socket) as the 12V power supply. Is it ok? Thanks
I'm kinda rookie, sorry
The analog input pins are, in reality, digital pins with analog input as a special function. Those pins have all of the attributes of any digital pin. So to use A0 as an output, just put pinMode(A0, OUTPUT);
in setup() and use digitalWrite to control the state of the pin or digitalRead to obtain the state of the pin. Or, if used as a digital pin you can also refer to A0 as pin 14.
If you are using the X and Y steppers, pins 2, 3, 5, 6 and 8 are used. So pins 4 (Z step) and 7 (Z dir) are free. If you are not using any of the limit switches, those pins are free (9, 10, 11) as are the spindle control pins (12 and 13) if no spindle control is desired.
Is the solenoid a 12V solenoid? If so then the wiring that you show should work. If the solenoid is not a 12V solenoid you will need a supply of the proper voltage.
Actually I am using the X and Z shield steppers. So what pins are free to use them as digital output?
I get now what is the diode for, and the transistor?
And finally (I swear), in the diagram that I showed, three GND are linked in a node :
and Arduino GND, a GND and the solenoid power GND.
How do I connect these three GND together as shown in the diagram?
So pins 3 (Y step) and 6 (Y dir) are free instead of pin 4 (Z step) and pin 7 (Z dir).
The transistor acts as a switch to control the 12V through the solenoid (it is a 12V device, right?) The Uno cannot drive the solenoid because the Uno outputs can only provide 5V at 20 mA max. But 5V and less than 20mA will control the transistor and the transistor can pas the 12V and the current required to actuate the solenoid.
The grounds that need to be connected are power supply ground, transistor emitter and Arduino ground. That is accomplished with the connection scheme that you diagram in reply #3.
so the minus side of the dual terminal block of the cnc shield v3 is connected to the arduino GND? is it correct?
or should I take any black header (those next to the white headers) and use it as "arduino gnd"? wouldn't it be better?
I would connect the ground side of the solenoid to the ground on the 2 terminal block. That would be the shortest path back to the power supply for the higher current. Connecting the solenoid ground to the black header would mean that the high current would have to flow through the small PCB traces. The resistance of those traces can actually cause the voltage on the ground to rise off of zero, which is bad. Always give the higher currents the shortest and "fattest" path to and from the power supply.
And, yes, the ground on the 2 terminal block is connected to the Uno ground.