cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

 Hello, 

   

I am looking to do a bit of data fusion on the PSoC.  The first thing I want to implement is a "simple" complementary filter ( as per this link: http://www.instructables.com/id/Segstick/step10/A-very-flattering-filter/ ). Stage two is a linear Kalman and stage 3 is an Unscented Kalman filter. 

   

Now, to get the data in I will be using a Pololu IMU v3 - I2C unit. This is working fine and I am getting the readings on the MCU. However, they are in 2s complement form and will need to be integrated. 

   

So my question is: what is the best way to convert 2s complement ( I think the print command is one option) and how can I integrate the signal robustley on the unit? It will be running as part of a more complex system that drives motors and looks at other sensor data, so ideally the integration should be done as fast as possible each loop. 

   

 

   

Thanks,

   

Andrei 

0 Likes
6 Replies
ETRO_SSN583
Esteemed Contributor

Pretty straightforward -

   

 

   

sandbox.mc.edu/~bennet/cs110/tc/tctod.html

   

 

   

www.google.com/url

   

 

   

Regards, Dana.

0 Likes
JoMe_264151
Expert II

Your two's complement numbers are sign-extended "Normal" ints. So you only need to care for the sign extension when reading from the IMU. AFAIK the IMU result are already sign extended, but this may depend on the used chip. I remember that my chip was able to collect and buffer some (32?) measures which I could read-off as a burst and add them up.

   

 

   

Regarding the filters

   

There is an AHRS implementation that seems to be better and easier to install than Kalman filters. I implemented that in a PSoC4 already and it works quite fast. It is using quaternion math and so does not need the rather time-consuming math functions except when converting quaternions to Euler.

   

 

   

Happy coding

   

Bob

0 Likes
Anonymous
Not applicable

 Thanks! Looks good, seems like printf is not the best /:) 

   

Any deas on integration? Best practice or hints? 

0 Likes
JoMe_264151
Expert II

Tell us a bit more (or even a byte more).

   

What does your sensor(s) deliver?

   

Accelleration? magnetic? Gyro? How many axes each?

   

Link to datasheet of your sensor(s)

   

What should your final device be capable of? Mowing the gras? Moving the gras with a heli upside down? Anything in between?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Yes, you ae right ... I was a byte too brief 🙂 

   

I am using I2C sensors ... pololu IMU V3 but the code should work with nay I2C module( it seems most are capable of 400kHz and return 2s complement data) 

   

I have Accel, Magneto, Gyro - all three axes but don't need all the axes at the moment. I will start with a single one and take it from there. 

   

The final application is of a on-ground robot unit. I will a 3 DOF pose estimator in the end, so yaw, pitch and roll. You mentioned the AHRS implementation on the PSoC 4 - that has a floating point math unit.  

   

I wonder how well integration would work on normal fixed point MCUs and how to best do it. Mostly interested on the loop time parameter - how to best manage the loop timer for integration and also keep my unit alive and doing the current operations. ( I've seen delay(XX) being used but I don't want to hang the MCU waiting for nothing just to ensure the loop time) 

   

Thanks for the help! 

0 Likes
JoMe_264151
Expert II

Have a look at this project for sensor integration.

   

 

   

Bob

0 Likes