Good day!

There is a cube inside of which is a microcontroller with sensors.

Sides of a cube are numbered from 1 to 6. When throwing the cube to determine what number fell.

There's a gyroscope and accelerometer. These sensors are enough for this task or need some more? And how can I withdraw formulas (conditions) for each side using their values?

There is a cube inside of which is a microcontroller with sensors.

Sides of a cube are numbered from 1 to 6. When throwing the cube to determine what number fell.

There's a gyroscope and accelerometer. These sensors are enough for this task or need some more? And how can I withdraw formulas (conditions) for each side using their values?

asked June 27th 19 at 15:12

2 answers

answered on

Solution

three-axis accelerometer. Gyro is not needed. Look at what axis we have the acceleration of free fall.

Suppose, on the x-axis, then if the acceleration is with the sign +, the bottom side is shaded, if-opposite to it. The accelerometer will naturally make noise and not always fall evenly, so interference is filtered quite a bit and not bothered and put the setting in the area of 8-9.

Suppose, on the x-axis, then if the acceleration is with the sign +, the bottom side is shaded, if-opposite to it. The accelerometer will naturally make noise and not always fall evenly, so interference is filtered quite a bit and not bothered and put the setting in the area of 8-9.

answered on June 27th 19 at 15:16

3 coordinates of the accelerometer, each has the value of "g" or "-g" if the surface on which the cube is perfect. The resulting value will be in the range of "g/2< val < g or-g < val < -g/2" for the opposite side. val is one of the coordinates x,y,z acceleration data from the accelerometer. you can even take 1/2 and 2/3 of the maximum to more clearly separate values.

Thank you. And which sensors to add to determine even with an imperfect surface? As still an ideal is not commented on June 27th 19 at 15:19

Find more questions by tags keyboard sensorsPhysicsAccelerometerSTM

Physics:

When the dice are calm, it operates only one acceleration - acceleration of free fall. In this case, if the accelerometer is exposed to the two axes is horizontal, the third axis will be the acceleration of free fall, in one case approximately +9.8, -9.8 in another

Implementation:

A cubed accelerometer(better charge - shield or self-made) as evenly as possible, so that the plane of the Board parallel to one of sides of the cube. In the drawing of a cube I would use about the same algorithm:

`<br / > You can simply use conditions to find the axis on which the acceleration of free fall, and depending on the axis and sign to choose a side.<br> You can filter this way:<br><pre><code>Ax=(Xinput-Ax)*dt/0.1+Ax //Xinput - value sensor, 0.1 constant time, in seconds, the more, the less the noise will be and the higher the reaction time, 0.1 close to the balance //dt is the integration step, if the signal is removed with a frequency of 100 Hz can be taken as 1/100</code></pre>`

- jeramie.Lesch commented on June 27th 19 at 15:20side = round((Ax*1/988)+(Ay*2/988)+(Az*3/988));

The values from -3 to 3 is displayed. Only problem with the definition of peace. In Your formula, verify in the range of (800;1200) does not work, because the values can go in the negative. Tried the condition ((800 < x < 1200) or (-1200 < x < -800)), but it also does not determine the rest. I have no idea yet, what do You think, how can this be solved? - Hobart_Swift commented on June 27th 19 at 15:35

The code first derivative is acceleration, i.e. the change of acceleration, then we look whether it is changing acceleration. If the acceleration does not change much (the threshold is 50, which is set empirically), then the cube is at rest. If we made 5 measurements and all 5 dimensions in the cube was at rest, then execute further code.

Example is provided only to the X-axis, and the need to check all three axis.

Too low threshold does not allow to detecting a state of rest even when the cube is stationary, too high will give false positives.

The number 5 can be changed from the calculation that we need the stillness of the cube for at least 0.3 seconds. That is, if you measure the acceleration with a frequency of 100 Hz (every 1/100 of a second), instead of the 5 must be wagered 30 (30*1/100=0.3 sec). - jeramie.Lesch commented on June 27th 19 at 15:38

Wanted to expand to the dodecahedron, it's the principle of construction of formulas :) - Hobart_Swift commented on June 27th 19 at 15:47

For the dodecahedron the same formula, you can display, but it will be necessary to consider the projection of the gravity axis. We can assume the angles of the accelerometer in three axes and depending on them to have to choose a side. Depending on the understanding of mathematics, in the Internet you can find different variants of implementation. And ready-made library for your MK certainly is. - jeramie.Lesch commented on June 27th 19 at 15:50