Now Reading
POV Candle – mitxela.com

POV Candle – mitxela.com

2023-12-02 06:23:05

Back to Hardware1 Dec 2023
Progress: Accomplished

A tiny volumetric show!

Video Demo




Naturally you may’t actually really feel the volumetric impact on digital camera. It appears to be like much more 3D in actual life.

Thought

I used to be lately lucky sufficient to seek out myself within the pub with some very inventive and proficient individuals. The dialogue turned to digital candles, and the way one may create one thing that might appear to be a flickering candle from any angle. I recommended a persistence-of-vision show, however the basic consensus was that these require an excessive amount of in the best way of supporting equipment to make them work: bearings, and possibly slip rings and so forth.



Afterwards I had a suppose and figured that if the motor and battery had been sufficiently small, the entire thing might spin. I used to be ordering another circuit boards the next day, so I rapidly threw collectively a easy LED matrix board and mixed that with the opposite orders. Small circuit boards from China are primarily free, quick postage is the one factor that issues.



Unassembled matrix boards



A while in the past, I obtained entry to a choose and place machine (a Charmhigh CHM-T36VA). I’ve it on semi-permanent mortgage. It is particularly for one more undertaking, which I’ll write up finally, however my emotions on it may be summarised as follows: Robots are the Future. I’ve spent sufficient of my life manually assembling circuit boards that to have a machine that may construct a board in seconds proper in entrance of me is bliss.



The one downside to it’s that loading the reels takes a very long time. For every distinctive element you must tediously load the reel, which may typically take the most effective a part of 20 minutes. The circuit I borrowed the machine for has 26 distinctive elements, so loading the reels was a full day of labor.



Nonetheless. This LED matrix has exactly one element, and so loading the reels was as brief as technically attainable. Then we are able to crank out the boards at break-neck pace!



Pick and place machine in action



I did not get a correct stencil, I simply laser-etched one in acetate. This undertaking was nonetheless very a lot on the minimal-investment stage, the place I am simply idly throwing concepts round. However a generic tiny LED matrix appeared like a worthwhile factor to have a handful of, it should nearly definitely turn out to be useful.



I did some with 0603 and likewise some with 0805, as I had a few of these already loaded.



Assembled matrix boards



If the circuit board design hadn’t been a rush job, I might have additionally made a round PCB to assist it at a proper angle. The pads alongside the underside had been to solder instantly between the boards. After I come to constructing the following model, that is what I am going to do.



For now I used to be enjoying with concepts. I knew that I wished a microcontroller with a good bit of flash reminiscence on it, as we might desire a good bit of volumetric video information. The temptation was to go together with a Pico, that is twin core 125MHz (or extra) and as much as 16MB flash (and importantly, it is low-cost). One of many foremost drawbacks to the Pico is that it is a ache to make use of the naked RP2040 chip by itself. It has no onboard flash reminiscence, so on the very least you have to wire up a QSPI flash chip, and nearly all the time you may want an exterior crystal and a good quantity of supporting caps. The Pico board by itself is way too massive for our state of affairs.



Nonetheless, a bunch of individuals have produced minimal RP2040 boards catering to precisely this type of state of affairs. Most of them had been inappropriate, both too large or not breaking out sufficient of the GPIO. I discovered one that appears promising referred to as the Waveshare RP2040-tiny. Right here they’ve primarily lower the pico board in half, placing the naked minimal on the primary board and having a secondary board, linked by a flat flex cable, with the USB port, reset and boot buttons.



RP2040-tiny board



This appeared excellent for our prototype. It is nonetheless a bit too large, and nonetheless would not get away all of the GPIO, however we should always be capable to get by.



As for the battery, I instantly grabbed a LIR2450. It is lithium-ion rechargeable, and may ship properly over 100mA. You will get smaller Li-ion batteries, however their capability and present functionality are a lot decreased. I additionally get a bit nervous having LIR2032 batteries mendacity round, as I really feel like I will accidently put one into one thing anticipating a CR2032 (similar bodily dimensions) and probably break it (LIR batteries are 4.2V totally charged). And apart from, that RP2040 board is about 29mm diagonally, so going with a smaller battery is not going to make the tip outcome any smaller.



