Monday, March 21, 2016

MOVE
Iteration #2

Project partner: Salma Kashani

Introduction:

Previously on iteration one, different actuation mechanisms were tested to design a haptic feedback in order to communicate  step commands.They include, Static pressure, direct force (impact) and vibration. We reached our paradigm, when we were applying poke stimuli using long sticks, which could also explain the reason that it was being used in martial art  and military training for gait modification. None of our experiments using pressure and vibration at constant frequency was as informative as poke experiment. We decided to make a similar vibration by exploiting the force impact feeling.

Motivation:

Our initial findings showed that having two body sites works more effectively compared to single body site. In addition one of our main objective is to make our haptic stimuli as close as we can to the poke feeling. These results have motivated us to expand our study on single vs two tractors and explore whether we can have more expressive force feedback using solenoids.



Objectives:

1) Tailoring the force impact by means of solenoid
Some of the main limitations of tractors such as small displacement and low produced force encourage us to see the effect of direct force on haptic perception. Although this force is much smaller than required force to move a leg but at least it is from the same family of poke.

2) One site vs two sites stimuli
 The effect of having redundancy in spatial stimuli mechanism is investigated for both vibration and force impact.


Step 1,


Solenoid vs Voice coil,

Although both of them are working based on electromagnetism forces there are differences in their mechanisms . A solenoid consists of a piece of ferromagnetic material which moves inside of a coil. When coil is energized using electrical current, the ferromagnetic part moves in order to increase the magnetic flux by filling the air gaps. A biased spring, will move back the metallic core when the coil is deenergized. They often are used  to create large displacement and forces very fast(1 time) but not at high frequencies.On the other hand voice coil is permanent magnet which is enclosed in a coil. Their main application is to create vibration so they work at high frequency and generate lower force and displacement compared to solenoids.

  • Implementation of Solenoid:
To install our solenoid on site, We needed to make a holder that mechanically connect the solenoid to the velcro. After trying different flexible and rigid materials with different hole sizes we found out that mounting any flexible or rigid material at the head of solenoid can damp the mechanical impact and would not be as effective if we have other contacts to skin close the point of impact. TO have more free of contact space around our impact point we made the box as depicted in fig.1 a.


Driving a device with a MOSFET


    
fig.1 a) Implementation of solenoid b)Electrical circuit for driving solenoid (http://electronics.stackexchange.com/)

First,we used a piece of balloon as a biased spring to bring the core of solenoid to initial position and later we removed that and benefit from the body stiffness to do the same job. We derived our solenoid by using a MOSFET and a push button circuit as depicted in fig.1.b.This system can be controlled both by arduino and push button. fig.2 shows the complete setup for one solenoid. In order to have more force,we slightly increased the maximum voltage since we were applying short pulses. (20 V and 500 mA).

Fig.2. Solenoid setup 

Step 2

At this part of our study we run some experiments on our friends to have more feedback on our system and have more unbiased results . Similar to iteration one we conduct our experiments on 6 differents points of the leg fig.3.


Fig.3. Stimulation points on the left leg  (photo courtesy: Salma Kashani)

for each point we tried different actuation and number of sites.the same signal of  vibration in iteration 1 was selected. Both vibration and force impact signals' length were less than a second. in each experiment we mount solenoid or tactor on velcro and make sure that there is enough initial stress that they can work perfectly.  Fig 4. shows the installation of tactor and solenoid on velcro.

fig.4.Mounting Solenoid and tactor on velcro 

In our first experiment we compared the behaviour of one site vibration to solenoid impact. We mounted both of actuators on velcro so the participant can switch between the force feedback immediately and compare them. we asked participant to step back and forth and bend and release her knee while we were  manually triggering the feedback system. A noise cancelling headphone was also used to eliminate the  effect of solenoid sound when being activated.

                                        
fig.5 Applying force feedback to participant's knee

We explained our experiment to the participants and asked them to tell us what was the message of the signal they had felt. if it took them so long to explain the message we provided them with some options and if they couldn't identify the message we considered that signal had no message. at each level we also checked whether they could feel the force signal or not. 
We  tested our two sites  stimuli on a new participant, similar question were asked. In addition we asked our participant to tell us her preference between vibration and force impact and which one she found more effective in conveying the gate modification message. fig.6 shows the two sites stimuli in action. 

fig6. a) Two sites force impact stimuli b)Two sites vibration stimuli 

we ran all of the experiments on our third participant, however as we got closer to the end of experiment our participant seems to be bored and gave the same answers. Due to our lengthy experiment, we decided to just study one subject on each participant in future.

Discussion:

Although our initial experiments on us were suggesting that force impact is more informative than vibration , running the same  experiments on the participant gave unpredicted results. It is still too soon to generalize our results due to limited number of participants and subjectivity of our study, but we reach to following findings based on common answers of our participant.

  •  Force impact vs vibration
