Below you have all the parts needed for the ESC PCB. You could also use a MSOFET driver instead of the BJT at the MOSFET gate. Aslo, for control and test, you will need wires, a potentiometer for throttle, the DC motor, some switches and a power supply. Check the list below and make the PCB.
- 1 x PCB GERBERs: GERBERs
- 1 x ATmega238p-AU: LINK eBay
- 1 x 16MHz crystal: LINK eBay
- 1 x ACS712-20A: LINK eBay
- 3 x IRFZ44N: LINK eBay
- 1 x BC547 npn: LINK eBay
- 2 x LM317: LINK eBay
- 3 x 470uF 50V DIP: LINK eBay
- 2 x 10uF 50V DIP: LINK eBay
- 6 x 100nF 0805 cap: LINK eBay
- 2 x 22pF 0805 cap: LINK eBay
- 3 x 10K 0805 res : LINK eBay
- 1 x 3K 0805 res: LINK eBay
- 1 x 2.7K 0805 res : LINK eBay
- 1 x 1K 0805 res: LINK eBay
- 5 x 150 0805 res: LINK eBay
- 3 x 10 0805 res: LINK eBay
- 1 x 3mm LED: LINK eBay
You have the scheamtic below. Remember that instead of the BC547 BJT you could add a MSOFET driver supplied at 24V and connected to the MOSFETs gate. The BJT has a pullup so it will be activated when the PCB starts, so the MOSFET gates are connected to GND, so those will be OFF. We don't want the MSOFETs to be ON for a short moment till the Arduino starts-up. The first part you will want to mount on the PCB is the "POWER" with the LM317 regulators. In this way, if the supplies fails and the output is higher than 5V, we won't burn the other components... Then add the ATmega328 basic configuration and then the rest of components.
Below you have the GERBER file for this project in a .zip format. You can make your own circuit on a breadboard for tests or maybe on a drilled prototyping PCB but if you want my PCB, you can download it from belwo for free. So go below, downlaod the .zip file with all the GERBERs and send it to a PCB manufacturer and get the boards. Then together with the schematic abobe and the part list, mount this project. Then upload the code and test it...
You must start mounting the PCB with the "Power" block from the schematic. In this way, if something fails and the voltage is more than 5V, we won't butn the rest of the ICs. So add the LM317, 10uF capacitors, small resistors and capacitors. Then solder wires at B- adn SW- pads and connect 35V at the input. With your multimeter, check the voltage on C5 and R4. The voltage should be around 23.5V on C4 and 5V on R1. The regulated voltage value is given by the used resistors, so make sure you use the same values as in the schematic.
Now that we have 5V, we can solder the basic configuration of the ATmega328 chip, so solder all the components you have in that square on the schematic. In my case, to spare time, I've took the chip from an Arduino NANO. In this way, I make sure it has a bootloader and that is working. If you use a brand new chip, follow the next tutorial link and see how to burn the bootlaoder to taht chip. Ok, once you have the chip in place, the resistors, capacitors and crystal, you can test it. Connect an External FTDI programmer to the UART pins and test it. Uplaod a test sketch. If the code runs, than the chip is well soldered and works well. In my case I upload a counter and print that on the serial monitor so I can really see that it works...
Bootloader tutorial here: LINK
Now that the voltage and microcontroller are ok, we can solder all the rest. Add the MOSFETs, the 470uF capacitors, the BJT transistor and the rest of the resistors. Pay atention: in the photos I'm using the PCB with two BJT. You will have the one with just one. Then you can go anf fill the tracks with solder so they could withstant more current. That's why I've designed the PCB with the power tracks exposed. Add the current ACS712 IC, the cables and the rest. The PCB is ready for the code.
This version of the code has minimum speed detection but it doesn't have speed limit yet. It has only current limit with the feedback from the ACS712. The code starts with the BJT turned ON so we have GND at the MSOFETs gate so those would be OFF. Then, according to the throttle pot, we increase the PWM signal, which is inverter, 255 to 0 instead of 0 to 255, because the BJT acts as an inverter. We only activate the PWM signal if the speed is higher than a certain value and throttle is in the lowest position. We do this for saferty. We don't want the motor to start from 0, that will put it into humming mode and draw so much current it could burn the circuit. So, first, the user should pedal a bit and then accelerate. Read more in the code.
Below you have a test example. The RPM limit is disabled here because we have no real wheel for feedback. Just increase pot and by that the speed. make sure you have head dissipators on the MOSFETs, otherwise those will blow up in seconds...
The case is as important as the PCB. Without a good heat dissipation, the MOSFETs would burn out in seconds. So, I will use this small metal case below. Measure and make the holes. Then I add some heat transfer paste between the MOSFETs and case but also below the PCB so it won't touch the case and create a short circuit. Once insulated, add the screws. Use a plastic washer for the screws so they won't touch the metal part and create short circuit. Add all wires, make a hole, pass the wires and glue them in place. Close the case and add label. That's it.