PDA

View Full Version : adc_input_driver differential mode question



max72
10-14-2011, 02:38 PM
I'm playing with the object
http://obex.parallax.com/objects/488/

I'm using the 4 channel ADC and it works in single mode with no problems, but I'm not able to correctly set up the differential mode.
In the code I cannot find a relevant comment.

Any suggestion is appreciated.

Thanks in advance,
Massimo

Bobb Fwed
10-17-2011, 07:14 PM
I'm the author of that object. You say, "In the code I cannot find a relevant comment." The comment you may be looking for is this (at the top of the start methods -- these are referring to the applicable parameter) "SingDiff: ADC single or differential mode (1 = single, 0 = differential)".

Have you already tried that, or are you talking about something else?

I haven't tried differential mode in a while, I can't imagine why it would be broken, but I'll be able to try it in an hour or so when I get back from lunch.

max72
10-17-2011, 09:55 PM
Sorry for my post, I didn't mean to be impolite.
I found the switch option, but I had problems getting and understanding data.
I cross checked with another object and re-read the datasheet and I found differential mode uses either channel to indicate the sign.
Moreover I have a funny effect with readings jumping and not evenly scaled in single mode, that is not present with the other object, so I'm probably missing something.
So at the moment I have the setup working with the slower object, but doing funny reading with yours. I had not time to test the protocol, but I'll do it as soon as I'll have time.
In this case the sheer power of the ADC driver is not necessary, but for sure it will prove useful in other projects.
Massimo

Bobb Fwed
10-17-2011, 10:15 PM
No, it didn't come off as impolite, I was just trying to understand at what point you were in deciphering the problem.

Are you running the object with FastMode enabled or not? If it is enabled, disable it, and it will likely fix the problem. The fast mode gathers data from the ADC faster than the datasheet specifies (though I've found most ADCs I have tested can outpace the datasheet specifications by a significant margin). If the ADC is powered at 5V (instead of, say, 3.3V), it increases the leniency of the speed. Non-fast mode is still quite fast, but maintains speeds below the max specifications, much closer to the ADC's specifications at 3V.

I couldn't find my MCP3204 (I'm guessing this is the 4-channel ADC you are trying to use), but I'm about to test my MCP3208, which has the same protocol as the 4-channel variant. So I'll let you know if there's any problems with the information in single or differential mode and/or fast or slow mode.

I also have a slightly improved version of the ADC driver object that I will likely be releasing soon anyway. Maybe you can try it out and see if it fixes your problem.

Bobb Fwed
10-18-2011, 12:06 AM
I just uploaded version 2.1.3. With this version, I tried single and differential modes in both fast and slow comm speed. In fast mode, there was problems with getting the expected linear values, that's just because (as i said before) the speed is faster than the IC can handle, so bits get skipped or duplicated.
But in slow mode, both single and differential worked great.

max72
10-18-2011, 09:06 AM
Thanks.
I'm using MCP3204 with 5V supply, and slow mode.
Nonetheless I had a linearity problem. I'm using and add on board with a resistor on the data pin. So bit skip could still be related to my setup.
JonnyMac's driver works, and it is spin only, so bit skip could be related to my setup.
I'll test it with my logic analyzer to see if this is the problem.
Massimo

max72
10-18-2011, 10:46 AM
A little update.
I tested with the logic analyzer both objects.
I'll report the clock timing:
Your object with slow option: high 41ns, low 0.25us
Spin only: high 7.4us, low 26us.
So it appears the linearity problem is related to my setup, causing bit skipping.
Thanks again,
Massimo