Menu
About me Kontakt

In the latest video from GreatScott!, Dmitry discusses the challenges of using the HT66F002 microcontroller in his project. His setup involves an infrared distance sensor, an Arduino microcontroller, and an LED, where the brightness of the LED changes based on the distance from the sensor. However, since he needs to build 14 of these units for a bigger project, costs can escalate quickly. Thus, he set out to find a cheaper alternative and found the HT66F002, which comes at a significantly lower price. However, the lack of beginner-friendly materials made it difficult to figure out if the microcontroller could meet his project needs, which he sought to investigate in the video.

The video begins with a sponsorship message from JLCPCB, a popular PCB service that Dmitry has used for many projects. He emphasizes the user-friendly nature of the platform and how quickly PCBs can be received. Following this, he lists the necessary functions that are required for the microcontroller to fulfill, which include pin operations as inputs and outputs, generating PWM signals, and I2C communication with the distance sensor. After reviewing the datasheets for HT66F002, Dmitry finds that most of his required functionalities are theoretically possible, but implementing them would be challenging.

Dmitry’s first step was to place the HT66F002 onto a breakout board and acquire the E-Link programmer. Programming began with the installation of the HT IDE 3000 and HOPE 3000 software. As he guides viewers through the process of coding a simple LED blink sketch for HT66F002, he encounters challenges related to timing features and the watchdog timer that initially hindered his success. After troubleshooting these issues, he disabled the watchdog timer, which finally allowed his blink code to work as intended.

In subsequent segments of the video, Dmitry tests other features, such as reading from a potentiometer and implementing sleep mode for power-saving. Ultimately, he discovers that the HT66F002 lacks I2C support in master mode, which hampers its usage in his project. While this revelation may seem discouraging, Dmitry believes that the video is still valuable, as it provides insight into the operation of low-cost microcontrollers, which might help viewers prepare for their own challenges.

As of now, this video has garnered significant attention with 674,597 views and 21,539 likes. Dmitry encourages viewers to support his work through Patreon and to follow his channel across social media. Interestingly, despite the challenges, HT microcontrollers present intriguing possibilities for specific applications, which could captivate electronics enthusiasts. However, considering the lack of documentation and guides, exploring a more suitable microcontroller may indeed be the better choice. In closing, Dmitry hints that he already has plans in mind for his next foray into finding a fitting microcontroller for his project.

Toggle timeline summary

  • 00:00 Introduction to the project using an infrared distance sensor, Arduino, and LED.
  • 00:20 The need to replicate the setup 14 times raises cost concerns.
  • 00:38 Discussion on the inefficiency of using an Arduino for the project.
  • 00:53 Finding the HT66F002 microcontroller as a cost-effective alternative.
  • 01:30 Explaining the scarcity of tutorials for the HT66F002.
  • 02:36 Outlining the basic functions required for the microcontroller.
  • 03:38 Check of the microcontroller's datasheet confirms potential functionality.
  • 04:15 Setting up the microcontroller on a breakout board.
  • 05:17 Beginning to write code to blink an LED.
  • 06:19 Troubleshooting LED issues due to the watchdog timer.
  • 07:15 Implementing button inputs to control the LED.
  • 07:45 Integration of PWM to control LED brightness.
  • 09:09 Incorporating analog input using a potentiometer.
  • 10:09 Setting up a sleep mode to save power.
  • 10:46 Exploring limitations of the microcontroller related to I2C communication.
  • 11:50 Conclusion on the programming experience with the HT microcontrollers.
  • 12:52 Encouragement to check resources in the video description.
  • 13:05 Closing remarks and invitation to support the channel.

Transcription

