BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Wed Jan 24, 2018 2:32 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: MBasic 05.3.1.6 ADIN question
PostPosted: Fri Aug 13, 2010 12:23 am 
Offline
Citizen

Joined: Wed Aug 20, 2008 5:57 pm
Posts: 27
I've used the ADIN command many times over the years with the older version of MBasic.
Now I can't seem to get it to compile tried and true code.
Here is the code:
; ad test

volts var word

Main

Adin a0,2,%10000000,volts

goto main

When I compile, I get [token 2]: expected variable

Nathan, did ADIN get goofed up in the new version??
I've tried to compile this for both the 877a and the 887.

Help!

Pete


Top
 Profile  
 
 Post subject: Re: MBasic 05.3.1.6 ADIN question
PostPosted: Fri Aug 13, 2010 4:16 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
5.3.1.6 uses the new simplified ADIN command. Syntax is adin pin,variable

No clock settings and no ad_setup setting.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: MBasic 05.3.1.6 ADIN question
PostPosted: Fri Aug 13, 2010 9:20 pm 
Offline
Citizen

Joined: Wed Aug 20, 2008 5:57 pm
Posts: 27
Thank you, Nathan. Is there a list of commands that changed or were added? I wasted an hour or so trying to get ADIN to work.
Your loyal MBasic user,
Pete


Top
 Profile  
 
 Post subject: Re: MBasic 05.3.1.6 ADIN question
PostPosted: Sat Aug 14, 2010 1:47 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
The MBasic 5.3.1.6 is considered beta so there isn't any documentation on the changes specific to MBasic. Many of the changes are what you see in the Atom and AtomPro manual(the current one, not so much the new beta manual). If you run into anything and want help the quickest solution is to post it. I'm in here a couple times every day most days.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: MBasic 05.3.1.6 ADIN question
PostPosted: Sun Aug 15, 2010 10:37 pm 
Offline
Citizen

Joined: Wed Aug 20, 2008 5:57 pm
Posts: 27
Hi Nathan
Ok I got the new ADIN to work on RA0 (pin 2 on the 16F887): adin A0,volts

I expected that ADIN A1,volts would read RA1. It reads RA2 instead (pin 4)

ADIN A2 reads RA5 (pin7)

ADIN A3 reads RE1 (pin 9)

Is there some kind of mapping that I don't know?
I really want to use RE0 and RE1 as my two analog inputs. How do I do this?

Thanks
Pete


Top
 Profile  
 
 Post subject: Re: MBasic 05.3.1.6 ADIN question
PostPosted: Mon Aug 16, 2010 3:33 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
It should just be AX0 = AN0,AX1 = AN1, AX2 = AN3. AX3 = AN4. But it's been a while since I've used ADIN with MBasic.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: MBasic 05.3.1.6 ADIN question
PostPosted: Mon Aug 16, 2010 5:46 pm 
Offline
Citizen

Joined: Wed Aug 20, 2008 5:57 pm
Posts: 27
Hi Nathan
ADIN AX0,volts reads AN0
ADIN AX1,volts reads AN0 (not AN1)
ADIN AX2,volts reads AN0 (not AN2)
ADIN AX3,volts reads AN0 (not AN3)
ADIN AX4,volts has an unexpected token type error at compile
Same error for all numbers above 3

Any thoughts?
Pete


Top
 Profile  
 
 Post subject: Re: MBasic 05.3.1.6 ADIN question
PostPosted: Mon Aug 16, 2010 8:32 pm 
Offline
Master

Joined: Mon Aug 18, 2008 1:26 am
Posts: 799
Location: CA bay Area
He's right. Using the "AX" numbers produces four identical value reports.
Still investigating.
kenjj

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: MBasic 05.3.1.6 ADIN question
PostPosted: Mon Aug 16, 2010 9:38 pm 
Offline
Master

Joined: Mon Aug 18, 2008 1:26 am
Posts: 799
Location: CA bay Area
Give up now. I started out to map the ADC inputs and got totally unexpected results. The code looks like:
Code:
; Mapping ADC inputs because of forum question from Pete Rowe (Wizard1)
ADCVal var word
ADCNum var byte
CLEAR