I 3D-printed probably the most minimal holder for the battery in PETG.



Tiny holder for a LIR2450 battery



I used to be undoubtedly too frugal right here, printing with a wall thickness of 0.5mm. It is printed in two components, with the highest glued on. I feel it could make extra sense to thicken up the entire components and print in a single go at 90 levels, which is one thing I performed with later. This 3D printed half is unquestionably the weakpoint, each time I drop the prototype it breaks and I’ve to connect it again collectively.



Anyway, we obtained so far as our first mockup:



RP2040 board on top of the battery



That is a TCRT5000 IR sensor I’ve soldered on, with tiny floor mount resistors. The sensor is a bit on the massive facet nevertheless it’s all I needed to hand. The output is analog, the detector is only a photodiode, however we are able to use a pullup and join this straight to a GPIO pin. There are schmitt triggers on the inputs of the RP2040 (that may be disabled by means of software program) so we primarily get a comparator at no cost.



There is a WS2812 LED on the board, linked to GPIO16. I might a lot relatively simply have an additional GPIO pin for my matrix, so I snapped off the LED and soldered some enamel wire to it. I wasn’t positive if it could be wanted however now’s the one probability we now have to do that.



Wire soldered to GPIO16



I then began soldering our matrix. The thought with the tabs on the backside of the matrix was to have slots within the board I join it to, which might hold all the pieces aligned. As a substitute, it appears they work properly as little legs to maintain the board simply above the elements. I soldered solid-core wire to the pads and wired it up in order that all the pieces could be very inflexible on the finish. It is attainable to right the angle between the boards, nevertheless it takes sufficient pressure that it will not occur accidentally.



Matrix partly soldered into place



That is half the connections finished, there’s one other ten wires to solder on the again, however earlier than we try this I wished to wire up the motor.



I’ve a handful of motors roughly the fitting dimension. The one I opted for is labelled RF-410CA. A lot of the related motors from CD and DVD drives are all barely completely different diameters and completely different shaft lengths. I additionally had a take into consideration RPM. Most of those motors have a no-load pace of 5000 to 10000RPM, which is way too quick. We are able to PWM the pace down, nevertheless it additionally says one thing about their beginning torque. To get to 30FPS, I might want an RPM of 1800. It is fairly onerous to make selections right here, as a result of as quickly because it begins spinning there can be air-resistance and it’ll in all probability hit some equilibrium. Eh, if the motor’s no good we are able to change it out later.



I deadbugged a bit sot-23 mosfet and a flyback diode onto our creation.



Mosfet and diode soldered behind the matrix



The IR LED was wired straight to the ability line. Ideally we might have software program management over it to avoid wasting energy whereas it is not spinning, however for this prototype I did not wish to waste a GPIO on that. The matrix is 8×10, so 18 GPIO, plus one for the sensor enter and one for the motor management, and I additionally wished to maintain one for monitoring the battery voltage. I feel it is attainable to wire up a pair extra of the GPIO on the RP2040-tiny board which have been damaged out as “consumer mode choice pads” however the present thought course of was to not fear and get this to a working prototype as fast as attainable.



Discover I am wiring the matrix on to the GPIO pins. There isn’t any present limiting or driver transistors. The RP2040 can supply/sink about 50mA whole throughout all its GPIO. I’ve realized that the dangerous, however oh-so-appealing approach to drive LEDs from microcontrollers is to skip the present limiting resistors and drive them with PWM. The inherent on-resistance of the GPIO pin is sufficient to restrict present – possibly to not a secure degree for steady illumination, however predictably. So long as you restrict the responsibility cycle it is fantastic. Right here we’ll be flickering the entire matrix in a short time, with quite a lot of cautious timing round it. I feel it is unlikely we’ll overdrive an LED, until the chip crashes and the matrix freezes.



I wired up the remainder of the matrix utilizing enamel wire, threading it beneath. We did not want any additional rigidity and it appears to be like fairly cool this manner.



Matrix wired up



There’s something surprisingly interesting in regards to the bare wires. It has a type of cyberpunk vibe. The vibe was solely enhanced once I powered up the matrix with a checkerboard take a look at sample for the primary time.



Orange glow of the matrix test pattern



I glued our 3D printed battery holder onto the motor, and connected the remainder of the prototype with squidgy 3M tape. I then needed to shorten the wires to the motor and join up the battery terminals.



I wired the battery’s constructive terminal straight to VBUS of the board. The RP2040 is behind the three.3V regulator, however with the battery linked because of this connecting the USB cable would put 5V throughout the battery terminals. We are able to fear about that later. For now I simply wish to know if the hacky prototype has any hope of working.



Motor, battery and circuit all connected



Amusingly, as soon as I configured it to gentle up the matrix in response to the IR photodiode, it could gentle up the matrix at any time when the digital camera flash fired.



Prototype with battery removed



With the battery eliminated you may see my connection to it, simply a few of the enamel wire stripped and tinned and threaded by means of a few small holes. At this level the battery snapped in with a constructive motion. It was solely after it had been dropped just a few instances and the plastic cracked that I wanted to make use of a rubber band to carry it in place.



Prototype with battery removed



I drilled a small gap on the again so as to have the ability to eject the battery, simply poke it out with a sharp factor.

Software program

We monitor the IR sensor and use the time between triggers to set the pace of the matrix show. It is all the standard stuff for a persistence-of-vision show, besides with one other dimension.



One factor I like in regards to the RP2040 is which you could set (or enter) each gpio pin in the identical clock cycle. STM32 chips, regardless of having 32 bit processors, group the IO into 16-bit registers that endure from bus competition in the event you attempt to change them abruptly.



Right here we are able to pre-process all the pieces we have to ship to the GPIO and step by means of it at a pace proportional to the measured rotation.



The processor is twin core ARM Cortex-M0. One factor to notice is that each cores have separate SysTick {hardware}. Reasonably than do that with interrupts, we are able to use each cores in busy-wait loops. The primary core displays the IR sensor, and makes use of its systick to measure the precise variety of cycles between triggers. The second core waits on the sign to light up, and as soon as it will get it, steps by means of the volumetric buffer utilizing its personal systick timer for cycle-accuracy.



When it comes to motor management, I used to be moderately assured we did not must do something too sophisticated. It is vital that the system spins at a relentless pace to get a constant framerate, nevertheless it needs to be pretty self-regulating. Paddle wheels had been usually used as regulators in previous mechanical units. I made the very easiest pace management logic attainable: if the RPM is beneath 1200, set the motor to 90% energy, else set it to 60% energy.



Later I’d improve it to correct PID management however to this point there’s sufficient inertia and air resistance that the easy management appears completely fantastic.



The primary time I obtained this factor to spin I used to be giddy with pleasure. Inside moments I had it drawing a easy volumetric checkerboard sample. This is one of many very first exams:



First illumination, on the messy desk



The plan was to machine a base for this system, with a bit signpost that might stick up for the IR sensor to catch glimpses of. I realised it labored fantastic by simply holding a finger close to it, so by no means obtained round to that half. The motor had a really small pulley connected, which was simply sufficient to let it spin up with out falling over. I later laser-cut a disk of delrin, only a push-fit over the shaft, which was solely presupposed to be a stop-gap till I made one thing on the lathe.



The code steps by means of the matrix in a columnwise style. Trying on the system top-down, every radial line may be very barely spiralled, however that is so much simpler to right for (if we cared) than having the entire thing be a helix. The responsibility cycle on the LEDs within the centre is proportionally decreased in comparison with the periphery.



I rapidly obtained this factor displaying a static take a look at quantity. It was solely a matter of time earlier than I let it fall on the ground. The 3D print cracked alongside the glue line.



3D printed part cracked open



No worries, we are able to simply hold gluing it again collectively. It is invincible!

Battery Stage