Two of our participants were mentioning that for single point of contact they could barely feel the force impact and found vibration to be more informative. We expected that our force impact to be at least more sensible because it has higher force and displacement amplitude, but in practice, since vibration was carefully selected from a library of vibration. it could evoke the feeling by working in certain range of frequency, on the contrary,  force impact is working similar to impulse signal and resonant all of the frequencies; however, this full spectrum of resonance can  cause ambiguity in receptors and may have smaller amplitude at certain range of frequency.

  • One vs two sites of stimuli
Two of our participants in addition to us found two sites of stimuli to be more transparent in conveying a message signal compared to one stimuli,regardless of the nature of it.  This means that, they got stronger messages of the same type when using two stimuli.  Sometimes  when they were using only one force feedback the message was vague and they could only feel that there was a vibration or impact in comparison with two stimuli that they could realize the message. The conveyed messages were not consistent from one participant to the other but for most of them the back of the leg stimulations had more propelling meaning while in the front leg was more dragging and stopping.  
fig.7. Conveyed messages at different points and different states (standing/walking)

As shown in fig.7 both position and timing of stimuli are important in cognition part. These massages can vary based on position of stimuli and state of the leg/activity. This is one example of different messages during Standing/Walking state.The question mark means no message. 

Why conveying a message using two stimulus is more direct and effective?

Based on our experience and asking our participants we believe that having just one stimuli can be precepted more accidental compared to two stimulus. Having two sites of vibration or impact make a redundancy to our signal and in most of the cases make the user think "for sure there is a message and what should I do? What is that message? " 
The further question that we should respond is the intensive or extensive nature of each of these stimulus. As we know the  intensive property does not depend on the stimuli amplitude and amount, nor the size and extent of actuator , while we have additive relationship in an extensive property.

Source of errors

  • Actuators placement
  • number of participants 
  • Solid design of  experiment
  • physical limitation


Conclusion 

In the iteration two, we tried to replicate the similar poking feeling by means of solenoid and expand our study on direct haptic messaging using local stimuli/stimulus. We designed studies to find the differences between 1) Vibration and force impact and 2) Single and two sites of stimuli.
Although we couldn't realize the communication of exact messages to each individual, but our findings show that having vibration or impact at the back part of the leg is more propelling while on the opposite site is more dragging and prohibiting. Perception of vibration is more stronger than force impact when we are dealing with only one site of stimuli, while two sites of force impact is overtaking two vibrators. We could also discover that having having redundancy in our stimuli can help better precepting of the signal and enhance expressiveness of our commands. 
In the next step, instead of exploring different actuation and sequence of activation that have great transparency and conveying a solid message to every user, we decided to study more the intensive and extensive properties of  each stimulus to find the answer that can explain why having two sites of stimuli works better than single site. Both temporal and spatial properties should be tested by means of  designing studies in which placement, amplitude and timing varies. The next question that we are curious about is to know if this is just because we are doubling the amplitude by having two stimulus or we have sensory integration similar to multimodal system.

My contribution

We were developing each part of the project together after having conversation and sharing ideas with each other, so it is hard for me to draw line between my work and Salma's.
I think because of my background, I was mainly involved in hardware developing and experimenting the best design of the solenoids, includes different mounting setups, different solenoid head sizes and mechanisms to bring the solenoid back to its initial position.
I was also involved in designing our study to meet our objectives, plus, synthesizing the results of our study.In addition, I was helping participants to mount the setup on their legs during study.


Thursday, March 10, 2016

Lab 5: Make Something Engaging





PID implementation and Haptic + graphic experience.


Q1-Modify the Arduino source control to accomplish the same output without using the provided library PID controller.

There are several ways to calculate and implement PID controller on microprocessors. In previous post we explained the difference between sampling methods and importance of sampling time in designing a controller. While it is feasible to tune the controller parameters after defining the sampling rate, it requires many trial and error attempts and will not be very accurate in practice. therefore, we need to have a mapping system to transfer our PID controller from continuous time into discrete one. To do that we need to transfer our system model from S plane to Z plane. From several different methods of transformation we will explain backward difference approximation (B.D) and Tustin model. Our PID controller can be written as:

(1)
We also consider a filter for our derivative term. By defining N we can change the position of pole of derivative term.

   (2)
to map from S domain to Z domain we can use the following approximation in which h is the sampling time.
 (3)
by substituting (3) to (1) we will have the general equation as follow: 
(4)

for different method we can find the a and b coefficients according to following table.


 and in order to implement that in microprocessor we just need to code this line:

Arduino PID Code:

To make our digital controller, first we need to make a fixed sampling time. I just used timer interrupt to read the encoder value at every 1 ms.


