Thursday, January 14, 2021

Pyro System 4 preview

 

Pyro System version 4 full video is coming soon! 

Friday, January 8, 2021

Hacking and upgrading a 3Doodler 3D pen

 



I recently received a 3Doodler 3D pen after only using cheapo $20 no-name 3D pens for several years (like this one). While the mechanical design on this one is nice, it had a few issues that left me not wanting to use it in its stock form:
  • used 3mm filament instead of the 1.75mm that my printers use
  • used switch presses as stop and start commands instead of momentary (hold to extrude, release to stop)
  • slow extrude was not slow enough (not their fault, I always want a slower extrude to better do detail work)
  • annoying behavior of the cooling fan (just runs along with the extrude regardless of temperature)
I decided to tear it apart and implement several upgrades to fix it:
  • closed-loop feedback control on the extrude speed to achieve slower speeds and better consistency
  • add temperature monitoring of the cold end of the extruder to more effectively use the cooling fan
  • change the power input to USB-C
These changes required some hardware updates and a complete rewrite of the firmware. First I worked on switching the filament size to 1.75mm. I was lucky enough to have the dimensions of common brass M3 threaded inserts work out to act as spacers on top of the existing extruder gears that grip the filament. I had to add the serrations to grip the filament by forming a screw into a cutter by cutting an axial slot in it, and spinning it against the inserts:

The spacers needed a small amount of trimming on the ends, and then I press-fit them onto the existing drive gears. I also cut down a short section of teflon tube (the kind used for Bowden extruders with 2mm ID) and pressed it into the cold end of the extruder to avoid the plastic building up there. The teflon tube is just visible at the bottom of this picture:

Those two changes were sufficient to mechanically convert the system to 1.75mm, but I also decided added some sections of tubing further upstream to better center the filament before it reaches the extruder. 

After the filament size conversion I worked on the speed control upgrade. Initially I tried to add rotation speed measurement to the bevel gear on the output of the motor gearbox, by drilling a hole and adding a 2mm magnet, and mounting a hall effect sensor above it on the PCB:

In the end I had to abandon this implementation since the rotation period was too slow to effectively implement feedback control. It took up to about 7 seconds for a revolution at the lower speeds so the control loop was too slow to be useful. To fix it, I set up rotation rate measurement further upstream in the gear train by finding a spot to add a very small magnet, which I cut and shaped using sandpaper from a larger magnet. In this particular gear train there happened to be a spot I could fit it on the third gear which spins roughly 40 times faster than the output shaft. I ground down the gear slightly to make a flat mounting spot and attached it with both CA glue and then epoxy:

I could then check the placement with a hall effect sensor and see how close I had to be to detect it. The camera frame rate happened to sync up with the motor speed here:
I mounted the hall effect sensor to the brass plates of the gearbox with CA glue, and it fit entirely within the envelope of the gearbox, so I didn't have to make any changes to the plastic frame that the motor fits into:

This new setup gave rotation measurement periods in the range of 50-200ms which was much more usable to close the feedback loop on extruder speed. 

The cooling fan upgrade was much simpler, I just installed a thermistor on the cold end of the extruder to monitor its temperature. This is an 0603 thermistor wrapped with kapton and mounted to the cold end with CA glue:

With all the hardware updates done it was time to do firmware, starting with reverse-engineering the control board. The stock microcontroller was an unlabelled 16-pin SOIC part:

Along with the microcontroller, the board has a FET and gate drive transistor for the heater, a FET and flyback diode for the fan, a motor driver (the SOIC-8 package), an RGB LED, and all associated passives. I took measurements on the microcontroller pins while operating the pen and came up with this list of pin functions:
1: VCC 5.05V
2: pulled low if switch is back (off)
3: pulled low if switch is forward (ABS mode)
4: icsp, not used in circuit
5: heater pwm 1khz active high
6: 2.5V reference for adc 
7: rear switch
8: fan pwm 200Hz 20% duty
9: extruder active low (high = backward)
10: red led active low
11: green led active low 
12: blue led active low
13: extruder forwards active high 600Hz 50% fast 20% slow
14: front switch
15: hot end temperature. lower=hotter. pla = 1.51V, abs = 1.24V
16: ground

