Go to Post People will only work toward common goals when they are part of the goal-setting process. - GaryVoshol [more]
Home
Go Back   Chief Delphi > Technical > Electrical
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-02-2007, 23:19
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Encoder help

Quote:
Originally Posted by JHale View Post
When we print off the value from Get_Encoder_1_Count(); all that is returned is either 256 or 260 without any change when the encoder is rotated.
How are you printing it? Note that the function returns a long integer. If you're trying to print it with a %d format, you'll only get the topmost two bytes.
  #2   Spotlight this post!  
Unread 16-02-2007, 11:02
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Encoder help

Quote:
Originally Posted by Alan Anderson View Post
How are you printing it? Note that the function returns a long integer. If you're trying to print it with a %d format, you'll only get the topmost two bytes.
That's what I was thinking too--printf() is very particular about the data type coming in.

To print out the encoder count, you could typecast it to an int for printf:
Code:
printf("Encoder 1 is %d\r\n", (int)Get_Encoder_1_Count());
would do it, I think.

I can't seem to find the documentation for the printf function, so I can't give you the %whatever value you need to make a long int print...I'm not even sure if it's possible directly. Just typecast it as I showed, and it should give you a good value out.

JBot
__________________
Aren't signatures a bit outdated?
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Encoder help Windward Programming 21 14-01-2006 15:10
Encoder code with hall effect sensors help brownster Programming 10 19-02-2005 09:23
Need Help with Encoder - Won't Count Clicks Kingofl337 Programming 5 16-02-2005 18:30
encoder.c Gary Bonner Programming 2 14-01-2005 13:41
shaft encoder help stephenthe1 Programming 2 03-12-2004 16:09


All times are GMT -5. The time now is 11:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi