ADin questions

Someone sent me two private messages about an ADin question but I accidently clicked “Delete all” instead of “Delete Marked”. If you could resend those questions I’d appriciate it.

Hello Acidtech,
Thanks for your kind support.
I think It was me about having issues with the A/D channels

Ive got connected two analog sensors to AX0 and AX1, both sensor work ok.
I get correct readings on AX0 but i get strange stuff on AX1, tried to PAUSE between the two readings but it is still the same.
Any hint of what could be happening?

What module are you using? Are you using one of our dev boards(BasicMicro) or a Lynxmotion board or one of your own? How is everything wired? A sample program that shows the problem would also be helpful. Have you tried using a different A/D pin instead of AX1?

This sounds like a lot like a problem I had awhile back and it turned out to be the way the IDE was handling the analog pins. I was using the Basic Atom at the time.

8-Dale

Hey guys,
Sorry for the late reply, i had to travel out of town, ive just returned so im again after this.

My board is a Lynxmotion Atom Pro 28, I tried P0 to P3, AX0 to AX3 no matter the combination i only get one good reading.

This is my code.

xflt var long(3)
xaccel var slong
yaccel var slong
plch1 var slong
plch2 var slong
yflt var long(3)

ENABLEHSERVO

control_loop
adin 18, xflt(3)
xaccel = (xflt(0)+(2*xflt(1))+(2*xflt(2))+xflt(3))/6

adin 19, yflt(3)
yaccel = (yflt(0)+(2*yflt(1))+(2*yflt(2))+yflt(3))/6

serout S_OUT,i9600,"x ", dec xaccel, " y ", dec yaccel, 13]

plch1 = (xaccel-340)*100 ; hservo
plch2 = (yaccel-340)*100 ; hservo

HSERVO [P10\plch1, P11\plch2]

xflt(0)=xflt(1)
xflt(1)=xflt(2)
xflt(2)=xflt(3)

yflt(0)=yflt(1)
yflt(1)=yflt(2)
yflt(2)=yflt(3)

goto control_loop

If you were using the Atom and not the Pro, I would guess that maybe it was the Adin bug that Linuxguy had in the thread:
lynxmotion.net/viewtopic.php?t=1356&start=15

But it is the Pro. Which IDE are you using? If it is 8.0.1.0, you might experiment and try disabling the HSERVO commands including the ENABLE and see if both analog inputs work properly. It is a long shot, but I had HSERVO cause problems with serial commands and other IO pins. Some of these are fixed in the 8.0.1.2 beta, but I know he is still looking into a few other issues with the beta.

Hey Kurte,
Im using 8.0.1.2
I also tried disabling HSERVO command and ENABLEHSERVO but no luck.
Ive been studying the renesas manual, it says there are two A/D reading modes; one is reading each A/D channel individually and a second mode in which you get four A/D readings at a time.
I set up the registers to activate the second mode but im a little stucked in getting the readings out of the ADDRA-D registers.
Not sure if its going to work tough. I wish i could read them from the ADIN command.
Maybe the Atom (not pro) bug fix could work on the PRO version, Acidtech any idea?

Sorry I haven’t had time to check this bug yet. I have however used the scan option for A/D conversion. (From memory) here is how to do it.

;Setup ADCSR to scan on channels AN0 to AN3
ADCSR=0x13
;start A/D scanning
ADCSR=0x33
;wait for a little while or do something else
;do something with ADDR values
if((ADDRA>>6)>512)then
;do something
endif

Note I shifted the A/D value to the right 6 times because the 10bits of A/D info is stored in the high 10bits. You can just use the 16bits of data as is becaus ethe low 6 bits are always 0 but I can “see” the values better when they are 0 to 1023 instead of 64 to 65535 in increments of 64.

Also I’m pretty sure the ADin problem you are having is only in the BETA version. I used 8.0.1.0 with ADin for a while. I’m using 8.0.1.2 for my projects now but I use the above scanning method which is probably why I didn’t catch it myself.

P.S. can someone email me to remind me to look at the ADin command when I’m at work on monday? [email protected]

I sent you one now. But could send another monday…

Kurt

Acidtech,
Thank you for the code! im going to test it tomorrow, i need to read four analog sensors so it will maybe work better (for processors hoverhead) than individual ADIN commands. Getting shifted the A/D values was where i was stuck at.

I will also help Kurte in emailing you tomorrow.

Will post the results.

Acidtech,
I am testing the code you posted above, it works ok in activating the scan capture on AN0 to AN3 but it still return weird readings, for example:
AN0 (ADDRA) returns the exact a/d value
AN1 (ADDRB) returns repeated a/d values (some king of lag)
AN2 (ADDRC) copies AN1 values
AN3 (ADDRD) returns the exact a/d value

tried different things but still happens… :imp: :imp: :imp: :imp: :imp:

ADin is fixed in the new beta.

Here is the link:

www.basicmicro.com/downloads/software/B … p_8013.exe

Your problem with ADDR registers has to be external. The ADDR regs are loaded by the hardware once scanning is enabled. If your signals have too high a capcitance though you can cause the A/D hardware to malfunction. Read the hardware manuals A/D section for more info.

Acidtech,
Downloading 8013, will check the manual and take care of the cap issues.

What would be the ADCSR value to scan on channels AX0 to AX1 instead of AN0 to AN3?

Thank You!