-
Project Origins
04/15/2023 at 05:29 • 0 commentsThis project originated back in 2016 as a "cruise control" circuit to provide a simple pushbutton so that I can go full speed easily. This was for convenience and less pain- to keep from injuring my hands since the stock configuration forces me to squeeze the spring tension lever at all times.
The idea was simple: use a analog MUX to switch to 2x trim potentiometers (configured as rheostats). These function as a full-speed "dummy" load - tricking the CPU to think the lever was in the full speed potentiometer position. As long as the CPU doesn't mind the switch (dead) time of the MUX it should (and did!) work. The mobility scooter went full speed with the press of a button :)
Everything was done with 74 logic, so there was no firmware at all. I utilized a type D flip-flop (74HC74) and a simple debounce (74HC14) for the latching mechanism. In order to get the small footprints for the parts, I used the "LV1G" (ahem, overpriced) variants from TI. The circuitry is a little archaic, since these parts were designed in the 1970s and constitute some of the building blocks of all microcomputers.
Here's what it looked like:
As you can see, the PCB had many flaws and required patchwork. It functioned though, and would probably still be working if I had an appropriate case for it. I believe the circuit got wet from the poor insulation of the tiller assembly and given it's amateur construction. I shelved it as a curiosity until something more robust could be developed with appropriate firmware.I also over-engineered it to be small, as it did not have appropriate heat dissipation for the DC-DC converter accepting the +24V (nominal) battery input. You can see the copper bar that I soldered across the IC to help keep it from overheating. Additionally, F1 was not properly size for current, so when it blew, the wheelchair would no longer function... a very serious problem to be stranded in one of these.
Fortunately I planned ahead and had a safety kill switch to return back to manual controls.
I could go on with the flaws in this design, but I think that's enough self-criticism for now :P Better things are coming...!
-
Basic Firmware Test
04/15/2023 at 05:42 • 0 commentsIn order to get this project off the ground, I need to see if I can digitally control the wheelchair in my own custom firmware. For that, I need a "dummy load" to essentially fake out the wheelchair's onboard CPU and think that there is the old stock analog potentiometer connected, when in fact, it isn't.
-- DIGITAL POTENTIOMETER --
To do this, I selected a digital potentiometer with a simple to use interface protocol (I2C) and some decent available libraries that are compatible with the Arduino IDE platform. I decided on the MCP4661-502. It comes in a handy TSSOP package with 2x 5k-ohm potentiometers and also has built in NV (non-volitile) memory for saving settings after power off! This simplifies the code, so I won't need to make use of the Arduino Nano's EEPROM storage space (which would change when I upgrade to a better MCU).
The rheostat variant (MCP4662) could be programmed for this purpose as well, which is nice to know, since there are supply shortages during this time.
Later, I would like to add a 2nd 50k-ohm digital pot to replace the stock analog speed dial as well (I'll go over that part later). This would give me more precise control of the speed curve in firmware. The analog dial is a 30k ohm pot set up as a rheostat.I also went with the 8-bit version (257 steps / taps) for the most precision.
It should be noted that there is an SPI version of these digipots, which would of course be a little bit faster, since SPI is a faster communication protocool than I2C. But seeing that the wheelchair CPU already tolerates an incredible amount of dead time (something like 500ms), I'm not too concerned with update speeds. I'm running the I2C display at 400kb/s and the digipot even slower, with no issues at all sharing the bus (I2C supports up to 128 different devices on a single bus).
This was a simple setup to start with, using some useful off-the-shelf parts. We have:
- Arduino Nano
- SSD1306 OLED display (widely supported, and easy to use with the Adafruit library)
- MCP4661 digital potentiomter
- generic rotary encoder (custom PCB with hardware debounce I designed)
- KY-024 analog hall effect sensor (we'll play with this more later)...
Fortunately, I wrote a lot of the firmware for another project last year using similar hardware. It didn't take too long to adapt it to this project. In fact, it was more work matching all the particular plugs and breakout cables to effectively connect this to the wheelchair and still be able to move it. But, behold:
[more to come...]
-
POWER UP! (DC-DC)
04/15/2023 at 06:51 • 0 commentsHaving a proof of concept from the working firmware test, it's time to dive into designing some PCBs.
We need to have a robust and reliable power system. This is a medical device, and something that I rely on heavily, so it can't be prone to errors and issues.
I made the mistake years ago of not allocating enough attention toward a large power PCB. It's time to fix that.
Since this is a battery-powered system, we will be saving power by using a DC-DC converter. The biggest challenge in the system comes with the high-voltage requirement - it utilizes 2x 12V lead acid batteries in series, giving us a max fvoltage of 29.4V(!) if you count the theoretical perfect float voltage charge state. In reality, it's going to be around 27-28V.
For this we need a bulky step-down converter, and nothing fits the bill for affordably and sourcing better than the LM2596 module:
specs (from this link):
Input voltage: 4V-35V
Output voltage: 1.23V - 30V
Input current: 3A (maximum)
DC-DC Buck Converter Step Down Module LM2596 Power Supply
Specifications:
Conversion efficiency: 92%(highest)
Switching frequency: 150KHz
Output ripple: 30mA9maxmum)These modules provide more than enough power and are cheap, so we'll need to make out own modifcations to improve the reliability. It's a great starting point.
I'll be replacing the capacitors with more reliable solid polymer ones, reflowing some of the poor quality solder, adding an improved heatsink, and (most importantly) fuses.
I also need to create reliable working voltages for the MCU, digipot, and other add-ons. +3.3V and +5V are standard for that. I also want things to be well regulated, with low voltage ripple and...fused! Lot's of fuses. Additionally, I want a schottky diode in series with the input, to prevent any potentional problems from affecting the $300 wheelchair CPU module.
For these reasons, I designed 2x add-on PCBs for the LM2596 module. One for input, one for output:
The input PCB incorporates a protection fuse, in-line shottky diode, an additional filter capacitor, an additional PCB heatsink, a JST-XH-2 power input, and a JST-PH-2 output for a battery gauge. I think this will prove to be useful...
The bottom PCB Has a little more going on. It incorporates 2x LDO (low dropout) regulators; an AMS1117-3.3 and AMS1117-5.0. These are popular low-cost LDOs that are very affordable and do a decent job of creating smooth power rails for microcontrollers. There are also fuses for each output and LED indicators. Note, the 3D model actually doesn't show the solder mask that I removed in the power sections. I kept heat dissipation in mind for this, as we'll see when the PCBs arrive in a couple weeks. Also, disregard the floating drill there, that is something that I kept in my LM2596 module footprint for alignment purposes. (It has no effect on fabrication).
Here are the two PCBs + module combined, just begging for a 3D enclosure to be modeled! :D(disregard the lack of detail on the Input PCB, KiCAD doesn't make it the easiest to export and re-import .step models. But this will do the job for the enclosure design and as a general mockup.).
With this set up, we have a respectable power module. It's a good place to start, so now it's on to more exciting things...
[coming soon...]
-
She Seems To Have a Capacitive Touch!
04/17/2023 at 05:53 • 0 commentsYes, that's a Phil Collins reference... :P
One neat aspect of this project has been investigating capacitive touch sensors.
I'm a big fan of slider controls, and actually hacked on a volume slider for my wheelchair to control the speed dial many years ago. What a nice upgrade it would be to have a capacitive touch slider with LED controls, don'cha think? :)
There are two popular forms of capacitive touch:
1) Resistive capacitive touch
2) Projected capacitive touchThe first one (I think most people agree with me) is quite terrible. If you remember touch sensor technology from the late 90s, where you had to press really hard or use a stylus, then you know exactly what I'm talking about.
Projected capacitive touch has been the clear winner for some time, and each new generation of ICs has made it easier to implement. In recent years, microcontrollers like the ESP32 have even integrated this feature.
Originally, I planned to just use the built in ESP32 touch GPIO pins, and didn't pay that much thought to planning it all out. However, capacitive touch sensors are delicate devices; they rely on minute electrical pulses from the human body to alter a pad capacitance to the tune of as little as 50-100pf!
Trace layout, wire length, and grounding planes play a significant role in proper engineering of these PCBs. So it wasn't a massive surprise when I was reading the technical documentation from Espressif and saw that they recommend limiting the trace length to just 300mm:
This is a limitation that can be really frustrating to work with since I'm going to have wire harnesses all over the place. I'll be working in a cramped space and having to adapt to the wheelchair's previous engineering, so I certainly don't like the idea of adding new constraints.
Also, this being a medical device, I want to optimize any capacitive touch or motion control to be the best and as responsive as possible. I want traces to be very short, but I also don't want to be stuck mounting my microcontroller under the slider....
-- Enter the TTP223 --
This is a wildly popular IC manufactured overseas. The manufacturing quantities produced to meet the demand from people around the world for this part have made it incredibly affordable. It's also well-documented, easy to solder, has a small external part count, has built-in calibration futures, doesn't require I2C or any programming, and can be purchased for as little as <$0.20 if you buy 100pcs.
I always opt to work with parts that are well-documented and affordable if I can, so this one looks ideal ! There's even a handy project right on it here on Hackaday by @mbsg99
I've ordered a bunch to work with, and I'll be designing my own custom circuit board with 5x of them soon, as a daughter board add-on to this new capacitive touch slider PCB:
This is the handy PCB I designed, influenced from research on Sparfun's PCB and a really cool (although out of stock one) designed by Seeed Studios. Ultimately, I went for a modular approach which I'm quite proud of. This design incorporates 5x indicator LEDs and breakout solder tabs for a add-on board to attach to. The add-on board will have an additional ground plane to help limit any stray capacitance, and also make testing and debugging other ICs (should I dislike the TTP223) far easier.For the layout guideline, I resorted to an extremely helpful application note by Azoteq which a very nice friend told me about:
I'm optimistic about this one so far, and look forward to the PCBs. I just hope this one turns out to be a Solid Slider :) -
TTP223 from the ground up!
04/19/2023 at 04:34 • 0 commentsSpent the past 2x days creating new PCB designs... Took a while because I decided to tweak all my FPC libraries for improved accuracy and also had to create the TTP223 footprint from scratch for Eagle (really? yes, I was surprised this common part isn't available). At least the package is a common SOT-23-6L.
It's worth noting that this smaller package for the TTP223 (there's a much larger one in SSOP-16 package) loses some features. It does not support:
1) Power on reset
2) Open drain output (a.k.a. hi-Z)
3) The press time is fixed at ~1.6ms
4) Doesn't have maximum on time (100 sec)
None of these are a significant loss though, so I think we're still in good shape.
we have here a 3D mockup of my 5X TTP223 touch PCB - specifically designed as a solder mount for my new slider PCB.
I think this slider design should work well, but just to be safe I made a 3X version as well for shorter finger travel distances.Disregard the silk and vias outside the board perimeter - these are edge castellations, but KiCAD 3D modeling doesn't know how to interpret them.
I also went ahead and designed a standalone version, since the cheapo models around the internet usually don't have:1) Mounting holes
2) FFC connectors
3) Proper isolation of the projective capacitance pin
4) A footprint to tweak the projective capacitance (0-50pf variable cap is in the TTP223 datasheet).
Alright, I think I'm all set for capcitive touch stuff! Next is onto breakout PCBs and magnet stuff :)[more coming soon...]
-
Magneto!
04/25/2023 at 06:28 • 0 commentsHere I am revisiting magnetic controls. It's not something I use frequently in my projects, but this project has me thinking outside the box in some neat ways.
Capacitive touch still seems to be the best contender for the Wheelchair EZ-Motion for now. So far the options are:
- Capacitive touch
- Push buttons
- Analog sliders / knobs
- Opto control
- Ultrasonic sensors
- Wireless communication (2.4Ghz bluetooth like the NRF24L01)
- Magnetic sensing
There may be others I've forgotten. All of these have their pros and cons, but what is most important is to keep in mind the environmental concerns. We're traveling on a moving object - a medical device, no less - outside and exposed to a lot of different types of elements and interference.Magnetic fields seem to be one of the less-likely things to come into contact with (unless you're going through a metal detector). While not as safe as capacitive touch, they offer 360 degree, hands-free motion without the complexity of a wireless protocol.
-- HALL EFFECT --
The KY-24 module seems like a good starting point. It uses a (short range) 49E hall effect sensor which is in fact linear. What's cool about that is it gives us a voltage range (these have built in op amps which change the output voltage respective to proximity of N and S) so they could theoretically be used for varying speeds.
The downside however, is the range is very limited (about 20-30mm at most). It would require designing a precise model / 3D print to interface with. E-Bikes, for example, use an accelleration knob with a linear hall effect like this one built in. It gives the needed precision but also... resorts to a spring to pull it back home. Springs! We're trying to avoid those... you have to grasp them, too. Not ideal for arthritis.-- MAGNETOMETER --
For a longer range, more flexible solution I was recommended a magnetometer:
These are cool: a 3-axis ultra sensitive device for detecting the earth's magnetic field. A digital compass! Apparently they are utilized in ocean exploration and can assist in finding shipwrecks! I wonder if these helped discover the Titanic in 1985? According to this, maybe not yet.
But I digress. The primary chip used here is the HMC5883L, however, most of the ones sold online are fakes and instead have the more common and much cheaper QMC5883. Still, they work well enough with different libraries.
The first time I fired it up (fortunately the I2C address had no conflicts with the digipot and OLED display) I got some pretty eratic and unpredictable readings when moving a magnet towards the device. It worked, but the reading was jumping all over the place. Not too shocking, since this is an ultra-sensitive sensor to measure far-away magnetic fields and I'm hacking it to do something it wasn't designed for.-- AZIMUTH --
Out of curiosity, I tried the "Azimuth" reading. A new (and very cool) word to me, it's actually a fascinating calculation used in astronomy and physics. And it is very useful here, employed for calculating the distance between two objects, especially on a short 2D plane like I am doing at close range (well, close range for a magnetometer, anyway).
The reading normalized! And gave me a value between 269 - 350 on Y axis from ~2mm - 150mm. I have more testing to do to fine tune that, but the rough numbers give me something I can toy with outside in the sidewalk.
...However, CriptasticHacker made a mistake. Unlike the correct PCB pictured above, I ordered a cheapo version that lacked the additional 3.3V LDO and level shifter for I2C data:
This means it is not meant to work on the Arduino Nano I'm using (a 5V system). The result? It worked OK on my bench for a while (maybe because the USB power had a voltage drop across the Arduino's shottky diode and the IC tolerated a ~4.2V input), but once I had it in the wheelchair (with a new PSU) things went wonky. I got stalled in the middle of the street multiple times! Are you saying it wasn't my looks that stopped traffic? :DAh well, I ordered the correct one and will do some more testing with it later!
-
Power PCBs arrived!
04/29/2023 at 06:22 • 0 comments
My "juggling" (as I like to call it) has been paying off. Engineering work is largely about playing a balancing act with manufacting and dev time, which I am quite used to at this point. I cranked out the most important PCBs in EagleCAD first, so I could do other things (like write these logs!) during the 2 week manufacturing lead times. Now the time to solder has arrived! :D
At the risk of being unpopular, I will add that I am always disappointed with the programmers who refuse to or are afraid to work with their hands. *gasp* what if we look blue collar?! I, on the other hand, love soldering and getting my hands dirty. It's my comfort zone and whenever I can take out the SMD tools and magnifier I am happy to do so :)
The PCB here assembled like a charm. My design worked very well, and only the trim pot resistor breakout PCB wasn't needed (because there is an 0603 pad for the rheostat on the LM2596 module - how convenient!)The feedback network to determine output voltage from the DC-DC buck converter (LM2596) has a pre-set 270ohm resistor for the low side, and this empty pad under the trim pot for the high side.
My new add-on PCB makes a split rail supply (+5V and +3.3V) from this output. Let's try something nice for the LDO, I find +7V works well to eliminate any drop outs.
Saving time with this nice little write-up, I decided on 1K3 for the rheostat since:
Vref = 1.23( (R2/R1) +1)where R2 = 1K3 and R1 = 270ohms.
This gives us ~7.15V output. A reliable 2.15V over to make sure there isn't any drop out.
and it works great so far :)
But what's that you say? It's naked? Exposed! *shrieks* the emperor has no clothes! I guess it's time to..
-- 3D ENCLOSURE MODEL --
I whipped this up in an hour to protecc the bottom of our new triple PCB combo, as well as help with alignment. It utilizes countersunk M2*5mm screws and sports a couple other nice additions. It has:
- counter sunk external mounts
- 3 different height standoffs to support the PCBs
- indentations in the middle for LM2596 alignment, and
- locking divets for a future lid design
Not too shabby. So how did the first print turn out?
Looks like the Ender 3 S1 Pro is doing a good job! I went for the magnetic build plate because I get tired of occasional adhesion issues with PEI. For a one-off print, these work pretty well. If you're wondering, I'm using Polymaker black PLA with all standard settings. Of course, gotta dial in those expand settings in Cura for dimensional accuracy too.
And did it fit...?Beautifully :) Might add 0.25mm on the LM2596 indents, but what's here is wonderful (1 hr 12 minutes print time @ 50mm/s speed). ^_^
[to be continued...]
-
UI (OLED + Rotary) Upgrade
04/29/2023 at 07:08 • 0 comments-- UI OLED Rotary PCB --
I also went ahead and made an ugpraded UI PCB:
False positives from janky breadboard rotary pushes were getting on my nerves...
This handsome lad has multi hardware debouncing, and expands our setup to 4x push buttons :) Everything is incredibly responsive on the interrupts and much more durable. Now we need a bottom case to protecc it....
This is V0.2 which has a support for those hard-presses on the rotary encoder, plus reinforced corner screw standoffs :)
Time to print!
Looks spiffy - but does it fit? I always hold my breath for this part...
Success! And one more close of shot of the handsome chap:Looking more and more like a real test rig!
[to be continued...]
-
Touch Sensor Success ^_^
05/04/2023 at 18:16 • 0 commentsThe TTP223 slider control and single touch PCBs came out beautifully - on the first iteration :) See my post below for more of the details and the reference design. Capacitive touch is so fun to work with and (when done right) is incredibly responsive and bug-free! and so much less painful to use.
The castellation design worked out perfect - 3x duplicate TTP223 modules. This modular design allows me to reuse the slider touch PCB with a different IC, or the ESP32's touch GPIOs later. The FPC-6 1.0mm connector is nice and durable and makes cable management and mounting a breeze :)
The next PCB I assembled was the single touch version. As mentioned in my previous post, I wanted to have more features than the cheapo ones that are already available. I also prefer the flexibility (no pun intended) of using Flat Flex Cables.
Unlike the slider, I did not design a special touch PCB for these. The red wire goes to a piece of copper for the touch sensor. I found that this (not surprisingly) made the triggering a lot easier to do, as there wasn't the surrounding ground plane or the hatched ground underneath to break up stray capacitance.
In order to keep the copper from triggering too easily, I changed the parallel touch capacitor from the frequently used 22pF value to a higher range of 47pF. the datasheet for the TTP223 mentions that higher values reduce sensitivity, and this worked like a charm. Problem solved.Now it's time to 3D model and print a panel mount case...
Took a couple iterations to get the FFC cutout and support, but it's solid now!
Then I had some fun making a 3D model to match my actual thumbprint. I love stuff like this - I thought this is the kind of customization that disabled people deserve to have with our medical aids. and why not? I took measurements, modeled, and 3D printed this in about an hour :)Here you can see I used the roll of adhesive copper foil to cut out a matching touch sensor. It's crude, but it does the job! I also modeled the case to have holes in it for the attaching wire.
After this, I updated my LED voltmeter case. It's also a panel mount now, with a nifty cable strain relief as well :)
With that done, I realized I needed some panel mount brackets to lock in my testing breadboard. Sure, it has a big slab of adhesive on the back, but I try to avoid hard to remove adhesives during prototyping whenever possible.
Now it's time to assemble this funky set up... Ideally I'd use a piece of plywood to screw everything into, or an enclosure case of some sort. I didn't feel like 3D printing a huge case that I will grow out of in a week of R&D. And I was feeling too lazy to take out my miter saw to do plywood cuts, so...The entire thing is assembled on two layers of cardboard - USPS flat rate cardboard! Free at the post office ^_^ my M2 wood screws threaded into it surprisingly well....now, it's time to update the firmware...
Nothing too fancy here - added some new globals for the touch I/O and variables [not shown].
The copper foil touch sensor definitely benefited from some denouncing, which took a little bit of fiddling with to get the cruise control to trigger just right. It works *really* nice now...
The slider code was easy to get working, but will take some time to get it perfected. I'm just guesstimating how much the pot values affect speed. It's logarithmic though, not linear, so it's a spotty business. I have to give it some TLC later on, although I'm hoping I can avoid a lot of the work by simply adjusting acceleration with the rheostat dummy load to another digipot (more on that later).
...Now it's time to take it for a spin! ^_^
[to be continued...]
-
Touch Control Demo!
05/06/2023 at 03:07 • 0 comments