PDA

View Full Version : ADC problem


hrishikesh
02-05-04, 11:10 PM
hi
i am doing motor control using ISOPOD.
As a feedback we are using another motor coupled with the first one which is driven through pin PWMA0.
The range of voltages it is giving as feedback is -6 to 6 volts.

Does IsoPod ADC pins support -ve voltages as well ?
what is the range supported ?

While printing the input from ADC it is not printing in decimal though the input voltage 0.48 volts.
I have checked the ADC program given on site, but still it didn't work when we scaled down the input to max=32760

Please give suggestions if you have worked on this.

Regards,

Hrishikesh

nmitech
02-06-04, 10:44 AM
ADC is programmable from one to eight sepearte channels when all inputs are configured as Single-Ended, or programmable from one to four, if all inputs are configured as Differential.

The Analog Input voltage range for both Single-Ended & Differential inputs are from 0V to 3.3V

where your indicated input voltage range are above and below the spec limits. You must scale it down with a simple voltage divider circuit, or use OP-AMP circuit to invert the negative signal to positive in order to provide the proper voltage level for the ADC inputs to avoid damaging the CPU. See chapter 9 of the motorola document link below for detail on ADC setup,
http://e-www.motorola.com/files/dsp/doc/user_guide/DSP56F801-7UM.pdf

The ADC test program link below should work for Single-Ended mode with the floating point results . Also makesure your analog input return signal needs to be connected to VSSA (pin 2) of J3 for common analog ground to get proper data.
http://www.newmicros.com/isopod/appnotes/Atod.txt

nmitech
02-06-04, 12:14 PM
I want to make a correction on my previous post, the ADC input voltage range should be only from 0V to +3.3V. Negative input voltage is not allowed. Sorry for the confusion.

hrishikesh
02-07-04, 12:40 AM
hello,

in addition to my earlier post,

we are giving PWM output to drive the motor, and we are taking the adc input via ADC1 pin from the output of the motor which is
coupled to the first motor. the input voltage is in the range 0 - 3.3 volts.

we are driving the first motor by giving HALFSPEEDCPU.
we observed that to print the adc input, we have to give
FULLSPEEDCPU. Is this so ? Can we do the other operations with HALFSPEEDCPU ? If yes, can you possibly give me a test code for that ?

the problem we are facing is if we give FULLSPEEDCPU before printing, then the motor runs with full speed not following the PWM wave sent.

my code is :


FVARIABLE TEMP

DECIMAL
3.30e FCONSTANT VREF
: GET-AD
CR
13 EMIT
ADC1 ANALOGIN S>F VREF FSWAP 32760.0e F/ F* TEMP F!

;

MACHINE TEST
ON-MACHINE TEST

APPEND-STATE X1

IN-STATE X1
CONDITION
CAUSES
HALFSPEEDCPU
25000 PWMA0 PWM-PERIOD
4740 PWMA0 PWM-OUT

FULLSPEEDCPU
GET-AD
DECIMAL TEMP F@ F.
THEN-STATE
X1
TO-HAPPEN

X1 SET-STATE
INSTALL TEST



we tried putting the FULLSPEEDCPU and the other commands in other state as well, but that didn't help.

Has anyone had similar problem ?
Can you give me some hint to work out on this ?


Regards,

Hrishikesh

RMDumse
02-07-04, 08:48 AM
HALFSPEEDCPU changed the rate the everything, including the CPU clocks. So when you say HALFSPEEDCPU, your baud rate will change as well. Perhaps this is why you can't "print" the A/D reading. Try to set for double rate serial on the same line as HALFSPEEDCPU and the printing might come out as you like.

Now as for saying HALFSPEEDCPU and a couple of instructions later FULLSPEEDCPU... that won't do. The return to full speed is almost immediate, so the motor commands will be run back up in speed, perhaps so fast a single cycle at lower speed is never even seen.

Generally, you use HALFSPEEDCPU at the beginning of the initialization of the program, and leave it that way.

hrishikesh
02-08-04, 12:25 AM
hello,

Thank you for the info.
It worked but gave some problem.

As you could see in the code i had given,
I have used the same code as given in Atod.txt
but still it is giving me 0.0000 reading instead of varying readings.

Is there some problem in that ?

Can you please send in your comments on this ?

thank you,

Hrishikesh

RMDumse
02-08-04, 11:02 AM
I have to think there is a problem in the scaling routine I'm not seeing. Perhaps it would help to first convince yourself that the A/D is or isn't working. To do this, let's just print out the value from the A/D and see if it is 0 or not. I bet it's not.

So do (even by hand without a state machine) a

ANA1 ANALOGIN .

and see what number you get.

If it is non zero, you can perhaps figure out what is going wrong in the conversion.

The idea of the conversion as I understand it is to take the 16-bit result from ANALOGIN and scale it to a voltage. So it is made into a float, then divided by 32767 (off a little in example) so it is proportion of 1 bit, then multiplied by 3.3 to scale to voltage.

Looks like we could simplify that conversion a bit

ADC1 ANALOGIN S>F VREF FSWAP 32760.0e F/ F* TEMP F!

We don't need VREF until the multiply, so we might redo this way:

ADC1 ANALOGIN S>F 32760.0e F/ VREF F* TEMP F!

Also the constant might be read wrong if it were in HEX. Hummm... We already discussed HEX and DECIMAL right? Maybe this would be a better way to write it.

ADC1 ANALOGIN S>F 32767.0e0 F/ VREF F* TEMP F!

Anyway, let's be sure the A/D is delivering a non zero value and we'll go from there.