General GravityArduino

Connecting Two Gravity DACs to an Arduino Zero problem

userHead Ferg.Colto 2024-08-05 09:46:41 164 Views2 Replies

Hello! 

I'm trying to connect two Gravity DAC 0-10V modules to an MKR Zero board. 

On the Gravity boards, i have one address set to 0x58 and one set to 0x5F - So the pins are 000 and 111 respectively.

 

The two boards kind of work, sometimes. In testing I found that each individual board would work well when tested on its own - the output voltages were stable and accurate. 

 

When i connect both boards, things go quite wrong. The code will upload, but then the Arduino will give Initialize Errors for the Gravity boards. 

If i plug out the Arduino USB, and back in it will work, but the voltages are now higher than i requested. Sometimes the Arduino USB wont connect - Windows says there is a USB not recognised error.

 

Is this a power supply issue, or does anyone know how to solve this?

 

thank you!

 

2024-08-05 13:03:29

Make sure you have the correct drivers installed for the MKR Zero. Reinstalling the drivers might help with the USB connection issue.

userHeadPic lia.ifat
2024-08-05 09:59:59

for reference, here is my code :

 

#include "DFRobot_GP8403.h"

DFRobot_GP8403 dac(&Wire,0x58);

DFRobot_GP8403 dac2(&Wire,0x5F);

 


int StateMachine = 0;


// Interrupt Service Routine (ISR)

 

void changeState ()

 {

 StateMachine++;

 if(StateMachine>4)

   {

     StateMachine=9;

   }

    Serial.print("Machine State = ");

    Serial.println(StateMachine);

 }

 


void resetState ()

 {    

   Serial.println("reset");

 StateMachine=0;

 }

 

void setup() {

 Serial.begin(115200);

 


 while(dac.begin()!=0){

   Serial.println("init error 1");

   delay(500);

  }

 


   while(dac2.begin()!=0){

   Serial.println("init error 2");

   delay(500);

  }

 


 Serial.println("init succeed");

 dac.setDACOutRange(dac.eOutputRange10V);//Set the output range as 0-10V

 dac2.setDACOutRange(dac2.eOutputRange10V);//Set the output range as 0-10V

 

 attachInterrupt(digitalPinToInterrupt(5), changeState, RISING);

 attachInterrupt(digitalPinToInterrupt(4), resetState, RISING);  

}

 


void loop(){

 

switch (StateMachine) {

 case 1:

   dac.setDACOutVoltage(2000,0); // OUT0 channel 1

   dac.setDACOutVoltage(2000,1); // OUT1 channel 1

   dac2.setDACOutVoltage(2000,0); // OUT0 channel 2

   break;

 case 2:

   dac.setDACOutVoltage(4000,0); // OUT0 channel 1

   dac.setDACOutVoltage(4000,1); // OUT1 channel 1

   dac2.setDACOutVoltage(4000,0); // OUT0 channel 2

   break;

 

 default:

   dac.setDACOutVoltage(0,0); // OUT0 channel 1

   dac.setDACOutVoltage(0,1); // OUT1 channel 1

   dac2.setDACOutVoltage(0,0); // OUT0 channel 2

   break;

}

 dac.store();

 dac2.store();

}

 

userHeadPic Ferg.Colto