Such device has been on my "someday to build" list for a long time. It was a popular video showing an Arduino based wire cutter using a 3D printer extruder and a servo driving side cutters which finally made me pull the trigger and design my own take on this topic. I'm using lots of short terminals made of solid 1mm copper wire in my builds. Pre cutting them per hand has always been a very boring procedure. This and for the simplicity of the build I didn't include any wire stripping option, although I had a few ideas on how to expand the design on the future. Someday I might do it, for now, the device as it is, has proven to be extremely useful.
At first I thought about using an Arduino as the main controller, but quickly switched back to my favorite all around MCUs: Cypress PSoCs, the CY8C4245AXI-483 from the 4200 line in this case. Being a one off evolving project, I often tend to overdesign them a little bit. The reason is, I find such projects to be a really good way to try out different solutions, interesting new ICs, expand the code base i might use in the future and just to learn and experiment. The plan was to make a base hardware which might be used for other stepper/servo related projects.
- Cuts wire pieces in preset length and count.
- 4 quick access presets for most often used jobs.
- Once started, the job can be paused, resumed or aborted.
- Calculates estimated time to end.
- Calculates required wire length to perform the task.
- Optional infrared wire presence detector.
- Single cut and rewind (remove the wire from the extruder) operations.
- Optional remote control via serial/telnet console.
- Built in help screen.
- Piezo buzzer for beeps and alarms.
- Optional footprint and surrounding components for the Cypress EZ-BLE module.
- Additional LEDs and prototyping area on the PCB.
- Show help: hold down any of the 1-9 keys, press to browse the pages, hold down again to exit.
- Enter the wire length: press #, enter the length in mm (resiolution 1mm), press * to delete the last digit if necessary, press # again to confirm the value.
- Enter the wire count: press *, enter the desired count, press * to delete the last digit if necessary, press # again to confirm the value.
- Start job: press the big red button.
- Pause/Resume job: while working, press the big red button.
- Abort job: while working, hold down the big red button for about 2 sec.
- Load one of the presets: press one of the A-B keys.
- Save the preset: hold down the red button and press A...D to store the current settings under the chosen preset.
- Perform a cut: hold down the # key.
- Quick rewind 50mm: hold down the * key.
- Turn the serial port echo on/off: hold down the red button and press the * key.
- Turn the IR wire presence on/off: hold down the 0 (zero) key, the icon will turn purple (detector is off).
The onboard ESP-12 (ESP8266) module is used as a transparent serial/Wifi bridge running the ESP-Link firmware. It is not required for the operation, though. The PCB has a 5V and a 3.3V UART pin headers available and can be used witn any type of TTL level serial converter.
help list the available commands ver show the firmware version setlen x set wire length "x" in mm. Example: setlen 55 setcnt x set wire count "x" in pcs. Example: setcnt 50 start start the new job with the current settings abort abort the currently running job reset reset the current job pause state pause/resume the current job. Examples: pause 1 (pause) pause 0 (resume) cut perform a single cut run x pull "x" mm of wire. Example: run 120 rew x rewind "x" mm of wire. Example: rew 120 report returns an 18 byte data packet containing the current settings and status of the device setcut x set the number of cuts in range 1 to 3. Example: setcut 2 freset perform the factory reset. The A-D presets will be overwritten. TMCsts prints out the TMC2130 stepper driver status
The prototype electronics was built on a home made dual layer PCB using the CY8CKIT-049 dev board, initially the A4988 stepper driver (changed to Trinamic TMC2130 Silent Step Stick), an SPI 12x128 TFT display, 4x4 keypad, MG996R servo (died shortly after), a 35W 15VDC switching power supply and a few other bits and pieces.
Most of the mechanical parts are made from the things I had laying around or could buy in a local hobby store, 10x10mm brass rod, a 1.5mm thick aluminuim sheet (3mm would be better, though), 10x10mm PVC rod, aluminum angle, some screws, nuts and magnets. An M4 cage nut + screw secured with Loctite is used to make the side cutter blades position adjustable.
A long M8 screw is used to hold the wire spool. A PVC spacer and a larger washer secured with a shrink tube acts as a rotating platform for the spool.
Both, the input and output from the extruder use an M6 screws, which are drilled through with a 4mm drill. In addition the input terminal has a small window used with the IR sensor (diode + phototransistor) to detect the presence of the wire.
Detailed view of the IR wire presence detector. An old printer is a good source for such diode + phototransistor modules, often used as paper presence detectors. The diode shines the light through the window in the inlet terminal. If there is no wire, the phototransistor will produce a logic 0 signal, a wire blocking the light will result in logic 1. I admit this method does not work 100% reliably with thin wires like the 1mm solid copper one, hence I added an option to override that function in firmware.
Some parts, that are often removed are mounted using neodymium magnets and a piece of ferrotape. I made a cover out of a thick transparent foil formed with a hot air gun. It helps the cut wire pieces land where they should. Underneath the servo there is another magnet to attach the cover when not in use.
Once I got the prototype working, I started with a final PCB design. Having the PCB fabbed I could pack the components on a significantly smaller area. The remaining space was used to add a few more extras on the board, make it more versatile and useful for any potential future projects. Things I added were: and ESP-12 (ESP8266) module, Cypress EZ-BLE module (Bluetooth low energy), a few LEDs and a prototyping area with 3.3V, 5V and GND power rails.
Here is the top view of final (almost, the latest version has a few optimizations aroung the ESP module) PCB. The type of the stepper motor drive can be set using the jumpers. The Trinamic Silent StepStick is controlled via SPI, for the A4988 driver, the microstep setting is set with jumpers and the motor current with the onboard trimpot.
Bottom view of the PCB. A DC-DC converter module provides the main 5VDC rail and the 3.3V one is generated with a linear regulator. Power to the servo and the stepper driver is fed through a MOSFET switches controlled by the firmware. This allows e.g. a hard reset of the TMC2130 driver or a power cut off in case of servo malfunction. A small PCB jumpers allow to separate the servo and the stepper driver signals from the main PSoC4, so they can be driven from another source. The small bodge wire around the ESP module has been rectified in the final version of the PCB.
The ESP-12 (ESP8266) module runs the ESP-Link firmware and is used as a Wifi/Serial bridge. If there is a 3.3V voltage detected on the programmer port, the ESP's UART lines are redirected to the programmer header. Normally the ESP's UART is routed to the PSoC's UART to operate the command console. A DTR signal from the CP2102 module is used to auto reset the ESP after programming.
Here is the Cypress EZ-BLE-022001-00 (ProC) part. It provides a footprint for the module with all the required components and pins available on a header. Added for potential future use of the board in projects using Bluetooth low energy connectivity.
128x128 ST7735 display mounted on the main board. There is a one additional pin underneath the display used to power the secondary side of the SPI level shifter. The display i used has a small onboard 3VDC linear regulator. I used that voltage to set the output level of the 74LVC4245 octal transceiver.
Everything installed and plugged in, apart from the main power. The power is provided by a Meanwell 15V DC 35V switching supply, trimmed up to about 16.5V. To operate silently the preferred voltage would be at around 20VDC. At 12V the stepper motor produces audible high pitched noises due to the way the PWM controller on the TMC2130 works. I found out, that at about 16.5-17VDC the noise goes away almost completely. The MP1584 based DC-DC step-down module has a max. input voltage of 28V.
After making a few changes to the layout the holes milled in the back panel did not match the new one. A thin 0.5mm ABS sheet, available at hobby/model making stores makes a nice cover plate. A thicker one could be used to make a new panel completely.
Before I go into details about writing the firmware, there is a few people who I'd like to credit first, as the code they provided helped a lot while building this device:
- Achim Döbler for the uGui graphical library, which I modified a little bit by adding symbol fonts, stripped system font to save flash space and a few other changes.
- Kustaa Nyholm / SpareTimeLabs for the excellent tinyprintf library.
- Moritz Walter for his Arduino TMC2130 library, on which the driver is based on.
- Bob Marlowe - for the PSoC Keypad component, which after removing a small bug and adding a few more features (long press detection, interrupts) serves as a keypad controller.
- Elecia White - for her command console code.
The firmware is split into a few functional blocks, governed by the main one: "engine". Each block accepts commands and reports back its state, which can be polled by the central "engine". Such approach, together with using interrupts, flags and IO buffers allows to write most of the functions in a non blocking manner, using wait states as little as possible.
Stepper | Servo | Display/GUI | Keypad | Button | Buzzer | EEPROM| Program
Stepper motor driver
I was planning to use the A4988 based stepper driver initially, but after discovering the interesting TMC2130 chip made by Trinamic I decided to try it out in my build. The hardware and the software can handle both drivers. Of course, having a PSoC onboard I wanted to make use of the hardware blocks and construct a stepper driver out of a PWM and counter components. After a few trials I ended up using a much simpler and, as it turned out, effective way: one of the SCB components (Serial Communication Block) configured as plain UART.
UART is set to 8 bit of data, one stop bit and no parity (8N1). The TX ouptut is inverted to make the pulses active high. Any desired number of pulses can be generated by sending a train of 0x55 bytes (5 pulses) followed by the last byte, containing 4, 3, 2 or 1 pulse (0x15, 0x05, 0x01, 0x00 respectively).
UART uses a TX buffer and interrupts to make the operation non blocking and "set and forget" type. The function takes the number of steps, recalculates it into a series of bytes and starts the interrupt driven transfer. Of course I could leave it at this stage as it is, since the stepper work does not require any ultra precision. However, I was curious if I could change the UART baudrate on the fly (well, almost, between fully sent bytes), thus creating an acceleration and deceleration phases. It worked! In the end, I had a very simple, yet versatile stepper driver using a simple UART block only.
The stepper driver selection is done automatically at startup. MCU tries to read one of the TMC2130's status registers. If the chip is not present the result will be a 32bit 0xFFFFFFFF value, hence the program can assume the driver used is the A4988, skip all the SPI config routines and set the microstepping via M1-M3 control pins.
The TMC2130 stepper driver has an internal temperature sensor and can signal if an overtemperature is about to happen. This flag is used to turn on the fan. A4988 does not have such a feature, thus the fan is turned on when the motor is working.
Analog servo driver is built around a PWM component, which is a typical approach. PWM is used to generate pulses of required width at frequency of 125Hz, matching the specs of the used BMS-L530MG high torque servo.
Although not used in the current firmware revision, the power to the servo runs through a controlled PMOS switch and can be switched on and off (Servo_PWR pin). Together with the boards supply current measurement it could be used to detect various malfunctions, e.g. blocked servo pulling too much current.
Display (128x128 SPI, ST7735) is driven with UGUI library written by Achim Döbler with a few changes and modifications:
- Added a stripped version of the system font, consisting of symbols 0x20...0x7F, thus saving the flash space.
- Added a large digit only font.
- Added a custom symbol font (play/stop etc).
- Changed the PutString function to return the end of string 'x' coordinate, similar to Adafruits' GFX library. It is quite handy to use that value to erase the line using a fast fillRect function instead of printing spaces.
- ST7735 driver rewritten, added display rotation functions.
The 4x4 keypad component originally written by Bob Marlowe (component found on Cypress community forums), required some reworking and fixing. I'm not sure if the version I found was the newest one, but it suffered from a few problems:
- Due to a bug the keypad component couldn't return the first character with the index 0, as return value of 0 was used as "no key pressed" event.
- Implemented, but commented out interrupt trigger.
While fixing the problems i decided to add a few more features:
- Long press detection with its own interrupt output.
- Since the key press events are stored in a buffer, added a way to clear it out and discard any detected events.
Here, again, I decided to make use of the highly versatile onboard logic fabric on the PSoC to create a hardware button handler. Clocked from a 120Hz clock source the Debouncer ensures a clean press detection. A rising edge will trigger an interrupt signaling a normal button press. The "q" output represents the debounced state of the button input. While pressed it will keep reloading the TimerCounter with a preset value. When the button is released, the Timer, set to one shot mode will be released and after overflowing will trigger a "Long press event" interrupt. "InputStateReg" allows software to read the debounced state of the button input. It is used to detect combinations of button and keypad presses.
In order to make the piezo buzzer sound less annoying it is driven via a simple shift register. Sending various byte values creates different kind of "beeps". In addition, these bytes can be sent in patterns, creating a crude, yet useful acoustic signaling block (anyone remember ProTracker on Amiga? similar idea). As other handlers, this one also works in a non blocking manner.
The first protype used a simulated EEPROM component to save data directly in FLASH. Since the program space was getting tight, I've switched to an external 25XX series SPI EEPROM, sharing the same bus with display and the TMC2130 stepper driver. Using another hardware driven CS (chip select) line for the EEPROM was not possible due to routing restrictions. The only left pin I could use couldn't be accessed by the SCB block. EEPROM chip select line has to be software controlled. Prior sending any data to the EEPROM, the hardware SPI CS line is set to a non used channel, as we don't want to access the display or the TMC2130, the software brings down the EEPROM's CS line and after the transmission is completed, CS is set to high and the hardware SPI channel is set back to default, most often used value: the display.
EEPROM is used to store the quick preset values, last job settings and a few other system settings.
As far as i know, the best and most economic way to get a PSoC programmer today is to get one of the CYCKIT-059 PSoC 5LP dev kits, containing a nice 5LP MCU to play with and a fully featured programmer/debugger: KitProg as a little snap off board. In addition the programmer is also an USB/UART bridge (UART_TX, UART_RX pins on the pic below). Really handy!
The simplest method to upload the firmware without installing all the PSoC Creator IDE is to use the PSoC Programmer software, available from Cypress site. The compiled HEX file is provided in the github repository (/software/hex).
Unfortunately the PSoC Creator and Programmer software is not multi platform and runs on windows only. Getting it to work on Mac and Linux requires using a virtual windows machine (ie. Virtualbox + Win7 or higher)
Design files are available in the github repository:
Click to open in new window
git clone https://github.com/hexeguitar/AutomatedWireCutter