Saturday, 6 October 2018

Allez, je construis un baby-foot

Bonjour !

L'un de mes plans pour conquérir le monde passe par la fabrication de baby-foots... Les baby-foots, c'est fun, et une fois je me suis dit que ça serait encore plus fun si on y mettait un peu d'électronique : on pourrait ajouter une ambiance de stade, la foule en délire quand on marque un but, des écrans LCD pour afficher le score, ... Et on peut même pousser le délire en ajouter des fonctionnalités au jeu : faire un plateau qui tremble, ou qui se penche légèrement dans un sens ou dans l'autre, faire un but qui se ferme pendant quelques secondes, ... On peut imaginer pas mal de choses, pour faire un baby-foot genre mario kart !

Bref, comme techniquement c'est pas super compliqué, je me suis dit que je pourrais commencer par me faire la main en fabriquant un baby-foot pour les enfants. Après quelques recherches sur Internet, je me rends compte que pas mal de gens font leur propre baby-foot, du modèle le plus simple (en carton) aux modèles pros avec des joueurs sculptés, pour des évènements particuliers. Alors c'est parti, je me suis décidé à faire quelque chose de sympa. Pas d'électronique pour l'instant, mais juste quelque chose de fonctionnel et de pas trop moche.

Du coup j'ai fait quelques plans, sous Blender bien évidemment :

Et c'est parti, je vais chez Leroy-Merlin pour commander du Medium. Du 15 et du 18, histoire que ça soit costaud :) Avec le recul c'était peut-être un peu beaucoup, j'aurais du faire du 10 et du 15, ça aurait suffi. Bref, j'ai tout fait à la découpe, comme ça j'ai des morceaux nickel.

J'accroche mes plans dans mon atelier tout neuf, et c'est parti :

Pour l'assemblage, j'ai décidé de partir sur la technique des tourillons : ça consiste à percer des trous de part et d'autre des morceaux à fixer ensemble, puis de les relier avec un tourillon, et fixer le tout avec de la colle à bois. C'est très efficace avec du Medium, et ça permet d'avoir un résultat quasi-parfait sans aucune vis apparente. Par contre c'est un peu long car il faut percer tous les trous exactement au bon endroit pour qu'ils soient alignés, avec l'outil adéquat. Un petit aperçu en cours de réalisation :

Une fois qu'on a percé tous les trous (en se trompant quelques fois...), on peut assembler le tout, d'abord sans coller pour vérifier que tout se monte :

Pas de soucis au montage, ouf ! Je perce les trous pour les barres, et je vérifie qu'elles coulissent bien (en agrandissant les trous au besoin). Et c'est parti, on gave tout ça de colle à bois, on met des serre-joints et on attend quelques heures. Une fois la colle sèche, on obtient un gros bloc cohérent. Il n'y a plus qu'à le poncer pour gommer les défauts de jointure, arrondir les bords et lisser les parties coupées. C'est encore un avantage du medium, ça se travaille très facilement à la ponceuse, du coup on peut facilement rattrapper les défauts et faire des arrondis. Et voilà le résultat :

Maintenant, grande question : comment vais-je faire des bonhommes qui ressemblent à quelque chose ? Souvent les gens font des cubes, ou de triangles de bois, c'est largement suffisant pour jouer, mais je trouve ça quand même pas très classe :) Du coup j'ai trouvé des vues de joueur "classiques" sur Internet, et j'en ai refait des modèles 3D. Et c'est parti pour les faire imprimer en plastique ! Le problème c'est qu'il m'en faut 16, et que sur les sites classique ça coûte genre 12€ l'unité, donc ça fait un tarif assez monumental... Bref, je recontacte le gars qui m'avait fait mon boîtier pour mon écran tactile, et il me propose de faire le tout pour 29€, tous frais compris :) et c'est parti !


Et cette fois encore le résultat est au-delà de mes attentes : on voit à peine les marques d'impression, et c'est largement assez solide. Un petit coup de papier de verre pour enlever les bavures, et c'est nickel. Il n'y a plus qu'à les peindre, avec l'aide des enfants bien sûr, qui ont aussi choisi les couleurs pour leur équipe !



Bon, le choix de couleurs n'est pas hyper original, mais ça leur plaît.. Pour pouvoir les peindre en une fois, je les ai accrochés sur un câble électrique, et j'ai fait des pliures pour qu'ils tiennent bien, comme ça toute leur surface est accessible.

