Dale(294engr]
04-02-2004, 23:39
It appears the sample code senses only one overcurrent direction.
Below represents potential ideas NOT tried code !!
dh- it's not clear how(if) neg current is included i.e. for backing into wall
(note: current polarity in code depends on sensor wiring direction)
Provided code may assume NO reverse motor drive will occur in autonomous ???
assumed: ADC return is int counts (10bits, 0 to 1023 counts)
if it was a real voltage proportional to current sensed,
ABS(real) would do the job
suggest something like this:
MAXPOS_CURRENT 700 (511+188)
MAXNEG_CURRENT 511-188 511 =midrange =2.5v =0A
For two AD Current Sensor channels with different zero current offsets
(note that new joysticks have all too easy bump access to wheel ZERO
with consequence !)
add unsigned char ad01cszero ad02cszero
init once @ robot turn-on with no drive (assumes wheel offset proper adj)
sum/difference with the counts representing desired +- current limits
MAXPOS_CURRENT01 ad01cszero+188
MAXNEG_CURRENT01 ad01cszero-188 // 188 = ~45A
MAXPOS_CURRENT02 ad02cszero+188
MAXNEG_CURRENT02 ad02cszero-188 // 188 = ~45A
for +-current tests w/AD01 & AD02 each w/theoretical
rather than actual measured offset+-current
if ( ((left_current[i] > MAXPOS_CURRENT) ||
(right_current[i] > MAXPOS_CURRENT ||
left_current[i] < MAXNEG_CURRENT) ||
(right_current[i] < MAXNEG_CURRENT))
&& (Navigator_State != WAIT_TO_DRIVE)
&& (Navigator_State != AT_TARGET))
{
Below represents potential ideas NOT tried code !!
dh- it's not clear how(if) neg current is included i.e. for backing into wall
(note: current polarity in code depends on sensor wiring direction)
Provided code may assume NO reverse motor drive will occur in autonomous ???
assumed: ADC return is int counts (10bits, 0 to 1023 counts)
if it was a real voltage proportional to current sensed,
ABS(real) would do the job
suggest something like this:
MAXPOS_CURRENT 700 (511+188)
MAXNEG_CURRENT 511-188 511 =midrange =2.5v =0A
For two AD Current Sensor channels with different zero current offsets
(note that new joysticks have all too easy bump access to wheel ZERO
with consequence !)
add unsigned char ad01cszero ad02cszero
init once @ robot turn-on with no drive (assumes wheel offset proper adj)
sum/difference with the counts representing desired +- current limits
MAXPOS_CURRENT01 ad01cszero+188
MAXNEG_CURRENT01 ad01cszero-188 // 188 = ~45A
MAXPOS_CURRENT02 ad02cszero+188
MAXNEG_CURRENT02 ad02cszero-188 // 188 = ~45A
for +-current tests w/AD01 & AD02 each w/theoretical
rather than actual measured offset+-current
if ( ((left_current[i] > MAXPOS_CURRENT) ||
(right_current[i] > MAXPOS_CURRENT ||
left_current[i] < MAXNEG_CURRENT) ||
(right_current[i] < MAXNEG_CURRENT))
&& (Navigator_State != WAIT_TO_DRIVE)
&& (Navigator_State != AT_TARGET))
{