I’m working with the Dobot Magician, trying to read an analog signal on port 9. With DoBot Studio, it works without a problem. I expect an ADC of around 3000 and that’s what it shows.
dType.SetIOMultiplexing(api, 9, 4, isQueued=0)
varX = dType.GetIOADC(api, 9)
print(varX)
//Output
3000
But I’m trying to get it working in C# using the DobotDll. I can get basically every other function and pin to work properly but not port 9 ADC reading. Here’s the code I’m using.
//Disable Gripper
DobotDll.SetEndEffectorGripper(false, false, false, ref cmdIndex);
//Set up Input A/D pin
IOMultiplexing ioMux;
ioMux.address = (byte)9;
ioMux.multiplex = (byte)IOFunction.IOFunctionADC;
DobotDll.SetIOMultiplexing(ref ioMux, false, ref cmdIndex);
//Read the pin
IOADC inputADC;
inputADC.address = (byte)9;
DobotDll.GetIOADC(ref inputADC);
txtBox.Text = inputADC.value.ToString();
The output of the C# program is 15. The ADC reading changes if I change the input voltage. But it only has a range of 0-15. Pulling the ADC pin to ground -> 0, Pulling it up to 3.3V -> 15.
Why is this not working?