Connect with us

Sending/Receiving data via UART

Discussion in 'Microcontrollers, Programming and IoT' started by Dada Krauter, Feb 22, 2015.

Scroll to continue with content
  1. Dada Krauter

    Dada Krauter

    28
    0
    Feb 22, 2015
    Hi everyone :)))

    I am working on a project Quadcopter, I want to make my own controller(Joystick), flight controller(MPU-6050+HMC5883L+NEO ublox 6M GPS+ATmega1284p), I am designing my own frame, so everything would be homemade. I have written C code in Atmel Studio 6, but I have problems and some questions to you.

    First: I written code for MPU-6050(Initialization, PID, DCM) but I don't know how to write about HMC5883L magnetometer to hold orientation and I don't know same for GPS. Can someone help me with that?

    Second(HIGH PRIORITY :D): So Im using xBee to communicate Controller and Quadcopter. xBee sends data trough UART. But I have here a PROBLEM:

    I want to send ADC values(I have connected joystick modules to ADC) > Throttle: 0 Yaw: 512 Pitch: 512 Roll: 512 < Than my controller on Quad will read this values and convert it to PWM(0=1000ms 512=1500ms 512=1500ms 512=1500ms) So I don't know how can I send: > Throttle: 0 Yaw: 512 Pitch: 512 Roll: 512 <> 0 512 512 512 < and than read it separately. Can someone help me to write C code with Atmel Studio 6?

    Thanks for all... (y)

    Also see attachment>
     

    Attached Files:

    • FOR.jpg
      FOR.jpg
      File size:
      84.4 KB
      Views:
      199
  2. Dada Krauter

    Dada Krauter

    28
    0
    Feb 22, 2015
    Thank you Frenoy Osburn for fast reply. :)

    I made my own Flight Controller, I have onboard MPU and HMC connected to SCL, SDA ports also FTDI to debug and onboard xBee-PRO 868. Im using ATmega1284p(16MHz) Also OC1A OC1B OC3A and OC3B ports for ESCs. I have also level shifters to communicate 5V and 3V3 devices. Im using 250000 baud rate. Also I have my own code... but here I have problems :\ (and I don't want to use Arduino im using Atmel Studio 6)

    First: I don't know how to use HMC and how to write code, also I want help with GPS module that has only TX/RX pins...
    Second: I understand something about what you say "AT123Y456P789R010" but I can't figure out how to write code.
    Third: you said that xBee doesn't have inbuilt ADC, but it has( http://www.digi.com/products/wirele...point-multipoint-rfmodules/xbee-pro-868#specs ). But im using ATmegas ADC, than I want to send values with UART to xBee and xBee will send that values to another one, to Quad.

    Please help me to understand and learn everything... ^_^

    Thank you again :)

    Best regards,
    DADA
     
    Last edited: Feb 22, 2015
  3. Dada Krauter

    Dada Krauter

    28
    0
    Feb 22, 2015
    OK, now I understand how can I transmit and receive data and read it separately. I have also draw small schematic of how that method works... But I need more help with C programming to finally write it. Also I will convert HMC Arduino library to work with Atmel Studio 6. Have you any idea how can I interface GPS module? It has only TX/RX pins. I want to make function like "Back to Home" or "Hold Position"...

    Thanks again :)

    See attached schematic(Quality not so good :D)>>
     

    Attached Files:

  4. Dada Krauter

    Dada Krauter

    28
    0
    Feb 22, 2015
    Now I understand that I can't write library for HMC5883L to use with my controller :D, can you help me with that. Also I will send you my entire project C code, take a look ok? and than help me to resolve problems... I don't know programming well so I need help to learn... And about GPS take a look at that too > https://learn.sparkfun.com/tutorials/gps-basics < It seems that GPS received data is same what we said in this topic "AT123Y456P789R010"

    Thanks a lot :)

    DADA
     
  5. Dada Krauter

    Dada Krauter

    28
    0
    Feb 22, 2015
    Hi Frenoy Osburn :)

    I wrote C code to receive data from controller and separately save it on MCU for next operation. I'm sending string like that > "%S,VALUE,T,VALUE,R,VALUE,P,VALUE,Y" %_Sign to start reading, S_Assign reading, T_Throttle, R_Roll, P_Pitch, Y_Yaw < I can send you a C code if you want :)

    "Are you writing the navigation algorithm yourself?"
    >>>Yes, I want to write code myself, but for now I don't know how to do that. I think that would be like error correction(Restoration).

    "Could you tell me if you have worked on such projects previously?"
    >>>Yes, I have experience with coding, programming... But I haven't worked on a such difficult project.

    Also what is the timeline for this?
    >>>I'm not limited in time. ;)

    One more question: Can I use MPU-9150(> http://www.invensense.com/mems/gyro/mpu9150.html <) instead of MPU-6050?

    Thanks a lot :D

    DADA
     
  6. Dada Krauter

    Dada Krauter

    28
    0
    Feb 22, 2015
    Hi again, :)

    ok I will use HMC5883L(I want really good stabilization>See attachment file(I don't know how to use Optical sensor, Bartometer...))

    >>>
    In my simulation I have two MCUs 1) Controller and 2) FlightController. Controller sends data "%S,ADCVALUE,T,ADCVALUE,R,ADCVALUE,P,ADCVALUE,Y" (If received data = %, continue reading, if received data = S, it means that MCU is reading joystick commands...(I doesn't have any idea how to write UART error correction code :( ))(I have connected two joysticks to ADC, I am sending ADC values 0-1024) Then FlightController takes the values, converts it to 1000-2000ms width and then sends to the motors(I wrote code for that) Also I have code to PID controls, DCM, UART, TWI and also MPU :) But I need lot more... e.g. HMC, GPS...

    About safety, you are right :) I will think about that... then I will tell you :D

    >>>
    What you mean? :)

    Thanks again ;)

    DADA
     

    Attached Files:

  7. Dada Krauter

    Dada Krauter

    28
    0
    Feb 22, 2015
    I had a contact with somebody who worked on the project like this and he helped me. But he didn't know about HMC, GPS and other things such like that... He helped me to write code for my flight controller but the MCU depended on normal remote controller(RC Radio) that transmits PWM pulses, but I transformed my C code to receive controller data via UART with xBee to make my own controller. :)

    Thats all... But I want to make my Quad multifunctional and I don't know programming very well so posted a question on this forum to solve some issues/problems and learn what I need for my Quad(Programming). :)

    I think you will be able to help me with all others, what's left. ;)

    DADA
     
    Last edited: Feb 26, 2015
  8. Dada Krauter

    Dada Krauter

    28
    0
    Feb 22, 2015
    Hi Frenoy Osburn :)

    I have question to you:
    >>>
    I want to use GPS(TX,RX) FT232RL(TX,RX) and XBEE(TX,RX) but my chip only have 2 UART ports. So I want to use 74HC4052 multiplexer(> http://www.newark.com/on-semiconductor/mc74hc4052adtg/analog-mux-dmux-dual-4-x-1-tssop/dp/42K0889 <). And I want to write code to control this IC. It have only two control pins(S0, S1) also 1 enable PIN(Grounded = Enabled). I want C code to control channels, can you help me with that?

    e.g.
    >>>
    1) Switch to channel 1
    2) Get data1
    3) Switch to channel 2
    4) Get data2
    >>>

    Thanks ;)

    DADA
     
    Last edited: Feb 28, 2015
  9. Dada Krauter

    Dada Krauter

    28
    0
    Feb 22, 2015
    Also see attachment>>> :)
     

    Attached Files:

    • PIC.jpg
      PIC.jpg
      File size:
      97.2 KB
      Views:
      140
  10. Dada Krauter

    Dada Krauter

    28
    0
    Feb 22, 2015
    Hi again :)

    I know how it works but I don't know how to write C code for that(I wrote something but it doesn't woks :( ) and I need help.

    Thanks ;)

    DADA
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-