Shop OBEX P1 Docs P2 Docs Learn Events
How many Cogs for IMU.spin? — Parallax Forums

How many Cogs for IMU.spin?

shanghai_foolshanghai_fool Posts: 149
edited 2008-12-07 23:48 in Propeller 1
I have written a demo to look at the variables produced by IMU in OBEX.
My main code runs in 1 cog and PC_Terminal runs in 1 cog yet after I start IMU, cogcounter says I have 4 cogs left.
I thought IMU starts a cog for itself and then starts 3 other cogs (MCP3208, Kalman[noparse][[/noparse]Pitch], and Kalman[noparse][[/noparse]Roll]). I was thinking 6 cogs in all. Where am I going wrong?

Thanks
·

Comments

  • JWoodJWood Posts: 56
    edited 2008-12-03 21:15
    shanghai_fool,
    One cog reads the ADC to get the analog outputs from the 5DOF unit.
    One cog is used for the Kalman filter's.
    Two cogs are for the floating point math functions. (these two cogs could be removed if you convert he filter to int math)

    Good Day
    Jason
    Wood

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • shanghai_foolshanghai_fool Posts: 149
    edited 2008-12-04 00:42
    Thanks Jason, but I am still confused. Main program (cog0) starts PC_Interface (cog1) and start IMU (cog 2).

    IMU does a cognew (cog 3, starting at go) . IMU.go starts MCP (cog4), fmath (cog5), KF (cog6), KF (cog7). fmath starts f32A (cog?).

    What am I missing here?

    I am trying to determine savings by running an FPU. I was thinking 2 cogs but upon looking closer at the modules, I couldn't figure it out.
    It seems that you are running 2 KF's, each on separate cogs. I thought that although only 1 copy of the program was in main memory, it would copy that same program into as many cogs as called for.

    I am defiinitely missing some understanding here. Where did I go wrong?

    Donald
  • JWoodJWood Posts: 56
    edited 2008-12-05 20:14
    The two KF modules do not take up a cog each. It's simply 1 cog for both KF's, 1 cog for MCP and 2 cogs for float math. If you were to remove the float math cogs and add external hardware you would save 2 cogs but add complexity to your hardware design. 6 one way 1/2 dozen another. [noparse];)[/noparse]

    Take Care,
    Jason
    Wood

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • JasonDorieJasonDorie Posts: 1,930
    edited 2008-12-06 00:05
    Donald - if the two Kalman filters are each using a cog for their float math, it's possible to 'merge' them, since they'll never be called in parallel. Download my "Propeller with Propellers" project from the Completed Projects forum and use the modified Float32 object from that.

    My IMU uses 1 cog for ADC, one for all float math, and one for all the main / filter / PID / flight code. I'll have to double check that statement, but I'm pretty sure that's correct.

    Jason
  • shanghai_foolshanghai_fool Posts: 149
    edited 2008-12-06 00:05
    Thanks Jason,

    I am planning to use the FPU to handle the GPS functions so was thinking it could also do the floating point for the IMU. I think it is fast enough to handle it if I can allow it to get access between GPS strings. I have tested the FPU with the 5 Hz GPS alone at 57600 baud and it handles everything OK. On the scope it looks like I get all 5 strings in ~80ms leaving it free for ~120ms. I'm not sure what will happen if I give it additional instructions within those 80ms bursts. Am I correct that the float routines are only used when called by the IMU routine? I think that will be called at about the same rate as the receiver PRF which is ~50 Hz. Some people have suggested that the stability servos/motors work better when updated at a faster rate of 100-150 Hz. I am still working on programming some GPS functions into the FPU so I haven't yet tested it with the IMU working also. The FPU also processes strings much easier. I think the biggest problem is when the FPU is waiting for the correct GPS header. It stays in the loop until it gets it. Of course, the "RNC" string takes the most computations but it seems to handle it even when calling the math from SPIN. Having a sequence of instructions "built-in" as internal functions can only make it faster. I may have to put a semaphore in place.

    The number of cogs is important as I am doing several things in this prop and will need all 8.

    The IMU works great on the bench. I can't wait until I get it into my plane.

    Donald
  • shanghai_foolshanghai_fool Posts: 149
    edited 2008-12-06 00:19
    Hi JasonD
    It looks like you were posting at the same time as I. I have given a quick look at you project and will definitely spend more time on it. I have just been working on getting all the pieces working independantly before trying to put them all together. Since I am new to the Propeller, it is taking some time. I also can't figure out why 1 of the accellerometers is about 7° off level.

    Donald
  • JasonDorieJasonDorie Posts: 1,930
    edited 2008-12-06 05:04
    7° isn't all that much - It's possible that the SMT chip is a little off kilter. They're so small that a little extra solder under one side can make a pretty large difference. I have the ability to set a programmable 'level' value in mine to compensate.

    The prop takes a little while to get your head around; I can relate. It's pretty cool once you get the hang of it though. [noparse]:)[/noparse]

    Jason
  • Jay KickliterJay Kickliter Posts: 446
    edited 2008-12-07 23:24
    I was reading the the Floating Point PDF that comes with the Float objects on the OE. One thing I didn't quite understand, does Float32Full use 2 cogs strictly because all the functions wont fit in 1 cog? If so, wouldn't it be possible to comment out some of the functions in Float32 the IMU object doens't need, and paste in the ones its missing form Float32Full?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-07 23:48
    Float32Full does use 2 cogs because all the functions needed won't fit in 1 cog.
    It certainly would be possible for someone to make the changes you suggest.
    It would take some work, mostly to understand enough about the details of
    Float32Full to be sure that rearranging things would still work when done.
Sign In or Register to comment.