Le dernier point qui m'a fait réfléchir, c'est d'avoir un système pour que je puisse le régler en hauteur. Les enfants, ça grandit rapidement, donc d'ici 6 mois il sera largement trop bas. Du coup j'ai fini par acheter des pieds de tables, et j'y ai fait quelques découpes :


De cette manière je peux glisser deux vis dans les grandes rainures, et on peut faire coulisser les deux parties l'une sur l'autre pour régler la hauteur. On serre les vis, et ça bouge plus ! Je devais pouvoir gagner 35cm, donc ça me laisse un peu de marge pour les mois/années à venir ! Bon j'ai un peu galéré, les pieds sont en bois massif très dense et ma pauvre scie sauteuse a souffert, il va vraiment falloir que je la change. Mais bon, avec un peu de ponceuse, le résultat est correct !

Et voilà pour aujourd'hui, il me reste encore à peindre tout ça, assembler les barres, faire une jolie pelouse, etc... Encore quelques heures d'amusement en perspective :)

Sunday, 6 April 2014

Still in progress !!

The audio hardware

I bought a simple 2x100W audio amplifier which is now placed in the toilets, fixed on the wall.
Then I have two Focal Custom IC speakers which are designed to be embedded into walls. I set one in the bathroom ceiling, just over the shower, and the other one in the living room :
And of course, they are water-proof ! The sound is very powerful, and the quality is perfect after some time of running in.
I really enjoy taking showers with music :)
The only bad point is, I have an unpleasant background noise when outputting the sound from the Raspberry PI. This is unnoticeable when the sound is loud, but very annoying when it is low, for example to make background music. I tried many solutions to get rid of it, but nothing works yet. I have asked for help on the Raspberry PI forums to finally find a fix.

Playlists

I wanted to manage playlists from the touchscreen, but editing them is not very convenient. The solution I found is using the playlists from my Synology NAS, where the musics are stored : in the Web Audio application, you can edit playlists which are then stored in an accessible file.
By the way, the songs information are also stored on the NAS, directly in a PostGreSQL database. Qt has a native driver to access it, so I can retrieve everything very easily and play the songs I want !
I also made a smart shuffle algorithm, because I really don't like to hear the same musics at short intervals.

The case

After finishing designing the case, I wanted to make a prototype to check that everything fits in. The final 3D-printed part costs about 80€ which is really expensive, so I had to be sure :) I discovered the website http://www.makexyz.com/ where you can ask people who own a 3D printer, to print parts and send them to you. The machines are not professionnal, so the cost is really lower. I could have my prototype for 12€ including shipping !

When I finally received it, the printing quality was much better than I expected, so I decided to make it my final part. I polished and painted it, so now it really looks good.
After all the wires modifications, I finally found some time to put everything together :
Everything just fits in the case ! I reduced the number of wires as much as possible, to avoid troubles. I removed the monitor board where the IR LED was solded, and directly connected it. I just need the LED, not the buttons, so I got rid of the PCB.
I thought I would stick the touch panel and the screen to the case with epoxy resin, but I didn't like the idea that I couldn't ever unmount these parts. A colleague told me I could add foam pads behind the screen, so that they would maintain it pressed on the wall once placed. It is not very elegant, but does work very well ! Here it is, once everything in place :

I'm actually very satisfied with the render ! The color is the very one of our living room theme. And with the screen turned on :
It does still work ! I was a bit scared when I placed all the wires in the wall, because there are a lot of them, but no problem.. But wait, 23.8°C ? Summer isn't already there ! It seems I have a problem of temperature : the screen, or the monitor board, is producing some heat which moves to the temperature sensor. Once stabilized, the sensor says 26°C even if it is quite cold in the house... When the monitor board's power supply is turned off, the temperature slowly lowers to a relevant temperature. That means I will have to isolate the sensor from the rest, or maybe externalize it as I first designed it.

What's next

I have worked on displaying the day's horoscope for my wife. I found an RSS channel which provides it. I couldn't find more accurate information than a simple text. I would have loved to display the day's luck rate or things like that, but couldn't find a webservice to provide it. Anyway, I don't believe any of these things myself :)

I have also bought an 8-channel relay board to turn on/off the audio amplifier and each speaker individually, but it doesn't work yet.

I should also update my big plan now everything is (nearly) definitive !

Saturday, 9 November 2013

State of progress