Now here's the problem. This right here is part of a big project I'm currently working on. We got an infrared distance sensor, an Arduino microcontroller and an LED. And as you would have guessed the closer we get to the distance sensor the brighter the LED gets. Sounds simple enough but the problem is that for the big project I need to build this setup 14 times and that can get expensive. Now using a cheaper distance sensor is not possible and I actually think its price is justified for what it can do. But we do not need such a big Arduino board or its ATmega 3280p microcontroller because it is way too overpowered with all of its features and also costs around two dollars per piece. So I searched through all corners of the internet to find a cheap alternative and I think I found one in the form of the HT66F002 that only costs around 0.2 dollars per piece which is a noticeable price difference. That of course sounds amazing but the next problem now is that unlike Arduino for which there exist thousands of tutorials and libraries online this microcontroller barely has any beginner's guides available. So the question is whether I can make this microcontroller work for my projects and that is exactly what we will be finding out in this video. Let's get started. Intro This video is sponsored by JLCPCB whose PCB service I used for many years and projects now. Their online platform is user friendly, easy to navigate and best of all you can receive your PCBs in just a week by using their fastest shipping option. If that sounds like your cup of tea then you can order their premium quality 1-8 layer PCBs starting at 2 dollars or even try out their 3D printing service starting at just 30 cents. And last but not least let me tell you a secret that their colorful silkscreen PCBs are coming soon so stay tuned. Now let's start off with finding out what the microcontrollers need to be able to do in my projects. The simplest thing would be using the pins as inputs and outputs meaning they can pull their pins high or low as an output to for example blink an LED or they can detect when their pins are getting pulled high or low as an input. Then we need to create a PWM signal with variable duty cycle which looks something like this on the oscilloscope. This is definitely mandatory to dim the brightness of LEDs. And while we're at it maybe it would be helpful to read the analog voltage of a potentiometer to dim the brightness of an LED accordingly which means we need an analog to digital converter. And last but not least a sleep mode would be beneficial to save a bit of power. And of course we definitely need to be able to use the I2C communication protocol to obviously communicate with our distance sensor. So yeah these are the main features I need for my projects and to find out whether my cheap microcontroller here can do them all I firstly checked its datasheets. And yes it seems like pretty much all functions are in theory possible to do except one that I will address later. And of course when comparing these specs to all the microcontrollers I already had a look at before then it is definitely not a powerhouse but certainly the cheapest option I ever looked at. So to get started with it I firstly sorted it onto a breakout board and next had to actually get myself another piece of hardware for it which is its dedicated programmer the E-Link. According to its manual you only need 4 FITS pins for programming which are VDD and GND for power and OCD-SCK and OCD-SDA for the data lines. Connecting those to the microcontroller was luckily super straight forward since the datasheet clearly states what pin connects where. And just like that it was time for programming for which I firstly had to install the HT IDE 3000 and the HOPE 3000 software. Now the IDE software is used to basically write your code, pretty much just like the Arduino IDE. And the HOPE software is then used to upload your created code to the microcontroller. And with that out of the way let's create our first project called Blink, select the HT66F002 and let's get started with coding a blinking LED. Now in Arduino language this is as simple as defining a pin as an output, pulling it high and low and waiting a bit in between. And luckily for me with the HT IDE it is not really hard to do either, the commands are just a bit different. For example with PAC1 equals 0 we set the PA1 pin seen here as an output and if we would say PAC1 equals 1 it would be an input. And by then pulling this pin high and low we should basically have a blink sketch. Right? Well sadly after compiling this code and then uploading it by clicking download, which worked wonderfully though even at the first try, my LED didn't feel like blinking properly. Now I probably spent around half a day figuring out what the problem was and tried solutions like decreasing the output current, adding capacitors and so on. Eventually though I realized that the watchdog timer was the problem which provides a device reset when its timer overflows. So after disabling it, my blink code finally worked like intended. And in case you are wondering what this code line here means, then it is basically used to alter the watchdog timer register, which I will need to do quite often with other registers as well. So if you want to know about that then definitely check it out in one of my previous videos. But anyway, next it was time for pushbutton inputs to for example turn on an LED which with the Arduino and its digital read function was super easy to do. And once again with the HTIDE it was also fairly simple to pull off. The only new function here is the PAPU one which enables a pull up resistor at the defined input pin. So after building this circuit up and uploading the new code, it worked perfectly fine, meaning the first mandatory feature was ready to practically use. Time to move on to the PWM one which if we look at Arduino programming is once again easy to pull off by using the analog write function in combination with an 8-bit value that constantly changes here to control the brightness of the LED aka the duty cycle of the PWM signal. When it comes to HT programming though this matter is definitely a whole lot more complicated because here we have to set up all the mandatory timer registers manually. Eventually though I ended up with a functional piece of code and the duty cycle can be changed here with a 10-bit variable. And after uploading this code you can see that it works just like the Arduino one and even features a higher frequency in direct comparison which was only around 490Hz before. Of course you could achieve a higher frequency with the Arduino as well by manipulating its timer registers and if you want to do that then check out my previous video about timers. But anyway PWM works and it was time for an analog input aka a potentiometer. And I feel like a broken record here by saying that Arduino makes it super simple to use this function. With the cheap microcontroller though it took me around 3 hours to manipulate the write register and then use bitmap to store the final analog voltage value in a variable that I can then pass over to the PWM function. But as you can see that was worth it in the end because I ultimately got it to work. And I think generally it is simpler to program with Arduino because there you got a serial interface meaning you can check at every point what the value of a certain variable is which makes troubleshooting so much easier. With my cheap microcontroller I cannot do that so it was a lot of trial and error. But either way ADC works meaning low power was next and here it was luckily easy to realize since this whole command puts the microcontroller into sleep mode. And by defining one input as a wakeup input you can bring the microcontroller back to life. Here you can see the final example which after blinking 5 times goes into sleep mode where I got the microcontroller current demand down to 11uA. And by pushing this button we basically turn it all back on and repeat this process. Nice. And that brings us to the last I2C feature which my small microcontroller is sadly missing. But luckily there are dozens of high tech microcontrollers out there and this HT66FO176 apparently comes with I2C and only costs around 30 cents per piece. So after soldering it on a breakout board and making sure that everything still works by uploading my PWM sketch it was time to dig into the I2C function. But sadly after around 1 hour I realized that this microcontroller along with apparently all other whole tech 8bit microcontrollers I could get a hold on only supports I2C in slave mode but for my project I need it as a master. This basically shattered my goal of using these microcontrollers for my projects and truth be told I only realized that after spending 3 days getting used to its programming. So was this video pointless in the end? I think not because now I know that the whole tech microcontrollers are not only cheap but also relatively easy to program for. And yes the IDE looks like Windows 95 but it is simple, free and does its job just fine. Combine that with the fact that they make lots of application specific microcontrollers like some for smoke detection, BLDC motors or even with a 24bit ADC and you got yourself some pretty compelling advantages here. But on the other hand though the programmer for the 8bit microcontrollers is quite pricey for a hobbyist. And like I said before there are not many libraries or guides around which are all in all my main complaints here. And if you want to use them for yourself then definitely check out the video description where I linked all good guides I found as well as all the codes I created in this video and a bit more. With that being said it is time for me to find another cheap microcontroller for my project and I think I already know what I will try next. Until then I hope you enjoyed this show and maybe consider supporting it through Patreon to keep it going. Don't forget to like, share, subscribe and hit the notification bell. Stay creative and I will see you next time.