PWM Controller with R/E

Last month I spent quite a lot of time on expansion modules for use with the ESP-12E I2C Base Card. While the system worked exceptionally well as a prototyping and firmware testing platform ( as originally intended ), I immediately saw that the physical size of everything ( base board, with the cards) would be a problem inside any enclosure, when used with a real-world project.

At the same time, I have an ongoing need to design and manufacture a device for a friend, that will have very limited space inside the enclosure due to other essential components.

I have thus decided to combine the functionality of two of the IO Expander cards into a more compact design, on a single PCB ( Which I plan to use to power and control an Air Assist blower on my desktop CNC/Laser cutter, as well as function as a next step prototype for my other project.

The PCB

Let us take a quick look at the PCB.

Starting from the top left, we have the Blower/Fan Header.
This supplies 12v DC to the Blower/Fan motor, as well as the PWM signal to control the speed. ( Level converted up from 5v DC to 12V, and then reduced to 3.3v ) This may seem strange.

Let me explain for some more clarity…
The PWM input on the Blower/Fan is internally pulled HIGH to 12v ( by the motor driver circuitry – I can not change that, as it is a commercial unit.) The datasheet however calls for a 0v to 3.3v PWM signal to control the speed.

There is also a further input from the fan, which is a pulsed speed indicator (Fan RPM). This signal is 5v.

Next to that header, is a UART Header, with Rx, Tx and DTR signals, with a ground. I do no longer add USB-to-UART chips to my designs because they are not used a lot, take up unnecessary space, and I tend to program with ICSP anyway.

On the right of that, (Red/Blue/Yellow Header) are 5v, Gnd and 6 Analog inputs(A0-A3, A6,A7) [A4 and A5 being used for I2C]

The ICSP programming header is below that,
with a jumper to select PCF8574 interrupt on Pin D2 or not

This is followed by 6 GPIO (P2-P7) from the IO Expander, and
additional GPIO (D10, D11, D12, D13) , as well as (D7,D8,D9) [To be used with a Rotary Encoder]

Another 6way Ground header, as well as the 12v input (red), follows.

Finally, we have J1 and J2, which will switch 12v through BSS138 Mosfets to control static speed 12v cooling Fans (Only one of these is PWM capable)


The 2 Relays are optically isolated from the controller and mains isolation cutouts are provided to further keep DC and AC voltages well away from each other. [ they really don’t play well together, don’t they ?]

This wraps up the quick PCB description.

Schematic

The Schematic is below, along with a download link ( zip format, with PNG image files)

Some more pictures

I use stencils with almost all of my SMD assembly. It saves a lot of time, makes for even solder paste application, and prevents the mess associated with applying solder paste with a syringe, or even worse a skewer-stick or something similar. They do cost extra though, but I find it well worthwhile in comparison to the mess and time that they save.

Manufacturing

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.


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 $5 USD 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 as the cost of your components, ARE NOT included in the initial quoted price. ( The quote will update depending on what options you select ).

8) When you are happy with the options that you have selected, you can click on the Save to Cart Button. From here on, you can go to the top of the screen, click on Cart, make any payment(s) or use any coupons that you have in your account.

Then just sit back and wait for your new PCB to be delivered to your door via the shipping company that you have selected during checkout.

ATMega 328P Based PWM controller Card

As part of my recent ESP-12E I2C Base Board project, I designed an ATMega 328P Based PWM controller card, that can be used as an add-on card with the existing project, or standalone as a custom Arduino Nano compatible development board.

What is on the PCB?

The PWM controller card contains standard Arduino Nano circuitry running at 16MHz, without the USB to Serial converter, as well as a 3v to 5v level converter on the I2C port ( A4 and A5 ), as well as another 12v to 5v level converter, with a build in resistor-divider circuit, used to drive a 12v blower with 3.3v PWM control circuitry.

All analog inputs are broken out to make attaching additional sensors easier.

All the other unused GPIO pins are also broken out, either directly to headers on the PCB (D6~,D7,D8,D9~), D11,D12,D12 (ISCP Header) and D3 ( Marked RPM on the Fan Header)

Most of these pins are also additionally broken out onto the 2x20p female header at the bottom of the card ( See schematic for more details)

The board is designed to be powered from 12v DC (via the VIN pins on the 2x20p header) which is internally regulated down to 5v via an LDO voltage regulator.


External 3.3v should also be supplied to the 2x20Pin header to enable the I2C level converters on the same header. I2C is not directly broken out onto the PCB in this version of the PCB.