Hi everyone !
It's been a while since my last post, but I have been working a lot on my domotic project, as you will see ! Today I just want to show you what I have successfully done, what problems I had, and what is to do next !


The case

I have spent a lot of time on designing the case, because I wanted something really great. My objectives were to have something looking good, as small as possible, and easily openable for maintenance. My first idea was to have a first part fixed on the wall with screws, holding all the electronic part, including the touch screen; then having a second part (polished and painted) which would slot on the first one, so that I would have no visible screw. It was a hard challenge, and I did something quite good, but I was stopped because of the price : having two parts means twice the price of printing, and with the required size, a part is around 100€, which is quite expensive, so I had to do it with a single part.
Finally, I came up with something very simple, and small. I also had to give up on the openable part : all the inside parts will be sticked to the case, so if the screen dies, it will be nearly impossible to replace it.
Here are some 3D renders of the case as it will be on the wall. The exterior desing is quite simple, with just a rounded border.
And here is a preview of the back/inside :

The screen will be sticked to the case, and the board sticked on the screen. The temperature sensor fits the hole so that it shouldn't move, but I will have to change its position (see below).
The hole on the left is for the infra-red receiver, not represented here.
The screws are represented in red, so that they are clearly visible.
The case is fixed on the walls by the screws, which are not visible from outside, except if you look at it from the very bottom. I will have to place the screws on the wall first with a pattern, then slot the case on them by moving it down, like any standard frame fixed on a wall. I hope it will be strong enough !

The wires

The most complicated part was to set the wires between the toilets, the Internet router, and the stove. I had to make a big hole in the toilet's ceiling, so that I could set the sheathes under the attic's floor. Then I screwed all the electronic boards directly on the toilet's wall, which will be covered later :
I looks quite a mess, I did the best as I could ! And as I don't have the outside case now, I also set the screen there.
The red/black wire is the one going to the stove, it is a simple HI-FI wire...
Here is the stove once the wire was upon it. The fire screens can be easily removed and they are hollow, so I can hide the wires between them.
Now, the wire is connected to the stove's RS232 port !
In the corridor, here is the hole I made in the toilet's wall. Right now, you can just see the temperature sensor going though it. At first, the sensor was outside the wall, so that it is the most reactive as possible. However, the first time we turned the stove on, the sensor was too much reactive, because it is quite high, and right towards the stove, so the hot air is directed to it, and the temperature raised to 25°C in half an hour. To correct this, I placed some rubberband on the hole, to isolate the sensor from the pushed air. That means I will have to work again on the case to embed the sensor inside it.


The software

I didn't mention the software earlier. The technology I use is the Qt framework with the C++ language. I made this choice because I am very familiar with them, and they are very easy to work with. The C++ is not the easiest language, I could have used Python with PySide (The Qt binding for Python), but C++ is a bit faster and allows more optimizing when required. As the Raspberry PI doesn't have a very powerful processor compared to a desktop PC, that's wiser.
The good thing is that I can make the software on my PC, test it heavily, and when everything works, compile it again for the Raspberry. I made a test interface so that I can simulate different conditions of the sensors and see if everythings goes well.
I don't plan to release the software by now, because I don't really see the need, but if anyone is interested, let me know and I will push it on github !

The software is not very complex though, I just need a few interfaces, and a nice enough design. Here are the main elements done :
The main screen, always displayed (when the screen is on). There are currently 4 widgets on it :
  • The first one simply displays the current date and time, useful because we don't have any clock in our living room
  • The second one displays the state of the stove and the trigger mode
  • The third one displays the current weather conditions
  • The fourth one displays the current inside temperature
When you click on the temperature widget, you can see a curve of the last 24 hours temperatures
When you click on the stove widget, you can :
  • Turn in on/off manually
  • Set it to automatic/manual trigger mode
  • Set it to holiday mode, so that it won't turn on until you come back and find your house hot :)
  • Configure the automatic mode thresholds and planning (not done yet, but I plan if for this week-end !)

It does work !

Once everything was set up, I was quite impatient to try it ! I had tested all the parts individually, but not together. I had to wait some days because it was not cold enough, and the first time I wanted to turn the stove on, I used the touch screen, and it just worked ! The day after, I set the automatic regulation mode, and was very happy to see the stove on when I got home, the hot air being very comfortable !

Sunday, 1 September 2013

The big plan

