109 int32_t reading = initialReading;
113 int16_t result = reading;
204 uint16_t position = calibrationStartPosition;
205 while (
sensor.readAveragedCounts() <
sensor.zeroCurrentCalibration + expectedCurrentRise && position >= 2000)
214 position = calibrationStartPosition;
217 while (
sensor.readAveragedCounts() <
sensor.zeroCurrentCalibration + expectedCurrentRise && position <= 63535)
241 void grip(uint16_t gripStrength = 0, uint16_t slowIncrement = 100, uint16_t fastSlowThreshold = 350, uint16_t fastIncrement = 3500)
248 if (gripStrength == 0)
250 gripStrength = 49152;
253 gripCurrent *= gripStrength;
331 uint32_t position = 0;
336 uint16_t minCurrentPosition = 0;
337 for (position = 0; position <= 65000; position += 1000)
341 uint16_t current =
sensor.readAveragedCounts();
345 minCurrentPosition = position;
355 sensor.calibrateIdleCurrent();
357 range *= rangeConstant;
409 int16_t
begin(uint8_t i2cAddress,
bool pin3IsVoltage =
false)
412 for (
int i = 0; i < 3; ++i)
423 pin3VoltageEnable =
true;
443 if (pin3VoltageEnable)
448 return ((uint16_t)v);
455 bool pin3VoltageEnable =
false;
@ SW_ERROR_PIN_NOT_CAPABLE
(#15) The commanded pin does not have the hardware support to perform the commanded pin mode
A class representing an Allegro ACS712 5A current sensor connected to a SW8B Analog input on a PCB003...
uint16_t calibrateIdleCurrent()
called to set the zero calibration current
int16_t readCurrent_mA()
returns the current reading in Milliamps. May be negative
uint16_t zeroCurrentCalibration
Variable holding the zero calibration value in counts.
GripACS712(SerialWombatChip &serialWombatChip)
Constructor for the GripACS712 Class.
int16_t begin(uint8_t pin)
Initialize a GripACS712 on the specified pin.
A class representing a servo output and an Allegro ACS712 5A current sensor connected to a SW8B Analo...
int16_t begin(byte pin, bool reverse=false)
Initialize a GripServo on the specified pin, and its associated sensor on pin + 4.
uint16_t calibratedMaxPosition
The highest position at which relatively low current was pulled during calibration.
void grip(uint16_t gripStrength=0, uint16_t slowIncrement=100, uint16_t fastSlowThreshold=350, uint16_t fastIncrement=3500)
Close a servo based gripper with a specified force.
uint16_t calibratedMinPosition
The position at which the least current was pulled during calibration.
GripServo(SerialWombatChip &serialWombatChip)
Constructor for the GripServo Class.
void release()
Disable the grip control algorithm and move the servo to the smallest non-stall position.
uint16_t calibratedMinCurrent
The lowest observed current during calibration.
void calibrateGripper(bool reverse=false, uint16_t rangeConstant=49152)
A single calibration call that will fully calibrate a gripper.
bool objectPresent(uint16_t divisor=50)
Reports if an object is in the gripper based on stop position of servo.
uint16_t calibratedMaxCurrent
The highest observed current during calibration.
void calibrateServoRange(uint16_t expectedCurrentRise=400, uint16_t calibrationStartPosition=0x8000)
Sweep a servo across its range measuring current to determine endstops.
SerialWombatAnalogInput_18AB powerVoltage
int16_t begin(uint8_t i2cAddress, bool pin3IsVoltage=false)
Initialize a PCB0031_Grip pcb on a given I2C address.
uint16_t readPowerVoltage_mv()
Returns the voltage provided to the Servos in mV.
int16_t writeScalingEnabled(bool enabled, uint8_t sourcePin)
Enable scaling and set which pin or public data is used as the input source.
int16_t writeOutputScaling(uint16_t outputMin, uint16_t outputMax)
Reduces the output range from 0 to 65535 to user specified range.
int16_t writeRamp(uint16_t slowIncrement, uint16_t incrementThreshold, uint16_t fastIncrement, Period samplePeriod, RampMode rampMode)
Configure the scaled output block into Ramp control mode.
int16_t writeScalingTargetValue(uint16_t target)
The target input value for PID control.
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
int16_t begin(HardwareSerial &serial, bool reset=true)
initialize a Serial Wombat chip to use a Serial Interface.
uint16_t writePublicData(uint16_t value)
Write a 16 bit value to this pin.
uint16_t readPublicData()
Read the 16 Bit public data associated with this pin.
SerialWombatServo_18AB(SerialWombatChip &serialWombat)
uint8_t pin()
Facilitates inheritance.
void attach(uint8_t pin, bool reverse)
Initialize a servo on the specified pin.