PAUSE 500
TRISA = $FF
TRISB = $FF
TRISC = $FF
TRISD = $FF
TRISE = $FF

MAIN

ADIN A4, ADCVal
GOSUB ReportADC
ADCNum = ADCNum + 1  ;1
ADIN E1, ADCVal
GOSUB ReportADC
ADCNum = ADCNum + 1   ;2
ADIN A0, ADCVal
GOSUB ReportADC
ADCNum = ADCNum + 1   ;3
ADIN A1, ADCVal
GOSUB ReportADC

ADCNum = 0
ADCVal = 111
GOTO MAIN


ReportADC
SEROUT C7, i9600, ["#",dec ADCNum, ": ", dec ADCVal, 13]
PAUSE 200
RETURN

i started with A0, A1, A2 and A3. The printout reports the #, followed by the resulting ADC reading. You just match up the # (0-3) with the specified pin number to do the map. The early results showed some pins, like A0 and B0, reported to the other three pins! I don't have a connection from the headers to pins A6 and A7, so can't say where they go.
The results were strange:
Code:
Used        Was
A0      -     A0
A1      -     A2
A2      -     A5
A3      -     E1
A4      -     A1
A5      -     A1
A6      -     NC
A7      -     NC
B0      -     E1
B1      -     E0

Somewhere in the pin definitions for this chip, the ADC pins got totally messed with.
Feel free to finish the map.
At least you know how to specify E0 and E1 for ADC: use B1 and B0! I think. E1 also appears on A3. I haven't checked the data sheet for the 16F887, these may have no connection to the real world?!
Later.

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: MBasic 05.3.1.6 ADIN question
PostPosted: Mon Aug 16, 2010 9:57 pm 
Offline
Master

Joined: Mon Aug 18, 2008 1:26 am
Posts: 799
Location: CA bay Area
PS, the BASICAtom28 and -40 are 16F886 and -887 chips and operate at 20 MHz. Studio is available for free to program these from, but of course you have to pay for each IC to program. Discounts are available for quantity purchases. If you went to the -887 to get cheaper parts, you lose here.
Documentation is available in Studio, but is specifically written for the Pro modules. The new forum manual is all inclusive, but incomplete. At least MOST of the syntax is the same between chips, but not entirely, and internal timings and variable sizes have changed in many places. That is, there is a learning curve.

You might want to consider going to another compiler/IDE. Some are free. Most of the established ones are >>$100. I know. I have three or four sitting on my PC. They are all limited in some way. They are all a pain to work with, for various reasons, compared to MB Pro.
I just purchased the Proton Development System (PDS) for $165. It has a lot of fire power, a long list of devices and features. My principal reason for buying it is that it supports the 18F25K22, which I call "super chip". Get the data sheet, it will knock your socks off.
PDS is damn near 180 degrees out from MBASIC. PDS is like shark fishing in shallow water with a boat hook. Yes, the final catch is amazing to behold, and there's lots to feed on, but getting there is a long, hard and brutal @#$! effort.
Take care.

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: MBasic 05.3.1.6 ADIN question
PostPosted: Mon Aug 23, 2010 9:00 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
Any analog pins that are floating near by another driven analog pin will tend to have a value close to that one driven analog pin. I beleive there is some coupling inside the PICmicro processor. As long as all the analog pins you are using have driven analog signals on them there shouldn't be a problem.

When testing which pin is analog make sure all the other analog pins are grounded. Otherwise you may see the analog signal on any of them as well. This is just inductive coupling(external or internal to the processor I don't know).

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: MBasic 05.3.1.6 ADIN question
PostPosted: Mon Aug 23, 2010 11:25 pm 
Offline
Master

Joined: Mon Aug 18, 2008 1:26 am
Posts: 799
Location: CA bay Area
Yes, internal coupling is a BIG factor. To eliminate this situation I eventually did the tests on a development board because it allowed me to pullup (5V) every pin. So no matter what real ADC pin I read, it read close to 1023, the ADC's highest reportable value. I then went and grounded the pin of interest, in which case it went to 0. After discovering several pins reported bogus values (as Nathan says above), I used FOR-NEXT loops to read JUST the supported pins, which led to faster reports and good values.
Later.

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


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