After some days of works, I have finally ended the big plan of connections. I thought it would be a mess, which is the case when you plug everything physically with all the wires, but the plan is clear enough :


Well, there are many things that can be noted about it :

The front panel

I wanted to have as few components as possible inside the front panel, so that I will be able to design a small case. Finally, there is :
  • the touch screen
  • the temperature sensor, which should be out of the case to sense the ambiant temperature
  • the monitor board, because the wire to the screen is very small and I can't extend it
  • the monitor conrol board, with the infrared receptor accessible from outside (see below)
  • the VGA plug, because the wire to the board is very short (or maybe I will try to extend it if it can't fit inside the case)


The monitor power management

As you can see, I have decided to have the monitor board always powered. Instead, I will turn off the screen backlight when I want it asleep. The reason is that the monitor board takes some time to initiate when turned on, and it displays a big blue "VGA" indication. This way, the board is always ready and the LCD screen actually displays something, but you can't see it. When you touch the panel, the backlight will be back on which is immediate.


The monitor control board

You may be asking why the monitor board is inside the front panel ? Actually, it's not really required, but in case there is a power loss (which happens quite often when there is a thunderstorm), the monitor needs to be reconfigured to display the correct resolution, so I have to include the control board and have the infrared LED visible from outside. Or maybe I will let the board behind and put a wire between it and the LED, to save space in the panel.


The music

I have decided to buy standard desktop speakers for the bathroom, and fix them at the ceiling. The point is, I don't expect them to work forever, especially because of the humidity. That means I have to be able to replace them easily, so I will add a power outlet and an audio plug at the ceiling, and plug the speakers from here. The day they die, I can replace them with new ones and just plug them. The plan is not really true about it : I will have the relay power the outlet itself, so that the speaker cable doesn't need to be customized.
Actually, this idea is obsolete as I have a new one which suits much better, I will talk about it in the next post !


The power

I will need many power outlets for the various boards. Fortunately, there are power cables inside the back wall of the toilets, used for an outlet in my son's room. I just have to open a hole and shunt the cables.
The network cable (not represented) will be a bit trickier because the main router is quite far, but I have meters of Ethernet cable left, and the up floor is not set up so I can join everything together (same for the stove cable !)

Feel free to ask any question if something is not clear !

Tuesday, 13 August 2013

More features !

Once I had set the idea of having a Raspberry PI, I started thinking of extra features I could add to my box. The question I asked is "what do I need a computer for, but does bother me to turn it on ?"

Weather forecast

This feature came quite naturally, because the box is supposed to manage the temperature inside the house, so having the information about the temperature outside and the forecast is very relevant. It also resolves the problems of "What am I going to wear today ? What will the weather like ?"

Technically, it is not very complicated to retrieve a weather forecast from any web service, and display it. After some research, I choose Weather Underground which is the provider of The Weather Channel. They offer a very complete and easy access to their data. They also have stations everywhere in the world for the real-time weather, and there is one at some kilometers of my house. You can query it 500 times a day freely, which is good enough !

Music in the bathroom

When I get up on saturday morning, I really enjoy turning on the music and taking a shower. However, not everybody at home like it, and I have to lower the volume so I don't hear anything. The idea is to buy some cheap desktop speakers, fix them at the ceiling in the bathroom, and connect them directly to the audio output of the Raspberry.
I have a NAS where all my music is stored, so I can access it easily by network. A shuffle play will be good enough !


Now all the features are described, I will present the (big) connection map of all the components, next time !

Friday, 26 July 2013

The components

Today I will present you the different components I have bought yet, what they are for, and how to connect them with each other.

The Raspberry PI
It is an mini-PC, very easy to use, running Linux. I guess most people buying them are geeks, but you can also use them as a media station, or something like that :



The LCD screen
This part was the most difficult to find. The original constraint was to find a 3-5'' LCD monitor including a touch panel, compatible with the Raspberry PI. However, all the monitors I could find were very expensive, around 150€, even the smaller ones.
The other solution was to buy a "naked" LCD screen, and find a way to make a case around it. After much reflexion, I finally bought this screen :




It is a 6.3'' LCD screen with a touch panel on it, native resolution 800x480. It has an RCA input, which is good because the Raspberry PI has an RCA output. It also has a remote control to configure the backlight and so on. The last part is the touch-panel controller, which is independant from the display part. It has a standard 4-wire resistive input for any touch panel, and a USB plug. I guessed there was a driver for Linux, which is the case fortunately :)
The complicated part is that the screen doesn't have a case. The solution for this problem is to design one and have it built using 3D printing. This method is becoming quite usual, and there are many services on the Web where you cand send a 3D file and receive the object some days later, in various materials. It is not really cheap, so I'd better do a one-shot-good :) The good thing is that I can integrate all the electronics inside the case, and let a hole for the temperature sensor. I will come back to the case later.
I bought the screen on Aliexpress (like all the other components, except the Raspberry), which is a good site for this kind of things. However, I received it after 2 months and a half, so if you ever buy something there, be patient !

