View Single Post
  #1   Spotlight this post!  
Unread 04-02-2004, 23:39
Dale(294engr]'s Avatar
Dale(294engr] Dale(294engr] is offline
Mentor/Sponsor since '98
FRC #0294 (Beach Cities Robotics)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Redondo Beach, CA
Posts: 92
Dale(294engr] is a glorious beacon of lightDale(294engr] is a glorious beacon of lightDale(294engr] is a glorious beacon of lightDale(294engr] is a glorious beacon of lightDale(294engr] is a glorious beacon of lightDale(294engr] is a glorious beacon of light
Exclamation Navigate.c Current Sense code=only one polarity

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))
{
Reply With Quote