This post is a update of my previous post. I ditched the idea of replacing my remote with a fixed touchscreen remote. Instead I wanted to be able to control everything through the internet. I decided to start with using the Adafruit IO service. The hardware used for this project are a Raspberry Pi 3, Pi camera, remote controlled switches, ESP8266 NodeMCU and a 433MHz transmitter.
The NodeMCU was used to make a wireless connection to the internet. It uses the MQTT protocol to get feed data from my Adafruit IO dashboard. This feed data determines if the transmitter needs to turn off or on a specific switch. Currently the switches are only controlled by the online commands (or manual override with a remote control). But automation scripts can easily be made, which can be handy when going on vacation. As can be seen in Figure 1 there are still a lot of IO pins unused on the MCU so upgrades can be connected.
As can be seen in Figure 2 the online dashboard also contains a live camera feed. This camera feed runs from a Raspberry Pi 3 with a Pi camera. Currently the camera is in a testing location. But when properly placed it will see my complete room. Because there is no QOS support from the online dashboard a different solution had to be created. That’s why the status of the received input feeds is send by the NodeMCU to the dashboard. This way we can make sure that the feed update was received and processed correctly. The ESP8266 is programmed with a last will and testament, so if the connection is lost the broker sees this and publishes the testament which donates that the module is OFFLINE. If the connection is open then the ESP8266 status is set to ONLINE.
The delta robot was a semester long project in my second year. In the first half the delta robot had to be designed, build and programmed using a PLC and HMI. The pill location would be entered manually on the HMI. The second half of the project the control needed to be automated by a vision system. And for extra difficulty the pills would be moving on a conveyor belt. The budget for the project was extremely low so that’s why it is not the fastest delta robot by far. But the knowledge gained from the project is very valuable.
Pills where picked by a vacuum gripper and the delta robot moved by using hobby servos. The vision system comprised of a normal webcam and a program written in Python and using OpenCV to process the images and control the PLC. The robot also had an automated calibration function, which used a cross-laser to calibrate the x and y axis of the robot. And to calibrate the height a vacuum sensor was used in combination with the vacuum gripper.
The second project of my Mechatronics education was to build a cart that could sens and record acceleration data and predict the carts path. The acceleration data also needed to be collected for post processing and analysis. My part of the project consisted of programming the Arduino and creating the python Gui and data analysis program. It also consited of designing and building of the hardware.
The setup can be seen in Figure 1. The cart gets accelerated over a predetermined path until it reaches the ramp. After it reaches the ramp the carts needs to give a visual indication if the carts turning point is between point a and b or not. This indication has to be done before the return point of the cart is reached.
The on-board hardware consists of a battery, a RGB-led, a Arduino Pro mini, a MPU6050 and a APC220. This can be seen in Figure 2. This electric circuit was turned into a PCB as can be seen in Figure 3. The MPU6050 consists of a 3-axis accelerometer and a 3-axis gyroscope, for this project only the accelerometer was used. The APC220 is a transceiver operating on 433Mhz, which is used to send and receive serial data from the Arduino to the PC. Because of the Arduino’s limited processing power and the need for a quick calculation, the Arduino uses two setpoints to determine if the carts return point is between a and b. The setpoints are compared to the measured acceleration of the cart during the acceleration phase. These two setpoint where calculated in advance. This was possible due to the fact that the tracks position was known and the friction coefficients where derived from a test setup. If the cart was not able to reach point a, then the RGB-led would turn orangje. If the cart would pass a but not b the RGB-led would turn green and if the cart would pass point b the RGB-led would turn red.
The acceleration data also needed to be recorded for later use. All groups decided to store their data onto an SD-card. Except for our group, we decided to transmit the data to a pc. We did this so that in order to processes the data the cart did not needed to be removed from the setup and analysis of the data could be a lot quicker. The pc used a python script to record the data from the card and store it in a CSV file. This CSV file could also be read by python so that recorded session could be easily analysed. See Figure 4 for recorded session. A other benefit of using python and wireless data acquisition is that it was also possible to give a life plot of the data.
The first project of my mechatronics education was to build a automated bridge with only two button and an emergency lowering of the bridge in case of high winds. The buttons where used for giving a up and a down command or if both buttons where pressed for an emergency stop. I used the following components for the bridge:
Two Arduino’s, for the processing of the data
H-bridge, for two direction motor control
3 buttons, I added a dedicated emergency stop
Fan, for measuring the wind
Op-Amp, boosting the fans signal
MPU6050, for measuring the bridges angle
SSD1306 OLED-display, display the position of the bridge
Two servo’s, for the barriers
555-timer circuit, for the warning lights
Lineair voltage regulators
Although the bridge worked according to plan it was an over-complicated mess .This included the use of an Op-Amp for boosting the voltage of the “wind meter”.
The use of two Arduino’s because one Uno did not have enough memory to run the complete code. And for the communication between the two Arduino’s I used three ‘three state bits’. This was done bu using PWM signals with a Low-Pass filter to stabilize the ‘second state’ enough so the second Arduino would measure this correctly with it’s analog input. The second Arduino would receive a low, middle or high signal on three inputs so was capable of receiving nine different states. These nine different states would correspond to nine different pictures on the display.
Measuring of the bridges angle was done by using a 6 DOF MPU6050 and using the accelerometer data to calculate the angle. The acceleration of the bridge was only partial compensated by averaging five consecutive data samples.
An Optop-coupler circuit was also needed due to the motor interfering with the I2C used by the MPU6050.
Because of a school projects, which was a battery powered Automated guided vehicle. I found the need for galvanic isolation of a high power and a low power circuit. The high power circuit was connected to a LiPo battery and because of this there was a safety risk. To reduce the safety risk the high power circuit had a circuit breaker and components that could handle a bit more power, then the Arduino and sensors in the low power circuit. When building a photocoupler board on a proto PCB I found that it toke me a bit more time then I expected to build the circuit. Because I think this wouldn’t be the last time I needed to use a photocoupler board, I thought why not create a simple PCB for it.
So that is why I created the photocoupler board.
The PCB can be found and ordered here. The board uses 5 PC817 Photocouplers, 5 300 Ohm 0805 resistors and 5 1kOhm 0805 resistors. These values are chosen for a 5V input. If you want it to work with higher input voltages the 300 Ohm resistors need to be replaced with higher resistance resistors. In the video you can see that the photocoupler board can easily handle Arduino PWM signals.
Because there was a hardware problem with the Exceed X8 PRO helicopter of a friend, we decided to remove all the hardware and replace it with custom build hardware. The first thing I did was replace the hardware in the remote controller, here is the blog about that part. In that blog there is also a part about the receiving end, but the hardware used there has been taken out of commission for my newly designed hardware.
Hardware –circuit boards
On the MOSFET board there are two identical MOSFET circuits. Each circuit controls one output which is an amplified version of the input for that circuit. By putting the two circuits on one board space could be saved and the heat dissipation capabilities are enlarged. It also means less wire clutter in the helicopter. The board is designed to be used with IPU06N03LA MOSFETS, but any TO251 package N-channel MOSFET can be used as long as it meets the requirements needed for your motor and controller. Because I’m using brushed DC motors a flyback diode is incorporated in the design. Each MOSFET has its own pull-down resistor to make sure the MOSFET is in the off position when it’s supposed to and to protect the Arduino there is a current limiting resistor placed between itself and the MOSFET. I use 47 Ohm 0805 resistors for R1 and R2 and 10kOhm 0805 resistors for R3 and R4.
Arduino control board
The control board was designed for this project but is released as “wireless board V2.0” on OSH Park shared projects. Because it was difficult to get 3.3v Arduinos with the right pin-out the board is now designed to accept 2 different Arduino pin-outs. Namely the “deek-robot” pin-out found in figure 6 and the cheap “ebay” pin-out found in picture 7. Accept being able to handle two different pin-outs the board is upgraded to accept 3.3v Arduinos and 5v Arduinos. That’s also why there is a 5v regulator and a 3.3v regulator onboard so that the Arduino can be controlled by a unregulated or higher voltage power supply. The nRF24L01+ module is powered by the separate 3.3v regulator so long range nRF24L01+ modules can be used, without asking too much power from the Arduino and so that a 5v Arduino can be used. After having having not enough PWM outputs on my previous wireless boards I’ve decided to change the routing, the new pins are the one used in the Mirf library and can be found in table 1. On the bottom side you can see that there are 3 resistors so the voltage applied to the BATT header can measured thru a simple voltage divider network. Having to voltage regulators makes it also easy to have a 5v and a 3.3v line broken out.
Table 1: nRf24L01+ routing.
RF module pin:
The H-bridge is the only circuit board that was not custom built but bought. The board is called “Mini VNH2SP30 Monster Moto Shield Stepper Motor Driver ” and uses the VNH2SP30 H-bridge motor driver chip. This board is a bit overkill, but was chosen because of it’s light weight, it needs just one PWM input and it has advanced protection features.
Hardware – helicopter
As mentioned above the helicopter used for this product is an Exceed X8 PRO. This is a coaxial helicopter, which means that going forward and backwards is controlled by the tail rotor and rotation is controlled by the ratio of the rotor speed.
As of now the helicopter is still being calibrated for stable flight. Because the main rotors are not identical the amount of throttle for each rotor still needs to be adjusted. The other thing that needs to be adjusted is the center of gravity that needs to be beneath the main rotors.
After I made the wireless boards I wanted to find a project to use the boards in.
Because a friend had a non functional remote controllable helicopter we wanted to make it work again.
So I figured that fixing the remote controller, by replacing the original PCB with the wireless board was a nice project.
After hooking up the hardware I started coding. The first and easiest thing I coded was the code to read all the potentiometers. The coding of the transmitter was A bit more challenging. Because I wanted to transmit all 5 the potentiometer values in one sequence. I ended up putting the values in a array which was a success. Because I couldn’t test the transmitter code without a receiver code I had to code an other wireless board as a receiver. The transmitted data that the receiver receives can be seen on the serial monitor in figure 4. The finished code can be found on my github. To ensure the controller can be updated and debugged without having to open the controller I created a FTDI port on the outside of the controller (figure 6). The FTDI port can be hidden behind a cover as shown in figure 7.
The receiver code enables the receiving Arduino to receive data from the nRF24L01+ chip and process that data. Because the analog-to-digital converters (ADC) have a resolution of 10 bits and the ‘normal’ analogWrite function only has a resolution of 8 bits the data values need to be remapped. The remapping of value ranges is easily done with the function map. After these values have been remapped the can be used to control the motors of the helicopter. Because the tail rotor needs to rotate in both direction a h-bridge is required. For this project I used a L298N dual h-bridge board, although we only use 1 h-bridge but this was the cheapest and fastest option to get. Because the board also has an 5 Volt regulator on board, we can use it to power the Arduino in the helicopter from the LiPo-battery. The L298N board is no longer in use because it would fail at random. My friend designed a PWM controller board to power the main rotors. The board uses 2 IRF540 MOSFETs to channel the power from the battery to the motors. These MOSFETS unfortunately need a drain to source voltage of at least 4.5 V which our 3.3v Arduino doesn’t supply. This is solved by using two NPN transistors for each MOSFET to power the MOSFETS with a high enough voltage.
After successfully testing the helicopters lift capability we decided to design a new board (Figure 8) which integrates all the different components in 1. The new board uses different MOSFETS for easier and more powerful motor control. These MOSFETS are easier because the can be directly controlled with 3.3V and thus do not need extra bipolar transistors to boost up the voltage. The new MOSFETS are IPU06N03LA MOSFETS and are made by infineon. A small comparison can be seen in Table 1. Because the new MOSFETS have a lower Rds(on) they have lower power losses due to lower Drain-source on-state resistance, which also has the benefit that the MOSFETS become less hot.
I’ve created a REV 1.3 version of my nRfL01+ board for the arduino pro mini 3.3V. This board still uses the same ports for connecting the nRF24L01+ module as REV 1.2 and 1.2.2. It also has the potentiometer and dip-switches that REV 1.2 and 1.2.2 have. But now there are separate I2C and a SPI connections. And the Raw input voltage can be measured using analog input A6 (as long as it is below 6.6 volts). The brd file can be found here.
I’m currently working on automating my remote outlets. To start I’m going to build a central remote control unit. The first step is controlling my Impuls outlets (Figure 3) and if that’s successful I’m going to try and add some automated features like shutting all my power outlets off when leaving the room. Controllin my Beamish BY-7E light switch (Figure 2) is also in the planning. I bought the Impuls outlets in the Action, a series of shops in the Netherlands. For 10 euros you get 1 remote and 3 outlets which is a seriously low price. The Beamish BY-7E was bought on dx.com for about 13,50 dollar.
Before opening the remote outlets I was planning on adding an nRF24L01 module or a Bluetooth module to each outlet. But after opening the outlets I found the relatively unknown and badly documented … chip in them. But in the transmitter I found the commonly used and good documented HX2262 chip. The HX2262 chip is also compatible with the SC5262 and PT2262 chips and can be replaced by an Arduino running the right software. These chips make my projects a lot easier, cheaper and safer, because the receiving units are already finished when buying them. The only thing I need to build is my own transmitter. This is done by connecting a 443.29 MHz super-regeneration transmitter that uses On-Off Keying (OOK) to an Arduino. The module I used (Figure 4) costs about 2 dollar on dx.com and can be bought on many different sites.
Because I find using normal buttons a bit boring and because you can’t change the button layout easily I decided to add a touchscreen to my control unit. The touchscreen I’m using is a Nintendo ds lite touchscreen, because these are easy to read out and are about 3 dollar per unit. I use the BOB-0917 break outboard from Sparkfun to connect the touchscreen to my Arduino. I’m not really happy with this board because it needs a piece of paper between the touchscreen cable ribbon and the connector to make a good connection. And this board also lacks pull-up resistors for a stable analog read out. But for now I don’t have an other option so I use a breadboard to connect the pull-up resistors. The current test rig can be seen in figures 5 and 6. The next challenge for me was powering the Arduino without using a power cord. I chose a 18650 battery and a solar panel combination because this combination can power the Arduino for a long time. Well that was the theory at least, so I began testing. After testing I concluded that this was a good combination if the Arduino could be in power down mode most of the time. In graph 1 you can see the result of my testing. You can also see that if the Arduino isn’t in power down mode most of the time that the power consumption of the Arduino is to high for these power sources. But extra power saving measures like desoldering the power led have not been done yet, but may be included in the future.
For transmitting the right codes with the Arduino the best library to use is the Remote Switch library (not written by me). And for the touchscreen I have written my own library based on this tutorial. I think that using libraries makes the code better readable. Update: The library and Arduino code now work in perfect harmony together. Here is the beta version of my touchscreen library and here is the beta Arduino code that goes with it. You also need the RemoteSwitch library which can be found in the link above. I’ve created a github repository for this project here and will be using this to update my code and not the links from above.
I created an other library to get the Arduino file smaller and more clearer. This library wasn’t working at first but Boris a friend of mine fixed the library for me. The new code and a movie demonstrating the setup will be uploaded this week, but currently I’m to busy to do that.
New code was uploaded to Github and the video is uploaded here.
All the hardware from the main control unit is going to be enclosed in a custom box that I’m going to make. The boxed is going to be made by gluing plates of PMMA that are cut with a laser cutter. Renderings of the box can be seen in Figure 7 and Figure 8. The cutouts in the box are for placing the solar panel, touchscreen, PIR-detector and two potiontiometers. The potentiometer and PIR-detector are for enhancements that are going to be added later on.
The GY-80 board consists of a BMP085, ADXL345, L3G4200D and a HMC5883L.
The BMP085 is a digital pressure and temperature sensor. It can easure from 300 to 1100hPa and as a pressure resolution of 0.01hPa. It can also measure temperature from 0 to 65°C with a resolution of 0.1°C. With both pressure and temperature readings combined the altitude can be calculated.
The ADXL345 is a 3-axis digital accelerometer. The sensors range is user selectable: ±2G, ±4G, ±8G and ±16G. The sensors bandwidth is also user selectable from 1600Hz to 3.125 Hz.
The L3G4200D is a three-axis digital gyroscope. It has 3 user selectable scales: 250, 500 and 2000 dps.
The HMC5883L is a 3-axis digital compass. Its full scale range is ±8 gauss.
Because I want to read all the sensors with 1 Arduino I have chosen to communicate with all the sensors via I²C. After searching I came to the conclusion that I was best off using the Adafruit_sensor, Adafruit_ADXL345, Adafruit_BMP085_Unified and the L3G4200 library. The adafruit libraries can be found on: adafruit github and the L3G4200 can be found on: pololu github. I refer to the github pages of the owners of the libraries because that way you get the most up-to-date libraries and I don’t get in license troubles. I’ve written and combined code to make all the sensors work in one sketch. The code can be found here. The next step is to use the sensors data to control a helicopter.