• Thanks Bill and UFO-MAN

    Great explantion.

    james a
  • Developer

    I would to fallow this threat, but i have to comment something to receive update emails.

    Bill i would like to export your code to floats (no funky variables). If we are using 70% of arduino for DSM, sorry DCM, why not use maybe 6% of the DsPIC and make the life easier for beginners (like me)?
    I guess i already mentioned this to you! But i would like to share it to everyone. XD

  • Hi Bill, I am wanting to add a transiver to my board to send some of the data back. I read in the manual that the Tx and Rx are allready being used. What do you suggest / Solution?
  • Hi folks. I need some suggestions.

    I am trying to send the elements from the rmat array to the serial port (UART1 on the dsPIC). The auxiliary serial port of the green board is up and running thru a FTDI chip to a COM port on my PC.

    The different elements of the rmat array are stored in fractional format. That is a storage format that I have not worked too much with before. I however interpret it as 16 bits long, and its basically Q15 format.

    For example 0.1111111 11111111 is in fractional format = 0.9999
    In integer format it is like decimal 32767

    So I was thinking that if I send the integer value to the PC as an unsigned int and then divided with 32768 and stored the result as a float on the PC, then I would have the value of the rmat to operate on in my PC software.

    Does this should good?

    Now the question: How do I most elegantly convert the rmat fractional elements to decimal to send out via the serial port? I guess it involves typecasting the fractional elements to an unsigned int (how?) and then converting that to ASCII (how). Or ... ?

    Bill or other, do you have any code and suggestions to share on this?

  • Hi. Let me try to help you:

    The values in the DCM array are cosine values. They are below one and above minus one as long as the matrix is normalized. That means that they are small values. Those values have to be transformed to values that are compatible with the range used in the registers used to control the pulse width modulators in the dsPIC chip. That is taken care of by the multiplication (scaling). The macros __builtin_mulss() are utilizing the fast hardware multiply functionality of the dsPIC chip to do multiplications. In this way the programmer has scaled up the cosine values linearly so the servo deflections are proportional to the cosine values in the array. Then the programmer has to take care of the centering of the servos as well. That is where the offset of 3000 comes in. I guess Bill can correct my interpretation if necessary.

    HTH :)

  • Hi

    I am just trying to workout this bit of code from the roll-pitch demo.

    void output_matrix(void)
    // This routine makes the direction cosine matrix evident
    // by setting the three servos to the three values in the
    // diagonal of the matrix.
    union longww accum ;
    accum.WW = __builtin_mulss( rmat[6] , 4000 ) ;
    PDC1 = 3000 + accum._.W1 ;
    accum.WW = __builtin_mulss( rmat[7] , 4000 ) ;
    PDC2 = 3000 + accum._.W1 ;
    accum.WW = __builtin_mulss( rmat[8] , 4000 ) ;
    PDC3 = 3000 + accum._.W1 ;
    return ;

    I think I understand that the rmat[6] and rmat[7] are the board pitch and roll angles in relation to the earth Z axis and that these values will be between -1 and 1.
    rmat[8] is the yaw angle.
    The bottom line is the PWM value sent to the servo.
    I dont understand 'builtin_mulss' or the '4000' that the rmat is multiplied by.
    Is my understanding right up to this point and could you help me fill in the blanks.

  • Hi Bill/all,

    I am looking to add “lean angle” to the PIC-based data-logger I have made for my motorbike, and am considering the autopilot board and RMatrix code for this purpose.

    I only really need to capture lean (er, "roll") but am unsure whether retaining all other axes will improve performance in roll - I read with interest about one user's test of "DCM lite". Given that turns at the track can be quite long, perhaps several seconds of up to ~1.5G lateral acceleration, I would be using the GPS too.

    Are there other factors I'm missing, or would this application be a good fit for the board/code?

    Appreciate any thoughts :)

  • Is there code out there that provides roll and pitch stabilitzation without the use of a GPS? My previous experience with c programming is zero, and am really struggling with all of it.


  • Might I using souce code for NAV " Return to home" only ? Just using Ruder control waypoint. Please give me some advice.
  • Hello Bill:

    I seem to be little late to the party and may be I don't belong to the tribe here :) I hope your project is proceeding smoothly. I am trying to build a location/attitude awareness system for an autonomous _ground_ vehicle. So there you see my vehicle needs to stay on ground unlike your birds. Essentially the system needs to be build using 6DOF IMU + GPS. While googling for ways of integrating gyro output with GPS I landed at your page. That was about two weeks back and since then I have read your DCMDraft2, this discussion topic, and several of the documentation you have put out on UAVBoard. I must congratulate you for what you have achieved and for being generous in releasing your system and code to the community.

    After initial reading of UAVBoard spec I was excited that I could adapt your board to build INS/GPS system for my vehicle. Your board does a lot more things that what I need. My interest is only in these parts of the board: ability to read the gyros, acclerometers, GPS. Then use dsPIC to merge all three in your DCM, correct the errors (gyro/accel drifts) and dispatch the 3 positional and 3 orientation parameters to my computer/laptop. Basically I was thinking something like what Louis did in his wonderful video. Right now I am not interested in servo outputs, but just logging the orientation and location information as reported by the board. I dont want to control any servos/motors at the moment. The killer thing was your boards ability to read GPS radio and proper development package for dsPIC, which is important to me since my background is in CS not in ECE.

    But after careful reading of the board specs, and this thread, it seems that the board was designed to be self contained and not interface with any computer. Am I correct? If that is correct, is there a way to adapt your board to my needs? Now adapt means both hardware and software. I understand the firmware needs to be modified, but is the board capable of interfacing with a laptop/computer and sending data to it using USB/RS-232 ports? Can this be done through additional hardware like ICD2 etc?

This reply was deleted.