With all those identified I could safely remove the stock microcontroller and install a new one. I chose to use the PIC16F1579 in a QFN package, and mounted it upside-down in the middle of the old uC pads with CA glue:


 I wired up the new microcontroller, using 34AWG enameled magnet wire. I also added a small chunk of PCB to hold the pull-down resistor and capacitor used to read the added thermistor, as well as a piece of a PCB to act as a programming port:


With that the hardware changes were complete and I moved on to firmware. For the initial work I set up a temporary UART debugging output so I could watch values for hotend temperature and extruder speed in order to tune those control loops. I ended up getting decent results for both using PD control loops, although the way I implemented it also has a sort of half-assed integral term since the P and D term results get added to the current duty cycle instead of calculating a new duty cycle every loop. After all the hardware and the two control loops (extruder speed and hotend temperature) were working, I figured out the new UI I wanted. Here it is as I wrote it before coding the state machine that runs the UI:
        /*switch on: rise to temperature
once up at temp, allow extruder movement
front switch is momentary forward extrude
short retract after forward movement
click rear switch shifts between 3 speeds
hold rear switch backs out filament until released
safety timeout 3 minutes
broken thermistor detection*/ 

The final source code is uploaded here: https://github.com/tterev3/3D_pen

In the course of finalizing the firmware I ended up wanting to fully reassemble the pen but still be able to reprogram, so I added a new programming port (this time just a flat PCB onto which I press a pogo pin programming header). The pen had this useful port on the side with a removable cover, which wasn't used for anything in the stock product, so I added the port there and could fully reassemble it:

Around this time I also decided to add one last hardware upgrade and swap out the barrel jack for a USB-C jack, which required a bit of trimming of the rear cover:


Here's a demo of how the pen works now after finishing my new firmware:

After all these changes I'm quite happy with this pen now - it's much nicer hardware to use than the cheapo pens, can do lower extrude speed, and can be run from a power bank since it's now 5V USB-C powered. 

Thursday, November 19, 2020

Saving a broken tablet with a charger hack

I found this Samsung Galaxy Tab S in an e-waste bin. It didn't have any visible damage, but it had been thrown away because it was dead and wouldn't charge or react at all when plugged in. My USB power meter showed it would only pull about 10mA from the USB cable. 



Since this was one of the older designs with the removable back cover, I could easily open it up and directly access the battery connector. By charging the battery from a bench supply, I got it to wake up, and everything seemed to work normally except for charging.  The previous owner had installed some kind of aftermarket OS on it that caused it to get stuck in a boot loop as soon as I tried to do a factory reset, so I had to spend a while figuring out how to use Odin to restore the stock OS. After that diversion it was wiped and working normally, but still unable to charge. 

I couldn't find any visible signs of damage, and I could confirm that the connections to the USB port were still good - in fact the system could still detect 5V when plugged in and indicate that it was charging, but no current was actually going into the battery. It also was still able to accurately report battery charge because it was based on voltage. This meant that if I could add something to charge the cell, the whole thing could be restored without having to dig further into the real source of the failure. 


I prepared a small board to hold a TP4056 charger IC. This was cut from blank flex PCB material since everything needed to stay very low profile to fit in the case. A higher-current charger would have been preferable since this is a 4.8Ah cell, but the only options I had would have required a PCB with a lot more support components and would have ended up being too thick. The TP4056 is set up to charge at 1.2A, which is a slow charge but probably good enough for the use case for a tablet. One other disadvantage is that it will only charge to 4.2V while this is a 4.35V cell, so it only gets to 92% (as estimated by Android). I figured these disadvantages were acceptable tradeoffs for keeping the repair simple and getting it working quickly. 


I probed out the connections for 5V and ground on the USB connector daughter board, and tapped into these with 34AWG magnet wire. 


From there it was very simple to wire in the new charger. I was lucky that system ground was connected to battery negative, so this charger architecture would work. All I had to do was wire 5V and ground to the TP4056, and then connect the output from the charger to a battery+ connection next to the battery connector. 


I then plugged it in, checked that everything was working on the USB meter, and closed up the case. The tablet now works normally and has no visible external changes - it just charges a bit slower and tops out at 92%. 




