Week 16

System integration input pillow

For this weeks assignment I’m going to work on the pillow that will send output to the nightlight using the step response sensors. I have first tried to let a small test pillow send data using a lithium battery. I read about it and learn that I can solder it directly to the back of the esp32-C3 Xiao board. With the BLE connection I made during networking I got to send the data to another ESP and can read this value on the serial monitor. When you power the board the LED is not turning on. I read in the Seeed Wiki that this is normal so there is no physical indication if the board is powered.

pillowsensor Here you see it working with a battery wireless sending sensor data to another ESP. On the monitor you can see the sensor value’s the other ESP is receiving. This is the first time I got the wireless connection to work on battery’s and nice sensor value’s!

There were some important things I read inside the Seeed wiki about powering your ESP32-C3 Ciao microcontroller with a battery:

  1. Be very careful soldering because if you make a shortcut you can fry everything.
  2. This note: Sorry, we currently have no way to help you check the remaining battery level through software (because there are no more chip pins available), you need to charge the battery regularly or use a multimeter to check the battery level.

pillowlableprocess

I’m realizing I want to know if the battery is charging and when it’s full because I don’t want to overcharge the battery and it’s a bit vague if this can happen or not. I also want a button to put the pillow on and off because now I can’t and it will keep sending data over to the nightlight ESP trying to connect even when the receiver is off and this will empty the battery quickly. I start reading about battery managers and decide I want to add one in this pillow project.

I start working on integrating a system of the following electronic components:

I want all the electronics on the outside of the pillow for useability (to charge and put the pillow on/off) and for safety because I’m using a battery, and i’m afraid it can get hot inside this pillow full of isolation. After careful consideration I decide I want to make a hard label with fabric to cover it and it will hold all the components.

I start by sketching on paper but quickly continue making a physical representation on all the components. Because I don’t have the changing module yet (waiting for delivery) I design box and print it so I know it’s size. I want to get the components positioned as flat and tiny as possible. I taped everything together trying to get the shape and size I wish the end product to be. I think about the orientation of each component. And try to visualize the wiring and I want to make it in a way that it’s possible to change the battery when it’s old and won’t charge properly anymore.

The orientation in the pictures below works best for me, it has the label like shape, it will be on the big side but i’m fine with that since I don’t think I can make it smaller with these components. It has both the USB C plugs (one for charging and one for coding) on the same side. I used a pies of silicon for the on / off switch to make it a flat surface on top and to make it feel nice.

Back side:

  • note: the blue square will be the battery charger module. pillowlableprocess

Front side: pillowlableprocess

New PCB

I start designing a new PCB for the step response sensor I made during input devices in the right shape. This new design uses both sides of the board. The Xiao board will be placed on the back and on the front the resistors for the stepresponse. To make this I use the back copper layer for the first time in KiCad by flipping the footprint of the Xiao using the short key F

Here you see the routing process: pillowlableprocess pillowlableprocess

Here is the milled and soldered result:

pillowlableprocess Download the svg files here

Casing

To design a nice hard shell casing to protect the electronics I create a new design in Fusion360. On grabcad I found the following 3D files:

  • Module of the battery charger : here
  • Xiao ESP32C3 : here
  • I export my kiCAD file as a STEPfile
  • I design the on / off switch and the battery myself because it’s easy shapes pillowlableprocess I put all the components inside an new project and start designing the casing around it using the move tool a lot to move the components around. pillowlableprocess pillowlableprocess pillowlableprocess

The first design with the lid: pillowlabel

I print the design on the Ultimaker 2+ extended together with my altered bearing holders for the nightlight. casing

After printing I do a test fit, the USB ports seems to fit nicely however the lid with the hole for the switch is to small to press it so I need make some changes. pillowlableprocess

I place it near my input sensor to see how it’s going to fit. pillowlableprocess

Here you see the wiring of the two sensors. sensor integration I can’t test it properly with the battery charging module because I do not yet have al the components and it needs to be soldered in place. So I decide to test it with power supply from the USB cable instead. Turns out I have a lot of interfering in my sensors and it’s hard to get a steady data reading.

