Post Go back to editing

AD5590 with 3.3V MCU

Category: Hardware
Product Number: AD5590

I have written a driver for the AD5590 and tested it with the Arduino Uno. My code works correctly on the Uno which is a 5V system. I am now trying to make the code work with a 3.3V ESP32. With the ESP32, the ADCs return values that are double what they should be.

I am doing my development with the eval board. The eval board is configured in almost the same way for the UNO and ESP32. Here are the differences:

For the ESP32, EXT VDRIVE is connected to 3.3V via J6 and jumper LK37 is in position B so that EXT VDRIVE is connected to VDRIVE. AVDD is connected to 5V via J5 (and jumper LK35 is in position A).

For the UNO, AVDD is connected to 5V via J5. EXT VDRIVE is not connected because LK37 is in position A, thus connecting VDRIVE to AVDD.

 

I have verified that there is a reference for the ADCs: V_REFA is connected to V_REF1/V_REFOUT1 by placing jumper LK16 in position C. I verified that the voltage there is 2.5V. This reference is the internal DAC reference.

With both the UNO and ESP32, the DACs work and with the UNO the ADCs work. However, with the ESP32 the ADCs report a voltage that is double what it should be. For example, 2.5V is incorrectly reported as a value of 4095 instead of 2048.

I have set the ADCs to return straight binary values and configured the range to be 0  to 2*VrefA. For example, I read ADC 0 by sending the following value to the ADC: 0x8310

Any ideas what the problem is?

Thanks

Top Replies

Parents
  • Hi  

    Can you probe the digital lines using a logic analyzer and post some screenshots? Have you checked the DAC outputs using a multimeter? Are you using the same code in both Arduino and ESP32 cases in the Arduino IDE?

    Regards

    Suraj

  • After examining this with a logic analyzer, I found that the AD5590 was producing the correct output value but the ESP32 was receiving the value left-shifted by one bit.

    I changed the SPI mode to MODE0 and this fixed the problem. Is this the correct mode?

    In case there is something else going on, I have included a screenshot from the logic analyzer for a case in which the code is reading ADC channel 0. (I perform this operation twice in a row and this is the second time.) The logic analyzer shows the expected result for the 2.5V analog signal connected to ADC 0.

    Thanks.

  • Hi  
    MODE2 is the correct mode for the ADC, while both MODE1 and MODE2 can work with the DAC. In the timing diagram attached here, you can see both the MOSI and MISO are sampled on the rising edge of SCLK, which can lead to issues. 

    I would advise also trying to gather screenshots for different values of DAC output, such as just above quarter scale, just above midscale, just above three quarters scale etc. after using the correct SPI Mode.


    And incase you didn't know already, the settings for the control register apply for the next conversion, hence the need to do the operation twice.

    Regards
    Suraj

  • Hi Suraj,

    I have found a few posts on other forums describing a problem in which the esp32 produces an SPI read result that is shifted one bit to the left. I change my code to use MODE2 as your recommended. I also modified my code to right-shift the return values from the ADCs by one bit. This did produce the correct results. I tested this by running a loop that incremented the DAC values from 1 to 4095 in steps of 1. I then measured the DAC outputs with the ADCs. Right-shifting the results by 1 bit did produce the correct measurements.

    To test that this problem is specific to the ESP32 Arduino libraries, I ran the code on a PI Pico without bit-shifting the results. The same code (without the bit-shift) worked properly on the Pico. The code (without the bit-shift) also worked properly on an Arduino Uno. My conclusion is that this is a bug with the ESP32.


    Thanks for all the help.

  • Hi  

    Glad to know you have found the root cause. Could you please post the exact model of the controller board you are using? Also have you looked at any other method apart from the Arduino IDE to program it?

    Regards

    Suraj

  • Hi Suraj,

    I haven't tried a tool chain other than the Arduino IDE. I will get to that eventually. The board that did NOT work was the Adafruit  HUZZAH32 (product ID 3405).

    The code worked fine on an Adafruit Feather RP2040 (product ID 4884), a Pi Pico, and an Arduino Uno. 

  • Hi  

    Thanks for letting us know. If you need help with anything else, please raise a new ticket.

    Regards

    Suraj

Reply Children
No Data