Thursday, October 29, 2020

Building an instrumented IP5328P power bank


 I bought some nice 21700 cells and an IP5328P power bank board with the intent to build a large (24Ah) power bank. I've done lots of power bank projects in the past where I added voltage and current instrumentation and displays to be able to monitor what was happening while using the power bank, and for this new one I wanted to use a nice RGB graphical display (whereas older projects used black and white OLED displays). 

When I received the boards I started doing some reverse engineering with the goal of taking my standard approach of adding in current sense resistors, voltage dividers, and INA219 power monitors to get the data I needed. After taking a look at the IC's datasheet though, I realized that all the information I wanted was available over an I2C connection, so I'd hardly have to implement any hardware at all. The I2C bus is available by connecting to some lines that are otherwise used for the indicator LEDs:


The datasheet had no information on the available registers though, but luckily an EEVBlog forum user had come across the needed documentation and share it in this thread. With that and a whole bunch of Google Translate I got my microcontroller (PIC18F26K40) talking to it. 


I wired up my microcontroller breakout board to the 1.8" RGB display, which I manually wired up to with 34AWG magnet wire (trying to keep things as low-profile as possible). 


And after connecting I2C as well as the INT signal and power to the main board, I was able to pull data and display it on the screen. You can also see that I relocated the inductor to save on height. 



I did a bit more work on the 3d-printed housing, including some manual adjustments with dremel and 3D pen, and got the display and power bank board installed. At this stage of assembly I spent a long time writing all the graphics code to show status and data. After getting that to a point I was happy with, I welded up the cells and installed them:


And closed it up:


Here's a demo showing the display in action:



Friday, September 25, 2020

Min/Max light version 2



Here’s version 2 of my Min/Max light – a flashlight built from scratch with the aim of having the minimum size with the maximum functions. I shared version 1 here.


This time around I designed and built this light from the ground up instead of modifying an existing light. I included every feature I could think of for a small EDC light:

  • adjustable brightness
  • red, green, and blue color modes
  • ultraviolet
  • a green laser
  • USB-C rechargeable
  • temperature control
  • battery power instrumentation
  • a graphical color display
  • a tail switch as well as up and down switches
  • a touch sensitive panel
  • a tailcap magnet

and of course this includes all the functions of my previous MELD flashlights – strobes, configuration options, automatic shutdown, etc.


I managed to fit it into a final size of 51×30×17mm.





The structural parts are 3d printed in ABS. a central plastic frame holds all the electronics wrapped around the lithium battery, and there is a heatsink formed from a folded copper sheet that wraps around the right side.




To get this to fit into the smallest package possible, I put all the electronics including the emitters onto a single flexible PCB. This PCB is folded to cover 4 sides so that it can hold emitters on the front, a display on the side, switches, touch panel, laser, and charge jack on top, and a tail switch on the back.



This light does all the same stuff as my other MELD lights, with the addition of the green laser, USB charging, a third switch, and of course the color display. The the display always shows mode, LED temperature, battery charge status, drive current, and a remaining runtime estimate.


Here’s a video with details on the build process and demos of the finished light:



Sunday, September 20, 2020

Cheap action cam hacked into dash cam

 


I found this cheap GoPro clone action camera on eBay for about $20. The video resolution is clearly a blatant lie, but if you don't need very high def video it's a pretty capable device for the price. I thought it would do well as a dash cam, but it needed a few hacks first. 

With a combination of 3D print and 3D pen (in ABS) I made a simple magnetic mount to attach it to my rearview mirror. 

When the car powers up, it provides power to the camera (via micro USB), and the camera powers up by default. But it still required me to manually start the recording, and then to stop it and turn off the camera after turning the car off. I wanted to make this process completely automatic, so I opened the housing and probed some connections to find what I needed. Fortunately all the signals necessary were available on this one board on the top of the camera where the record button is:


After the scope showed that switch signals weren't scanned or multiplexed, it was easy to fake button presses just by directly connecting switch signals to GPIO lines. The added microcontroller would run from a switched 3.3V rail, so to safely sense the 5V external power, I added an N-channel FET to provide a pull-down signal when it was present. The added microcontroller is a PIC10F322 on a small breakout board:


The firmware is a very simple state machine that detects a bootup due to external power, and then provides switch inputs to start recording. If the camera is started up manually instead, the hack chip does nothing so that the camera can be used normally. While recording, it just waits until external power is removed (because the car has been turned off), records for a bit longer, then stops recording and turns the camera off. 

Here is the firmware: https://github.com/tterev3/dash-cam-controller/blob/master/dash%20cam%20controller.c

And here is a short demo video of the whole process:





Wednesday, July 22, 2020

Build: 100mW green laser, adjustable with instrumentation



This is a 100mW green DPSS laser pointer I built that has instrumentation and safety features. It's a small form-factor laser with realtime measurement of current, voltage, power, and temperature, has a graphical RGB display, and is rechargeable via USB type C. The laser is built into a 3d-printed housing that measures 42x34x16mm. 

It has adjustable laser output power with a linear constant-current driver and includes a password to unlock high power mode making it relatively safe.This project started when i came across my old wicked lasers pointer from many years ago, which I removed the diode and optics from. After measuring the stock driver's output current at 600mA, I started building a new linear constant-current driver that could have output current adjustable via firmware.


This is done by forming a linear constant current sink with an N-channel FET, a current sense resistor, and an opamp. The positive reference for the opamp which sets the current setpoint is generated via resistor divider from a PWM signal. Capacitors are added for negative feedback and to filter the PWM to DC. The microcontroller that runs this is a PIC18F26K40.

Also connected to the microcontroller are two momentary switches for user input, and two thermistor-based voltage dividers for measuring laser diode and heatsink temperatures. The high sides of the thermistors are powered via an output pin so that they can be powered off in standby.

The display is a small 160x80 pixel IPS RGB display with an ST7735 controller, which is driven via SPI from the microcontroller.



Charging is done with a USB-C input jack and an LTC4054 lithium battery charger, which also provides a charge status signal to the microcontroller.



The current and voltage on the lithium ion cell are monitored with an INA219 power monitor and a current sense resistor, and that device communicates via I2C.

I built the driver on some copper clad blank pcb cut by hand and included a piece of half-millimeter copper sheet connected to the MOSFET drain to act as a heatsink, since the FET will dissipate significant heat at high current.

 

The battery is a 300mAh lipo with protection circuit. The display is soldered to one of my custom general-purpose display boards which is essentially a microcontroller breakout with solder pads for the FFC on the display.

 

With all the major components established I 3D-modeled all the parts and worked out a fairly compact layout. Here you can see the laser optics, driver, battery, display, USB jack, switches, and lithium protection circuit.



Then I designed the housing around them. The housing is printed in 3 parts - the front is solvent-welded on after some of the components were installed, and the back is a friction fit that can be removed for access to the programming connector. The button caps are printed separately in green.




I built up most of the electronics on top of the battery, and then insulated everything with kapton.




The display breakout board with the INA219 went on top of that.



Then I started installing hardware into the housing, starting with the laser optics and USB jack, then switches, and then the battery with all the rest attached to it.


I also broke out the programming connections to a small .05 female header so I could work on the firmware after it was fully assembled.


I designed the user interface for this so that it could easily be used as a normal laser pointer at a safe power level, by simply pressing a button from standby. This wakes up the microcontroller and it starts outputting 5mW as long as the button is held.

At all times the display shows operating mode, labels for the actions of the two buttons, a live laser diode current readout, the laser power setting, and then the temperatures of the laser diode and heatsink, the battery voltage, and the battery charge level. After a few seconds of inactivity in safe mode, it will go back to sleep.

For higher power, it needs to be unlocked with a password. the password is just a sequence of 5 presses of up and down - not very secure obviously with only 32 possible passwords, but this at least prevents unintended high power outputs and makes it relatively safe around kids or people who don't know what it is.

In armed mode there's a countdown bar for when it will automatically re-lock and shut off after a period of inactivity. While armed, there is an adjustment page where you can pick any power level from 5 to 100mW.
The firmware monitors the temperatures of the driver heatsink and laser diode continuously and will force a cooldown by reducing the power level if they exceed 50C. The laser can be recharged with a USB-c cable, and that will wake it up to display the charge status and current.


Here is a video that demonstrates the entire UI: