40X2 and ReadADC

SD70M

Senior Member
Ok, got a problem somewhere.

I had ADC working on one 20M2 in simulator and the code for a second 20M2 worked too.

Due to merging the second 20M2's code with the first one, so I only have one picaxe instead of 2, I required more pins, so I tried to go over to a 40X2.

I read manual 2, page 29, adcsetup. It states:
Function:
On X2 parts it is necessary to configure the ADC pins for use with the ‘readadc/
readadc10’ commands. On all other parts this configuration is automatic.
Ok I say, so I read page 30, which corresponds to the 40X2.
It states:
Note that with these parts the appropriate bit is always automatically set upon
any readadc / readadc10 / touch / touch16 command.
Now, I've used the mask anyway to test this out
adcsetup = %0000000001100110
for pins A.1, A.2, A.5, and A.6

It still doesn't work in PICAXE VSM but it works in the PE simulator.

Any ideas?

I tried both the PICAXE 40X2 and the PICAXE 40X2-IC parts and neither works.

Angie
 

Technical

Technical Support
Staff member
The manual is a little dated with regards to adcsetup on the X2s, this is more up to date:
http://www.picaxe.com/BASIC-Commands/Advanced-PICAXE-Configuration/adcsetup/
Here we have clarified the difference between 28X2 and older 28X2-5V more.

For VSM simulations the adcsetup bit does not actually matter, the bit is not relevant to the simulation engine.
However that does not explain why your 40X2 readadc does not simulate correctly, we'll have to look into that.
 

SD70M

Senior Member
I've included the test circuits for 40X2 and 20M2 (two sheet design) together with code for each.

I tried the ADC-IN on various pins and when I tried it on D.4 (ADC24) it didn't just fail to read, it threw an error.

Hope this is of some help.

Angie
 

Attachments

Technical

Technical Support
Staff member
We have tried this with the latest 4.0.4 patch and can't find any issues, apart from the fact you are incorrectly using pin numbers (not ADC channels) on the 40X2 symbol definitions. Modifying to

Code:
    symbol B8Adc = 1 'A.1
    symbol B35Adc = 2 ' A.2
    symbol B36Adc = 24 ' D.4
    symbol PB6Adc = 9 'B.3
seems to work ok for us here.
 

SD70M

Senior Member
Changed the pins to ADC channels and it worked straight away.

Didn't see (read) about addressing by ADC channels on the 40X2. The 20M2 worked fine using pin references so wrongly assumed.

Thanks for the time taken. My mistake.

Angie
 
Top