One factor that fearful me is that we now have no safety circuit for the battery. If it drops a lot beneath 3V it should get completely broken. (In follow the restrict is extra like 2.7V, nevertheless it will depend on the cell. I’ve destroyed just a few by means of this course of.) Most lithium batteries have safety circuits in-built, that can disconnect when it reaches a dangerously low degree. Not so, with a naked cell. On the very least I wished to watch the battery voltage so we are able to alert and fail to run if we predict it is too low.



The conventional approach of monitoring provide voltage degree is so as to add a possible divider to get it right into a readable vary of the ADC. The Pico boards I feel usually have this wired to one in every of their GPIO, however not the RP2040-tiny. I added two 100K resistors to energy and floor to our final out there GPIO.



The issue is, there isn’t any reference voltage on the Pico. There’s an exterior pin (not damaged out on the RP2040-tiny) that can be utilized, but when the ADC reference is simply its provide voltage, then when the availability voltage dips we cannot be capable to detect that. At the least, not properly.



Schematic of VBat monitoring connection



The three.3V LDO regulator has half quantity RT9193-33, and a dropout of 220mV at 300mA. Meaning when the battery voltage reaches 3.52V, our RP2040 provide voltage will begin to droop as properly. The ADC studying as a operate of battery voltage will find yourself one thing like this:



Plot of ADC reading vs battery voltage



After all, the dropout voltage is a operate of present load, so it is not at the same time as predictable as that. For this prototype, I made the system present a warning when it reaches just below 3.6V. That is the one factor we are able to actually do right here. For the following model, we’ll add a reference voltage. It could even be attainable to attach the ADC ref to the Pico’s inside 1.8V regulator. That will be sufficient.

Battery charger

The idea was to come out the LIR2450 when it will get low and stick it right into a standalone charger. I purchased a standalone charger. It broke the very first time I used it.



I used to be fairly pissed off {that a} model new charger would let me down (it wasn’t even the most cost effective!). And this, at my most excited second, able to show extra volumetric information! Woe is me!



I 3D printed one other battery holder, this time within the different airplane. The spring tabs are technically flexing within the weakest course, however they’re beneficiant sufficient and the wall thickness is all 1mm now.



New battery holder



I wasn’t planning to make use of this for the show, that is simply my new battery charger. I set the bench energy provide to present restrict of 50mA and fixed voltage of 4.2V. This is sufficient to cost a single lithium-ion cell. The fixed present is on the conservative facet, I wasn’t positive if this was a 120mAh battery or a 60mAh battery. It is best to cost no sooner than about 1C until the battery says in any other case. Nevertheless it’s usually by no means an issue to cost slower than 1C.



This obtained me fired up once more, and the volumetric journey continued. However earlier than we resume the narrative, let me simply add that eradicating the battery and connecting to an influence provide is the least handy approach of charging the system, particularly after the prototype cracked and I had so as to add that rubber band to cease the battery flying out.



The RP2040-tiny USB adapter board was nonetheless getting used to load code onto the chip. If we construct a type of USB-intercept board, we are able to carry the 5V line, and expose the pins for the battery. This sits between the USB cable from the PC to RP2040-tiny programming board.



USB intercept board



Now we are able to join the ability provide to the battery with out eradicating it from the prototype. The information strains are nonetheless linked beneath, so we are able to program it with the battery in place as properly.



I realised that soldering this up was a waste of time as I might have merely put wires on the RP2040-tiny adapter board.



Power lines soldered to the RP2040-tiny adapter board



Nonetheless within the mad frenzy induced by the working volumetric show, and the kicking of myself for less than having one LIR2450 in inventory, I discovered this nonetheless too inconvenient for speedy improvement. In a drawer someplace, I had some lithium-ion charging ICs. It took me a second to seek out them. These are fairly good high quality ones, which price about 90p every. The half quantity is BQ21040DBVR. I went again to that USB intercept board, and smashed the charging IC into the center of it.



USB intercept with charging IC



With this, we are able to depart the programming cable linked and it is going to be charging the battery whereas we predict.



