Magnetic Levitation - The Digital Way
Magnetic-Levitation-Object with only - an ESP32Pico M5Stack „ATOM LITE“ or „ATOM MATRIX“ - a modified simple 5V-relais and - a HALL-sensor A1302/A1308 The wooden carrier is made of an embroidery frame.
After I had successfully built up a "Magnetic Levitation Object" in conventional analog design and showed that in article "Magnetic Levitation - The Easy Way" , I now wanted to replace the technology of the 1980s with modern digital components. The object should also get a little smaller, and -as I hope - more beautiful.
In this video you can see the result: Magnetic Levitation - The Digital Way
Instead of the analog comparator, an ESP32 SoC module from M5Stack is now used. The ATOM LITE or also the ATOM MATRIX are extremely small (24mm*24mm*10mm or 15mm) and still offer all the appreciated features of the ESP32.
So especially a quite fast 12Bit-ADC is available.
Furthermore a modified 5V relay is used as electromagnet. The modification of the relay is described in detail HERE. It can be controlled directly with 3V3 from the ESP32.
The Hall sensor A1302 is now operated with 3V3 (comming from the ESP32-board) so that the level is suitable for the ESP32 ADC. This is a bit below the sensors data sheet specification, but works very well.
The small minmalistic ARDUINO IDE program makes sure that the ADC of the ESP32 behaves like the comparator LM311 of the analog version - including the hysteresis, which stabilizes the behavior of the control very much. This is extremely easy to program, but works very well once you have experimentally determined the correct value for the TRIGGER variable. This value is very dependent on the magnets and the payload weight, as there is only a range of a few mm where the electromagnet can control the flightlevel of the magnetic object..
With a future extension of the program this value could be determined in the program and stored in the permanent memory of ESP32.
I describe this circuit and my practical experiences >>HERE<< in more detail.
The Magnetic Levitation did fascinate me a lot and so this story goes on in meanwhile four parts at https://peterneufeld.wordpress.com/category/magnetic-levitation/
Here you see the program-code:
In this video you can see the result: Magnetic Levitation - The Digital Way
Instead of the analog comparator, an ESP32 SoC module from M5Stack is now used. The ATOM LITE or also the ATOM MATRIX are extremely small (24mm*24mm*10mm or 15mm) and still offer all the appreciated features of the ESP32.
So especially a quite fast 12Bit-ADC is available.
Furthermore a modified 5V relay is used as electromagnet. The modification of the relay is described in detail HERE. It can be controlled directly with 3V3 from the ESP32.
The Hall sensor A1302 is now operated with 3V3 (comming from the ESP32-board) so that the level is suitable for the ESP32 ADC. This is a bit below the sensors data sheet specification, but works very well.
The small minmalistic ARDUINO IDE program makes sure that the ADC of the ESP32 behaves like the comparator LM311 of the analog version - including the hysteresis, which stabilizes the behavior of the control very much. This is extremely easy to program, but works very well once you have experimentally determined the correct value for the TRIGGER variable. This value is very dependent on the magnets and the payload weight, as there is only a range of a few mm where the electromagnet can control the flightlevel of the magnetic object..
With a future extension of the program this value could be determined in the program and stored in the permanent memory of ESP32.
I describe this circuit and my practical experiences >>HERE<< in more detail.
The Magnetic Levitation did fascinate me a lot and so this story goes on in meanwhile four parts at https://peterneufeld.wordpress.com/category/magnetic-levitation/
Here you see the program-code:
/************************************** Magnetic Levitation object: Lets a LEGO man, glued together with a neobodymium magnet, float under a modified 5V relay - SoC: ESP32, very good: M5Stack's ATOM LITE or ATOM MATRIX - Electromagnet: Modified 5V-Relais HW-482 with 3V3/5V transistor input - Sensor: HALL-sensor A1302 or A1308 ***************************************/ // int TRIGGER = 2740; // Triggerlevel is set to a level where weight of payload is equal to the force between magnet and electromagnet int TRIGGER = 2740; // good for payload = 2 Neobdym-Magnets and a LEGO-Man int HYST = 35; // Hysterese for trigger level int HALL_PIN = 33; // analog Signal from HALL-sensor at GPIO33 int HALL_VAL = 0; // int RELAIS_PIN = 23; // GPIO23 to drive the transistor input of the modified 5V-relais that is used as electromagnet int X = 0; // void setup(){ Serial.begin(115200); pinMode(RELAIS_PIN, OUTPUT); Serial.print("Magnetic Levitation: START " ); } void loop(){ HALL_VAL =analogRead(HALL_PIN); //read HALL-Sensor with default 0-3.9V input >> 12bit if (HALL_VAL < (TRIGGER + X) ){ digitalWrite(RELAIS_PIN, HIGH); // lift the payload X = HYST; } else{ digitalWrite(RELAIS_PIN, LOW); // drop the payload X = 0 - HYST; } // no delay is best // delay (1); }
Discussion (0 comments)