A reset button, and power led, as well as the standard led on D13 is also provided.

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.


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 $5 USD 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 as the cost of your components, ARE NOT included in the initial quoted price. ( The quote will update depending on what options you select ).

8) When you are happy with the options that you have selected, you can click on the Save to Cart Button. From here on, you can go to the top of the screen, click on Cart, make any payment(s) or use any coupons that you have in your account.

Then just sit back and wait for your new PCB to be delivered to your door via the shipping company that you have selected during checkout.

VC-01 and VC-02 Offline Voice Module

In a recent article, I took a look at the new VC-01 and VC-02 Voice offline voice modules from AI-Thinker. I mentioned that I was working on a very simple prototype PCB to do some more tests, as well as make practical use of the module in real life.

In this very short post, I will show off the initial prototype that I came up with.
While I have to admit that it is still in an extremely basic stage, It is already definitely useful.

Part of the reason for this is that there is not a lot of information available on the VC-01 and VC-02 at this stage, as well as the fact that more exotic features like I2C and SPI are still not accessible in the current firmware. I thus had to work with what was available, as well as take into consideration what will work with the standard factory firmware as well.

The prototype carrier PCB will thus only have two optically isolated relays and their supporting circuitry. I intend to actually use the PCB in my EE LAb area to control some of the lights in the area.

The Schematic

The schematic shows the relay control circuitry, comprising of my standard optic isolator-based relay driver, as well as headers to accept the VC-01 or VC-02 offline voice module kit PCB.

Testing the PCB

The PCB was tested using the standard factory firmware, as well as my custom firmware, kindly provided by AI-Thinker. Below is a short video of that in action. Please note that the relays was not yet connected to any external devices at this stage.

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.


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 $5 USD 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 as the cost of your components, ARE NOT included in the initial quoted price. ( The quote will update depending on what options you select ).

8) When you are happy with the options that you have selected, you can click on the Save to Cart Button. From here on, you can go to the top of the screen, click on Cart, make any payment(s) or use any coupons that you have in your account.

Then just sit back and wait for your new PCB to be delivered to your door via the shipping company that you have selected during checkout.

ESP-12E Card

A few months ago, I started working on an MCU Card design, which borrows from the idea of a standard desktop PC, in which there are a main-board, MCU and expansion slots, to add and remove peripherals as needed quickly.

The ESP-12E Card is a continuation of that project, with the ultimate goal to have a universal “main-board” that can accept various MCUs and standardised “expansion modules” that perform a specific task.

ESP-12E Card
ESP-12E Card

The PCB

The ESP-12E Card contains the bare minimum components to allow the chip to function. There are no power regulators or USB-to-TTL converters onboard. Code is flashed via an external USB-to-TTL converter, with Flash and Reset buttons on the actual PCB, or available in the 2×20 Pin female header at the bottom of the card.

Most of the GPIO is also broken out to the 2×20 pin header, with the exception of the 6 GPIO that is usually connected to the internal Flash on the ESP-12E module.

I have made provision for enough power and ground pins on the header as well.

As far as GPIO is concerned, They have been grouped together by function, as much as possible at least, to make interfacing with the base-board as easy as possible.

The Schematic

ESP-12E Card Schematic

The schematic is not complicated. It is a standard ESP-8266 configuration, with all non-essential components removed.

The “base-board” ( a sneak preview )

Sneak preview of the Base Card

In a future article, I will tell you more about this ( for the time being limited to I2C ) base card. [ a quick explanation: When I mean limited to I2C, it relates to the fact that at the moment, the base card, ( a prototype ) can only communicate back to the MCU via I2C protocol from each of the expansion slots, as well as via two dedicated IRQ lines from each slot ]Power is supplied via a small SMPS module.

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.


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 $5 USD 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 as the cost of your components, ARE NOT included in the initial quoted price. ( The quote will update depending on what options you select ).

8) When you are happy with the options that you have selected, you can click on the Save to Cart Button. From here on, you can go to the top of the screen, click on Cart, make any payment(s) or use any coupons that you have in your account.

Then just sit back and wait for your new PCB to be delivered to your door via the shipping company that you have selected during checkout.

Robotic Toy Car – Part 5

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.

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 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 as the cost of your components, ARE NOT included in the initial quoted price. ( The quote will update depending on what options you select ).

8) When you are happy with the options that you have selected, you can click on the Save to Cart Button. From here on, you can go to the top of the screen, click on Cart, make any payment(s) or use any coupons that you have in your account.