After all, it will not ever totally cost the battery this manner as a result of the prototype by no means turns off. The IR LED alone is consistently drawing about 9mA. There was a really shiny energy LED on the RP2040-tiny adapter board, I swapped out the resistor to a 20K to cease it losing energy there. However nonetheless, I feel even when the prototype is not operating it is drawing about 15mA total. The charging IC, within the constant-voltage section, will wait till the charging present drops to 0.1C. As our charging present is ready to 54mA, that’ll by no means occur. Additionally, with the voltage drop throughout the cable the battery in all probability will not get above 4.1V. None of this actually issues, it is simply stuff to remember for the following model.



Finally we might begin doing fluid simulations!

Producing volumetric information

We have to create our volumetric information in 3D polar coordinates, that’s, r, theta and z.

See Also



I began with a wireframe dice, which ought to a minimum of be considerably recognisable. I intentionally rotated it to be on-end, to maximise the awkwardness of displaying it. Actually I suppose we should always write a vector show routine for the system, that might carry out some type of 3D polar coordinate Bresenham interpolation. There’s loads of information on the market about making use of Bresenham to 3D, and drawing circles, however we wish to draw straight strains in polar coordinates. This appears like a enjoyable factor to consider however for now let’s concentrate on exporting polar voxel information from Blender.



Wireframe cube in Blender



That is the default dice with a wireframe modifier. To rotate a dice to be on-end, with a nook going through instantly upwards, we have to first rotate x by 45 levels, then rotate y by atan(1/sqrt(2)). One of many pretty issues about Blender is you may simply kind in formulation anyplace.



To get slices of this wireframe dice, I added one other dice, reshaped it to be considerably slice-like, and did a boolean modifier between them. I then parented each the digital camera and this slice to an empty, and animated the empty’s Z rotation.



Slice of the wireframe cube



I configured the digital camera projection to be orthographic, and its decision to be our tiny 8×10. I set the background to black and the dice’s materials to emissive. Within the compositor, we are able to use a color ramp to threshold this. The volumetric show presently has solely a bit-depth of 1, so every voxel is simply on or off. Thresholding it right here lets us visually choose the most effective cutoff.



Screenshot of compositor



“Render animation” now generates 24 photographs, 24 slices of the wireframe dice. I used a fast python script to chew these up right into a header file that may be included within the code.



In Blender, not solely can any enter settle for a components, and never solely can just about all of them might be keyframed, it’s also possible to arrange a driver. Reasonably than resolve the components as you enter it, it should recalculate the outcome for every body. So as an alternative of keyframing the rotation of the digital camera and manually setting it to linear interpolation, I simply typed in (body/24)*2*pi which is able to loop indefinitely. For the y-rotation of the dice, I now typed in ground(body/24)*pi/24 so it should rotate a fraction for every full loop of the digital camera.





Actually it could have been fantastic for the rotation to be steady, however I wished every body of information to be discrete, simply in case we wished to regulate playback pace based mostly on motor RPM.



Volumetric display of the rotating cube



You may merely should take my phrase for it that the show appears much more three-dimensional in actual life. Trying on the photos and watching the video it does appear similar to a bunch of random dots illuminated. If solely you, pricey reader, had a volumetric show to expertise it on!

Fluid simulations

Working a fluid simulation in Blender is each simple and troublesome. Simple to get began, troublesome to get good. There are an terrible lot of parameters concerned.



Liquid simulation is barely simpler to port to the volumetric show because it’s trivial to transform the fluid particles to a mesh. In principle, we should always be capable to run a fluid simulation at 1/twenty fourth pace, and use the identical method as above to extract polar volumetric information.



Sadly utilizing excessive parameters like a really gradual time scale results in instabilities. There would not appear to be an easy approach to play again a simulation at a slower charge, and the very gradual simulation pace appears to be like solely improper when sped up. I did fiddle round with this for some time with no luck. On the plus facet, we’re focusing on a really low spatial decision, so the fluid simulations are all quick sufficient to run in real-time on my desktop machine.



I appeared into different methods to render the volumetric information. There is a function referred to as Multi-view, or Stereoscopy, that is supposed for rendering 3D video. This allows you to add two cameras and render a scene from each views concurrently. It is attainable so as to add any variety of cameras, and output all of them based mostly on their naming suffix. I am undecided if there is a fast approach so as to add 24 cameras and evenly rotate them (sadly you may’t apply an array modifier to a digital camera, I am undecided if anybody has ever requested for that earlier than) however an extra downside with this tactic is that we additionally want the boolean modifiers of our slices to be rendered on the similar time.



