Giter Club home page Giter Club logo

Comments (5)

pjueon avatar pjueon commented on July 28, 2024

The library only generates PWM signal.
How your motor moves completely depends on the motor you're using.

First check your motor(what kind of motor, model, etc) and check the data sheet of it.

from jetsongpio.

MotorCityCobra avatar MotorCityCobra commented on July 28, 2024

I thought it might be something to do with the 'high' and 'low'.
I'm pretty sure it is a software option to change the direction of the motor. On a Raspberry Pi and Arduino IDE I can change the direction with code.

from jetsongpio.

pjueon avatar pjueon commented on July 28, 2024

There's no direction in pwm signal. Just frequency and duty cycle.
https://www.analogictips.com/pulse-width-modulation-pwm/

Can you give more details?

What Jetson device are you using?
What kind of motor are you using? (Servo, dc, step, etc)
Motor model?
How do you setup the circuit?

from jetsongpio.

MotorCityCobra avatar MotorCityCobra commented on July 28, 2024

You're probably the most responsive repo owner on GitHub.

Nvidia Jetson AGX Xavier.
Nema 17 motor.
Driver is a Usongshine Stepper Motor Driver TB6600 4A 9-42V

I was just thinking about how I might need to change something with the driver's wiring.
I don't know how to wire it up. Right now I just have a wire in pull+ to the PWM pin and the pull- to the ground pin.

from jetsongpio.

MotorCityCobra avatar MotorCityCobra commented on July 28, 2024

Okay, I got the motor running clockwise and then counterclockwise with the code below.
I also wired the driver differently. For the signal pins on the driver, all the + sockets are connected to each other and connected to my Jetson's 5V output.
The signal's dir - is connected to my pin 15.
The signal's pul - is connected to my pin 18.


#include <iostream>
// for delay function.
#include <chrono>
#include <map>
#include <string>
#include <thread>

// for signal handling
#include <signal.h>

#include <JetsonGPIO.h>

using namespace std;

inline void delay(int s) { this_thread::sleep_for(chrono::seconds(s)); }

static bool end_this_program = false;

void signalHandler(int s) { end_this_program = true; }

int main()
{
    // Pin Definitions
    int output_pin = 18;
    int direction_pin = 15;

    // When CTRL+C pressed, signalHandler will be called
    signal(SIGINT, signalHandler);

    // Pin Setup.
    // Board pin-numbering scheme
    GPIO::setmode(GPIO::BOARD);

    // set pin as an output pin with optional initial state of HIGH

    GPIO::setup(output_pin, GPIO::OUT, GPIO::HIGH);
    GPIO::PWM p(output_pin, 200); 
    GPIO::setup(direction_pin, GPIO::OUT, GPIO::LOW);
    GPIO::PWM e(direction_pin, 200);

    auto val = 75.0;
    e.start(val);
    p.start(val);

    cout << "PWM running. Press CTRL+C to exit." << endl;
    for (int i = 0; i < 4; i++){
        delay(1);
        cout << 1;
    }
    e.stop();
    
    for (int i = 0; i < 4; i++){
        delay(1);
        cout << 1;
    }

    
    p.stop();

    GPIO::cleanup();

    return 0;
}

from jetsongpio.

Related Issues (20)

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.