Jump to content
43oh

austen520

Members
  • Content Count

    4
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    austen520 got a reaction from nicknguyen in Self-balancing PID robot w/ code + schematic + UART tool   
    Thanks for checking it out! Unfortunately the left motor is currently out of commission, and we lacked the foresight to design a chassis that would allow for easy motor replacements, among other shortcomings. I'm hoping to find the time to build a new chassis sometime over the next few weeks. Although I can't make any guarantees, if that day comes I'll be sure to post a video.
  2. Like
    austen520 reacted to RAKSH in Analog to Digital Conversion on Tiva C Series MCU   
    Here's  code performing ADC on Pin E5 on the Tiva C Series meant for struggling beginners like myself
    #include <stdbool.h> #include <stdint.h> #include "inc/hw_memmap.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "inc/hw_types.h" #include "driverlib/debug.h" main(void) { uint32_t pui32ADC0Value[1]; SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ); //Set clock at 40 Mhz , Sometimes //ADC may not work at 80Mhz SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ADCReferenceSet(ADC0_BASE, ADC_REF_INT); //Set reference to the internal reference // You can set it to 1V or 3 V GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_5); //Configure GPIO as ADC ADCSequenceDisable(ADC0_BASE, 3); //It is always a good practice to disable ADC prior //to usage ,else the ADC may not be accurate // due to previous initializations ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); //Use the 3rd Sample sequencer ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_CH8 | ADC_CTL_IE | ADC_CTL_END); //Configure ADC to read from channel 8 ,trigger the interrupt to end data capture // ADCSequenceEnable(ADC0_BASE, 3); //Enable the ADC ADCIntClear(ADC0_BASE, 3); //Clear interrupt to proceed to data capture while (1) { ADCProcessorTrigger(ADC0_BASE, 3); //Ask processor to trigger ADC while (!ADCIntStatus(ADC0_BASE, 3, false)) { //Do nothing until interrupt is triggered } ADCIntClear(ADC0_BASE, 3); //Clear Interrupt to proceed to next data capture ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value); //pui32ADC0Value is the value read SysCtlDelay(SysCtlClockGet() / 12); } //Suitable delay } It is important to refer to datasheet before selecting the GPIO for the ADC and the channel through which it is done .
     
  3. Like
    austen520 got a reaction from vinicius.jlantunes in Self-balancing PID robot w/ code + schematic + UART tool   
    I recently completed a final project for an undergrad circuits class, throughout which this forum was a huge help, and so I just wanted to try and give back a little by presenting our code here. The project was, as you may have guessed, a two-wheeled self-balancing robot via a PID controller:

     
    We used an MSP430G2553 with the EXP430G2 launchpad, although the code should of course be applicable to any similar MCU. We also used the apparently popular MPU6050 IMU to produce angle estimates, and a simple H-bridge using TIP-102 transistors for motor control. The schematic that I've attached is a complete reproduction of our setup (including our pin configuration), and can also be found on the github linked to at the bottom of this post.
     
    The files that describe the primary control sequences are main.c, which of course has the setup and main loop, as well as the PID controller code; and StateEstimate.c, which describes how the raw IMU data is combined into a more accurate estimate of the robot's current angle with the ground (we used the so-called "complementary filter" with reasonable success, which just sums a low-passed accelerometer reading with a high-passed gyroscope reading). Furthermore, the parameters for the PID controller are located in Config.h (the parameters currently in the repo are just toy values), and the parameters for the state estimator are located in StateEstimate.h.
     
    The two biggest frustrations we faced when developing the project was successfully communicating with the MPU6050 over I2C (included in the github is the i2c device library, separately available at http://www.i2cdevlib.com),and getting useful information sent over a UART connection. So, I hope that by releasing this code we can make those tasks at least a little bit smoother for people tackling the same problems. The code is set up, by default, to use pins 1.1 and 1.2 for UART communication over the hardware serial interface. The MSP430 will send the angle estimate and PID control signal over UART, which can be captured and saved as a CSV, or even displayed in an OpenGL gui, using the supplied serialReader.py python utility (instructions are in the repository README). Using the supplied C code as a template, sending and receiving arbitrary data for post-processing should hopefully be trivial. UART is configured in main.c, and the functions for sending data over the connection are located in hwuart.c.
     
    Link to github: https://github.com/austensatterlee/robotbuddy
     
    Anyway, I hope this is helpful or at least interesting to some of you. I'd be happy to answer any questions about how we got this working, or receive any criticisms from more knowledgeable members!

  4. Like
    austen520 got a reaction from SonCo in Self-balancing PID robot w/ code + schematic + UART tool   
    I recently completed a final project for an undergrad circuits class, throughout which this forum was a huge help, and so I just wanted to try and give back a little by presenting our code here. The project was, as you may have guessed, a two-wheeled self-balancing robot via a PID controller:

     
    We used an MSP430G2553 with the EXP430G2 launchpad, although the code should of course be applicable to any similar MCU. We also used the apparently popular MPU6050 IMU to produce angle estimates, and a simple H-bridge using TIP-102 transistors for motor control. The schematic that I've attached is a complete reproduction of our setup (including our pin configuration), and can also be found on the github linked to at the bottom of this post.
     
    The files that describe the primary control sequences are main.c, which of course has the setup and main loop, as well as the PID controller code; and StateEstimate.c, which describes how the raw IMU data is combined into a more accurate estimate of the robot's current angle with the ground (we used the so-called "complementary filter" with reasonable success, which just sums a low-passed accelerometer reading with a high-passed gyroscope reading). Furthermore, the parameters for the PID controller are located in Config.h (the parameters currently in the repo are just toy values), and the parameters for the state estimator are located in StateEstimate.h.
     
    The two biggest frustrations we faced when developing the project was successfully communicating with the MPU6050 over I2C (included in the github is the i2c device library, separately available at http://www.i2cdevlib.com),and getting useful information sent over a UART connection. So, I hope that by releasing this code we can make those tasks at least a little bit smoother for people tackling the same problems. The code is set up, by default, to use pins 1.1 and 1.2 for UART communication over the hardware serial interface. The MSP430 will send the angle estimate and PID control signal over UART, which can be captured and saved as a CSV, or even displayed in an OpenGL gui, using the supplied serialReader.py python utility (instructions are in the repository README). Using the supplied C code as a template, sending and receiving arbitrary data for post-processing should hopefully be trivial. UART is configured in main.c, and the functions for sending data over the connection are located in hwuart.c.
     
    Link to github: https://github.com/austensatterlee/robotbuddy
     
    Anyway, I hope this is helpful or at least interesting to some of you. I'd be happy to answer any questions about how we got this working, or receive any criticisms from more knowledgeable members!

  5. Like
    austen520 got a reaction from enl in Self-balancing PID robot w/ code + schematic + UART tool   
    I recently completed a final project for an undergrad circuits class, throughout which this forum was a huge help, and so I just wanted to try and give back a little by presenting our code here. The project was, as you may have guessed, a two-wheeled self-balancing robot via a PID controller:

     
    We used an MSP430G2553 with the EXP430G2 launchpad, although the code should of course be applicable to any similar MCU. We also used the apparently popular MPU6050 IMU to produce angle estimates, and a simple H-bridge using TIP-102 transistors for motor control. The schematic that I've attached is a complete reproduction of our setup (including our pin configuration), and can also be found on the github linked to at the bottom of this post.
     
    The files that describe the primary control sequences are main.c, which of course has the setup and main loop, as well as the PID controller code; and StateEstimate.c, which describes how the raw IMU data is combined into a more accurate estimate of the robot's current angle with the ground (we used the so-called "complementary filter" with reasonable success, which just sums a low-passed accelerometer reading with a high-passed gyroscope reading). Furthermore, the parameters for the PID controller are located in Config.h (the parameters currently in the repo are just toy values), and the parameters for the state estimator are located in StateEstimate.h.
     
    The two biggest frustrations we faced when developing the project was successfully communicating with the MPU6050 over I2C (included in the github is the i2c device library, separately available at http://www.i2cdevlib.com),and getting useful information sent over a UART connection. So, I hope that by releasing this code we can make those tasks at least a little bit smoother for people tackling the same problems. The code is set up, by default, to use pins 1.1 and 1.2 for UART communication over the hardware serial interface. The MSP430 will send the angle estimate and PID control signal over UART, which can be captured and saved as a CSV, or even displayed in an OpenGL gui, using the supplied serialReader.py python utility (instructions are in the repository README). Using the supplied C code as a template, sending and receiving arbitrary data for post-processing should hopefully be trivial. UART is configured in main.c, and the functions for sending data over the connection are located in hwuart.c.
     
    Link to github: https://github.com/austensatterlee/robotbuddy
     
    Anyway, I hope this is helpful or at least interesting to some of you. I'd be happy to answer any questions about how we got this working, or receive any criticisms from more knowledgeable members!

  6. Like
    austen520 got a reaction from oPossum in Self-balancing PID robot w/ code + schematic + UART tool   
    I recently completed a final project for an undergrad circuits class, throughout which this forum was a huge help, and so I just wanted to try and give back a little by presenting our code here. The project was, as you may have guessed, a two-wheeled self-balancing robot via a PID controller:

     
    We used an MSP430G2553 with the EXP430G2 launchpad, although the code should of course be applicable to any similar MCU. We also used the apparently popular MPU6050 IMU to produce angle estimates, and a simple H-bridge using TIP-102 transistors for motor control. The schematic that I've attached is a complete reproduction of our setup (including our pin configuration), and can also be found on the github linked to at the bottom of this post.
     
    The files that describe the primary control sequences are main.c, which of course has the setup and main loop, as well as the PID controller code; and StateEstimate.c, which describes how the raw IMU data is combined into a more accurate estimate of the robot's current angle with the ground (we used the so-called "complementary filter" with reasonable success, which just sums a low-passed accelerometer reading with a high-passed gyroscope reading). Furthermore, the parameters for the PID controller are located in Config.h (the parameters currently in the repo are just toy values), and the parameters for the state estimator are located in StateEstimate.h.
     
    The two biggest frustrations we faced when developing the project was successfully communicating with the MPU6050 over I2C (included in the github is the i2c device library, separately available at http://www.i2cdevlib.com),and getting useful information sent over a UART connection. So, I hope that by releasing this code we can make those tasks at least a little bit smoother for people tackling the same problems. The code is set up, by default, to use pins 1.1 and 1.2 for UART communication over the hardware serial interface. The MSP430 will send the angle estimate and PID control signal over UART, which can be captured and saved as a CSV, or even displayed in an OpenGL gui, using the supplied serialReader.py python utility (instructions are in the repository README). Using the supplied C code as a template, sending and receiving arbitrary data for post-processing should hopefully be trivial. UART is configured in main.c, and the functions for sending data over the connection are located in hwuart.c.
     
    Link to github: https://github.com/austensatterlee/robotbuddy
     
    Anyway, I hope this is helpful or at least interesting to some of you. I'd be happy to answer any questions about how we got this working, or receive any criticisms from more knowledgeable members!

  7. Like
    austen520 got a reaction from bluehash in Self-balancing PID robot w/ code + schematic + UART tool   
    I recently completed a final project for an undergrad circuits class, throughout which this forum was a huge help, and so I just wanted to try and give back a little by presenting our code here. The project was, as you may have guessed, a two-wheeled self-balancing robot via a PID controller:

     
    We used an MSP430G2553 with the EXP430G2 launchpad, although the code should of course be applicable to any similar MCU. We also used the apparently popular MPU6050 IMU to produce angle estimates, and a simple H-bridge using TIP-102 transistors for motor control. The schematic that I've attached is a complete reproduction of our setup (including our pin configuration), and can also be found on the github linked to at the bottom of this post.
     
    The files that describe the primary control sequences are main.c, which of course has the setup and main loop, as well as the PID controller code; and StateEstimate.c, which describes how the raw IMU data is combined into a more accurate estimate of the robot's current angle with the ground (we used the so-called "complementary filter" with reasonable success, which just sums a low-passed accelerometer reading with a high-passed gyroscope reading). Furthermore, the parameters for the PID controller are located in Config.h (the parameters currently in the repo are just toy values), and the parameters for the state estimator are located in StateEstimate.h.
     
    The two biggest frustrations we faced when developing the project was successfully communicating with the MPU6050 over I2C (included in the github is the i2c device library, separately available at http://www.i2cdevlib.com),and getting useful information sent over a UART connection. So, I hope that by releasing this code we can make those tasks at least a little bit smoother for people tackling the same problems. The code is set up, by default, to use pins 1.1 and 1.2 for UART communication over the hardware serial interface. The MSP430 will send the angle estimate and PID control signal over UART, which can be captured and saved as a CSV, or even displayed in an OpenGL gui, using the supplied serialReader.py python utility (instructions are in the repository README). Using the supplied C code as a template, sending and receiving arbitrary data for post-processing should hopefully be trivial. UART is configured in main.c, and the functions for sending data over the connection are located in hwuart.c.
     
    Link to github: https://github.com/austensatterlee/robotbuddy
     
    Anyway, I hope this is helpful or at least interesting to some of you. I'd be happy to answer any questions about how we got this working, or receive any criticisms from more knowledgeable members!

×
×
  • Create New...