As a substitute of the boolean modifier and a slice, we might cheat a bit and use the built-in clipping distances. By setting the digital camera to solely render a 0.1 slice of the scene we get nearly the fitting output. The issue is that solely surfaces are drawn, not strong fill for the clipped objects. I believed that possibly making use of volumetric materials to the objects might make them a minimum of partially stuffed, however after enjoying about for a bit I had no luck.



As a substitute, let’s go for a extra generic (however extra concerned) method: simply write a python script. Within the scripting tab in blender, I wrote the next:


import bpy
import os
from math import pi
 
obj = bpy.information.objects['Empty']
output_path = bpy.context.scene.render.filepath
 
for i in vary(24):
  obj.rotation_euler[2] = (i/24)*2*pi
  bpy.context.scene.render.filepath = os.path.be part of(output_path, f"###_{i:02}.png")
  bpy.ops.render.render(animation=True)
 
bpy.context.scene.render.filepath = output_path



This manner we run the fluid simulation in actual time, and easily re-render the entire animation 24 instances with completely different rotations of the Empty (guardian to the digital camera and the slice).



Screenshot of a single fluid slice render



The idea confirmed, I ploughed forward with the fireplace simulation. The way in which to render that is principally the identical however with a pair extra steps. We arrange our hearth simulation, after which bake it in OpenVDB format. Right here I set a small dice on hearth.



Fire simulation



Then begin over, and import the OpenVDB information again into Blender. We are able to then create a brand new mesh and apply a Quantity to Mesh modifier on it, which lets us threshold the quantity information. Lastly, one other boolean modifier with our digital camera slice, and re-run the script above.



Fire simulation on the display



Once more, I really feel the {photograph} would not actually seize the sensation right here, however you hopefully get the thought.



It happens to me that the LED alignment could possibly be corrected for in software program, if it had been predictable. We might offset the boolean slice both nearer or additional away from the digital camera, in order that it would not spin across the precise centre. If it matched the motion of the actual show we needs to be golden. Equally, as an alternative of a stretched dice, we might make it a barely curved form to compensate for the matrix scanning sample because the board rotates. At this degree of decision nonetheless, I do not suppose any of those enhancements could be seen.



The one factor that actually issues is that illuminating a person voxel close to the perimeter ought to appear to be a single dot, not a double dot from some angles. You’ll be able to see it within the picture beneath, the place the voxel nearest the digital camera is elongated as a result of the 2 illuminations because the matrix rotates did not fairly line up:



Display showing text



The letter “m” within the centre is completely clear, as a result of I intentionally cheated there. To make the textual content readable from all instructions, the textual content voxels are rendered in another way. I made it so the textual content scrolls within the readable orientation no matter in the event you’re trying on the entrance or again of the show. Anyway this voxel discrepancy can solely actually be seen on the periphery of the show, the place each illuminations are seen without delay.

Conclusion, for now

There’s loads of work to do on my hearth simulation, however maybe I am going to delay a bit till I crank out the following prototype which may be a bit higher aligned and a bit higher-resolution.



If I had a tiny slide-switch in inventory, I might have added it to this prototype, to disconnect the battery with out eradicating it. I began looking my packing containers for one thing appropriate earlier than realising I might merely insert a small piece of acetate between the battery and the contact, like they do with coin cells for IR remotes and so forth. That works fantastic.



As regards to IR remotes, it could be fairly good to have a distant management for this. We have already got an IR sensor, though it is not a demodulating kind. As proven within the video, I merely advance to the following mode after a timeout of no exercise.



Listed here are some self-importance photographs of the system.



Vanity shot of prototype



Vanity shot of prototype



The IR is in fact completely invisible to the bare eye, however the digital digital camera picks it up as a faint purple glow.



Vanity shot with IR sensor facing camera



I’ve caught the source code on github as traditional.

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top