Once I received the screen and the Raspberry, I connected them through the RCA. I then had a bad surprise, because the RCA output of the Raspberry is low-resolution only, so the dispay was quite ugly. The only solution to have a clean display is to use the HDMI output of the Raspberry, but the screen only has a VGA input, so I had to buy an HDMI to VGA converter, which is not a simple cable because the HDMI signal is digital, and the VGA is analogic :


Once connected this way, the screen works perfectly (after setting some parameters on the Raspberry, which I will describe later).

The temperature sensor
I first bought a simple USB temperature sensor on Aliexpress :


Once I got it, I found some piece of code on the Internet to communicate with it and retrieve the temperature. It worked, but after some hours of temperature retrieving every second, I observed some strange values. Sometimes the communication with the sensor just didn't work, and sometimes the returned value was irrelevant. After speaking with a colleague at work, he suggested that I use one of the sensors we are working on, and we know are very robust. The sensor is based on a TMP102 chip, communicating using an I2C bus. For those who don't know, it is a 2-wire communication protocol, often used to communicate between electronic chips. The Raspberry PI has an I2C controller on some of the multi-purpose pins, so I just had to cut the cable, and solder a plug :


Once done, I just plug it on the Raspberry, and I have to retrieve the value of a register on the I2C bus, then convert it to the temperature, according to the TMP102 datasheet. Actually I already had the code, because I implemented it for an other project at work.

The relay
A relay is just a switch, but instead of switching it with your finger, you can switch it by sending an electric current :


This is what will allow me to actually control the stove, by connecting it on the serial port. It should be easy to use with the Raspberry, because it has General Purpose Input Outputs (GPIO), which are pins you can easily control to send a current or not. It did not test the relay yet, but I have no doubt that it will work...
As you can see, there are two relays on the board : having an extra-relay might prove useful later, for example to turn the screen on/off if I can't control it otherwise. By the way, A 2-relay board is not more expensive than a 1-relay... Actually, I have other ideas which may require other ones, so I'd better have bought an 8-relays in the first place !

Next time, I will come back on how everything is connected together !

Thursday, 11 July 2013

The stove controller

So, once the idea was set in my mind, I started thinking about how I could make it work in the most convenient way. Definitely, I needed an electronic board and a relay to control the stove. Then, I still wanted to be able to control the stove manually, or change the temperature configuration easily. That meant I needed an interface. Moreover, the temperature sensors needs to be somewhere in the middle of the house, far from the stove itself.

The best thing was to have a small LCD screen with a touch panel. The good point is, I have a corridor which leads to the rooms, and there is some space on the wall :


As you can see on the left image, there is currently a CO sensor on the wall, but I plan to move/remove it. That leaves me a lot of space for the screen. And the very good point is that there is plenty of space behind the wall (right image) : the half-painted wall will be closed one day (to hide the toilets frame), so I can put all the electronics here without having a clean case. Moreover, I can bring the required cables there and hide them easily.

So what I need right now is an electronic board, and LCD touch screen !

For the electronic board, I first thought about an ARMadeus board, because I use them at work so I am very familiar with them. However, the processor board requires a motherboard, so the whole solution is not really cheap. Actually I could afford one, but one challenge of the project is to keep it very cheap. Finally, I decided to use a Raspberry PI. If you are even a half-geek, you probably know about it. It is a mini-PC with all the connections one need. Some months ago, I thought they were useless, but actually, they're perfect for this kind of project : very cheap (around 40€), ready to use, a decent processor and enough RAM, 2 USB ports, an Ethernet port, an HDMI port, everything required to control external electronic devices : I2C, GPIOs, 3.3V and 5V power supplys.

With the Raspberry Pi, I've got everything I need in the first place : an output for my screen, an input for the temperature sensor, an input for the touch panel, and an output to control an external relay.

So next time, I will talk about the other components !