#include "Twiddlerino.h"
#include "PID_v1.h"
#include <MsTimer2.h>

void setup()
{
  Serial.begin(115200);
  TwiddlerinoInit();
  target = 0;
    MsTimer2::set(h,read);
    MsTimer2::start();

}

then in the read function, I made my controller  as follow:

void read(){
                 K=p;
                 Ti=i;
                 Td=d;
                 Tf=Td/N;
                 H=h/1000;
               //  a0=2*Ti*(2*Tf+H);// Tustin begins
               //  a1=-8*Ti*Tf;
               //  a2=2*Ti*(2*Tf-H);     
               //  b0=K*(H*H+2*(Ti+Tf)*H+4*Ti*(Td+Tf));
               //  b1=K*(2*H*H-8*(Td+Tf)*H-2*H*(Ti+Tf));
               //  b2=K*(H*H+4*Ti*(Ti+Tf)+2*H*Ti*(Ti+Tf)); //Tustin ends
                 b0=(K+(Ti*H*0.5)+((2*Td)/H));// Bilinear approximation begins
                 b1=((Ti*H)-(4*(Td/H)));
                 b2=-K+(Ti*H*0.5)+((2*Td)/H);
                 a2=1;
                 a1=0;
                 a0=1; // bilinear approximation ends
                     pos2=pos1;
                     pos1=pos;
                    pos=ReadEncoder();
                     er0=pos-target;
                     er1=pos1-target;
                     er2=pos2-target;
                     //Uout=(b0*er0+b1*er1+b2*er2+a1*Uout1+a2*Uout2)/a0;
                     Uout2=Uout1;
                     Uout1=Uout; 
                     Uout=K*er0+i*er0*H+d*(er1-er2)/H; //simple error and integral terms
          }

Q2- Make an engaging experience!

In this part, I decided to use a 3D Puma Robotic Demo library from Matlab and connect  it to the Twiddler.  This code presents a 6 degree of freedom robotic arm, which can simulate forward and reverse kinematics.The Idea is that user can select and control any degree of freedom that they want. Based on the size of the motor, the PID coefficients will change so that for example by moving theta1 which is a large motor, they feel, large control effort while for moving the robot End-effector (small motor) they can rotate it much more easily.

Fig 1, 3D puma robotic arm (@Mathworks)



Implementation:

First, I wrote the codes that can map the slidebar position to the target point of Twiddler so by moving the slide bar we can feel the movement and visually see it. However the communication was slow and there was a delay between visual command and physical response. Second I made a push button  called TControl to connect the position of the Twiddler to robotic arm. When being pressed, user can move the arm with Twiddler and feel the motor reaction which tries to bring it back to set position. As we can see in Vid 1, By moving the slide bar we can change the set point. To have more smooth tracking of the handler I changed the time interval for sending data from arduino to matlab. 


Next step:

To solve the problem of delay we need to empty the of arduino's buffer  before trying to write on serial port or we can send a package of data or sending data by software's requests. As we can see in Vid 1, by pressing the TControl, we see first  the memory of previous movements is running and then it starts working. I didn't write the codes to select different degrees of freedom and change the PID  coefficients based on them, and it would be further steps of this projec.



Vid1. Controlling robot arm with haptic feedback 

Thursday, March 3, 2016

Lab 4: Controlled Actuation using the PID 


Design a PID controller for position control and implementation of virtual wall!

lab partner: Salma Kashani,


Twiddler haptic knob can be considered as an integrator system in which by applying constant input voltage the system knobe rotates and sum up the rotating angle.  We can simply find the parameters of a integral system model as    

                                                      K          -Td s
                                    G(S) =  ----------- e
                                                      S
and design a PID controller with ziegler nichols or other control methods; however, for this lab we try to do it manually.

Q1. Run the code and try out the P controller. How does it feel? What happens when you change the target position? What does changing the P parameter do? Do you notice any problems? 

We have started our experiment with P=0,  which means that we bypassed the controlling system and therefore we can rotate the knob freely.. by having small values  of P =~0.4 we could see that our system starts to track the target, however the response was so slow and error was high  e=~400.We observed that by changing the target position our system by increasing the P value system responds much faster but becomes unstable. by having large P=~100 even being so close to the target point system starts fluctuating and diverging from target point.    





Q 2. Add the D component to your controller. Tip: you’ll need to modify a parameter in Lab4Arduino.ino, and work it up/down to find an effective value. How does this change the behaviour of the Twiddlerino? Are there any problems?

D can work similar to adding a  damper to our system. first of all it could make our system stable. second by having large value of D system response was slow with no overshoot while decreasing this value can lead to faster responses and generating some overshoot. Third, in order to have small error value we needed to have large P constant and then designing D which can increase the amount of control effort and error was never completely 0,

