Picaxe Shield base 28X2 - Vref reads 1.8V - adcsetup - stacking

domwild

Member
Hi,

AXE401 shield, 12V supply, is 1.8V a correct reading for VREF? In my confused mind I always thought 5V is the reference voltage as the voltage regulator in my 12V system would supply that.

Looks like the 28X2 needs the adcsetup command to make all the pins usable for analogue input. I want to use readadc10 for voltage and my resistor network would have reduced the range to 5VDC max. Do I need to set the first 10 or least-significant 10 bits via ADCSETUP and how do I achieve that??

What else do I need to do to finally be able to read the voltage with 10 bit accuracy via readadc10?? A code snippet with Vref? and adcsetup would be appreciated or a link to code.

As a single AXE405 shield does not seem to hold a lot of real estate I may have to stack another one on top. Stacking pins are available but does one use the three mounting holes with nylon cylinders then as offsets?

A fourth mounting hole is supplied in the LH top corner, not much space is left between the header and the shunt for a 3 mm bolt, any suggestions for the fourth offset to keep the bottom of the AXE401 off the ground?

Thanks.
 

srnet

Senior Member
The Vref on the shield base is connected to PICAXE pin A.3, which as the adcconfig command identifies is the pin used for the connection of an external Vref. On the AXE401 circuit diagram there is nothing shown connected, so any voltage reading on the pin is spurious.

The readadc10 command does as it suggests and produce a 10bit result using for the Vref the PICAXE supply as the default (could be 5V or 3V3)

The adcconfig command is used to setup the Vref to be your choice, the external Vref pin (A.3), the PICAXE supply voltage or the internal fixed voltage referance.
 

SAborn

Senior Member
Dom, in your case you can simply use the internal Vref of the chip and dont need to use an external Vref pin, yes you will need to use adcsetup to tell the chip which pins you will be using for the ADC inputs.

You only set the ADC pins you will be using in adcsetup and not all pins to ADC.

Once the pins are set via adcsetup you can use either "Readadc" or "Readadc10" in program they will both function normal, but you must use the adcsetup prior to reading a ADC pin, the adcsetup only needs to be used once and best to use it at the top of your program before "Main"
 

domwild

Member
Thanks for both replies. I see, Vref can be used to supply an external reference voltage. Another question: As I use a 12V supply and my H1 jumper is set to 5V I take it the reference voltage of the system is the internal 5V regulated supply?? Like in the old XP days with my 28X: I take it then that 5V is the equivalent to 1023 for a ten-bit readadc10 command?

Using adcsetup do I set up the bits bit0 to bit9 as the ones I will use as the 10-bit recipients?
 

domwild

Member
To switch all ten bits from digital to analogue for my 28X2:

adcsetup = %0000001111111111

Setting all low-order 10 bits on allows all 10 bits to be used for the readadc10 command - is this correct?
 

BeanieBots

Moderator
To switch all ten bits from digital to analogue for my 28X2:

adcsetup = %0000001111111111

Setting all low-order 10 bits on allows all 10 bits to be used for the readadc10 command - is this correct?
No. To get all 10-bits you simply need to use the command ReadADC10 (remember to use a WORD variable to hold the 10-bits)
To get only 8-bits, use the command ReadADC

adcsetup has nothing to do with the bits of the ADC. It is used to configure inputs for analogue use.
My understanding (somebody please correct if I'm wrong) is that on the latest firmware, you don't NEED adcsetup anymore. Just using a ReadADC command will automatically do all that is required.
 

Technical

Technical Support
Staff member
BB is correct, forget about adcsetup completely and simply use readadc10/readadc.
The Vref will automatically be the PICAXE supply e.g. 5V.
 

domwild

Member
Thanks Technical and BB. I suspect my adcsetup command is wrong anyway as it does not contain the pin number. No need to use it then, great.
 

SAborn

Senior Member
Dom,

Email me your code and i will help you, you have my email address, and i can work through it with you.

If you prefere to seek forum help than im fine with that.

Pete.
 
Top