sensor and pillow integration process

This week I put much time in creating the sensing pillow to control the nightlight. I would say I made two mistakes:

  • doing the testings with one instead of two sensors.
  • not fully think about the way these sensors behave. Leo mentioned in a chat I had with him about my issues I’m trying to combine two things in one sensor. A pressure sensor and a touch sensor. And he was right about this.

During input devices I made my first test pillow and I had trouble reading steady data. Neil discus the problem with me and told me about designing the second sensor al the way around the first on so the reading will be similar on all sides of the pillow. More about this topic here So I redesigned the pillow with one plate of the sensor in the middle and the other plate on the side by making a piny pillow inside the big pillow.

The reading are more steady because they are only going down if you touch the pillow instead of up and down, but it still fluctuates a lot. I think it’s because the tiny pillow can more, it’s not fixed. And the wiring is also interfering.

I decide to design the pillow with a pannel in the middle for the ground sensor plate. This way it will be held in place: pillowsensor

I decide I wan’t to get rid of the wires moving inside the pillow to. So I design the routing as part of the coper fabric. I first make a test and use a marker to draw the design of the coper fabric.pillowsensor pillowsensor After this I design it in Coreldraw pillowsensor During this process I have the idea to also test a design that has a triangle shape instead of a square. The idea is that on the thin side the measurements will be lower than on the wide side. Thus making a slicer from low to high that will be able to power the motor and led from low to high. While working with the step response I’ve noticed the volume of the plate influences the readings to I want to play with it. So I made a quick test pillow with one triangle that I used on top of this page video. The sliding sensor reading actually works really well and i’m very enthusiastic.

pillowlableprocess Back to the Corel draw design, I draw and lasercut two cardboard stencil. One with square sensors and one with triangles. I use the stencils to draw the design on the copper fabric which I then cut out with scissors and iron on the fabric:

pillowsensor pillowsensor

Thinking this will be it the perfect pillow for my final project that will fit nicely inside the cushion cover I made before, I sew the design extra carefully and made the pillow. All the 4 wires from the two step response sensors enter at the side of this pillow making it easy to connect the micro controller and getting rid of long wires in between. pillowsensor

Sadly when I try to read the sensor data it’s extremely fluctuating you can see that making nooo sense at all. The slicing effect is gone and after some testing I convince myself The triangles must be faced the same side, so the wide part needs to be where the wire is connected. And I think the coper fabric traces are interfering even more..

I quickly make a new design. This is how the sensors are located inside the pillow. pillowsensor Since i’m running out of time I skip the side panels, this part will be inside of a cover anyways plus it’s easier to put the stuffing in. Here you see the making process: pillowsensor pillowsensor

And the result. Surely this must work since it’s exactly the same as the tiny yellow test pillow that worked nicely with the only difference it’s two sensors next to each other instead of one… pillowsensor

Nope.. still no accurate sensor readings. It’s going all sorts of directions but I don’t have the sliding effect I had with the yellow pillow. I decide to debug.

  • Step 1. test the yellow pillow with one sensor, that worked before, with the new PCB -> done, still works fine so it’s not the new board.

  • Step 2. Only connect one of the two sensors from the newly made pillow-> done, doesn’t work

  • Step 3. wondering…

  • Step 4. Do step one again and put new pillow with the double sensor close to it. I see now that the presence of the coper plates make the sensor reading fluctuate.. all this time the problem was the two sensors near to each other… The coper plate interferes the reading. Even when not connected to power.

  • Step 5. flabbergasted.. Put a message in mattermost and decide what to do next.. One sensor instead of two or something else?


My fabacademy peer Leo has some time to do a chat with me. Together we discuss my findings. Leo remembers that insulating the whole sensor with a coper shield connected to the ground will stop all the interference. But it will also stop making it a touch sensor and it will become a pressure/ movement sensor. Since squeezing the pillow will change the distance of the two plates and this will be readable. Here you see a drawing on the matter: pillowsensor

Before putting to much effort in this I decide to test it. (I learned from my mistakes) It actually works pretty well. Well enough to have a reading. Even tough the design was not made to be a pressure sensor (triangle shaped coper pads and the sensor in the middle). It’s not perfect but I’m running out of time! pillowsensor

I decide to make it, be done with it, focus on the bigger picture again. pillowsensor

Here you see it all together. alt text consisting of the following layers:

  • first layer, outer fabric
  • second layer, coper shield
  • thirds layer, outer two plates curled like taco’s
  • fourth layer, inner plates in the middle of the pillow.

By now i’m wondering if I should have gone with the Velostat sensor I did earlier instead of step response since it’s a squeaking sensor now ;D.

night light system integration

Beside from the pillow, this week was also the first time I connected the neopixels and the stepper motor to check if everything worked nice with the power supply board I made and it did! pictures

After testing the power supply I dove into this code I used during output devices.

Microstepping
/*
 * Simple demo, should work with any driver board
 *
 * Connect STEP, DIR as indicated
 *
 * Copyright (C)2015-2017 Laurentiu Badea
 *
 * This file may be redistributed under the terms of the MIT license.
 * A copy of this license has been included with this distribution in the file LICENSE.
 */
#include <Arduino.h>
#include "BasicStepperDriver.h"

// Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step
#define MOTOR_STEPS 200
#define RPM 120

// Since microstepping is set externally, make sure this matches the selected mode
// If it doesn't, the motor will move at a different RPM than chosen
// 1=full step, 2=half step etc.
#define MICROSTEPS 1

// All the wires needed for full functionality
#define DIR D9
#define STEP D10
//Uncomment line to use enable/disable functionality
//#define SLEEP 13

// 2-wire basic config, microstepping is hardwired on the driver
BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP);

//Uncomment line to use enable/disable functionality
//BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP, SLEEP);

void setup() {
    stepper.begin(RPM, MICROSTEPS);
    // if using enable/disable on ENABLE pin (active LOW) instead of SLEEP uncomment next line
    // stepper.setEnableActiveState(LOW);
}

void loop() {
  
    // energize coils - the motor will hold position
    // stepper.enable();
  
    /*
     * Moving motor one full revolution using the degree notation
     */
    stepper.rotate(360);

    /*
     * Moving motor to original position using steps
     */
    stepper.move(-MOTOR_STEPS*MICROSTEPS);

    // pause and allow the motor to be moved by hand
    // stepper.disable();

    delay(5000);
}

I changed the speed of the motor by altering this line: #define RPM 120 Now I see the motor is moving in steps, it’s vibrating too. It’s definitely not a smooth micro stepping movement. I’m very bumped because I though It was since it moved to nice with higher speed.

I start by checking with my multimeter if the M1, M2 and M3 pins on the A4988 driver are 5V in the circuit. I now think it must be a coding problem. Maybe this arduino library it’s working with microsteps. I start a messy process testing different things starting with Accelstepper library and a few samples without librarys including the code from the groupassignment but nothing seems to work. I also check the Vref on more time but it seems to be fine, during week 9 I tested this.

I ask for help from my college Niels. He point’s me out to the fastaccelstepper library made for working with steppermotors and ESP’s. I have trouble installing it because apparently installing it via the arduino library interface gives a compiling error. it’s saying the library is not compatible with ESP32 that can not be right.. The problem was that it was an old version. You have to download the library directly form their github and past it inside documents -> arduino -> librarys This fixed the compilation error.

This was the wrong library version directly from Arduino: alt text

This is the right library version from Github alt text

The code I used for testing the micro stepping with the FastAccelStepper library I borrowed from a project from Niels rotary tumbler with a continuously running stepper motor and I used his code as a base for my project. He worked with the fastAccel Library. I altered the code to the most simple form so it will only turn forward to test the micro stepping.

Microstepping FastAccelStepper
// code based on the FastAccelStepper library
// code altered by Niels van Houtum
// simplified by Vera Schepers
#include <FastAccelStepper.h>

 int motorSpeed = 50;
// init fastaccel objects
FastAccelStepperEngine engine = FastAccelStepperEngine();
FastAccelStepper *stepper = NULL;

