BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 8:11 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Long limited to 65,535?
PostPosted: Tue May 24, 2011 9:30 pm 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
I don't take 20 samples anymore since I had to work around the problem.
But I still don't understand why I don't get a long and I can't go over 65K

Chris


Top
 Profile  
 
 Post subject: Re: Long limited to 65,535?
PostPosted: Tue May 24, 2011 10:25 pm 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 528
ChrisB wrote:
Here it is:
Results :
Tensmax=41985
Tensmax/20=8239
(tensmax/20-8192)=48
(tensmax/20-8192)*4583=18793

Again not sure where your numbers are coming from, for example:
41985/20 = 2099 not 8239

So would need to see where it goes from there.

Kurt


Top
 Profile  
 
 Post subject: Re: Long limited to 65,535?
PostPosted: Wed May 25, 2011 12:07 pm 
Offline
Master

Joined: Tue Jun 22, 2010 1:15 pm
Posts: 203
Yeah, I don't know. I'm just using int an float in my current project, no need for a long.

Alan KM6VV

ChrisB wrote:
I don't take 20 samples anymore since I had to work around the problem.
But I still don't understand why I don't get a long and I can't go over 65K

Chris

_________________
Visit:
http://groups.yahoo.com/group/SherlineCNC/
http://tech.groups.yahoo.com/group/HexapodRobotIK/


Top
 Profile  
 
 Post subject: Re: Long limited to 65,535?
PostPosted: Thu May 26, 2011 12:56 am 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
You are right Kurt, it is pretty strange !

Maybe somebody from the Atom team can answer us?
I work around the problem, everything works fine for me but maybe we have a bug here?

Thanks again for your help

Chris


Top
 Profile  
 
 Post subject: Re: Long limited to 65,535?
PostPosted: Sun May 29, 2011 12:24 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
I simiplified your program and had it oputput to the terminal

Code:
Baud            con     i9600
Tx              con     s_out

tens             var       long
tensMax         var     long
tenscur         var     long
n                var       word

test:
   gosub Mesurtension   
   SEROUT Tx, Baud, [dec tens," "]
   
   gosub Mesurcourant
   SEROUT Tx, Baud, [dec tenscur,13]
goto test

Mesurtension:
   tensmax=0
   FOR n=0 TO 19
      ;adin16 p0,tens
      tens = 65535
      tens = tens>>4   
      tensmax=tensmax+tens
   NEXT
   tens=tensmax/20*586/100
return

Mesurcourant:

   ;adin16 p3,tens
   tens = 65535
   tens = tens>>2

   tenscur=tens*1000
return


The output is:
23996 16383000

I replaced the adin16 with the maximum 16bit value which is: 65535

The math checks out exactly like it should. This would indicate the problem is in the adin16 command or inte analog values being sent to it.

I'm looking at the ADIN command now.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Long limited to 65,535?
PostPosted: Sun May 29, 2011 12:40 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
So I uncommented the adin16 commands from my modified version of your code. I then tied the p0 pin to 5v and ran the code and I get:

23979 16368000

That is exactly what I should get if I calculate it out manually.

64 * 1023 = 65472(this is the maximum value you will get from an adin16 command. 65472 >> 4 = 4092. 4092 * 20 / 20 = 4092. 4092 * 586 = 2397912. 2397912 / 100 = 23979

And

65472 >> 2 = 16368. 16368 * 1000 = 16368000

THis is not floating point so all calculations are truncated to integer values.

So the math is correct, the adin16 appears to be reading correctly, that only leaves your source signal. Source signals must be able to charge the internal AD hardwares cap quickly enough to get a good reading. Maybe this is the problem?

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO