• Robotic Toy Car - Part 6 - The Remote Control

    MakerIoT20205 days ago 0 comments

    Today we will look at the remote control unit for the Robotic Toy Car – Part 6. The project is close to being completed, and as such, there are quite a lot of final things that need to be taken care of.

    One of these will definitely be the final coding, which I will release in the final part of the project, so with that in mind, let us take a look at the remote control unit.

    Remote Control Unit, designed to be used with ESP-Now

    I have decided to do something completely different from standard remote control units, being that I will use ESP-Now, a protocol developed by Espressif. ESP-Now runs on the Wifi hardware of the ESP8266 or ESP32 and is basically a peer-to-peer protocol, that does not require Wifi but can co-exist with it on the same device. Outdoors, ESP-Now has a range of about 100m, which should work very well for my intended use.

    The Remote control, as designed, will have 4 dedicated buttons: forward, reverse, left and right, divided into two groups to make two-handed control easier, similar to a standard game controller. No input on either of the two groups will result in stopping the vehicle, in the case of forwards and backwards, and centring the steering, in the case of the left-right axis.

    a 3D Rendered Image of the PCB, motion axis on SW1 and SW2, steering axis on SW3 and SW4

    As I always try to make my designs somewhat reusable for other purposes, I have also broken out most of the unused GPIO pins to header pins, with also adding a jumper on GPIO16 to make deep-sleep wakeup mode possible., You can also re-use the switch pins for other purposes, just remember to first remove the 10k pull-up resistors at R14, R15, R16, and R17… SW4 -> R16 , SW4 = GPIO4 SW3 -> R17 , SW3 = GPIO5 SW2 -> R15 , SW2 = GPIO13 SW1 -> R14 , SW1 = GPIO12

    GPIO16 can be reused as well, just remove the jumper, but remember that it is pulled up through a LED and a 470ohm resistor…

    There is no USB-to-serial converter onboard, I have been having quite a lot of headaches with them over the last few months, with almost all CH340G chips that I have purchased, being fake, or dead-on arrivals that don’t work… Sending them back to the suppliers, unfortunately, results in unpleasantries, because even placing them in verified working circuits, still proves them to be not working… This is however not an issue, as it is quite easy to upload the board with an external adapter.

    The Schematic

    Schematic Diagram

    Manufacturing the PCB

    Over the past eight years, PCBWay has continuously upgraded their MANUFACTURING plants and equipment to meet higher quality requirements, and now THEY also provide OEM services to build your products from ideas to mass production and access to the market.

    https://player.vimeo.com/video/723212010?h=bce20fbd96

    The PCB for this project has been manufactured at PCBWay. Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to have manufactured.

    PCBWay

    If you would like to have PCBWAY manufacture one of your own, designs, or even this particular PCB, you need to do the following… 1) Click on this link 2) Create an account if you have not already got one of your own. If you use the link above, you will also instantly receive a $5USD coupon, which you can use on your first or any other order later. (Disclaimer: I will earn a small referral fee from PCBWay. This referral fee will not affect the cost of your order, nor will you pay any part thereof.) 3) Once you have gone to their website, and created an account, or login with your existing account,

    4) Click on PCB Instant Quote

    5) If you do not have any very special requirements for your PCB, click on Quick-order PCB

    6) Click on Add Gerber File, and select your Gerber file(s) from your computer. Most of your PCB details will now be automatically selected, leaving you to only select the solder mask and silk-screen colour, as well as to remove the order...

    Read more »

  • Robotic Toy Car - Part 5 - Power Distribution PCB

    MakerIoT20206 days ago 0 comments

    Robotic Toy Car – Part 5



    Robotic Toy Car Project

    In this almost post we look at the power distribution PCB for the almost completed Robotic Toy Car. I had many interesting issues to solve here, especially since I did not design my own Lipo battery charger circuit, but used a very useful little commercially available unit instead, the MH-CD42

    Based on a relatively difficult chip to get information on, the module is basically an integrated Lipo charge/discharge module, with a built-in boost converter that provides 5v at a maximum of 2A current. What makes it special is the ability to simultaneously provide current and voltage, as well as charge the attached LiPo cell at the same time, when connected to an external charger. It does, however, in my view at least, also have a few serious flaws, the most irritating of these being that it will completely discharge the attached LiPo cell even when completely switched off…

    I have thus tried to stop this issue from occurring by adding a switch in line with the Lipo Cell, a quite obvious solution, but it should not have been needed if the chip functioned as intended… ( As far as I can gather, the module was originally designed to be used in USB power banks. This makes the flaw even more serious, as a self-discharging power bank really defeats the purpose)

    Enough of that though, when it does work, it works great. just remember that you can not apply more than 5.5v DC to the charging input of the module.

    The completed Power Distribution and charging module

    The Schematic

    There is actually not a lot going on here, as everything is already on the supplied module. I have just added a charging port, additional power headers for 5v output and ground, as well as direct access to the LiPo Cell output, and a switch header to cut off power to the MH-CD42 when it is not in use.

    The PCB

    The PCB was manufactured as a 2-layer FR-4 board. The entire top layer is used as a ground plane, and the bottom layer was used for the 5v and Vbat traces, which were made as big as possible to allow for the high current ( up to 2A ) that the unit can supply to a load.

    The TOP later of the PCB is a complete ground plane.
    The BOTTOM Layer caries only power traces for 5v and VBat
    a 3D Render of the PCB, showing header pins and other connections

    It is also worth mentioning that the VBAT pins are NOT 3.3v ( Remember that the LiPo cell can run from 4.2v down to 3.0v depending on the charge. These headers were only placed on the board to provide direct access to the LiPo cell, for use with for example an ADC input or for connection to a dev board that is already fitted with a buck converter or a suitable LDO voltage regulator.

    The Actual PCB, as received from PCBWay
    Top Layer of the PCB
    Bottom Layer of PCB

    Manufacturing the PCB


    Over the past eight years, PCBWay has continuously upgraded their MANUFACTURING plants and equipment to meet higher quality requirements, and now THEY also provide OEM services to build your products from ideas to mass production and access to the market.


    https://player.vimeo.com/video/723212010?h=bce20fbd96

    The PCB for this project has been manufactured at PCBWay. Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to have manufactured.

    PCBWay

    If you would like to have PCBWAY manufacture one of your own, designs, or even this particular PCB, you need to do the following… 1) Click on this link 2) Create an account if you have not already got one of your own. If you use the link above, you will also instantly receive a $5USD coupon, which you can use on your first or any other order later. (Disclaimer: I will earn a small referral fee from PCBWay. This referral fee will not affect the cost of your order, nor will you pay any part thereof.) 3) Once you have gone to their website, and created an account, or login with your existing account,

    4) Click on PCB Instant Quote

    5) If you do not have...

    Read more »

  • Robotic Toy Car - Part 4

    MakerIoT202006/23/2022 at 11:12 0 comments

    In this part of the series, Robotic Toy Car – Part 4, We will add some custom side-panels to the project. While the original toy did come with some laser cut aluminum side panels, I decided to replace them with PCB versions, with even more flashing lights (yes, this thing is turning into a “Christmas tree” , but that is what the eventual owner wanted… )

    These side-panels will not be programmable. They will simply be operated from a standard 555 timer and a couple of other components, to give a flash time of about one second on and off each…

    It is also an excellent project to showcase the capabilities of PCBWay, in dealing with a “rather difficult” PCB to manufacture. As you may know by now, I use PCBWay‘s services quite extensively, and I also only design my PCB’s with EasyEDA. EasyEDA is however quite limited in some aspects, and as far as myself, making panels of different designs on one PCB with complex shapes is not something that I do every day…

    Let us take a look at what had to be done, and how well it was manufactured…

    The PCB Layout

    What we have here, is basically two mirrored side-panels ( as far as the visible “outside” is concerned anyway ) That consists of 6 led’s per side that will flash alternatively. On the “inside” we have a 555 timer chip, with some resistors and capacitors, as well as transistors that does the switching.

    The Schematic

    The difficulty of this PCB is definitely in the manufacturing. I was however pleasantly surprised with the excellent work that was done by PCBWay. Their Engineering staff did contact me early on in the order, with a suggested plan to manufacture, and once I approved that, they very quickly went on to production. My initial concern was that they suggested “mouse-bites” which we all know can sometimes come out a bit strange…

    I was however extremely pleased when the above parcel arrived… They added side rails, and the “mouse-bytes” were super tiny.

    After assembly ( not cleaned up yet )
    After Assembly ( not cleaned up yet )
    Installed on the toy car body

    The “almost completed ” Robotic Toy Car

    With the completion of the side-panels, it was also time to start work on the power wiring and other essential components of the project, which will get their own detailed post in a few days.

    the “almost completed” project

    Some details on the construction: The toy originally came with a single 500mA 14500 cell, which unfortunately stopped working very soon after only a few uses… This was however one of the reasons why the entire project happened in the first place, so no complaints there. I decided to replace it with a 18560 cell with a capacity of about 1900mA. This cell is much bigger however, and I had to think of where to place it. I decided to put it on the roof, sort of emulating a “spoiler”.

    Some of the next parts of the project will be the remote control unit, which will basically be an ESP8266 running ESP-Now protocol, as well as a decent battery charging and power distribution circuit, that will protect the Lipo cell from over charging and discharging, as well as provide sufficient power for all the added electronics in the toy car.

    “But you said it was Robotic, so why have a remote control?”

    The initial plan for the project did indeed say robotic, but it is also designed to be a learning platform, especially to teach coding. With that in mind, it is definitely better to keep things simple for now, and add sensors and more capabilities later on, especially as I am actually planning to replace the main MCU board with a more powerful ESP32 in a next version anyway. The car body is also extremely cramped, and does not have any space for mounting sensors at all. I plan to remedy that by designing and 3d-printing a whole new custom body shell later… providing that my young friend actually stays interested...

    Read more »

  • Adding Flashing Lights to the Robotic Toy Car Project

    MakerIoT202006/17/2022 at 11:33 0 comments

    In this, part 3 of the "Giving new Life to an Old Toy Car" series, we will be adding some flashing lights to the toy car project. This will ultimately serve two purposes, with the most obvious being to give some life and excitement to the project ( as the final user will be a young boy of 7, the visual aspect is important). The second purpose is more obscured, and mostly only usable to programmers and coders, or those that will debug the project... The flashing lights will function as status indicators, at startup, as well as during the normal operation of the toy. Obviously, the diagnostic nature should be well obscured so as to not distract from the visual aspects.

    The flasher unit is made up of an extremely simple circuit, with only a PCF8574 IO extender, bypass capacitors, some LED lights, and current limiting resistors.

    The bottom layer of the flasher unit, shows the Io extender, bypass capacitors, and current limiting resistors.
    The top layer is designed to be as clean as possible, with only LED's and some labeling

    Schematic

    Schematic

    The schematic is straightforward, with no surprises, consisting only of a few components, like the PCB8574, bypass capacitors, current limiting resistors, and of course the LEDs. It is also important to remember that I plan to use this entire robot car to teach a young boy to program microprocessors. I believe that visual is best, thus, all the lights :)

    Coding

    As this is still a project in quite a lot of development stages, I will not publish my exact code at this moment. You can however look forward to the future conclusion post, which will contain all my code at that stage. For now, however, we need to keep in mind that the PCF8574 is an I2C port extender, with an 8-bit IO port. It is thus possible to do something simple like the below:

    #include <Wire.h>
    
    void setup() { 
    wire.begin(); 
    wire.beginTransmission(0x20); 
    wire.write(0b11111111); // All LEDS off // our circuit is sinking current into the io expander 
    wire.endTransmission();
    delay(1000); // delay for illustration purposes, production code will use
    // non blocking code
    wire.beginTransmission(0x20); 
    wire.write(0b10100101); // All blue LED on // our circuit is sinking current into the io expander 
    wire.endTransmission();
    delay(1000);
    }
    
    void loop() {
    }
    

    Obviously, this is just a very quick example and is meant to just test functionality. Your own application will ultimately determine the exact code that you would need.

    Manufacturing the PCB

    The PCB for this project is currently on its way from China, after having been manufactured at PCBWay. Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to be manufactured.

    PCBWay

    If you would like to have PCBWAY manufacture one of your own, designs, or even this particular PCB, you need to do the following… 1) Click on this link 2) Create an account if you have not already got one of your own. If you use the link above, you will also instantly receive a $5USD coupon, which you can use on your first or any other order later. (Disclaimer: I will earn a small referral fee from PCBWay. This referral fee will not affect the cost of your order, nor will you pay any part thereof.) 3) Once you have gone to their website, and created an account, or login with your existing account,

    4) Click on PCB Instant Quote

    5) If you do not have any very special requirements for your PCB, click on Quick-order PCB

    6) Click on Add Gerber File, and select your Gerber file(s) from your computer. Most of your PCB details will now be automatically selected, leaving you to only select the solder mask and silk-screen colour, as well as to remove the order number or not. You can of course fine-tune everything exactly as you want as well.

    7) You can also select whether you want an SMD stencil, or have the board assembled after manufacturing. Please note that the assembly service, as well...

    Read more »

  • Robot Toy Car - The Next Steps

    MakerIoT202006/09/2022 at 05:04 0 comments

    In our last project, we started working on repurposing an old toy car. In this part, Robot Toy Car – The next steps, we will take a look at the controller board for this project and discuss some of the problems that we have encountered up to now. Most of the various components for this project are still in the prototype stage, but It is quite important to get them tested to verify the final designs. There are quite a few unique challenges in a project like this, which looks quite easy to solve but turn out to become quite challenging to get working just right in practice…

    One of the most important, as well as the most frustrating part, turned out to be the H-Bridge Motor controller. The first prototype of this was introduced in the first part of this project. While functional on paper, as well as working quite well in real life, (when tested with an Arduino, as well as manually), It performs extremely poorly when used with the actual controller for this project, an ESP8266 12-E…

    What could the reason be? How will I fix it…? The answers to that will be provided in a follow-up post. For now, let us take a look at the controller.

    The unassembled ESP-8266 Controller board, straight from the factory
    The Assembled ESP-8266 Controller board.

    The Controller Board, details

    Space inside the toy car is at a premium, so from the start, it was important to design a PCB that was small enough to fit, while also taking into consideration functionality, as well as all additional add-on components to ultimately be fitted to the project. With this in mind, I have decided on the ESP-8266, which, while bigger than an Atmega328, does offer a few additional features, like WiFi, and ESP-Now, which will greatly help in controlling and even updating firmware OTA. The ESP-8266 does however also have a few serious flaws in this design, like limited useable GPIO pins, a 3.3v working voltage requirement, and quite high operating current requirements.

    As the toy will likely not be used continuously, as well as the fact that it will run on batteries, which, can be replaced or recharged, I did not worry too much about the power issue. As far as the limited GPIO, that is where I2C comes in… It is quite easy to expand the GPIO with an IO Expander or two… My main problem came in the form of the CH340G USB-to-UART converter chip. It seems like there must be quite a lot of counterfeit versions of these around, as none of the chips that I purchased, from many different suppliers, actually functioned, with the best one actually providing a USB port, but, when investigating with a logic analyser, the Rx and Tx lines of the UART, generating garbage… Replacing it with a known working chip from a NodeMCU V1 board, magically solved the problem, verifying the PCB circuit as correct and working, and also proving that the purchased chips are definitely fake!

    This was easily repaired by temporarily soldering jumper cables to the Rx and Tx lines on the ESP-8266, and using an external UART-to-USB converter to upload the initial sketch to the device. Future updates will be OTA, so not a problem in the long run anyway.

    Controller Schematic

    The controller schematic, above, is basically a rearranged stock NodeMCU v1 circuit, with the only difference being that only specific pins were broken out onto header pins. These will be used for controlling the two H-Bridges, and provide PWM as well as access to the I2C bus.

    Software

    Due to the fact that this controller is still definitely considered a prototype, my main focus is definitely on getting the control software sorted out first. That way, at least in my opinion, I can then focus on hardware issues responding to verified software inputs, without having to do both at the same time. As mentioned before, I require OTA capability to upload new firmware to the device, so my starting point was the BasicOTA sketch provided with the Arduino IDE. This sketch was modified to perform some additional functionality,...

    Read more »

  • Part 1 - The Motor Controller

    MakerIoT202005/27/2022 at 12:55 0 comments

    Many of us have old toys laying around the house, they belong to our children or the children of our friends. In this article, I will attempt to show you how to give an old toy car new life, as well as hopefully teach a child a few interesting things with electronics.

    The inspiration for this article comes from my friend’s 7-year-old boy, who, way too clever for his age, always has a lot of very interesting questions. His mother and I have thus decided to do an experiment: “Let us try to teach him Arduino programming, so he can start to make his own toys”

    Obviously, the challenges in this venture are many… To name a few: The boy speaks only Thai, so English is a no-go. Soldering is out of the question, due to his age, as well as safety issues – All teaching will have to be done on a breadboard.

    My challenges apart, this is a project that many people would want to attempt, so it is important to start with a bit of theory.

    Controlling a DC Motor from a microcontroller

    DC motors, like those found in toy cars, are inductive loads, and that means that they induce electromagnetic fields when switched on or off. These EMF fields can damage your sensitive microcontroller quite easily. Another thing to remember is that your typical microcontroller can only source or sink in the region of 25mA to 50mA of current, not quite enough to drive a motor, let alone a toy car.

    Directional control of the motor

    In our toy car, we would definitely want the driving motor to be able to change direction, meaning spin forwards or backwards, thereby changing the direction that the car is travelling. This is achieved by using a circuit called an H-Bridge. In this circuit, four transistors, either BJTs or MOSFETs are arranged in a particular way to allow us to change the direction that the motor spins by changing certain logic signals.

    Implementing an H-Bridge with switches

    In the picture above, we simulate the H-Bridge circuit using slide switches in order to explain the method of operation. It should be clear that the direction is changed by switching on diagonally opposite switches.

    Driving a motor with a transistor

    In the picture above, we implement a simple, one-directional motor control circuit using a single transistor. This circuit still has the limitation that the motor can only spin in a single direction.

    Half of an H-Bridge

    In the circuit above, we combine the two motor driver circuits (with PNP and NPN transistor ) to complete one half of the H-Bridge circuit. This circuit still has the limitation that we can only spin the motor in a single direction.

    The completed H-Bridge circuit

    In the picture above, we added another half H-Bridge to complete the circuit. We will thus have 2 PNP and 2 NPN transistors, which form the completed circuit. This circuit will give us full bi-directional control of the motor. We can also control the speed of the motor if we apply a suitable PWM signal to the bases of the NPN transistors – we do need to be careful of SHOOT THROUGH and shorts though.

    My proposed Motor Driving Circuit

    the inside of the toy car, without the old broken circuit-board

    In the picture above, we can clearly see that there is not a lot going on inside this toy car. An On-Off switch is connected to the battery compartment, and two wires go to the drive- and steering motor.

    Interfacing this car to a microcontroller is thus going to require two separate H-Bridge circuits. One for the drive motor, and the second for the steering.

    Dual H-Bridge Circuit diagram

    I have designed the circuit above to control both motors of the toy car, the control signals are simplified to 2 per H-Bridge, and a common PWM signal to control speed.

    Manufacturing the PCB

    The PCB for this project is currently on its way from China, after having been manufactured at PCBWay. Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to be manufactured....

    Read more »