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 ?
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.
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.
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.
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.
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 ();
}
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.
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.
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.
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.
Comments
That's very cool. Thanks for posting it.
What a fun thing to have sitting on your desk!
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 ?
I have to improve the long term stability, then I make a small docu and provide it as Open Source project.
best regards
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
Nicely done! Looks like it's nearly stable, a bit better tuning and it should float for hours.
Lawson
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
Graham
Graham
here is the try of a docu.
any comments and suggestions are welcome.
Reinhard
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
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
When I said I wanted to try this I was referring to the project, not your code.
Sorry to confuse you, good luck.
Graham
Chaotic and at the same time beautiful!
Thanks for posting this.
must zip the vid, because have trouble with upload.
Reinhard
video is here : http://home.mnet-online.de/reimay/Projects/
starts with o-scope sreenshot of pwm and sensorsignal in closed loop process
Reinhard
Was a fun to do that.
bye
Reinhard
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
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
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
I agree in all points.
btw. another nice experiment could be to overlay the set point with a sine function.
Reinhard