ADC5 input, 40X2

edmunds

Senior Member
Dear all,

Has anyone experienced strange behavior of ADC input 5 (A.5, pin 8) on 40X2? I have strange readings with a regular readadc command and they turn alright if I switch to input 13 (B.5, pin 38) for an example. I tried to use adcsetup command, but that did not change anything either.

Thank you for your input,

Edmunds
 

hippy

Technical Support
Staff member
I don't recall anything mentioning problems with ADC on A.5. What sort of strange readings are you getting ?
 

lbenson

Senior Member
Not sure that it applies to your situation, because it wasn't specific to A.5, but I seem to recall that if you are using a variable to specify the adc port, you may not get what you expect.

For instance, "READADC 5,b0" and "READADC A.5,b0", will give you the same thing, but these would not:

b1=B.2 : READADC b1,b0 : SERTXD(#b0," ") : READADC B.2,b0 : SERTXD(#b0," ")

This is because the ADC channel number is not the same as the value of B.2, but if you use the form "READADC B.2,b0" then the interpreter knows what you mean and inserts the right channel number; but if you've used a variable, it can't know that you meant something other than what you specified.

A.5 is ADC channel ADC5, but SERTXD(#A.5) yields 21.

But as I say, this may not be related to your issue (and maybe I'm misremembering the whole thing--it was years back).
 

edmunds

Senior Member
It is really hard to describe sensibly :).

Too small for low voltages, then too high, and then too small again. It is with the code from the other thread. If I use ADC0-3 inputs, everything is fine. Sadly, the board I want to test this with, has lost A.2 trace, so I thought to move to some other pin right from the beginning, so I don't have to adjust the code later on. On the prototype board, I can use A.5 (5) that does not work or B.4 (11) that does work. According to what I can see, all port A pins up from A.3 behave wrongly. Port C seems fine again (say, ADC4 on C.3).

I cannot find a software problem, so I'm starting to blame hardware :).

Edmunds
 

edmunds

Senior Member
Not sure that it applies to your situation, because it wasn't specific to A.5, but I seem to recall that if you are using a variable to specify the adc port, you may not get what you expect.

For instance, "READADC 5,b0" and "READADC A.5,b0", will give you the same thing, but these would not:

b1=B.2 : READADC b1,b0 : SERTXD(#b0," ") : READADC B.2,b0 : SERTXD(#b0," ")

This is because the ADC channel number is not the same as the value of B.2, but if you use the form "READADC B.2,b0" then the interpreter knows what you mean and inserts the right channel number; but if you've used a variable, it can't know that you meant something other than what you specified.

A.5 is ADC channel ADC5, but SERTXD(#A.5) yields 21.

But as I say, this may not be related to your issue (and maybe I'm misremembering the whole thing--it was years back).
Thank you for your input.

I'm using the ADC channel numbers just to avoid this confusion. Maybe I should check the big datasheet if there is a mistake with channel numbering and I'm just trying to read my signal on a different pin...

Edmunds
 

edmunds

Senior Member
Put this in a loop for testing:

Code:
  Symbol LL_ADC = b4          'Leftmost hall sensor reading
  Symbol L_ADC = b5           'Left hall sensor reading  
  Symbol R_ADC = b6           'Right hall sensor reading
  Symbol RR_ADC = b7          'Rightmost hall sensor reading

  readadc 0, LL_ADC         'A.0
  readadc 1, L_ADC          'A.1
  readadc 2, R_ADC          'A.3 could be 2 and A.2, but not broken pin on prototype board
  readadc 5, RR_ADC         'A.5
  readadc 13, b8
  sertxd (#LL_ADC,"  ",#L_ADC,"  ",#R_ADC,"  ",#RR_ADC,"  Test value: ",#b8,CR,LF)
Maybe I should try to feed something from DAC into the channel and compare those...

Edmunds
 

edmunds

Senior Member
I tried the DAC test and input5 functions is (almost) identical to input13. No idea at this point. Must be me doing something wrong.

Edmunds
 

edmunds

Senior Member
Sorted. AXE091 has this strange thing to accommodate 28-pin device in between 40-pin device. I have never used it and thought you could use the inside row of pin headers as well. Apparently, some pins are routed the same and work, but some are not. Sorry for the trouble ;)

Thank you for your time,

Edmunds
 

hippy

Technical Support
Staff member
AXE091 has this strange thing to accommodate 28-pin device in between 40-pin device.
I was thinking it sounds like you're not reading the right ADC channel but reading another and seeing the residual voltage in the internal ADC cap, but I couldn't figure out how that would be if you were connecting to Leg 8, and 'that's not easy to get wrong'. But that explains it.

If you place a 28X2 pinout over a 40X2 pinout, you can see the right hand side is the same but the left differs which is why there are two rows of headers. Leg 8 is 0V on the 28X2, A.5 on the 40X2.
 
Top