Skip to content

runger1101001/SimpleFOCNano

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleFOC Nano Shield

A small BLDC driver shield in Arduino Nano form-factor.

Features:

  • Brushless motor driver shield for small motors
  • 8V - 30V power input
  • DRV8313 driver supports 2.5A / phase current
  • Supports 5V or 3.3V logic operation
  • Supports all Arduino Nano models from original Nano to Nano ESP32
  • On-board buck converter powers your Nano via VIN
  • SPI pins routed to 6-pin JST plug for easy sensor attachment
  • I2C pins routed to 4-pin JST plug (StemmaQT/Qwiic compatible) for easy sensor or peripheral attachment
  • Power and fault indication LEDs
  • 3-PWM + 3-EN configuration
  • Fault output indicates error conditions
  • Sleep input allows shutdown/reset via software
  • Measure supply voltage on A0

Pinout

The board has the following connections.

Front:

Back:

The shield uses the following pinout on the nano:

Pin Purpose
D3 PWM Input U
D6 PWM Input V
D9 PWM Input W
D4 EN Input U
D7 EN Input V
D8 EN Input W
A0 Bus Voltage Sense (analog)
A3 Driver Sleep (active low, 10k pull-up)
A6 Driver Fault (active low, open drain)
A7 Driver Reset (active low, 10k pull-up)
VIN Powered with 8V

Note that the Nano's default lines for serial RX/TX are not used by the shield.

I2C and SPI are not used, but are routed to the shield's JST-SH-1.0 ports. They can also be used via the pin-headers. Pin D10 is used as the SPI nCS signal, and has a 10k pull-up resistor. Note that pins A4 and A5 (I2C lines SDA and SCL) have no additional pull-up resistors on the SimpleFOC Nano board.

The following are the routed pins:

Pin Purpose
D10 SPI nCS
D11 SPI MOSI
D12 SPI MISO
D13 SPI SCLK
A4 I2C SDA
A5 I2C SCL

Power supply

The board accepts power via its power input pads, you can solder cables, a 2.54mm spaced header, or 3mm spaced header to make the connection.

Power input is 8V - 30V, although in my tests the driver begins to operate at around 7V.

The on-board buck regulator produces 8V from the input voltage, which is provided to Arduino Nano on the VIN pin. The VIN pin is protected by a diode, so you can plug USB power into the Nano at the same time. If less than 8V is supplied to the SimpleFOCNano shield, the buck converter operates in full conduction, and the input voltage is provided on VIN. In my tests, 5V is enough to make any of the Ardunino Nano boards come to life.

When operating from battery power, this means you should really use a 3S-6S battery - 2S may be enough, but might be too little for the driver when partially discharged.

3.3V vs 5V solder jumper

The solder jumper on the back of the board can be used to configure the logic voltage used by the shield to either 3.3V or 5V. The default setting is 3.3V and is correct for all the Nano boards except the original Nano and the Nano Every, for which the solder jumper should be changed to 5V.

When using the Nano shield with other MCU boards, select the voltage appropriate for the MCU board you are using. Make sure to connect either the 3.3V or the 5V header pin to the selected voltage.

To change the default configuration, use a sharp knife to carefully cut the existing solder pad connection at the point where it joins the pads, and lift the copper trace off the pcb.

Then use solder to create a new connection between the centre pad and the other solder pad.

After finishing, please check that the old pad is disconnected and the new pad is well connected using a multi-meter.

Usage

Set up the Hardware

The SimpleFOC Nano is designed to connect directly underneath or on top of your Nano board using the standard Nano headers.

So if your Nano and/or SimpleFOC Nano shield came without headers soldered on, the first step is soldering headers. Of course, you can also connect it with jumper wires or by other means, in which case you can also connect any other type of MCU board supported by SimpleFOC. In this case check the connections carefully, and note which pins you use for what purpose on your MCU board. These instructions assume you're using some kind of Arduino Nano (all of them are supported) and connecting directly with headers.

It doesn't matter whether the SimpleFOC Nano shield is mounted above or below the Nano, you can solder the headers either way. If one of your boards already came with headers and the other did not, pay careful attention to solder the other board's headers (male/female, orientation) to match.

For the power input and motor output, you can solder either 2.54mm headers or 3.5mm terminal blocks to the shield, or you can solder wires directly to the solder pads.

Once the headers are soldered (and cooled) you can connect the boards.

At this point, if you apply 8V to 30V input power to the shield, the Arduino should be powered on also, and you should see green LEDs on both Arduino Nano and the shield. If so you are ready to try open-loop mode.

For closed loop mode, you must still connect a sensor. The Nano's I2C and SPI pins are free, and depending on the model of Nano these pins could also connect a ABZ type encoder.

A magnetic sensor like this AS5048A sensor connects directly to the SPI port on the SimpleFOC Nano shield.

TODO setup examples with pictures

Monitoring the supply voltage

The supply voltage is connected to pin A0 via 1/10 voltage divider. If you don't want this functionality, don't connect the A0 pin between the boards.

Write your Software

Simplest possible sketch for SimpleFOCNano:

#include <SimpleFOC.h>
#include <SimpleFOCDrivers.h>
#include <drivers/simplefocnano/SimpleFOCNanoDriver.h>

SimpleFOCNanoDriver driver = SimpleFOCNanoDriver();
BLDCMotor motor = BLDCMotor(7);

void setup() {
    driver.voltage_power_supply = driver.getBusVoltage(3.3f, 1024);
    driver.init();
    motor.linkDriver(driver);
    motor.voltage_limit = driver.voltage_limit / 2.0f;
    motor.controller = MotionControlMode::velocity_openloop;
    motor.init();
}

void loop(){
    motor.move(2.0f); // 2 rads per second, open-loop
}

The SimpleFOCNanoDriver is just a wrapper class around SimpleFOC's BLDCDriver3PWM that saves you having to configure the pins. You can also use the SimpleFOCNano shield using the standard BLDCDriver3PWM like in many of our examples. In this case, use the pin numbers as defined above.

Using SPI is easy, you can use the standard SPI object as the pins used by the SPI plug on the shield are the standard ones. Use pin 10 as the nCS signal.

Using I2C via the JST port on the shield is easy. Stemma/QT compatible I2C extension boards should plug directly to this port, the standard I2C pins for the Nano are used.

Further examples can be found in the SimpleFOCNanoDriver's code repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published