Then just sit back and wait for your new PCB to be delivered to your door via the shipping company that you have selected during checkout.

Robotic Toy Car – Part 4

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…

Completed PCB in packaging..

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 enough to learn the coding… If he doesn’t, he will as least have a very interesting looking custom remote controlled toy car.

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 as the cost of your components, ARE NOT included in the initial quoted price. ( The quote will update depending on what options you select ).

8) When you are happy with the options that you have selected, you can click on the Save to Cart Button. From here on, you can go to the top of the screen, click on Cart, make any payment(s) or use any coupons that you have in your account.

Then just sit back and wait for your new PCB to be delivered to your door via the shipping company that you have selected during checkout.

Adding flashing lights to the Robotic Toy Car Project

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 useable 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.

A short test of the display unit, disguised as a “police-style” flasher unit

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

The bottom layer of the flasher unit, shows the Io expander, bypass capacitors, and current limiting resistors.
The top layer is designed to be as clean as possible, with only LEDs 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 expander, 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 as the cost of your components, ARE NOT included in the initial quoted price. ( The quote will update depending on what options you select ).

8) When you are happy with the options that you have selected, you can click on the Save to Cart Button. From here on, you can go to the top of the screen, click on Cart, make any payment(s) or use any coupons that you have in your account.

Then just sit back and wait for your new PCB to be delivered to your door via the shipping company that you have selected during checkout.

Robot Toy Car – The Next steps

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, such as controlling the H-Bridges, PWM as well as a roof-mounted “status panel” with LED’s that also doubles as a visual display, to give a bit of colour to the project.

The “status panel” will be shown in a future post, however, with the only mention of it here being that it is I2C controlled, and based on a PCF8574.

The BasicOTA sketch is listed below.

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

#ifndef STASSID
#define STASSID "your-ssid"
#define STAPSK  "your-password"
#endif

const char* ssid = STASSID;
const char* password = STAPSK;

void setup() {
  Serial.begin(115200);
  Serial.println("Booting");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
  }

  // Port defaults to 8266
  // ArduinoOTA.setPort(8266);

  // Hostname defaults to esp8266-[ChipID]
  // ArduinoOTA.setHostname("myesp8266");

  // No authentication by default
  // ArduinoOTA.setPassword("admin");

  // Password can be set with it's md5 value as well
  // MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
  // ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");

  ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH) {
      type = "sketch";
    } else { // U_FS
      type = "filesystem";
    }

    // NOTE: if updating FS this would be the place to unmount FS using FS.end()
    Serial.println("Start updating " + type);
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) {
      Serial.println("Auth Failed");
    } else if (error == OTA_BEGIN_ERROR) {
      Serial.println("Begin Failed");
    } else if (error == OTA_CONNECT_ERROR) {
      Serial.println("Connect Failed");
    } else if (error == OTA_RECEIVE_ERROR) {
      Serial.println("Receive Failed");
    } else if (error == OTA_END_ERROR) {
      Serial.println("End Failed");
    }
  });
  ArduinoOTA.begin();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  ArduinoOTA.handle();
}

Controlling the Toy Car Robot

Controlling the Toy Car is a complicated question, with many ideas jumping into my mind, only to be pushed aside by technical issues, as well as real-world constraints on what is physically possible to be mounted on the plastic body of the toy car, space available on the inside, as well as not interfering with suspensions, springs, turning wheels etc.

The chassis of the toy car

As is clearly visible, there is really not a lot of space available here for sensors. Mounting sensors to the body will also provide a bit of a challenge, as well as won’t really look nice either…

Give an old toy car new life

I have thus decided to implement remote control for the time being, and later, maybe after 3d-printing a more suitable body, to add sensors for autonomous functionality. The ESP-Now protocol will be used extensively for the remote control, as, in my opinion, it required no additional hardware, is quite fast, as well as being extremely easy to use. It does however make it necessary to use another ESP deice in the remote control unit.

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 as the cost of your components, ARE NOT included in the initial quoted price. ( The quote will update depending on what options you select ).

8) When you are happy with the options that you have selected, you can click on the Save to Cart Button. From here on, you can go to the top of the screen, click on Cart, make any payment(s) or use any coupons that you have in your account.

Then just sit back and wait for your new PCB to be delivered to your door via the shipping company that you have selected during checkout.

Give an old toy car new life…

Give an old toy car new life

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.

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 as the cost of your components, ARE NOT included in the initial quoted price. ( The quote will update depending on what options you select ).

