Multiplexing Digital pins as ADC's. SAMD21

For the discussion of Arduino related topics.

Moderator: phalanx

Post Reply
boggydew
Posts: 4
Joined: Mon Jan 28, 2019 12:17 am

Multiplexing Digital pins as ADC's. SAMD21

Post by boggydew » Thu Feb 07, 2019 5:45 pm

Hi, I have a SAMD21 Dev board and am trying to add ADC functionality to some of the digital pins. One of the best features of the SAMD21 is that the pins can be multiplexed, but Arduino have not made any effort to explain how to do it in their environment. I am surprised by the lack of support that Arduino give to their Zero considering it is the flagship of their portfolio. They seem to have just put it out there and expect the broader community to develop support for it. I digress.

I followed the instructions posted here https://forum.arduino.cc/index.php?topi ... msg4049447 on the Arduino forum with some limited success. I managed to get D8 and D9 working as A6 and A7 respectively, but A6 has issues. I use two 68K resistors to make a voltage divider between VCC and ground; 3.3V/2 = 1.65V. If I analogRead() this voltage on pins A1 to A5 I get a stable return between 510 and 514; working as expected. I get the same stable result for A7, but A6 gives a reading that fluctuates between 470 and 500, so there is definitely something wrong there. Using the same code mods in variants.cpp to try and make D3 or D4 into A8 did not work. I managed to get D3 working as A8 if I changed its pin definition entirely, from PIO_TIMER to PIO_ANALOG, but it is terrible, returning values between 450 and 520.

Has anyone got experience at multiplexing these pins?

THX.

boggydew
Posts: 4
Joined: Mon Jan 28, 2019 12:17 am

Re: Multiplexing Digital pins as ADC's. SAMD21

Post by boggydew » Thu Feb 07, 2019 8:35 pm

Problem solved: see thread at arduino forum: Topic: Arduino Zero additional analog inputs? Thx

Post Reply