Code Monkey home page Code Monkey logo

motorghino's Introduction

Motorghino library

Arduino library for Motorghino (Ultra High precision Motor Feed)

About

Motorghino detects the absolute angular position of the shaft

For more information of Motorghino, and Open Lamborghino proyects

http://lamborghino.com

License

Written by Andres Bercovich, CEO Lamborghino.

Kinds of Motorghinos

There are 2 types of Motorghinos. Motorghino Wired, and Motorghino Direct.

Motorghino Wired work with the typical pins 2.54mm pitch, and can be conected by simple cable conections. (Recomendable for newers robotics designers), and Motorghino Direct work with a direct connection (PCB to PCB), easy and elegant assembling. Motorghino Direct work with OpenLamborghino 2.2 or upper. Also you can make your own pcb with motorghino using a public socket library for Autodesk Eagle.

Motorghino Wired

Motorghino Wired 1 Motorghino Wired 2 Motorghino Wired 3

Motorghino Direct

Motorghino Direct 1 Motorghino Direct 2

Motorghino Direct 3 Motorghino Direct 4 Motorghino Direct 5

Connections

Power supply

Motorghino Arduino Motor Terminal
M1 Terminal (Driver)
3.3V 3.3V
GND GND
CLK CLK (D13)
MISO MISO (D12)
CS CS (Any digital pin D2, for example)
M2 Terminal (Driver)
Warning
Unlike most Arduino & Genuino boards, MOTORGHINO RUNS AT 3.3V**. Even if the I/O can tolerate 5V, check that the voltage applied to VDD is at 3.3V. Applying a voltages higher than 3.3V to the VDD pin could damage the sensor.

SPI communication

MOTORGHINO have a SPI communication interface.

Arduino SPI pin mapping

Arduino / Genuino Board MOSI MISO SCK CS Voltage Level
Zero ICSP-4 ICSP-1 ICSP-3 defined by the user, any digital pin (default: pin 0) +3.3V
MKRZero 8 10 9 defined by the user, any digital pin (default: pin 0) +3.3V
MKR1000 8 10 9 defined by the user, any digital pin (default: pin 0) +3.3V
101 11 or ICSP-4 12 or ICSP-1 13 or ICSP-3 defined by the user, any digital pin (default: pin 0) +3.3V
Due ICSP-4 ICSP-1 ICSP-3 defined by the user, any digital pin (default: pin 0) +3.3V
Uno or Duemilanove 11 or ICSP-4 12 or ICSP-1 13 or ICSP-3 defined by the user, any digital pin. Default pin must be changed because pin 0 is also used by the Serial port. (use pin 7 for example) +5V
Mega1280 or Mega2560 51 or ICSP-4 50 or ICSP-1 52 or ICSP-3 defined by the user, any digital pin (default: pin 0) +5V
Leonardo ICSP-4 ICSP-1 ICSP-3 defined by the user, any digital pin (default: pin 0) +5V

Check Arduino SPI library reference page for more information on the SPI signal connections.

Setup

Install the library directly from within the Arduino IDE by using the Library Manager (Sketch => Include Library => Manage Libraries...).

It is also possible to import the library Zip file (check release tab) from the Arduino IDE (Sketch => Include Library => Add .ZIP Library...).

The library can also be manually installed by copying the Motorghino library folder in your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE to see the library.

Using the library

Step 1, import the library:

Include the lamborghino library in the header of the code

#include <Motorghino.h>

Step 2, Create the motorghino object:

Create the motorghino object with the name whatever you want, for example Motor_Left

Motorghino Motor_Left; 

Step 3, Begin and set the motor parameters:

Begin the motorghino object setting the 3 parameters:

(int) Diameter of the Wheel: That value is for calculate speed of the wheel.

(int) Gear Reduction: Some N20 micrometal gear motors have reductions. Motorghino work detecting the angle position of the extended motor shaft, then, to get the correct rps, rpm or speed of the wheel, you must set the gear reduction.

(int) Chip Select: Set the chip select pin (SC), of the Motorghino. Motorghino work with SPI sensor, then you must specify which pin you are use. (If you use Open Lamborghino, the default Chip select pins are D2 and D3 for Left and Right motor respectively.

 Motor_Left.begin(uint8_t diameter_wheel, uint8_t reduction_motor, uint8_t cs_motorghino);

Example:

 Motor_Left.begin(32, 5, 2); //if you have a wheel of 32mm of diameter, a 5:1 gearmotor reduction, and the chip select pin connected in D2.

Step 4, Use the get functions:

Finally, to get the values of the sensor, just use the function to get it.

Motorghino work with a sensor of 14 bits/revolution, (16.384 counts/revolution of the extended motor shaft).

(uint16_t) get_bits(): get the angle position of the wheel in bits (between 0 and 16.384);

(long) get_counts(): get the accumulated wheel path in counts.

(float) get_rps(): get the current angular speed of the wheel, in revolution/second;

(float) get_rpm(): get the current angular speed of the wheel, in revolution/minute;

(long) get_mm(): get the accumulated wheel path in mm.

(float) get_speed_mms(): get the current speed of the wheel, in mm/s;

Example:

  float sp;

  // assign the path (mm) to "sp" variable
  sp = Motor_Left.get_mm();

  // finally, print "sp" variable through Serial Terminal
  Serial.println(sp);

Complete code example:

#include <Motorghino.h>

//Declare the motorghino variable, like a "Motor_Left"
Motorghino Motor_Left;

void setup() {
 //Begin function of the element have 3 arguments: .begin(Diametert of the wheel, Reduction Ratio, CS pin of SPI)
 // Keep in mind that OpenLamborghino 2.2 have the CS pin of the left motor in D2, and right motor in D3 in Arduino), but
 //if you want a use Motorghino without Open Lamborghino, you can select any digital pin (except SPI pins)

  Motor_Left.begin(32, 5, 2);

  //init the serial port comunication
  Serial.begin(115200);

}

void loop() {
// Declare variable, for example "mm" (Remember that "get_mm" function, return a float variable).
float mm;

// assign the speed (mm) to "sp" variable
mm = Motor_Left.get_mm();

// finally, print "sp" variable through Serial Terminal
Serial.println(mm);

}

motorghino's People

Contributors

andresbercovich avatar

Stargazers

Martín Tomás Canario Dauros avatar

Forkers

nystwysrt madac1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.