MATLAB Support Package for Arduino Hardware (Changing the pin mode on "Aref")

4 views (last 30 days)
Hello! Im using Matlab for my Master Thesis. The circuit I am using is a differential amplifier circuit, which requires me to use the bias voltage as the Analog referance on the arduino, so I can use the whole ADC range when sampling. I've been researching this problem for a few weeks, looking through old source/server codes for the Arduino, and I can't seem to find a solution (I did find this old arduino object code).
There was another thread on using the "srv.pde" from Adafruit Motor shield libraries (AFmotor). This file can't be located.
My conclusion is that the arduino object needs to be rewritten with the option to write 'external' to pinMode through the fwrite in MATLAB. Is there someone that have come across a solution of this?
My main question is: How can you change the pin mode of "Aref" to 'external' in MATLAB?
In MWProtocol.m, I found:
function value = readVoltage(obj, pin, aref)
msg = [...
obj.READ_VOLTAGE;
pin
];
value = sendMWMessage(obj, msg);
value = (bitshift(value(2), 8) + value(3))/1023*aref;
end
Does this mean I can pass 'external' in the readVoltage function? And if so, how can I use the readVoltage function from the MWProtocol class?
Addons:
  • MATLAB Support Package for Arduino Hardware
  • Adafruit\MotorshieldV2
Board:
  • Arduino UNO
  • MUX shield
Thank you very much in advance.

Answers (0)

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!