3. Add the I component to your controller. How does this change the behaviour of the Twiddlerino? Can you create a stable system that reaches the target?

By adding the integrator to our controller we can design a PID with moderate values with no overshoot that can make the error value to 0. Our final values are P=10, I = 5, and D=1,


4. Implement a virtual wall, as a one-sided spring (like Step 1) but active only for θ>0.) What happens? By adding/tweaking PID parameters, can you make it more wall-like?

In our design to have only one sided spring as a wall, we decided to make our controller to be active only when (Theta>0) and for (Theta<0) we set the output of PWM to 0,  by having large P constant we can make a large spring representing our wall. applying small torques to our knob we could definitely see that our controller resists to small disturbance and doesn't let us rotate the knob. by applying larger torque to our system we could eventually rotate the knob but when we suddenly decrease the torque it push us out of the wall and since it had some overshoot which means that our virtual wall was extending out which was incorrect. Then we added large damping effect to our system when we are going inside the wall to a have viscoelasticity in our wall and reduce this damping effect when the wall pushes our finger out. The only reason that we keep some small  D value was to make the overshoot zero. To differentiate between going inside and outside we introduced new position term which keeps the previous value of position after reading the new value.


    pos = ReadEncoder();
   if (pos>=0){
                        p=100;
                          i=2;
                         d=5;
                             if (pos>pos1){
                                                   p=128;
                                                    i=2;
                                                     d=100;}
                                              else {
                                                   p=100;
                                                   i=2;
                                                  d=5;   } 
       
                          myPID.SetTunings(p, i, d);
                         SetPWMOut(PWMOut);}
                    else{
                           p=10;
                            i=0;
                           d=0;
                           myPID.SetTunings(p, i, d);
                            SetPWMOut(0);
                           }
     pos1 =pos;


VID1 - The implementation of  virtual wall



Q5. Play with the controller update rates, and with introducing delays. Hint: use the PID’s SetSamplingRate() command. How does this change the system? What happens if you sample faster or slower? Can you make the interrupt service routine run faster, and see better performance that way

The graph below can explain the behaviour of SetSampleTime. When T1 is switching and T2 and T3 are closed.At this point, we can obtain the error at high speed but our controller cannot generate proper output based on real value of error and works based on previous acquired sample. basically, this value can determine how often The PID algorithm runs and generates output. The default value was set at 1 millisecond which was the minimum. by increasing this value we could see system overshoots and becomes unstable.


Fig1 - Sampling time and controlling diagram 

VID 2 - 10 ms update rate for PID

Q6. Think about different ways of timing the loop (polling “run as fast as you can”, vs. clocked “wake up at a specified time”). Hint: Look at the following Arduino examples: Blink (01 Basics), BlinkWithoutDelay (02 Digital), and FlashLED (MsTimer2). What are the impact of each of these? Which method is implemented in the sample code? Can you make a theory about impact on the
Twiddlerino sketch, and test it?

At this point we are changing the sampling rate and this is similar to the case when  is switching and  are closed. Although our controller is working at high speed sampling rate the value of error is not a real-time value and therefore the control effort is not valid and lead to system instability so the values of our primary PID controller are not useful anymore and we need to design a new controller.

The function of  updateinterval is to send the value of position to screen through processing software. This timing can be present in our control diagram as T2. Different interval time will not affect the performance of controller and our accordingly our feeling, but higher timing will update the visual display at  slower rate and subsequently sudden jump and steps in position display.
In flash Led  example we have an adjustable timer interrupt. By using this timer we can control the sampling rate of the system so we don't need to read it in main loop of the system. To do that we have added the following codes to our arduino:
 void read(){
                     pos=ReadEncoder();
                  }
void setup()
{
                       Serial.begin(115200);
                        TwiddlerinoInit();
                        target = 0;
                        myPID.SetOutputLimits(-255, 255); //for PWM
                         myPID.SetMode(AUTOMATIC); //compute() and things will work
                         myPID.SetSampleTime(1); //every 1 ms
                          last_time = millis();
                           MsTimer2::set(10,read);
                           MsTimer2::start();
       }
This will help us to make sure that our heavy computation in main loop of the system will no affect our sampling rate and controller's performance. 

Vid3, Sampling rate of 100 ms

This case T3 is switching and T1, T2 are closed. Although our controller is working at 100ms sampling rate the value of error is not a real-time value and therefore the control effort is not valid and lead to system instability so the values of our primary PID controller are not useful anymore and we need to design a new controller. 

Conclusion :
We observed that by having any sampling in control loop our first design of controller for (high speed sampling =continues)should be changed based on sampling time. If we introduce both sampling at sensing and updating the control the maximum time will be dominant and should be considered. The sampling time outside of control loop will not affect on mechanical response of the system and only make step like visual graph of position.