8) When you are happy with the options that you have selected, you can click on the Save to Cart Button. From here on, you can go to the top of the screen, click on Cart, make any payment(s) or use any coupons that you have in your account.

Then just sit back and wait for your new PCB to be delivered to your door via the shipping company that you have selected during checkout.


Compact Remote Alarm Transceiver – Part 2

In part one of this series, I took a look at some of my experiments using different voltage regulators, to design and build the Remote Alarm Transceiver prototype, and also mentioned that I will be looking at a single chip logic converter solution. In this (hopefully short) post, I will take a detailed look at that logic converter chip, as well as show you how it is used.

The Logic Level Converter Chip

I have chosen the TXS0108E Bi-Directional 8-bit Logic-Level Voltage translator from Texas Instruments for this application.

Some of the features of the device is listed below:

• AEC-Q100 Qualified for Automotive Applications
– Device Temperature Grade 1: –40°C to 125°C
– Device HBM ESD Classification Level 2
– Device CDM ESD Classification Level C6
• No direction-control signal needed
• Maximum data rates
– 110 Mbps (push pull)
– 1.2 Mbps (open drain)
• 1.4 V to 3.6 V on A port and 1.65 V to 5.5 V on B
port (VCCA ≤ VCCB)
• No power-supply sequencing required – either
VCCA or VCCB can be ramped first
• Latch-up performance exceeds 100 mA per
JESD 78, Class II
• ESD protection exceeds JESD 22 (A Port)
– 2000-V human body model (A114-B)
– 1000-V charged-device model (C101)
• IEC 61000-4-2 ESD (B port)
– ±8 kV contact discharge
– ±6 kV Air-gap discharge

Datasheet description:

This device is an 8-bit non-inverting level translator
that uses two separate configurable power-supply
rails. The A port tracks the VCCA pin supply voltage.
The VCCA pin accepts any supply voltage between 1.4
V and 3.6 V. The B port tracks the VCCB pin supply
voltage. The VCCB pin accepts any supply voltage
between 1.65 V and 5.5 V. Two input supply pins
allows for low Voltage bidirectional translation
between any of the 1.5 V, 1.8 V, 2.5 V, 3.3 V, and 5
V voltage nodes.
When the output-enable (OE) input is low, all outputs
are placed in the high-impedance (Hi-Z) state.
To ensure the Hi-Z state during power-up or power-down periods, tie OE to GND through a pull-down
resistor. The minimum value of the resistor is
determined by the current-sourcing capability of the
driver.

Typical Application:

Reference Design / Typical Application for the TXS0108E

My Thoughts:

I really like the tri-state (high impedance) mode of the chip, as it allows for isolation between the different voltage level circuits, for example, If I were to communicate on a 5v SPI bus, to another device, I can for instance put the chip in Tri-state mode, and not worry about stray signals interfering from the 3v side.

On the downside, the chip is very small, which makes it a real challenge to solder by hand. On the speed side, It is also not quite as fast as my usual MOSFET based circuitry. It does however do the job it was designed for quite well.

Updated Circuit

Integrating the chip into the existing Remote Alarm Transceiver circuit is very easy, allowing us to replace almost all of the Mosfet-based Logic level converters. We do still need a few of them, as we have only 8 bidirectional channels on the TXS0108.

Schematics

Some Notes on the schematics:

A battery level monitor is connected through a voltage divider, with a MOSFET as a switch to the A0 pin. The voltage divider is set up for a 12v DC input source. The MOSFET is controlled from the D6 Pin.

The reason that I did this is, that I found some parasitic voltage leakage through the A2D converter in a previous design, reducing battery life. My hope is that by only reading battery level when the MOSFET is on, there can be an increase in battery life ( Taking into consideration that the Voltage regulators are not very efficient, it won’t really amount to a big gain unless I switch to an SMPS in the future. )

The PCB

Remote Alarm Transceiver PCB
The PCB

In the picture above, we can see the completed PCB (The relay and buzzer were not populated yet)

Manufacturing the PCB

PCBWay

This PCB was manufactured at PCBWAY. The Gerber files and BOM, as well as all the schematics, will soon be available as a shared project on their website. 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 as the cost of your components, ARE NOT included in the initial quoted price. ( The quote will update depending on what options you select ).

8) When you are happy with the options that you have selected, you can click on the Save to Cart Button. From here on, you can go to the top of the screen, click on Cart, make any payment(s) or use any coupons that you have in your account.

Then just sit back and wait for your new PCB to be delivered to your door via the shipping company that you have selected during checkout.