// IO pin assignments
#define dirPinStepper D8
#define stepPinStepper D9

// config variables
int rpm;
int microStepping = 16;

void setup() {
 // initialize stepper
    engine.init();
    stepper = engine.stepperConnectToPin(stepPinStepper);
    if (stepper) {
      stepper->setDirectionPin(dirPinStepper);
      stepper->setAutoEnable(true);
      stepper->setSpeedInHz(motorSpeed);  
      stepper->setAcceleration(200 * microStepping);    // 00 steps/s²
      stepper->applySpeedAcceleration();
    
    }

} 

void loop() {
  if (stepper) {
    // dit laat de stepper draaien (continu)
    stepper->runForward();
  }
}

Same thing happened as before, in high speeds it works fine, in low speeds not. Is seems there is a problem with micro stepping. And maybe the Vref because of the odd behavior of the motor.

I decide to change the Vref from 0.68 V to 0.92. See notes on the topic from week 9:

Vref=Imot x 8 x Rsen

Imot = maximum motor current = 1.7 Amps in the datas sheet

Rsen = current sensing resistance = driver datasheet 0.050 ohms before 2017 0.068 ohms after

1.7 * 8 * 0.068 = 0.92

1.7 * 8 * 0.050 = 0.68


1 X 8 X 0.1
Since I don’t know if the driver is older or younger than 2017 I used both to check what works.

Maybe it’s an old driver? At this point I mention the Jack plug to power my my PCB is a bit lose and doesn’t always connect, I replace the component and will try it again later.


I wanted to work on the base of the lamp to implement the motor and neopixels. I started by adding the Nema stepper motor to my Fusion 360 design but that’s were I left it. I had been to occupied with the input pillow and the stepper motor.. To be continued. pictures

But I did finally cut, drill, bend and mount al the acrylic leafs for the light bending effect. I also replaced the bearing holders with a new design and I tested it by turned it with my hand. In this video I have put the flash light of my phone below the object to test the effect in the dark:

Reflection

I still have lots to do. I have learned to first do more testing instead of thinking. I made a lot or wrong assumptions in the pillow design process costing me pressure time. I feel the pressure for finishing this project and that’s why I started working on a day to day schedule for the coming weeks on the final project process page to give me more grip. I do really enjoyed seeing the kinetic mechanism functioning for the first time and that’s very motivating!

Notes on Neil’s lecture

This week is about the system integration,we will see how all the component come together. Making things look nice will also change how you interact with it. We wan’t things to be beautiful and useful

A good design needs:

  • simplicity
  • visibility and feedback
  • Natural mappings this means controls where you expect them to be, if your using symbols, use symbols that make sense.

Jan made a nice recitation here about system integration. here you can find some examples of system integration

Some tips: When design for manufacturing use standard components and use:

  • flexures if possible
  • fasteners otherwise
  • adhesives if no other option Think about the right to repair and recycle. What will happen at the end of their lifetime Try to eliminate the need of careful alignment Try to minimize parts

Incorporate how to make/ use your design:

  • BOM Bill of materials KiCad has a plugin to generate this
  • Assembly instructions
  • Document how to use it fun fact: HOWTOONS cartoon instructions

Packaging

  • How will the electronics ensemble
  • Design were the wires go, design the routing.
  • align the mechanisms

Testing

  • Quality assurance defect detections
  • QC Quality control
  • Fuzzing

Common mistakes

  • Power transistors, you can blow them up. A motor act like a coil, if current flows though there is a magnetic fields, it can turn into a reverse current and blow out the motor. Add a diode to protect it.
  • Voltage regulator and input output if you connect the supply the wrong orientation you kill the regulator, use a polarized connector.
  • Use vinyl foil to shield sensitive electronics to reduce the noise.
  • Power can fail test how much current you need from everything.
  • Power drop, weird behavior can be the battery of the power supply.
  • If wires get longer the resistors go’s up and the inductance goes up. use Bypass capacitors because the wire has lots of conductance
  • make sure you have a common ground, For high current connect them to one point ! not via other wires
  • check for buffer overflow