CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to calculate degree of angle from MEMSIC2125 with CCS?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mmc01



Joined: 16 Jun 2010
Posts: 31

View user's profile Send private message

How to calculate degree of angle from MEMSIC2125 with CCS?
PostPosted: Tue Jun 19, 2012 10:29 am     Reply with quote

I measurement pulse width with CCS Example code EX_CCPMP.C.
http://www.parallax.com/dl/docs/prod/acc/memsickit.pdf

The result of sensor like this.

4757 us
5906 us
6187 us
6142 us
5995 us
6251 us
6227 us
6227 us
6060 us
5887 us
5551 us
5026 us
4733 us
4166 us
3796 us
3750 us
3746 us
3763 us

I don't know how to calculate degree of angle with these values.
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jun 19, 2012 1:42 pm     Reply with quote

The answer lies in reading the dotPDF documentation that you show a link to. Within those 10 pages is the answer, though you'll have to convert the BASIC code to C( not THAT hard to do).

If you want to send me 3 of those modules, I'll be more than happy to spend an hour and cut the code....

If YOU do the work, YOU gain the knowledge of what to do and why.In the end, YOU will be a better programmer.
mmc01



Joined: 16 Jun 2010
Posts: 31

View user's profile Send private message

PostPosted: Tue Jun 19, 2012 11:48 pm     Reply with quote

I don't understand about formula. Basic Stamp have to use */ 204 for convert read pulse output to uSecs . I think in PIC the uSec I'm not want to convert. but when I use the formula like in datasheet it's not be correct result.

xRaw = xRaw */ Scale
xGForce = ((xRaw / 10) - 500) * 8

if I calculate like this

xGForce = ((4757 / 10) - 500) * 8

but the result xGForce is -194.4 .I think the result is not correct because it is - degree and 194.4 is more than degree
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 20, 2012 1:55 pm     Reply with quote

What is your PIC ? What is the oscillator frequency for your PIC ?

This thread has a PULSIN function for CCS. It's similar to PULSIN for the
BasicStamp. You should try it:
http://www.ccsinfo.com/forum/viewtopic.php?t=42353

Then post the usec numbers that you get.
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jun 20, 2012 3:23 pm     Reply with quote

You also have to figure out how to recode the */ operator that is unique to Stamp BASIC( as far as I know). Called 'multiply middle', it's used in the calcuations. I've never heard of it let alone used it and I have a drawer full of 'stamps'.

As well the /10 on the next line I believe refers to the 10 milliseconds of the total pulse width of the reading (the sum of T1 and T2).

You would be wise to grab a pencil and paper and do the math to see what Parallax is doing 'with the numbers'. Once you figure that out, then convert ito CCS C code.

Yes, it may be a bit of a challenge, but once you figure it out, you'll probably say 'well that was easy'.....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group