Shop OBEX P1 Docs P2 Docs Learn Events
Search for "floating ball" application - Page 2 — Parallax Forums

Search for "floating ball" application

2

Comments

  • ReinhardReinhard Posts: 489
    edited 2012-01-16 11:51
    lift off . . .
    Film.zip 512.7K
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-16 11:56
    Reinhard,

    That's very cool. Thanks for posting it.
  • jazzedjazzed Posts: 11,803
    edited 2012-01-16 12:00
    Excellent!
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-01-16 12:17
    This is great!! It needs to be turned into an Instructable and/or any other project site.

    What a fun thing to have sitting on your desk!
  • jmgjmg Posts: 15,183
    edited 2012-01-16 12:18
    Reinhard wrote: »

    Good link - that is an impressive tooled design. (and the English link)

    http://www.bis0uhr.de/projekte/schwebekugel/english.php

    They use magnets at both ends, to help reduce the control power needed, and get a nice levitation distance.

    I notice it needs careful initial placement, as there will be a point above which it flies up magnet-to-magnet, and below which the coil AT just are not enough to overcome gravity.

    Less clear is if the control point is true analog, or if it hits the limits, but at a certain self centering duty cycle.
    The 1N4148 is likely to not survive 500mA switching operation ?
    R1 & C2 suggest an attempt to loop compensate the control.

    Perhaps this could add some LEDs to show control ?

    Notice there seems to be a spin-pendulum action on the suspended magnets ?

    Do they sell these as kits ?
  • ReinhardReinhard Posts: 489
    edited 2012-01-16 12:43
    Thanks all,
    I have to improve the long term stability, then I make a small docu and provide it as Open Source project.

    best regards

    Reinhard
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-01-16 19:48
    Reinhard wrote: »
    Hi,
    Do anyone know a propeller based application about "floating ball" control loop?
    Means to keep a metallic object in a certain distance by a (PWM) - controlled magnetic field.
    Measure the object position with hallsensor or phototransistor.
    I search in the forum, but nothing found, maybe I used the wrong keyword.

    Thanks for any hints,
    Reinhard

    Reinhard,

    Do you know anyone employed by Siemens UB Med? They have a device out which does precisely that, used for positioning a catheter tip with the assistance of a magnetic field.
    http://www.hoise.com/vmw/02/articles/vmw/LV-VM-10-02-26.html


    For an idea of what they are doing. This link is probably a bit dated, but you may find more from there.

    Frank
  • LawsonLawson Posts: 870
    edited 2012-01-16 20:18
    Reinhard wrote: »
    lift off . . .

    Nicely done! Looks like it's nearly stable, a bit better tuning and it should float for hours.

    Lawson
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-01-16 21:09
    Just noticed this. Great project!
  • lardomlardom Posts: 1,659
    edited 2012-01-16 22:24
    I find that interesting too. I favorited a couple of links. Video
  • ReinhardReinhard Posts: 489
    edited 2012-01-17 02:27
    Hi, thanks again
    it is time to answer some postings:
    @jmg:
    Do they sell these as kits ?
    I am not sure, but I believe not, because I have not found a remark about sell the kit.

    @frank freedman:
    Do you know anyone employed by Siemens UB Med?
    No I know nobody from Siemens MED,but is nice to see to do meaningful properties with solenoids. ( contrast to me )

    @Lawson:
    Thank you for the large explanation, if have not forget it, but I must read it again and again. (seriously lecture )

    Before I continue the software part, I have to build the setup in an acceptable state.
    Actualy the wiring is a little bit.. chaotic.

    Reinhard
    1024 x 768 - 115K
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-01-17 03:50
    What about measuring the coil's inductance or at least a quantity proportional to it? Must be a function of the object's position. The novelty toys must be doing something like that, if the PWM waveform ends up trapezoidal perhaps you could get the slope and use that as the error signal.

    Graham
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-01-17 03:51
    oops, did not see this is three pages long. Will read it first!

    Graham
  • ReinhardReinhard Posts: 489
    edited 2012-01-17 08:38
    Hi,
    here is the try of a docu.

    any comments and suggestions are welcome.

    Reinhard
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-01-17 08:44
    To find the set point you need to hold the ball in place but on a stand placed on a balance, adjust PWM until weight reduces by the balls weight. The magnetic field measured will be a good starting point for the set point and could then be adjusted to change the ride height.

    It would also be a good check to see that the sensor is not saturated and that your coil has sufficient pull.

    Cheers,

    Graham
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-01-17 09:01
    It also seems like you just need a little push on the software front, do you have your current code? I'd love to try this myself but just no time.

    Graham
  • ReinhardReinhard Posts: 489
    edited 2012-01-17 09:08
    It also seems like you just need a little push on the software frontGraham

    :smile::smile:
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-01-17 09:14
    Actually I have done PID control but I don't have hardware for this project otherwise I would probably find the time to fiddle with the code.
  • ReinhardReinhard Posts: 489
    edited 2012-01-17 09:27
    Graham, please give ma a little more time.

    I have started this project in middle of last week and I am very happy about the progress.

    But I like to play with the sw a few days, before I go public .

    Please have comprehension.

    best regards

    Reinhard
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-01-17 09:31
    When I suggested that you post your code it was not because I want it. I thought you might like some help.

    When I said I wanted to try this I was referring to the project, not your code.

    Sorry to confuse you, good luck.

    Graham
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-17 09:38
    Reinhard wrote: »
    Actualy the wiring is a little bit.. chaotic.

    Chaotic and at the same time beautiful!

    Thanks for posting this.
  • ReinhardReinhard Posts: 489
    edited 2012-01-17 14:31
    Now with the pid algo it works over hours, after about sixty minutes I switched off the power supply.

    must zip the vid, because have trouble with upload.
    #include "max147.h"
    #include <propeller.h>
    #include <stdio.h>
    
    
    #define STACKSIZE 20
    #define W 1050
    
    int PWM;
    static int cog_stack[STACKSIZE];
    
    ///////////////////////////////////////////////////////////
    #if(0)
    void msleep(int t)
    {
        waitcnt((CLKFREQ/1000)*t+CNT);
    }
    #endif
    ///////////////////////////////////////////////////////////
    void usleep(int t)
    {
        if(t < 10)  
            return; 
        waitcnt((CLKFREQ/1000000)*t+CNT);
    }
    ////////////////////////////////////////////////
    // PWM Generation run in a single cog
    ////////////////////////////////////////////////
    void Task_PWM_Pin ()
    {
        int t;
        int tInc = CLKFREQ/1000000; 
        int tC = 100 * tInc;
    
        CTRA = (1<<28) + 15;
        FRQA = 1;
        DIRA |= (1 << 15);
        
        t = CNT;
        
        while(1)
        {
            if(PWM > 100)
                PWM = 100;
            if(PWM < 0)
                PWM = 0;
            
            PHSA = - PWM * tInc;
            t += tC;
            waitcnt(t);
        }
    }
    ////////////////////////////////////////////////
    // used for see the Sensor Characteristic
    ////////////////////////////////////////////////
    #if(0)
    void getTranferCharacteristic ()
    {
        unsigned short adc;
        
        DIRA |= 0xFF;
        
        for(PWM = 0; PWM <= 100; PWM++)
        {
            adc = readMAX147(0xFF);
            
            OUTA = adc / 4;
            
            msleep(100);
            
            printf("%d;%d\n",PWM,adc);
        }
    }
    #endif
    ////////////////////////////////////////////////
    // used for determine the set point
    ////////////////////////////////////////////////
    #if(0)
    void getRefPos()
    {
        short x;
        DIRA |= 0xFF;
        PWM = 50;
        while(1)
        {
            x = readMAX147(0xFF);
            OUTA = x >> 2;    
            printf("%d\n",x);
        }
    }
    #endif
    
    ////////////////////////////////////////////////
    // several methods for control
    ////////////////////////////////////////////////
    void comparator_method ()
    {
        short w,x;
        
        w = W;
        DIRA |= 0xFF;
        
        while(1)
        {
            x = readMAX147(0xFF);    // read actual value
            
            OUTA = x >> 2;            // scale to 8 bit for DAC
            
            if(x < w)
                PWM = 90;
            else
                PWM = 5;
                
            //printf("%d\n",x);
            
        }
    }
    ////////////////////////////////////////////////
    void proportional_method ()
    {
        short w,x,e,y;
        
        #define Kp 4
        
        w = W;
        DIRA |= 0xFF;
        
        while(1)
        {
            x = readMAX147(0xFF);    // read actual value
            
            OUTA = x >> 2;            // scale to 8 bit for DAC
            
            e = w - x;                // error
            
            y = Kp * e;                // control output ( only Proportional term )
            
            PWM = y ;
            
        }
    }
    ////////////////////////////////////////////////
    void pd_method ()
    {
        short w,x,e,e2,y;
        
        #define Kp2 40
        #define Kd  25
        
        w = W;
        e2 = 0;
        DIRA |= 0xFF;
        
        while(1)
        {
            x = readMAX147(0xFF);    // read actual value
            
            OUTA = x >> 2;            // scale to 8 bit for DAC
            
            e = w - x;                // error
            
            y = e * Kp2 + (e - e2) * Kd ;    // control output 
            
            e2 = e;
            
            PWM = y ;
            
            
        }
    }
    ////////////////////////////////////////////////
    void pid_method ()
    {
        short w,x,e,e2,ei,y;
        
        #define Kp3 40
        #define Kd2  25
        #define Ki 4
        
        w = W;
        e2 = 0;
        ei = 0;
        DIRA |= 0xFF;
        
        while(1)
        {
            x = readMAX147(0xFF);    // read actual value
            
            OUTA = x >> 2;            // scale to 8 bit for DAC
            
            e = w - x;                // error
            
            ei += e;
            
            y = e * Kp3 + (e - e2) * Kd2  + ei * Ki;    // control output 
            
            e2 = e;
            
            PWM = y ;
            
            
        }
    }
    ////////////////////////////////////////////////
    // main returns never
    ////////////////////////////////////////////////
    void main ()
    {
        initMAX147();
        _start_cog_thread(cog_stack + STACKSIZE, Task_PWM_Pin, NULL, NULL);
        
          //getTranferCharacteristic();
          //getRefPos();    
          
          //comparator_method();
          //proportional_method();
          //pd_method ();
          pid_method ();
          
    }
    

    Reinhard
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-01-17 15:09
    Great stuff! Look forward to the video. Might be time to start a youtube channel :)
  • ReinhardReinhard Posts: 489
    edited 2012-01-17 15:18
    Hi
    video is here : http://home.mnet-online.de/reimay/Projects/

    starts with o-scope sreenshot of pwm and sensorsignal in closed loop process

    Reinhard
  • ReinhardReinhard Posts: 489
    edited 2012-01-18 02:28
    for correct finish this thread, I send the updated documentation.

    Was a fun to do that.

    bye
    Reinhard
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-01-18 02:31
    Looks really good though it has a steady state oscillation, some tweaking of the gains might fix that or maybe it needs to be faster?
  • ReinhardReinhard Posts: 489
    edited 2012-01-18 02:39
    Looks really good though it has a steady state oscillation, some tweaking of the gains might fix that or maybe it needs to be faster?

    This is what I in next time will do.
    Learning more about this system.
    Will vary the gains and see how is the system react.
    Therefore if have the DAC output to view into the system.
    Another idea is to give the DAC output ( digitized sensor signal) to the pc soundcard and meas the frequency of this swing.
    Maybe more perception be win.

    What you think about ?

    Reinhard
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-01-18 03:54
    Something like viewport is really useful for things like this and more flexible than a scope (easy to capture step response etc).

    When trying position control of a motor with PID I learnt a great deal from simple experiments, it is good fun and there are lots of details that just don't appear in most of the books.

    Graham
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-01-18 05:34
    Reinhard wrote: »
    Hi,
    here is the try of a docu.

    any comments and suggestions are welcome.

    Reinhard

    Yeah, one thought just popped out of the mental delay line.......

    For positioning (at least in an open frame assembly), consider a ping module for vertical position (and one for horizontal positioning if two axis of control). Use the ping to measure the actual distance from ping to ball, and couple lines of code to determine actual distance of ball in range of travel. Use value as feedback into your PID algorithm.

    FF
  • ReinhardReinhard Posts: 489
    edited 2012-01-18 05:40
    Something like viewport is really useful for things like this and more flexible than a scope (easy to capture step response etc).

    When trying position control of a motor with PID I learnt a great deal from simple experiments, it is good fun and there are lots of details that just don't appear in most of the books.

    I agree in all points.
    btw. another nice experiment could be to overlay the set point with a sine function.

    Reinhard
Sign In or Register to comment.